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
6ceb7ab8
Commit
6ceb7ab8
authored
Oct 22, 2011
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DNS
parent
2dce984b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
356 additions
and
17 deletions
+356
-17
IEnumerableExtensions.cs
PcapDotNet/src/PcapDotNet.Base/IEnumerableExtensions.cs
+27
-0
RandomDnsExtensions.cs
...t/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
+13
-0
DnsResourceData.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
+314
-17
DnsType.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
+2
-0
No files found.
PcapDotNet/src/PcapDotNet.Base/IEnumerableExtensions.cs
View file @
6ceb7ab8
...
@@ -222,5 +222,32 @@ namespace PcapDotNet.Base
...
@@ -222,5 +222,32 @@ namespace PcapDotNet.Base
{
{
return
sequence
.
Count
(
element
=>
element
.
Equals
(
value
));
return
sequence
.
Count
(
element
=>
element
.
Equals
(
value
));
}
}
public
static
bool
IsStrictOrdered
<
T
>(
this
IEnumerable
<
T
>
sequence
)
{
return
IsStrictOrdered
(
sequence
,
element
=>
element
);
}
public
static
bool
IsStrictOrdered
<
T
,
TKey
>(
this
IEnumerable
<
T
>
sequence
,
Func
<
T
,
TKey
>
keySelector
)
{
return
IsStrictOrdered
(
sequence
,
keySelector
,
Comparer
<
TKey
>.
Default
);
}
public
static
bool
IsStrictOrdered
<
T
,
TKey
>(
this
IEnumerable
<
T
>
sequence
,
Func
<
T
,
TKey
>
keySelector
,
IComparer
<
TKey
>
comparer
)
{
if
(!
sequence
.
Any
())
return
true
;
IEnumerable
<
TKey
>
keys
=
sequence
.
Select
(
keySelector
);
TKey
last
=
keys
.
First
();
foreach
(
TKey
key
in
keys
.
Skip
(
1
))
{
if
(
comparer
.
Compare
(
last
,
key
)
>=
0
)
return
false
;
last
=
key
;
}
return
true
;
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
View file @
6ceb7ab8
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
PcapDotNet.Base
;
using
PcapDotNet.Base
;
using
PcapDotNet.Packets.Dns
;
using
PcapDotNet.Packets.Dns
;
...
@@ -173,6 +174,18 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -173,6 +174,18 @@ namespace PcapDotNet.Packets.TestUtils
case
DnsType
.
Srv
:
case
DnsType
.
Srv
:
return
new
DnsResourceDataServerSelection
(
random
.
NextUShort
(),
random
.
NextUShort
(),
random
.
NextUShort
(),
random
.
NextDnsDomainName
());
return
new
DnsResourceDataServerSelection
(
random
.
NextUShort
(),
random
.
NextUShort
(),
random
.
NextUShort
(),
random
.
NextDnsDomainName
());
case
DnsType
.
AtmA
:
return
new
DnsResourceDataAtmAddress
(
random
.
NextEnum
<
DnsAtmAddressFormat
>(),
random
.
NextDataSegment
(
random
.
Next
(
100
)));
case
DnsType
.
NaPtr
:
IEnumerable
<
byte
>
possibleFlags
=
Enumerable
.
Range
(
'0'
,
'9'
-
'0'
+
1
).
Concat
(
Enumerable
.
Range
(
'a'
,
'z'
-
'a'
+
1
)).
Concat
(
Enumerable
.
Range
(
'A'
,
'Z'
-
'A'
+
1
)).
Select
(
value
=>
(
byte
)
value
);
return
new
DnsResourceDataNamingAuthorityPointer
(
random
.
NextUShort
(),
random
.
NextUShort
(),
new
DataSegment
(
FuncExtensions
.
GenerateArray
(()
=>
random
.
NextValue
(
possibleFlags
.
ToArray
()),
10
)),
random
.
NextDataSegment
(
random
.
Next
(
100
)),
random
.
NextDataSegment
(
random
.
Next
(
100
)),
random
.
NextDnsDomainName
());
default
:
default
:
return
new
DnsResourceDataAnything
(
random
.
NextDataSegment
(
random
.
Next
(
100
)));
return
new
DnsResourceDataAnything
(
random
.
NextDataSegment
(
random
.
Next
(
100
)));
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
View file @
6ceb7ab8
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
View file @
6ceb7ab8
...
@@ -243,12 +243,14 @@
...
@@ -243,12 +243,14 @@
/// <summary>
/// <summary>
/// ATMDOC.
/// ATMDOC.
/// ATM Address.
/// ATM Address.
/// Payload type: DnsResourceDataAtmAddress.
/// </summary>
/// </summary>
AtmA
=
34
,
AtmA
=
34
,
/// <summary>
/// <summary>
/// RFCs 2168, 2915, 3403.
/// RFCs 2168, 2915, 3403.
/// Naming Authority Pointer.
/// Naming Authority Pointer.
/// Payload type: DnsResourceDataNamingAuthorityPointer.
/// </summary>
/// </summary>
NaPtr
=
35
,
NaPtr
=
35
,
...
...
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