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
317b6a4a
Commit
317b6a4a
authored
Jan 14, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DNS.
Code Coverage 92.97%
parent
78b7976d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
46 deletions
+29
-46
LivePacketDeviceTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
+1
-1
DatagramTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/DatagramTests.cs
+2
-1
DnsTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs
+26
-44
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
View file @
317b6a4a
...
...
@@ -188,7 +188,7 @@ namespace PcapDotNet.Core.Test
// Break loop
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
,
0
,
2
,
PacketSize
,
0
,
0
,
0.032
);
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
,
NumPacketsToSend
/
2
,
2
,
PacketSize
,
NumPacketsToSend
/
2
,
0
,
0.
043
);
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
,
NumPacketsToSend
/
2
,
2
,
PacketSize
,
NumPacketsToSend
/
2
,
0
,
0.
1
);
}
[
TestMethod
]
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/DatagramTests.cs
View file @
317b6a4a
...
...
@@ -63,7 +63,8 @@ namespace PcapDotNet.Packets.Test
{
Assert
.
AreNotEqual
(
datagram
,
Datagram
.
Empty
);
Assert
.
AreNotEqual
(
datagram
,
random
.
NextDatagram
(
datagram
.
Length
));
Assert
.
AreNotEqual
(
datagram
.
GetHashCode
(),
random
.
NextDatagram
(
datagram
.
Length
).
GetHashCode
());
if
(
datagram
.
Length
>
2
)
Assert
.
AreNotEqual
(
datagram
.
GetHashCode
(),
random
.
NextDatagram
(
datagram
.
Length
).
GetHashCode
());
}
else
Assert
.
AreEqual
(
datagram
,
Datagram
.
Empty
);
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs
View file @
317b6a4a
...
...
@@ -170,52 +170,34 @@ namespace PcapDotNet.Packets.Test
}
[
TestMethod
]
public
void
SimpleDns
Test
()
public
void
DnsResourceDataNextDomain
Test
()
{
DnsLayer
dnsLayer
=
new
DnsLayer
{
//Queries = new[] {new DnsQueryResourceRecord(new DnsDomainName("abc.def."), DnsType.A, DnsClass.In)}.ToList(),
Answers
=
new
[]
{
// new DnsDataResourceRecord(new DnsDomainName("abc.def."), DnsType.A, DnsClass.In, 100,
// new DnsResourceDataUnknown(new DataSegment(Encoding.ASCII.GetBytes("abcd")))),
// new DnsDataResourceRecord(new DnsDomainName("abc.def."), DnsType.A, DnsClass.In, 100,
// new DnsResourceDataUnknown(new DataSegment(Encoding.ASCII.GetBytes("abce")))),
new
DnsDataResourceRecord
(
new
DnsDomainName
(
""
),
DnsType
.
A
,
DnsClass
.
Any
,
1
,
new
DnsResourceDataIpV4
(
new
IpV4Address
(
"1.2.3.4"
)))
}.
ToList
(),
// Authorities =
// new[]
// {
// new DnsDataResourceRecord(new DnsDomainName("def"), DnsType.Ns, DnsClass.In, 2222,
// new DnsResourceDataUnknown(new DataSegment(Encoding.ASCII.GetBytes("123"))))
// }.ToList(),
// Additionals =
// new[]
// {
// new DnsDataResourceRecord(new DnsDomainName(""), DnsType.A, DnsClass.In, 2222,
// new DnsResourceDataUnknown(new DataSegment(Encoding.ASCII.GetBytes("444")))),
// new DnsDataResourceRecord(new DnsDomainName("123"), DnsType.A, DnsClass.In, 2222,
// new DnsResourceDataUnknown(new DataSegment(Encoding.ASCII.GetBytes("444")))),
// }.ToList(),
// DomainNameCompressionMode = DnsDomainNameCompressionMode.All,
// FutureUse = 6,
// Id = 16365,
// IsAuthoritiveAnswer = false,
// IsQuery = false,
// IsRecusionAvailable = true,
// IsRecusionDesired = true,
// Opcode = DnsOpcode.Query,
// ResponseCode = DnsResponseCode.ServerFailure,
};
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
(),
new
UdpLayer
(),
dnsLayer
);
Assert
.
IsTrue
(
packet
.
IsValid
,
"IsValid"
);
DataSegment
bitMap
=
DnsResourceDataNextDomain
.
CreateTypeBitMap
(
new
[]
{
DnsType
.
A
,
DnsType
.
Aaaa
});
DnsResourceDataNextDomain
resourceData
=
new
DnsResourceDataNextDomain
(
new
DnsDomainName
(
"a.b.c"
),
bitMap
);
Assert
.
IsFalse
(
resourceData
.
Equals
(
null
));
Assert
.
IsTrue
(
resourceData
.
IsTypePresentForOwner
(
DnsType
.
A
));
Assert
.
IsTrue
(
resourceData
.
IsTypePresentForOwner
(
DnsType
.
Aaaa
));
Assert
.
IsFalse
(
resourceData
.
IsTypePresentForOwner
(
DnsType
.
Ns
));
}
// DNS
Assert
.
AreEqual
(
dnsLayer
,
packet
.
Ethernet
.
IpV4
.
Udp
.
Dns
.
ExtractLayer
(),
"DNS Layer"
);
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
))]
public
void
DnsResourceDataNextDomainTooLongBitmapTest
()
{
DataSegment
bitMap
=
new
DataSegment
(
new
byte
[]
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
});
DnsResourceDataNextDomain
resourceData
=
new
DnsResourceDataNextDomain
(
new
DnsDomainName
(
"a.b.c"
),
bitMap
);
Assert
.
IsNull
(
resourceData
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
))]
public
void
DnsResourceDataNextDomainZeroEndedBitmapTest
()
{
DataSegment
bitMap
=
new
DataSegment
(
new
byte
[]
{
1
,
0
});
DnsResourceDataNextDomain
resourceData
=
new
DnsResourceDataNextDomain
(
new
DnsDomainName
(
"a.b.c"
),
bitMap
);
Assert
.
IsNull
(
resourceData
);
Assert
.
Fail
();
}
private
static
void
TestDomainNameCompression
(
int
expectedCompressionBenefit
,
DnsLayer
dnsLayer
)
...
...
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