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
1ccbfd97
Commit
1ccbfd97
authored
Nov 25, 2011
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DNS
parent
b3807c73
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
0 deletions
+105
-0
RandomDnsExtensions.cs
...t/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
+3
-0
DnsResourceData.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
+100
-0
DnsType.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
+2
-0
No files found.
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
View file @
1ccbfd97
...
@@ -290,6 +290,9 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -290,6 +290,9 @@ namespace PcapDotNet.Packets.TestUtils
case
DnsType
.
NInfo
:
case
DnsType
.
NInfo
:
return
new
DnsResourceDataNInfo
(((
Func
<
DataSegment
>)(()
=>
random
.
NextDataSegment
(
random
.
NextInt
(
1
,
10
)))).
GenerateArray
(
10
).
AsReadOnly
());
return
new
DnsResourceDataNInfo
(((
Func
<
DataSegment
>)(()
=>
random
.
NextDataSegment
(
random
.
NextInt
(
1
,
10
)))).
GenerateArray
(
10
).
AsReadOnly
());
case
DnsType
.
RKey
:
return
new
DnsResourceDataRKey
(
random
.
NextUShort
(),
random
.
NextByte
(),
random
.
NextEnum
<
DnsAlgorithm
>(),
random
.
NextDataSegment
(
random
.
NextInt
(
0
,
100
)));
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 @
1ccbfd97
...
@@ -5926,4 +5926,104 @@ namespace PcapDotNet.Packets.Dns
...
@@ -5926,4 +5926,104 @@ namespace PcapDotNet.Packets.Dns
return
new
DnsResourceDataNInfo
(
strings
.
AsReadOnly
());
return
new
DnsResourceDataNInfo
(
strings
.
AsReadOnly
());
}
}
}
}
/// <summary>
/// Reid.
/// <pre>
/// +-----+-------+----------+-----------+
/// | bit | 0-15 | 16-23 | 24-31 |
/// +-----+-------+----------+-----------+
/// | 0 | flags | protocol | algorithm |
/// +-----+-------+----------+-----------+
/// | 32 | public key |
/// | ... | |
/// +-----+------------------------------+
/// </pre>
/// </summary>
[
DnsTypeRegistration
(
Type
=
DnsType
.
RKey
)]
public
sealed
class
DnsResourceDataRKey
:
DnsResourceDataSimple
,
IEquatable
<
DnsResourceDataRKey
>
{
private
static
class
Offset
{
public
const
int
Flags
=
0
;
public
const
int
Protocol
=
Flags
+
sizeof
(
ushort
);
public
const
int
Algorithm
=
Protocol
+
sizeof
(
byte
);
public
const
int
PublicKey
=
Algorithm
+
sizeof
(
byte
);
}
private
const
int
ConstantPartLength
=
Offset
.
PublicKey
;
public
DnsResourceDataRKey
(
ushort
flags
,
byte
protocol
,
DnsAlgorithm
algorithm
,
DataSegment
publicKey
)
{
Flags
=
flags
;
Protocol
=
protocol
;
Algorithm
=
algorithm
;
PublicKey
=
publicKey
;
}
/// <summary>
/// Reserved and must be zero.
/// </summary>
public
ushort
Flags
{
get
;
private
set
;
}
/// <summary>
/// Must be set to 1.
/// </summary>
public
byte
Protocol
{
get
;
private
set
;
}
/// <summary>
/// The key algorithm parallel to the same field for the SIG resource.
/// </summary>
public
DnsAlgorithm
Algorithm
{
get
;
private
set
;
}
/// <summary>
/// The public key value.
/// </summary>
public
DataSegment
PublicKey
{
get
;
private
set
;
}
public
bool
Equals
(
DnsResourceDataRKey
other
)
{
return
other
!=
null
&&
Flags
.
Equals
(
other
.
Flags
)
&&
Protocol
.
Equals
(
other
.
Protocol
)
&&
Algorithm
.
Equals
(
other
.
Algorithm
)
&&
PublicKey
.
Equals
(
other
.
PublicKey
);
}
public
override
bool
Equals
(
DnsResourceData
other
)
{
return
Equals
(
other
as
DnsResourceDataRKey
);
}
internal
DnsResourceDataRKey
()
:
this
(
0
,
1
,
DnsAlgorithm
.
None
,
DataSegment
.
Empty
)
{
}
internal
override
int
GetLength
()
{
return
ConstantPartLength
+
PublicKey
.
Length
;
}
internal
override
void
WriteDataSimple
(
byte
[]
buffer
,
int
offset
)
{
buffer
.
Write
(
offset
+
Offset
.
Flags
,
Flags
,
Endianity
.
Big
);
buffer
.
Write
(
offset
+
Offset
.
Protocol
,
Protocol
);
buffer
.
Write
(
offset
+
Offset
.
Algorithm
,
(
byte
)
Algorithm
);
PublicKey
.
Write
(
buffer
,
offset
+
Offset
.
PublicKey
);
}
internal
override
DnsResourceData
CreateInstance
(
DataSegment
data
)
{
if
(
data
.
Length
<
ConstantPartLength
)
return
null
;
ushort
flags
=
data
.
ReadUShort
(
Offset
.
Flags
,
Endianity
.
Big
);
byte
protocol
=
data
[
Offset
.
Protocol
];
DnsAlgorithm
algorithm
=
(
DnsAlgorithm
)
data
[
Offset
.
Algorithm
];
DataSegment
publicKey
=
data
.
SubSegment
(
Offset
.
PublicKey
,
data
.
Length
-
ConstantPartLength
);
return
new
DnsResourceDataRKey
(
flags
,
protocol
,
algorithm
,
publicKey
);
}
}
}
}
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
View file @
1ccbfd97
...
@@ -386,6 +386,8 @@
...
@@ -386,6 +386,8 @@
/// <summary>
/// <summary>
/// Reid.
/// Reid.
/// RKEY.
/// RKEY.
/// Can be used to encrypt NAPTR record.
/// Payload type: DnsResourceDataRKey.
/// </summary>
/// </summary>
RKey
=
57
,
RKey
=
57
,
...
...
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