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
7d204fb5
Commit
7d204fb5
authored
Nov 28, 2015
by
Boaz Brickner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #66 from bricknerb/master
IGMP Version 0.
parents
1b3a8cb3
6f5691e2
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
58 additions
and
18 deletions
+58
-18
WiresharkCompareTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
+7
-2
WiresharkDatagramComparerDns.cs
.../src/PcapDotNet.Core.Test/WiresharkDatagramComparerDns.cs
+21
-6
WiresharkDatagramComparerIgmp.cs
...src/PcapDotNet.Core.Test/WiresharkDatagramComparerIgmp.cs
+1
-1
IgmpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
+2
-2
RandomIgmpExtensions.cs
.../src/PcapDotNet.Packets.TestUtils/RandomIgmpExtensions.cs
+1
-1
IgmpCreateGroupRequestVersion0Layer.cs
...otNet.Packets/Igmp/IgmpCreateGroupRequestVersion0Layer.cs
+2
-2
IgmpDatagram.cs
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpDatagram.cs
+3
-3
IgmpVersion0CreateGroupRequestCode.cs
...DotNet.Packets/Igmp/IgmpVersion0CreateGroupRequestCode.cs
+19
-0
IgmpVersion0ReplyCode.cs
...tNet/src/PcapDotNet.Packets/Igmp/IgmpVersion0ReplyCode.cs
+1
-1
PcapDotNet.Packets.csproj
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
+1
-0
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
View file @
7d204fb5
...
@@ -592,8 +592,13 @@ namespace PcapDotNet.Core.Test
...
@@ -592,8 +592,13 @@ namespace PcapDotNet.Core.Test
case
"frame.time_epoch"
:
case
"frame.time_epoch"
:
double
timeEpoch
=
double
.
Parse
(
field
.
Show
(),
CultureInfo
.
InvariantCulture
);
double
timeEpoch
=
double
.
Parse
(
field
.
Show
(),
CultureInfo
.
InvariantCulture
);
DateTime
fieldTimestamp
=
new
DateTime
(
1970
,
1
,
1
).
AddSeconds
(
timeEpoch
);
// TODO: Remove this condition when https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=11744 is fixed.
MoreAssert
.
IsInRange
(
fieldTimestamp
.
AddMilliseconds
(-
1
),
fieldTimestamp
.
AddMilliseconds
(
1
),
packet
.
Timestamp
.
ToUniversalTime
(),
"Timestamp"
);
if
(
timeEpoch
>=
int
.
MinValue
)
{
DateTime
fieldTimestamp
=
new
DateTime
(
1970
,
1
,
1
).
AddSeconds
(
timeEpoch
);
MoreAssert
.
IsInRange
(
fieldTimestamp
.
AddMilliseconds
(-
1
),
fieldTimestamp
.
AddMilliseconds
(
1
),
packet
.
Timestamp
.
ToUniversalTime
(),
"Timestamp"
);
}
break
;
break
;
case
"frame.cap_len"
:
case
"frame.cap_len"
:
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkDatagramComparerDns.cs
View file @
7d204fb5
...
@@ -170,6 +170,7 @@ namespace PcapDotNet.Core.Test
...
@@ -170,6 +170,7 @@ namespace PcapDotNet.Core.Test
ResetRecordFields
();
ResetRecordFields
();
var
resourceRecordField
=
resourceRecordFieldsArray
[
i
];
var
resourceRecordField
=
resourceRecordFieldsArray
[
i
];
var
resourceRecord
=
resourceRecordsArray
[
i
];
var
resourceRecord
=
resourceRecordsArray
[
i
];
int
dnsResponseTypeIndex
=
0
;
foreach
(
var
resourceRecordAttributeField
in
resourceRecordField
.
Fields
())
foreach
(
var
resourceRecordAttributeField
in
resourceRecordField
.
Fields
())
{
{
switch
(
resourceRecordAttributeField
.
Name
())
switch
(
resourceRecordAttributeField
.
Name
())
...
@@ -191,11 +192,25 @@ namespace PcapDotNet.Core.Test
...
@@ -191,11 +192,25 @@ namespace PcapDotNet.Core.Test
break
;
break
;
case
"dns.qry.type"
:
case
"dns.qry.type"
:
case
"dns.resp.type"
:
resourceRecordAttributeField
.
AssertShowDecimal
((
ushort
)
resourceRecord
.
DnsType
);
resourceRecordAttributeField
.
AssertShowDecimal
((
ushort
)
resourceRecord
.
DnsType
);
resourceRecordAttributeField
.
AssertNoFields
();
resourceRecordAttributeField
.
AssertNoFields
();
break
;
break
;
case
"dns.resp.type"
:
DnsType
expectedDnsType
;
if
(
dnsResponseTypeIndex
==
0
)
{
expectedDnsType
=
resourceRecord
.
DnsType
;
}
else
{
expectedDnsType
=
((
DnsResourceDataNextDomain
)
resourceRecord
.
Data
).
TypesExist
.
Skip
(
dnsResponseTypeIndex
-
1
).
First
();
}
resourceRecordAttributeField
.
AssertShowDecimal
((
ushort
)
expectedDnsType
);
resourceRecordAttributeField
.
AssertNoFields
();
++
dnsResponseTypeIndex
;
break
;
case
"dns.qry.class"
:
case
"dns.qry.class"
:
case
"dns.resp.class"
:
case
"dns.resp.class"
:
resourceRecordAttributeField
.
AssertShowDecimal
((
ushort
)
resourceRecord
.
DnsClass
);
resourceRecordAttributeField
.
AssertShowDecimal
((
ushort
)
resourceRecord
.
DnsClass
);
...
@@ -833,19 +848,19 @@ namespace PcapDotNet.Core.Test
...
@@ -833,19 +848,19 @@ namespace PcapDotNet.Core.Test
case
"dns.loc.size"
:
case
"dns.loc.size"
:
Assert
.
AreEqual
(
0
,
locData
.
Version
);
Assert
.
AreEqual
(
0
,
locData
.
Version
);
string
sizeValue
=
dataField
.
Showname
().
Split
(
new
[]
{
'('
,
')'
}
)[
1
];
string
sizeValue
=
dataField
.
Showname
().
Split
(
'('
,
')'
)[
1
];
Assert
.
AreEqual
(
GetPrecisionValueString
(
locData
.
Size
)
+
" m"
,
sizeValue
);
Assert
.
AreEqual
(
GetPrecisionValueString
(
locData
.
Size
),
sizeValue
);
break
;
break
;
case
"dns.loc.horizontal_precision"
:
case
"dns.loc.horizontal_precision"
:
Assert
.
AreEqual
(
0
,
locData
.
Version
);
Assert
.
AreEqual
(
0
,
locData
.
Version
);
string
horizontalPrecisionValue
=
dataField
.
Showname
().
Split
(
new
[]
{
'('
,
')'
}
)[
1
];
string
horizontalPrecisionValue
=
dataField
.
Showname
().
Split
(
'('
,
')'
)[
1
];
Assert
.
AreEqual
(
GetPrecisionValueString
(
locData
.
HorizontalPrecision
),
horizontalPrecisionValue
);
Assert
.
AreEqual
(
GetPrecisionValueString
(
locData
.
HorizontalPrecision
),
horizontalPrecisionValue
);
break
;
break
;
case
"dns.loc.vertial_precision"
:
case
"dns.loc.vertial_precision"
:
Assert
.
AreEqual
(
0
,
locData
.
Version
);
Assert
.
AreEqual
(
0
,
locData
.
Version
);
string
verticalPrecisionValue
=
dataField
.
Showname
().
Split
(
new
[]
{
'('
,
')'
}
)[
1
];
string
verticalPrecisionValue
=
dataField
.
Showname
().
Split
(
'('
,
')'
)[
1
];
Assert
.
AreEqual
(
GetPrecisionValueString
(
locData
.
VerticalPrecision
),
verticalPrecisionValue
);
Assert
.
AreEqual
(
GetPrecisionValueString
(
locData
.
VerticalPrecision
),
verticalPrecisionValue
);
break
;
break
;
...
@@ -1840,7 +1855,7 @@ namespace PcapDotNet.Core.Test
...
@@ -1840,7 +1855,7 @@ namespace PcapDotNet.Core.Test
double
resultValue
=
value
/
100.0
;
double
resultValue
=
value
/
100.0
;
if
(
resultValue
<
1000000
)
if
(
resultValue
<
1000000
)
return
resultValue
.
ToString
()
;
return
resultValue
+
" m"
;
int
log
=
(
int
)
Math
.
Log10
(
resultValue
);
int
log
=
(
int
)
Math
.
Log10
(
resultValue
);
resultValue
/=
Math
.
Pow
(
10
,
log
);
resultValue
/=
Math
.
Pow
(
10
,
log
);
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkDatagramComparerIgmp.cs
View file @
7d204fb5
...
@@ -124,7 +124,7 @@ namespace PcapDotNet.Core.Test
...
@@ -124,7 +124,7 @@ namespace PcapDotNet.Core.Test
break
;
break
;
case
"igmp.group_type"
:
case
"igmp.group_type"
:
field
.
AssertShowDecimal
(
igmpDatagram
.
IsPrivat
e
);
field
.
AssertShowDecimal
(
(
byte
)
igmpDatagram
.
CreateGroupRequestCod
e
);
break
;
break
;
case
"igmp.mtrace.max_hops"
:
case
"igmp.mtrace.max_hops"
:
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
View file @
7d204fb5
...
@@ -121,7 +121,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -121,7 +121,7 @@ namespace PcapDotNet.Packets.Test
switch
(
igmpLayer
.
MessageTypeValue
)
switch
(
igmpLayer
.
MessageTypeValue
)
{
{
case
IgmpMessageType
.
CreateGroupRequestVersion0
:
case
IgmpMessageType
.
CreateGroupRequestVersion0
:
Assert
.
AreEqual
(((
IgmpCreateGroupRequestVersion0Layer
)
igmpLayer
).
IsPrivate
,
packet
.
Ethernet
.
Ip
.
Igmp
.
IsPrivat
e
);
Assert
.
AreEqual
(((
IgmpCreateGroupRequestVersion0Layer
)
igmpLayer
).
CreateGroupRequestCode
,
packet
.
Ethernet
.
Ip
.
Igmp
.
CreateGroupRequestCod
e
);
break
;
break
;
case
IgmpMessageType
.
CreateGroupReplyVersion0
:
case
IgmpMessageType
.
CreateGroupReplyVersion0
:
...
@@ -519,7 +519,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -519,7 +519,7 @@ namespace PcapDotNet.Packets.Test
{
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
(),
new
IgmpQueryVersion1Layer
());
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
(),
new
IgmpQueryVersion1Layer
());
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsFalse
(
packet
.
Ethernet
.
IpV4
.
Igmp
.
IsPrivat
e
);
Assert
.
AreEqual
(
IgmpVersion0CreateGroupRequestCode
.
Private
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
CreateGroupRequestCod
e
);
}
}
[
TestMethod
]
[
TestMethod
]
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomIgmpExtensions.cs
View file @
7d204fb5
...
@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.TestUtils
case
IgmpMessageType
.
CreateGroupRequestVersion0
:
case
IgmpMessageType
.
CreateGroupRequestVersion0
:
return
new
IgmpCreateGroupRequestVersion0Layer
return
new
IgmpCreateGroupRequestVersion0Layer
{
{
IsPrivate
=
random
.
NextBool
(),
CreateGroupRequestCode
=
random
.
NextEnum
<
IgmpVersion0CreateGroupRequestCode
>
(),
Identifier
=
identifier
,
Identifier
=
identifier
,
};
};
...
...
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpCreateGroupRequestVersion0Layer.cs
View file @
7d204fb5
...
@@ -19,7 +19,7 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -19,7 +19,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary>
/// <summary>
/// Indicates if the new host group is to be private or public.
/// Indicates if the new host group is to be private or public.
/// </summary>
/// </summary>
public
bool
IsPrivat
e
{
get
;
set
;
}
public
IgmpVersion0CreateGroupRequestCode
CreateGroupRequestCod
e
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Contains a value to distinguish the request from other requests by the same host.
/// Contains a value to distinguish the request from other requests by the same host.
...
@@ -44,7 +44,7 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -44,7 +44,7 @@ namespace PcapDotNet.Packets.Igmp
internal
override
byte
CodeValue
internal
override
byte
CodeValue
{
{
get
{
return
IsPrivate
.
ToByte
()
;
}
get
{
return
(
byte
)
CreateGroupRequestCode
;
}
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpDatagram.cs
View file @
7d204fb5
...
@@ -281,13 +281,13 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -281,13 +281,13 @@ namespace PcapDotNet.Packets.Igmp
/// <summary>
/// <summary>
/// In IGMP version 0 Create Group Request message, indicates if the new host group is to be private or public.
/// In IGMP version 0 Create Group Request message, indicates if the new host group is to be private or public.
/// </summary>
/// </summary>
public
bool
IsPrivat
e
public
IgmpVersion0CreateGroupRequestCode
CreateGroupRequestCod
e
{
{
get
get
{
{
if
(
MessageType
!=
IgmpMessageType
.
CreateGroupRequestVersion0
)
if
(
MessageType
!=
IgmpMessageType
.
CreateGroupRequestVersion0
)
throw
new
InvalidOperationException
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
Name
+
" can only be accessed for CreateGroupRequestVersion0."
);
throw
new
InvalidOperationException
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
Name
+
" can only be accessed for CreateGroupRequestVersion0."
);
return
ReadBool
(
Offset
.
Code
,
Mask
.
Code
)
;
return
(
IgmpVersion0CreateGroupRequestCode
)
this
[
Offset
.
Code
]
;
}
}
}
}
...
@@ -628,7 +628,7 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -628,7 +628,7 @@ namespace PcapDotNet.Packets.Igmp
case
IgmpMessageType
.
CreateGroupRequestVersion0
:
case
IgmpMessageType
.
CreateGroupRequestVersion0
:
return
new
IgmpCreateGroupRequestVersion0Layer
return
new
IgmpCreateGroupRequestVersion0Layer
{
{
IsPrivate
=
IsPrivat
e
,
CreateGroupRequestCode
=
CreateGroupRequestCod
e
,
Identifier
=
Identifier
,
Identifier
=
Identifier
,
};
};
...
...
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpVersion0CreateGroupRequestCode.cs
0 → 100644
View file @
7d204fb5
namespace
PcapDotNet.Packets.Igmp
{
/// <summary>
/// RFC 988.
/// In an IGMP version 0 Create Group Request message, the code field indicates if the new host group is to be public or private.
/// </summary>
public
enum
IgmpVersion0CreateGroupRequestCode
:
byte
{
/// <summary>
/// The new host group is to be public.
/// </summary>
Public
=
0
,
/// <summary>
/// The new host group is to be private.
/// </summary>
Private
=
1
,
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpVersion0ReplyCode.cs
View file @
7d204fb5
...
@@ -2,7 +2,7 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -2,7 +2,7 @@ namespace PcapDotNet.Packets.Igmp
{
{
/// <summary>
/// <summary>
/// RFC 988.
/// RFC 988.
/// In an IGMP version 0 Reply message, specifies the outcome of the request
:
/// In an IGMP version 0 Reply message, specifies the outcome of the request
.
/// </summary>
/// </summary>
public
enum
IgmpVersion0ReplyCode
:
byte
public
enum
IgmpVersion0ReplyCode
:
byte
{
{
...
...
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
View file @
7d204fb5
...
@@ -313,6 +313,7 @@
...
@@ -313,6 +313,7 @@
<Compile
Include=
"Igmp\IgmpReportVersion2Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpReportVersion2Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpReportVersion3Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpReportVersion3Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpRequestVersion0Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpRequestVersion0Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion0CreateGroupRequestCode.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion0Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion0Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion1PlusLayer.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion1PlusLayer.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion1PlusSimpleLayer.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion1PlusSimpleLayer.cs"
/>
...
...
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