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
39ca222f
Commit
39ca222f
authored
Aug 30, 2014
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IPv6
Code Coverage 95.94%
parent
cf2a308f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
218 additions
and
3 deletions
+218
-3
IpV6Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
+218
-0
IpV6MobilityOptionComplex.cs
...pDotNet.Packets/IpV6/Options/IpV6MobilityOptionComplex.cs
+0
-3
No files found.
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
View file @
39ca222f
...
...
@@ -1556,5 +1556,223 @@ namespace PcapDotNet.Packets.Test
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6OptionCalipsoDataTooShort
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
new
IpV6Options
(
new
IpV6OptionCalipso
(
IpV6CalipsoDomainOfInterpretation
.
Null
,
0
,
null
,
DataSegment
.
Empty
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
2
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6OptionCalipsoDataTooShortForCompartmentBitmap
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
new
IpV6Options
(
new
IpV6OptionCalipso
(
IpV6CalipsoDomainOfInterpretation
.
Null
,
0
,
null
,
new
DataSegment
(
new
byte
[
8
])))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
2
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionAlternateIpV4CareOfAddressDataTooShort
()
{
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
IpV6MobilityOptionAlternateIpV4CareOfAddress
(
IpV4Address
.
Zero
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionAuthenticationDataTooShort
()
{
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
IpV6MobilityOptionAuthentication
(
IpV6AuthenticationSubtype
.
HomeAgent
,
0
,
DataSegment
.
Empty
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionBindingAuthorizationDataForFmIpV6DataTooShort
()
{
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
IpV6MobilityOptionBindingAuthorizationDataForFmIpV6
(
0
,
DataSegment
.
Empty
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionBindingRefreshAdviceDataTooShort
()
{
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
IpV6MobilityOptionBindingRefreshAdvice
(
0
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionDnsUpdateDataTooShort
()
{
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
IpV6MobilityOptionDnsUpdate
(
IpV6DnsUpdateStatus
.
ReasonUnspecified
,
false
,
DataSegment
.
Empty
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionFlowIdentificationDataTooShort
()
{
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
IpV6MobilityOptionFlowIdentification
(
0
,
0
,
IpV6FlowIdentificationStatus
.
FlowBindingSuccessful
,
IpV6FlowIdentificationSubOptions
.
None
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionGreKeyDataTooShort
()
{
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
IpV6MobilityOptionGreKey
(
0
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionIpV4AddressAcknowledgementDataTooShort
()
{
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
IpV6MobilityOptionIpV4AddressAcknowledgement
(
IpV6AddressAcknowledgementStatus
.
Success
,
0
,
IpV4Address
.
Zero
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionIpV4DhcpSupportModeDataTooShort
()
{
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
IpV6MobilityOptionIpV4DhcpSupportMode
(
false
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
--
packet
.
Buffer
[
14
+
40
+
24
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
}
}
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6MobilityOptionComplex.cs
View file @
39ca222f
...
...
@@ -34,9 +34,6 @@ namespace PcapDotNet.Packets.IpV6
internal
override
sealed
void
Write
(
byte
[]
buffer
,
ref
int
offset
)
{
base
.
Write
(
buffer
,
ref
offset
);
// TODO: Remove this check.
if
(
DataLength
>
byte
.
MaxValue
)
throw
new
InvalidOperationException
(
"DataLength is too big."
);
buffer
[
offset
++]
=
(
byte
)
DataLength
;
WriteData
(
buffer
,
ref
offset
);
}
...
...
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