Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pcap-Net
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Pcap-Net
Commits
9c02de2e
Commit
9c02de2e
authored
Aug 15, 2014
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IPv6
Code Coverage 95.63%
parent
89e9eb33
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
15 deletions
+143
-15
WiresharkDatagramComparerIpV6MobilityHeader.cs
....Core.Test/WiresharkDatagramComparerIpV6MobilityHeader.cs
+1
-0
IpV6Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
+117
-2
IpV6MobilityOption.cs
...src/PcapDotNet.Packets/IpV6/Options/IpV6MobilityOption.cs
+14
-12
IpV6MobilityOptionAccessNetworkIdentifier.cs
...IpV6/Options/IpV6MobilityOptionAccessNetworkIdentifier.cs
+5
-0
IpV6MobilityOptions.cs
...rc/PcapDotNet.Packets/IpV6/Options/IpV6MobilityOptions.cs
+3
-0
IpV6Options.cs
...DotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6Options.cs
+3
-1
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkDatagramComparerIpV6MobilityHeader.cs
View file @
9c02de2e
...
@@ -108,6 +108,7 @@ namespace PcapDotNet.Core.Test
...
@@ -108,6 +108,7 @@ namespace PcapDotNet.Core.Test
protocol
==
IpV4Protocol
.
Skip
||
protocol
==
IpV4Protocol
.
Skip
||
protocol
==
IpV4Protocol
.
Bna
||
protocol
==
IpV4Protocol
.
Bna
||
protocol
==
IpV4Protocol
.
InterDomainRoutingProtocol
||
protocol
==
IpV4Protocol
.
InterDomainRoutingProtocol
||
protocol
==
IpV4Protocol
.
ActiveNetworks
||
protocol
==
IpV4Protocol
.
RemoteVirtualDiskProtocol
))
protocol
==
IpV4Protocol
.
RemoteVirtualDiskProtocol
))
return
false
;
return
false
;
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
View file @
9c02de2e
...
@@ -423,6 +423,75 @@ namespace PcapDotNet.Packets.Test
...
@@ -423,6 +423,75 @@ namespace PcapDotNet.Packets.Test
Assert
.
IsNull
(
new
IpV6AccessNetworkIdentifierSubOptionNetworkIdentifier
(
false
,
DataSegment
.
Empty
,
new
DataSegment
(
new
byte
[
256
])));
Assert
.
IsNull
(
new
IpV6AccessNetworkIdentifierSubOptionNetworkIdentifier
(
false
,
DataSegment
.
Empty
,
new
DataSegment
(
new
byte
[
256
])));
}
}
[
TestMethod
]
public
void
IpV6AccessNetworkIdentifierSubOptionNetworkIdentifierDataTooShort
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionAccessNetworkIdentifier
(
new
IpV6AccessNetworkIdentifierSubOptions
(
new
IpV6AccessNetworkIdentifierSubOptionNetworkIdentifier
(
false
,
DataSegment
.
Empty
,
DataSegment
.
Empty
))))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
2
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6AccessNetworkIdentifierSubOptionNetworkIdentifierDataTooShortForNetworkName
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionAccessNetworkIdentifier
(
new
IpV6AccessNetworkIdentifierSubOptions
(
new
IpV6AccessNetworkIdentifierSubOptionNetworkIdentifier
(
false
,
new
DataSegment
(
new
byte
[
1
]),
DataSegment
.
Empty
))))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
2
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6AccessNetworkIdentifierSubOptionNetworkIdentifierDataTooShortForAccessPointName
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionAccessNetworkIdentifier
(
new
IpV6AccessNetworkIdentifierSubOptions
(
new
IpV6AccessNetworkIdentifierSubOptionNetworkIdentifier
(
false
,
DataSegment
.
Empty
,
new
DataSegment
(
new
byte
[
1
])))))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
2
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
),
AllowDerivedTypes
=
false
)]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
),
AllowDerivedTypes
=
false
)]
public
void
IpV6ExtensionHeaderRoutingRplCommonPrefixNotCommon
()
public
void
IpV6ExtensionHeaderRoutingRplCommonPrefixNotCommon
()
...
@@ -918,8 +987,54 @@ namespace PcapDotNet.Packets.Test
...
@@ -918,8 +987,54 @@ namespace PcapDotNet.Packets.Test
new
IpV6MobilityOptionMobileNodeIdentifier
(
IpV6MobileNodeIdentifierSubtype
.
NetworkAccessIdentifier
,
new
DataSegment
(
new
byte
[
1
])),
new
IpV6MobilityOptionMobileNodeIdentifier
(
IpV6MobileNodeIdentifierSubtype
.
NetworkAccessIdentifier
,
new
DataSegment
(
new
byte
[
1
])),
new
IpV6MobilityOptionMobileNodeIdentifier
(
IpV6MobileNodeIdentifierSubtype
.
NetworkAccessIdentifier
,
new
DataSegment
(
new
byte
[
2
])));
new
IpV6MobilityOptionMobileNodeIdentifier
(
IpV6MobileNodeIdentifierSubtype
.
NetworkAccessIdentifier
,
new
DataSegment
(
new
byte
[
2
])));
Assert
.
IsFalse
(
Assert
.
IsFalse
(
new
IpV6MobilityOptionMobileNodeIdentifier
(
IpV6MobileNodeIdentifierSubtype
.
NetworkAccessIdentifier
,
new
DataSegment
(
new
byte
[
1
])).
Equals
(
new
IpV6MobilityOptionMobileNodeIdentifier
(
IpV6MobileNodeIdentifierSubtype
.
NetworkAccessIdentifier
,
new
DataSegment
(
new
byte
[
1
])).
Equals
(
null
));
null
as
IpV6MobilityOptionMobileNodeIdentifier
));
}
[
TestMethod
]
public
void
IpV6OptionsDataTooShortForReadingOptionDataLength
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
new
IpV6Options
(
new
IpV6OptionPadN
(
3
),
new
IpV6OptionPad1
())))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
packet
.
Buffer
[
14
+
40
+
7
]
=
(
byte
)
IpV6OptionType
.
PadN
;
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6OptionsDataTooShortForOptionDataLength
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
new
IpV6Options
(
new
IpV6OptionPadN
(
4
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
packet
.
Buffer
[
14
+
40
+
3
]
=
50
;
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6OptionsEnumerableConstructor
()
{
IpV6Options
options
=
new
IpV6Options
(
new
IpV6Option
[]{
new
IpV6OptionPad1
()}.
Concat
(
new
IpV6OptionPad1
()));
Assert
.
AreEqual
(
2
,
options
.
Count
);
Assert
.
AreEqual
(
new
IpV6OptionPad1
(),
options
[
0
]);
Assert
.
AreEqual
(
new
IpV6OptionPad1
(),
options
[
1
]);
}
}
}
}
}
}
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6MobilityOption.cs
View file @
9c02de2e
...
@@ -23,18 +23,6 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -23,18 +23,6 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
IpV6MobilityOptionType
OptionType
{
get
;
private
set
;
}
public
IpV6MobilityOptionType
OptionType
{
get
;
private
set
;
}
internal
abstract
IpV6MobilityOption
CreateInstance
(
DataSegment
data
);
protected
IpV6MobilityOption
(
IpV6MobilityOptionType
type
)
{
OptionType
=
type
;
}
internal
override
void
Write
(
byte
[]
buffer
,
ref
int
offset
)
{
buffer
[
offset
++]
=
(
byte
)
OptionType
;
}
public
override
int
Length
public
override
int
Length
{
{
get
{
return
sizeof
(
byte
);
}
get
{
return
sizeof
(
byte
);
}
...
@@ -51,6 +39,20 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -51,6 +39,20 @@ namespace PcapDotNet.Packets.IpV6
OptionType
==
other
.
OptionType
&&
Length
==
other
.
Length
&&
EqualsData
(
other
);
OptionType
==
other
.
OptionType
&&
Length
==
other
.
Length
&&
EqualsData
(
other
);
}
}
public
virtual
bool
IsValid
{
get
{
return
true
;
}
}
protected
IpV6MobilityOption
(
IpV6MobilityOptionType
type
)
{
OptionType
=
type
;
}
internal
abstract
IpV6MobilityOption
CreateInstance
(
DataSegment
data
);
internal
override
void
Write
(
byte
[]
buffer
,
ref
int
offset
)
{
buffer
[
offset
++]
=
(
byte
)
OptionType
;
}
internal
abstract
bool
EqualsData
(
IpV6MobilityOption
other
);
internal
abstract
bool
EqualsData
(
IpV6MobilityOption
other
);
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6MobilityOptionAccessNetworkIdentifier.cs
View file @
9c02de2e
...
@@ -31,6 +31,11 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -31,6 +31,11 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
IpV6AccessNetworkIdentifierSubOptions
SubOptions
{
get
;
private
set
;
}
public
IpV6AccessNetworkIdentifierSubOptions
SubOptions
{
get
;
private
set
;
}
public
override
bool
IsValid
{
get
{
return
SubOptions
.
IsValid
;
}
}
internal
override
IpV6MobilityOption
CreateInstance
(
DataSegment
data
)
internal
override
IpV6MobilityOption
CreateInstance
(
DataSegment
data
)
{
{
return
new
IpV6MobilityOptionAccessNetworkIdentifier
(
new
IpV6AccessNetworkIdentifierSubOptions
(
data
));
return
new
IpV6MobilityOptionAccessNetworkIdentifier
(
new
IpV6AccessNetworkIdentifierSubOptions
(
data
));
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6MobilityOptions.cs
View file @
9c02de2e
...
@@ -101,6 +101,9 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -101,6 +101,9 @@ namespace PcapDotNet.Packets.IpV6
break
;
break
;
}
}
if
(!
option
.
IsValid
)
isValid
=
false
;
options
.
Add
(
option
);
options
.
Add
(
option
);
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6Options.cs
View file @
9c02de2e
...
@@ -35,7 +35,9 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -35,7 +35,9 @@ namespace PcapDotNet.Packets.IpV6
{
{
if
(
paddingSize
==
0
)
if
(
paddingSize
==
0
)
return
this
;
return
this
;
return
new
IpV6Options
(
OptionsCollection
.
Concat
(
paddingSize
==
1
?
(
IpV6Option
)
new
IpV6OptionPad1
()
:
new
IpV6OptionPadN
(
paddingSize
-
2
)));
IEnumerable
<
IpV6Option
>
paddedOptions
=
OptionsCollection
.
Concat
(
paddingSize
==
1
?
(
IpV6Option
)
new
IpV6OptionPad1
()
:
new
IpV6OptionPadN
(
paddingSize
-
2
));
return
new
IpV6Options
(
new
Tuple
<
IList
<
IpV6Option
>,
bool
>(
paddedOptions
.
ToList
(),
IsValid
));
}
}
internal
static
Tuple
<
IList
<
IpV6Option
>,
bool
>
Read
(
DataSegment
data
)
internal
static
Tuple
<
IList
<
IpV6Option
>,
bool
>
Read
(
DataSegment
data
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment