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
c775ec22
Commit
c775ec22
authored
Nov 26, 2011
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DNS
parent
76715009
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
2 deletions
+115
-2
RandomDnsExtensions.cs
...t/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
+4
-1
DnsResourceData.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
+105
-0
DnsType.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
+6
-1
No files found.
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
View file @
c775ec22
...
...
@@ -308,6 +308,10 @@ namespace PcapDotNet.Packets.TestUtils
random
.
NextDataSegment
(
random
.
NextInt
(
0
,
100
)),
random
.
NextUShort
(),
random
.
NextEnum
<
DnsResponseCode
>(),
random
.
NextDataSegment
(
random
.
NextInt
(
0
,
100
)));
case
DnsType
.
Uri
:
return
new
DnsResourceDataUri
(
random
.
NextUShort
(),
random
.
NextUShort
(),
((
Func
<
DataSegment
>)(()
=>
random
.
NextDataSegment
(
random
.
NextInt
(
0
,
100
)))).
GenerateArray
(
random
.
NextInt
(
0
,
10
)));
default
:
return
new
DnsResourceDataAnything
(
random
.
NextDataSegment
(
random
.
Next
(
100
)));
}
...
...
@@ -338,7 +342,6 @@ namespace PcapDotNet.Packets.TestUtils
default
:
throw
new
InvalidOperationException
(
string
.
Format
(
"Invalid gateway type: {0}"
,
gatewayType
));
}
}
}
}
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
View file @
c775ec22
...
...
@@ -6513,4 +6513,109 @@ namespace PcapDotNet.Packets.Dns
return
new
DnsResourceDataTransactionSignature
(
algorithm
,
timeSigned
,
fudge
,
messageAuthenticationCode
,
originalId
,
error
,
other
);
}
}
/// <summary>
/// Faltstrom.
/// <pre>
/// +-----+----------+--------+
/// | bit | 0-15 | 16-31 |
/// +-----+----------+--------+
/// | 0 | Priority | Weight |
/// +-----+----------+--------+
/// | 32 | Target |
/// | ... | |
/// +-----+-------------------+
/// </pre>
/// </summary>
[
DnsTypeRegistration
(
Type
=
DnsType
.
Uri
)]
public
sealed
class
DnsResourceDataUri
:
DnsResourceDataSimple
,
IEquatable
<
DnsResourceDataUri
>
{
private
static
class
Offset
{
public
const
int
Priority
=
0
;
public
const
int
Weight
=
Priority
+
sizeof
(
ushort
);
public
const
int
Target
=
Weight
+
sizeof
(
ushort
);
}
private
const
int
ConstantPartLength
=
Offset
.
Target
;
public
DnsResourceDataUri
(
ushort
priority
,
ushort
weight
,
IList
<
DataSegment
>
target
)
{
Priority
=
priority
;
Weight
=
weight
;
Target
=
target
.
AsReadOnly
();
}
/// <summary>
/// The priority of the target URI in this RR.
/// A client must attempt to contact the URI with the lowest-numbered priority it can reach;
/// URIs with the same priority should be tried in the order defined by the weight field.
/// </summary>
public
ushort
Priority
{
get
;
private
set
;
}
/// <summary>
/// A server selection mechanism.
/// The weight field specifies a relative weight for entries with the same priority.
/// Larger weights should be given a proportionately higher probability of being selected.
/// </summary>
public
ushort
Weight
{
get
;
private
set
;
}
/// <summary>
/// The URI of the target.
/// Resolution of the URI is according to the definitions for the Scheme of the URI.
/// </summary>
public
ReadOnlyCollection
<
DataSegment
>
Target
{
get
;
private
set
;
}
public
bool
Equals
(
DnsResourceDataUri
other
)
{
return
other
!=
null
&&
Priority
.
Equals
(
other
.
Priority
)
&&
Weight
.
Equals
(
other
.
Weight
)
&&
Target
.
SequenceEqual
(
other
.
Target
);
}
public
override
bool
Equals
(
DnsResourceData
other
)
{
return
Equals
(
other
as
DnsResourceDataUri
);
}
internal
DnsResourceDataUri
()
:
this
(
0
,
0
,
new
DataSegment
[
0
])
{
}
internal
override
int
GetLength
()
{
return
ConstantPartLength
+
Target
.
Sum
(
targetPart
=>
GetStringLength
(
targetPart
));
}
internal
override
void
WriteDataSimple
(
byte
[]
buffer
,
int
offset
)
{
buffer
.
Write
(
offset
+
Offset
.
Priority
,
Priority
,
Endianity
.
Big
);
buffer
.
Write
(
offset
+
Offset
.
Weight
,
Weight
,
Endianity
.
Big
);
int
targetOffset
=
offset
+
Offset
.
Target
;
foreach
(
DataSegment
targetPart
in
Target
)
WriteString
(
buffer
,
ref
targetOffset
,
targetPart
);
}
internal
override
DnsResourceData
CreateInstance
(
DataSegment
data
)
{
if
(
data
.
Length
<
ConstantPartLength
)
return
null
;
ushort
priority
=
data
.
ReadUShort
(
Offset
.
Priority
,
Endianity
.
Big
);
ushort
weight
=
data
.
ReadUShort
(
Offset
.
Weight
,
Endianity
.
Big
);
List
<
DataSegment
>
target
=
new
List
<
DataSegment
>();
int
targetDataOffset
=
Offset
.
Target
;
while
(
data
.
Length
>
targetDataOffset
)
{
DataSegment
targetPart
=
ReadString
(
data
,
ref
targetDataOffset
);
if
(
targetPart
==
null
)
return
null
;
target
.
Add
(
targetPart
);
}
return
new
DnsResourceDataUri
(
priority
,
weight
,
target
);
}
}
}
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
View file @
c775ec22
...
...
@@ -453,24 +453,28 @@
/// <summary>
/// RFC 1995.
/// Incremental transfer.
/// Query Type.
/// </summary>
Ixfr
=
251
,
/// <summary>
/// RFCs 1035, 5936.
/// Transfer of an entire zone.
/// Query Type.
/// </summary>
Axf
t
=
252
,
Axf
r
=
252
,
/// <summary>
/// RFC 1035.
/// Mailbox-related RRs (MB, MG or MR).
/// Query Type.
/// </summary>
MailB
=
253
,
/// <summary>
/// RFC 1035.
/// Mail agent RRs (Obsolete - see MX).
/// Query Type.
/// </summary>
MailA
=
254
,
...
...
@@ -484,6 +488,7 @@
/// <summary>
/// Faltstrom.
/// URI.
/// Payload type: DnsResourceDataUri.
/// </summary>
Uri
=
256
,
...
...
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