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
3bfe71e1
Commit
3bfe71e1
authored
Oct 20, 2011
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DNS
parent
c93107dd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
490 additions
and
3 deletions
+490
-3
PcapDotNet.Base.Test.csproj
...tNet/src/PcapDotNet.Base.Test/PcapDotNet.Base.Test.csproj
+1
-0
SerialNumber32Test.cs
PcapDotNet/src/PcapDotNet.Base.Test/SerialNumber32Test.cs
+71
-0
PcapDotNet.Base.csproj
PcapDotNet/src/PcapDotNet.Base/PcapDotNet.Base.csproj
+1
-0
SerialNumber32.cs
PcapDotNet/src/PcapDotNet.Base/SerialNumber32.cs
+58
-0
RandomDnsExtensions.cs
...t/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
+6
-0
DnsResourceData.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
+329
-3
DnsType.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
+24
-0
No files found.
PcapDotNet/src/PcapDotNet.Base.Test/PcapDotNet.Base.Test.csproj
View file @
3bfe71e1
...
...
@@ -73,6 +73,7 @@
<Compile
Include=
"MemberInfoExtensionsTests.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"PropertyInfoExtensionsTests.cs"
/>
<Compile
Include=
"SerialNumber32Test.cs"
/>
<Compile
Include=
"UInt128Tests.cs"
/>
<Compile
Include=
"UInt24Tests.cs"
/>
<Compile
Include=
"UInt48Tests.cs"
/>
...
...
PcapDotNet/src/PcapDotNet.Base.Test/SerialNumber32Test.cs
0 → 100644
View file @
3bfe71e1
using
System
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
PcapDotNet.TestUtils
;
namespace
PcapDotNet.Base.Test
{
/// <summary>
/// Summary description for SerialNumber32Test
/// </summary>
[
TestClass
]
public
class
SerialNumber32Test
{
/// <summary>
/// Gets or sets the test context which provides information about and functionality for the current test run.
/// </summary>
public
TestContext
TestContext
{
get
;
set
;
}
#
region
Additional
test
attributes
//
// You can use the following additional attributes as you write your tests:
//
// Use ClassInitialize to run code before running the first test in the class
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#
endregion
[
TestMethod
]
public
void
SimpleTest
()
{
Assert
.
AreEqual
<
SerialNumber32
>(
1
,
1
);
Assert
.
AreNotEqual
<
SerialNumber32
>(
1
,
2
);
MoreAssert
.
IsBigger
(
1
,
2
);
MoreAssert
.
IsSmaller
(
2
,
1
);
SerialNumber32
serialNumber
=
1
;
serialNumber
=
serialNumber
.
Add
(
10
);
Assert
.
AreEqual
<
SerialNumber32
>(
11
,
serialNumber
);
serialNumber
=
serialNumber
.
Add
(((
uint
)
1
<<
31
)
-
1
);
Assert
.
AreEqual
<
SerialNumber32
>(
2147483658
,
serialNumber
);
MoreAssert
.
IsSmaller
<
SerialNumber32
>(
1
,
serialNumber
);
MoreAssert
.
IsBigger
<
SerialNumber32
>(
20
,
serialNumber
);
serialNumber
=
serialNumber
.
Add
(((
uint
)
1
<<
31
)
-
1
);
Assert
.
AreEqual
<
SerialNumber32
>(
9
,
serialNumber
);
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
))]
public
void
OverflowAddTest
()
{
SerialNumber32
serialNumber
=
1
;
serialNumber
=
serialNumber
.
Add
((
uint
)
1
<<
31
);
Assert
.
Fail
(
serialNumber
.
ToString
());
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Base/PcapDotNet.Base.csproj
View file @
3bfe71e1
...
...
@@ -96,6 +96,7 @@
<Compile
Include=
"MatchExtensions.cs"
/>
<Compile
Include=
"MemberInfoExtensions.cs"
/>
<Compile
Include=
"PropertyInfoExtensions.cs"
/>
<Compile
Include=
"SerialNumber32.cs"
/>
<Compile
Include=
"TimeSpanExtensions.cs"
/>
<Compile
Include=
"TypeExtensions.cs"
/>
<Compile
Include=
"UInt128.cs"
/>
...
...
PcapDotNet/src/PcapDotNet.Base/SerialNumber32.cs
0 → 100644
View file @
3bfe71e1
using
System
;
namespace
PcapDotNet.Base
{
public
struct
SerialNumber32
:
IEquatable
<
SerialNumber32
>,
IComparable
<
SerialNumber32
>
{
public
const
int
SerialBits
=
32
;
public
const
uint
MaxAdditiveNumber
=
((
uint
)
1
<<
(
SerialBits
-
1
))
-
1
;
public
SerialNumber32
(
uint
value
)
{
_value
=
value
;
}
public
uint
Value
{
get
{
return
_value
;
}
}
public
SerialNumber32
Add
(
uint
value
)
{
if
(
value
>
MaxAdditiveNumber
)
throw
new
ArgumentOutOfRangeException
(
"value"
,
value
,
string
.
Format
(
"Cannot add a number bigger than {0}"
,
MaxAdditiveNumber
));
return
_value
+
value
;
}
public
bool
Equals
(
SerialNumber32
other
)
{
return
Value
==
other
.
Value
;
}
public
override
bool
Equals
(
object
obj
)
{
return
obj
is
SerialNumber32
&&
Equals
((
SerialNumber32
)
obj
);
}
public
int
CompareTo
(
SerialNumber32
other
)
{
if
(
Equals
(
other
))
return
0
;
if
(
Value
<
other
.
Value
)
return
(
other
.
Value
-
Value
<
MaxAdditiveNumber
+
1
?
-
1
:
1
);
return
(
Value
-
other
.
Value
<
MaxAdditiveNumber
+
1
?
1
:
-
1
);
}
public
override
string
ToString
()
{
return
Value
.
ToString
();
}
public
static
implicit
operator
SerialNumber32
(
uint
value
)
{
return
new
SerialNumber32
(
value
);
}
private
readonly
uint
_value
;
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
View file @
3bfe71e1
...
...
@@ -88,6 +88,7 @@ namespace PcapDotNet.Packets.TestUtils
case
DnsType
.
Mg
:
case
DnsType
.
Mr
:
case
DnsType
.
Ptr
:
case
DnsType
.
NsapPtr
:
return
new
DnsResourceDataDomainName
(
random
.
NextDnsDomainName
());
case
DnsType
.
Soa
:
return
new
DnsResourceDataStartOfAuthority
(
random
.
NextDnsDomainName
(),
random
.
NextDnsDomainName
(),
...
...
@@ -131,6 +132,11 @@ namespace PcapDotNet.Packets.TestUtils
case
DnsType
.
Nsap
:
return
new
DnsResourceDataNetworkServiceAccessPoint
(
random
.
NextDataSegment
(
1
+
random
.
Next
(
10
)),
random
.
NextUInt48
(),
random
.
NextByte
());
case
DnsType
.
Sig
:
return
new
DnsResourceDataSig
(
random
.
NextEnum
<
DnsType
>(),
random
.
NextEnum
<
DnsAlgorithm
>(),
random
.
NextByte
(),
random
.
NextUInt
(),
random
.
NextUInt
(),
random
.
NextUInt
(),
random
.
NextUShort
(),
random
.
NextDnsDomainName
(),
random
.
NextDataSegment
(
random
.
Next
(
100
)));
default
:
return
new
DnsResourceDataAnything
(
random
.
NextDataSegment
(
random
.
Next
(
100
)));
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
View file @
3bfe71e1
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
View file @
3bfe71e1
...
...
@@ -11,126 +11,147 @@
/// <summary>
/// RFC 1035.
/// A host address.
/// Payload type: DnsResourceDataIpV4.
/// </summary>
A
=
1
,
/// <summary>
/// RFC 1035.
/// An authoritative name server.
/// Payload type: DnsResourceDataDomainName.
/// </summary>
Ns
=
2
,
/// <summary>
/// RFC 1035.
/// A mail destination (Obsolete - use MX).
/// Payload type: DnsResourceDataDomainName.
/// </summary>
Md
=
3
,
/// <summary>
/// RFC 1035.
/// A mail forwarder (Obsolete - use MX).
/// Payload type: DnsResourceDataDomainName.
/// </summary>
Mf
=
4
,
/// <summary>
/// RFC 1035.
/// The canonical name for an alias.
/// Payload type: DnsResourceDataDomainName.
/// </summary>
CName
=
5
,
/// <summary>
/// RFC 1035.
/// Marks the start of a zone of authority.
/// Payload type: DnsResourceDataStartOfAuthority.
/// </summary>
Soa
=
6
,
/// <summary>
/// RFC 1035.
/// A mailbox domain name (EXPERIMENTAL).
/// Payload type: DnsResourceDataDomainName.
/// </summary>
Mb
=
7
,
/// <summary>
/// RFC 1035.
/// A mail group member (EXPERIMENTAL).
/// Payload type: DnsResourceDataDomainName.
/// </summary>
Mg
=
8
,
/// <summary>
/// RFC 1035.
/// A mail rename domain name (EXPERIMENTAL).
/// Payload type: DnsResourceDataDomainName.
/// </summary>
Mr
=
9
,
/// <summary>
/// RFC 1035.
/// A null RR (EXPERIMENTAL).
/// Payload type: DnsResourceDataAnything.
/// </summary>
Null
=
10
,
/// <summary>
/// RFC 1035.
/// A well known service description..
/// Payload type: DnsResourceDataWellKnownService.
/// </summary>
Wks
=
11
,
/// <summary>
/// RFC 1035.
/// A domain name pointer.
/// Payload type: DnsResourceDataDomainName.
/// </summary>
Ptr
=
12
,
/// <summary>
/// RFC 1035.
/// Host information.
/// Payload type: DnsResourceDataHostInformation.
/// </summary>
HInfo
=
13
,
/// <summary>
/// RFC 1035.
/// mailbox or mail list information.
/// Payload type: DnsResourceDataMailingListInfo.
/// </summary>
MInfo
=
14
,
/// <summary>
/// RFC 1035.
/// Mail exchange.
/// Payload type: DnsResourceDataMailExchange.
/// </summary>
Mx
=
15
,
/// <summary>
/// RFC 1035.
/// Text strings.
/// Payload type: DnsResourceDataText.
/// </summary>
Txt
=
16
,
/// <summary>
/// RFC 1183.
/// For Responsible Person.
/// Payload type: DnsResourceDataResponsiblePerson.
/// </summary>
Rp
=
17
,
/// <summary>
/// RFCs 1183, 5864.
/// For AFS Data Base location.
/// Payload type: DnsResourceDataAfsDb.
/// </summary>
AfsDb
=
18
,
/// <summary>
/// RFC 1183.
/// For X.25 PSDN address.
/// Payload type: DnsResourceDataString.
/// </summary>
X25
=
19
,
/// <summary>
/// RFC 1183.
/// For ISDN address.
/// Payload type: DnsResourceDataIsdn.
/// </summary>
Isdn
=
20
,
/// <summary>
/// RFC 1183.
/// For Route Through.
/// Payload type: DnsResourceDataRouteThrough.
/// </summary>
Rt
=
21
,
...
...
@@ -138,18 +159,21 @@
/// RFC 1706.
/// Network Service Access Point.
/// For NSAP address, NSAP style A record.
/// Payload type: DnsResourceDataNetworkServiceAccessPoint.
/// </summary>
Nsap
=
22
,
/// <summary>
/// RFC 1348.
/// For domain name pointer, NSAP style.
/// Payload type: DnsResourceDataDomainName.
/// </summary>
NsapPtr
=
23
,
/// <summary>
/// RFCs 2535, 3755, 4034.
/// For security signature.
/// Payload type: DnsResourceDataSig.
/// </summary>
Sig
=
24
,
...
...
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