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
d2e2016f
Commit
d2e2016f
authored
Oct 04, 2014
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 warning left.
parent
274e1c7d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
2 deletions
+46
-2
EthernetBaseDatagram.cs
...t/src/PcapDotNet.Packets/Ethernet/EthernetBaseDatagram.cs
+4
-0
IpDatagram.cs
PcapDotNet/src/PcapDotNet.Packets/Ip/IpDatagram.cs
+11
-0
IpV4Datagram.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
+4
-0
IpV6ExtensionHeaders.cs
...Net.Packets/IpV6/ExtensionHeaders/IpV6ExtensionHeaders.cs
+3
-0
IpV6Datagram.cs
PcapDotNet/src/PcapDotNet.Packets/IpV6/IpV6Datagram.cs
+8
-1
IpV6Layer.cs
PcapDotNet/src/PcapDotNet.Packets/IpV6/IpV6Layer.cs
+16
-1
No files found.
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetBaseDatagram.cs
View file @
d2e2016f
...
@@ -113,6 +113,10 @@ namespace PcapDotNet.Packets.Ethernet
...
@@ -113,6 +113,10 @@ namespace PcapDotNet.Packets.Ethernet
get
{
return
PayloadDatagrams
.
IpV6
;
}
get
{
return
PayloadDatagrams
.
IpV6
;
}
}
}
/// <summary>
/// Returns the IP Datagram.
/// This is either an IPv4 Datagram or an IPv6 Datagram (according to the Ethernet Type).
/// </summary>
public
IpDatagram
Ip
public
IpDatagram
Ip
{
{
get
get
...
...
PcapDotNet/src/PcapDotNet.Packets/Ip/IpDatagram.cs
View file @
d2e2016f
...
@@ -46,6 +46,9 @@ namespace PcapDotNet.Packets.Ip
...
@@ -46,6 +46,9 @@ namespace PcapDotNet.Packets.Ip
get
{
return
(
byte
)((
this
[
Offset
.
Version
]
&
Mask
.
Version
)
>>
Shift
.
Version
);
}
get
{
return
(
byte
)((
this
[
Offset
.
Version
]
&
Mask
.
Version
)
>>
Shift
.
Version
);
}
}
}
/// <summary>
/// The total length - header and payload according to the IP header.
/// </summary>
public
abstract
int
TotalLength
{
get
;
}
public
abstract
int
TotalLength
{
get
;
}
/// <summary>
/// <summary>
...
@@ -119,6 +122,10 @@ namespace PcapDotNet.Packets.Ip
...
@@ -119,6 +122,10 @@ namespace PcapDotNet.Packets.Ip
}
}
}
}
/// <summary>
/// Returns the inner IP Datagram.
/// This is either an IPv4 Datagram or an IPv6 Datagram (according to the Payload Protocol).
/// </summary>
public
IpDatagram
Ip
public
IpDatagram
Ip
{
{
get
get
...
@@ -244,6 +251,10 @@ namespace PcapDotNet.Packets.Ip
...
@@ -244,6 +251,10 @@ namespace PcapDotNet.Packets.Ip
}
}
}
}
/// <summary>
/// Calculates the Transport checksum field value.
/// </summary>
/// <returns>The calculated checksum value.</returns>
protected
abstract
ushort
CalculateTransportChecksum
();
protected
abstract
ushort
CalculateTransportChecksum
();
internal
IpDatagram
(
byte
[]
buffer
,
int
offset
,
int
length
)
internal
IpDatagram
(
byte
[]
buffer
,
int
offset
,
int
length
)
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
View file @
d2e2016f
...
@@ -314,6 +314,10 @@ namespace PcapDotNet.Packets.IpV4
...
@@ -314,6 +314,10 @@ namespace PcapDotNet.Packets.IpV4
return
IsPayloadValid
;
return
IsPayloadValid
;
}
}
/// <summary>
/// Calculates the Transport checksum field value.
/// </summary>
/// <returns>The calculated checksum value.</returns>
protected
override
ushort
CalculateTransportChecksum
()
protected
override
ushort
CalculateTransportChecksum
()
{
{
return
CalculateTransportChecksum
(
Buffer
,
StartOffset
,
HeaderLength
,
(
ushort
)
Transport
.
Length
,
Transport
.
ChecksumOffset
,
Transport
.
IsChecksumOptional
,
Destination
);
return
CalculateTransportChecksum
(
Buffer
,
StartOffset
,
HeaderLength
,
(
ushort
)
Transport
.
Length
,
Transport
.
ChecksumOffset
,
Transport
.
IsChecksumOptional
,
Destination
);
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/ExtensionHeaders/IpV6ExtensionHeaders.cs
View file @
d2e2016f
...
@@ -115,6 +115,9 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -115,6 +115,9 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
ReadOnlyCollection
<
IpV6ExtensionHeader
>
Headers
{
get
;
private
set
;
}
public
ReadOnlyCollection
<
IpV6ExtensionHeader
>
Headers
{
get
;
private
set
;
}
/// <summary>
/// The total number of bytes the extension headers take.
/// </summary>
public
int
BytesLength
{
get
;
private
set
;
}
public
int
BytesLength
{
get
;
private
set
;
}
/// <summary>
/// <summary>
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/IpV6Datagram.cs
View file @
d2e2016f
...
@@ -164,6 +164,9 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -164,6 +164,9 @@ namespace PcapDotNet.Packets.IpV6
}
}
}
}
/// <summary>
/// The total length - header and payload according to the IP header.
/// </summary>
public
override
int
TotalLength
public
override
int
TotalLength
{
{
get
{
return
HeaderLength
+
PayloadLength
;
}
get
{
return
HeaderLength
+
PayloadLength
;
}
...
@@ -198,6 +201,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -198,6 +201,10 @@ namespace PcapDotNet.Packets.IpV6
return
IsPayloadValid
;
return
IsPayloadValid
;
}
}
/// <summary>
/// Calculates the Transport checksum field value.
/// </summary>
/// <returns>The calculated checksum value.</returns>
protected
override
ushort
CalculateTransportChecksum
()
protected
override
ushort
CalculateTransportChecksum
()
{
{
return
CalculateTransportChecksum
(
Buffer
,
StartOffset
,
HeaderLength
+
ExtensionHeaders
.
BytesLength
,
(
uint
)
Transport
.
Length
,
Transport
.
ChecksumOffset
,
return
CalculateTransportChecksum
(
Buffer
,
StartOffset
,
HeaderLength
+
ExtensionHeaders
.
BytesLength
,
(
uint
)
Transport
.
Length
,
Transport
.
ChecksumOffset
,
...
@@ -249,7 +256,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -249,7 +256,7 @@ namespace PcapDotNet.Packets.IpV6
else
if
(
nextLayerProtocol
.
HasValue
)
else
if
(
nextLayerProtocol
.
HasValue
)
actualNextHeader
=
nextLayerProtocol
.
Value
;
actualNextHeader
=
nextLayerProtocol
.
Value
;
else
else
throw
new
InvalidOperationException
(
"Can't determin
t
e next header. No extension headers and no known next layer protocol."
);
throw
new
InvalidOperationException
(
"Can't determine next header. No extension headers and no known next layer protocol."
);
buffer
.
Write
(
offset
+
Offset
.
NextHeader
,
(
byte
)
actualNextHeader
);
buffer
.
Write
(
offset
+
Offset
.
NextHeader
,
(
byte
)
actualNextHeader
);
buffer
.
Write
(
offset
+
Offset
.
HopLimit
,
hopLimit
);
buffer
.
Write
(
offset
+
Offset
.
HopLimit
,
hopLimit
);
buffer
.
Write
(
offset
+
Offset
.
SourceAddress
,
source
,
Endianity
.
Big
);
buffer
.
Write
(
offset
+
Offset
.
SourceAddress
,
source
,
Endianity
.
Big
);
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/IpV6Layer.cs
View file @
d2e2016f
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Collections.ObjectModel
;
using
System.Globalization
;
using
System.Linq
;
using
System.Linq
;
using
PcapDotNet.Base
;
using
PcapDotNet.Base
;
using
PcapDotNet.Packets.Ethernet
;
using
PcapDotNet.Packets.Ethernet
;
...
@@ -97,6 +98,12 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -97,6 +98,12 @@ namespace PcapDotNet.Packets.IpV6
get
{
return
IpV6Datagram
.
HeaderLength
+
ExtensionHeaders
.
BytesLength
;
}
get
{
return
IpV6Datagram
.
HeaderLength
+
ExtensionHeaders
.
BytesLength
;
}
}
}
/// <summary>
/// The IPv6 last next header field.
/// If there are no extension headers, this is the IPv6 layer next header field.
/// If there are extesion headers, this is the last extension header next header field.
/// Returns null if the last next header should be calculated automatically when building a packet.
/// </summary>
public
IpV4Protocol
?
LastNextHeader
public
IpV4Protocol
?
LastNextHeader
{
{
get
{
return
ExtensionHeaders
.
Any
()
?
ExtensionHeaders
.
NextHeader
:
NextHeader
;
}
get
{
return
ExtensionHeaders
.
Any
()
?
ExtensionHeaders
.
NextHeader
:
NextHeader
;
}
...
@@ -126,6 +133,14 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -126,6 +133,14 @@ namespace PcapDotNet.Packets.IpV6
TrafficClass
,
FlowLabel
,
(
ushort
)(
payloadLength
+
ExtensionHeaders
.
BytesLength
),
NextHeader
,
nextLayerProtocol
,
HopLimit
,
Source
,
CurrentDestination
,
ExtensionHeaders
);
TrafficClass
,
FlowLabel
,
(
ushort
)(
payloadLength
+
ExtensionHeaders
.
BytesLength
),
NextHeader
,
nextLayerProtocol
,
HopLimit
,
Source
,
CurrentDestination
,
ExtensionHeaders
);
}
}
/// <summary>
/// Finalizes the layer data in the buffer.
/// Used for fields that must be calculated according to the layer's payload (like checksum).
/// </summary>
/// <param name="buffer">The buffer to finalize the layer in.</param>
/// <param name="offset">The offset in the buffer the layer starts.</param>
/// <param name="payloadLength">The length of the layer's payload (the number of bytes after the layer in the packet).</param>
/// <param name="nextLayer">The layer that comes after this layer. null if this is the last layer.</param>
public
override
void
Finalize
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
nextLayer
)
public
override
void
Finalize
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
nextLayer
)
{
{
IIpNextTransportLayer
nextTransportLayer
=
nextLayer
as
IIpNextTransportLayer
;
IIpNextTransportLayer
nextTransportLayer
=
nextLayer
as
IIpNextTransportLayer
;
...
@@ -173,7 +188,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -173,7 +188,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
string
.
Format
(
"{0} -> {1} ({2})"
,
Source
,
CurrentDestination
,
NextHeader
);
return
string
.
Format
(
CultureInfo
.
InvariantCulture
,
"{0} -> {1} ({2})"
,
Source
,
CurrentDestination
,
NextHeader
);
}
}
}
}
}
}
\ No newline at end of file
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