Commit 24414bbe authored by Brickner_cp's avatar Brickner_cp

Smaller indentation for SendingASinglePacketWithSendPacket example.

parent f951ad00
...@@ -128,17 +128,19 @@ namespace SendingASinglePacketWithSendPacket ...@@ -128,17 +128,19 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildEthernetPacket() private static Packet BuildEthernetPacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.IpV4, Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.IpV4,
};
PayloadLayer payloadLayer = new PayloadLayer
{ PayloadLayer payloadLayer =
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")), new PayloadLayer
}; {
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")),
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, payloadLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, payloadLayer);
...@@ -150,22 +152,24 @@ namespace SendingASinglePacketWithSendPacket ...@@ -150,22 +152,24 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildArpPacket() private static Packet BuildArpPacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
ArpLayer arpLayer = new ArpLayer
{ ArpLayer arpLayer =
ProtocolType = EthernetType.IpV4, new ArpLayer
Operation = ArpOperation.Request, {
SenderHardwareAddress = new byte[] {3, 3, 3, 3, 3, 3}.AsReadOnly(), // 03:03:03:03:03:03. ProtocolType = EthernetType.IpV4,
SenderProtocolAddress = new byte[] {1, 2, 3, 4}.AsReadOnly(), // 1.2.3.4. Operation = ArpOperation.Request,
TargetHardwareAddress = new byte[] {4, 4, 4, 4, 4, 4}.AsReadOnly(), // 04:04:04:04:04:04. SenderHardwareAddress = new byte[] {3, 3, 3, 3, 3, 3}.AsReadOnly(), // 03:03:03:03:03:03.
TargetProtocolAddress = new byte[] {11, 22, 33, 44}.AsReadOnly(), // 11.22.33.44. SenderProtocolAddress = new byte[] {1, 2, 3, 4}.AsReadOnly(), // 1.2.3.4.
}; TargetHardwareAddress = new byte[] {4, 4, 4, 4, 4, 4}.AsReadOnly(), // 04:04:04:04:04:04.
TargetProtocolAddress = new byte[] {11, 22, 33, 44}.AsReadOnly(), // 11.22.33.44.
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, arpLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, arpLayer);
...@@ -177,25 +181,28 @@ namespace SendingASinglePacketWithSendPacket ...@@ -177,25 +181,28 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildVLanTaggedFramePacket() private static Packet BuildVLanTaggedFramePacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
VLanTaggedFrameLayer vLanTaggedFrameLayer = new VLanTaggedFrameLayer
{ VLanTaggedFrameLayer vLanTaggedFrameLayer =
PriorityCodePoint = ClassOfService.Background, new VLanTaggedFrameLayer
CanonicalFormatIndicator = false, {
VLanIdentifier = 50, PriorityCodePoint = ClassOfService.Background,
EtherType = EthernetType.IpV4, CanonicalFormatIndicator = false,
}; VLanIdentifier = 50,
EtherType = EthernetType.IpV4,
PayloadLayer payloadLayer = new PayloadLayer };
{
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")), PayloadLayer payloadLayer =
}; new PayloadLayer
{
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")),
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, vLanTaggedFrameLayer, payloadLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, vLanTaggedFrameLayer, payloadLayer);
...@@ -207,30 +214,33 @@ namespace SendingASinglePacketWithSendPacket ...@@ -207,30 +214,33 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildIpV4Packet() private static Packet BuildIpV4Packet()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None,
};
IpV4Layer ipV4Layer = new IpV4Layer
{ IpV4Layer ipV4Layer =
Source = new IpV4Address("1.2.3.4"), new IpV4Layer
CurrentDestination = new IpV4Address("11.22.33.44"), {
Fragmentation = IpV4Fragmentation.None, Source = new IpV4Address("1.2.3.4"),
HeaderChecksum = null, // Will be filled automatically. CurrentDestination = new IpV4Address("11.22.33.44"),
Identification = 123, Fragmentation = IpV4Fragmentation.None,
Options = IpV4Options.None, HeaderChecksum = null, // Will be filled automatically.
Protocol = IpV4Protocol.Udp, Identification = 123,
Ttl = 100, Options = IpV4Options.None,
TypeOfService = 0, Protocol = IpV4Protocol.Udp,
}; Ttl = 100,
TypeOfService = 0,
PayloadLayer payloadLayer = new PayloadLayer };
{
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")), PayloadLayer payloadLayer =
}; new PayloadLayer
{
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")),
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, payloadLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, payloadLayer);
...@@ -242,32 +252,35 @@ namespace SendingASinglePacketWithSendPacket ...@@ -242,32 +252,35 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildIcmpPacket() private static Packet BuildIcmpPacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
IpV4Layer ipV4Layer = new IpV4Layer
{ IpV4Layer ipV4Layer =
Source = new IpV4Address("1.2.3.4"), new IpV4Layer
CurrentDestination = new IpV4Address("11.22.33.44"), {
Fragmentation = IpV4Fragmentation.None, Source = new IpV4Address("1.2.3.4"),
HeaderChecksum = null, // Will be filled automatically. CurrentDestination = new IpV4Address("11.22.33.44"),
Identification = 123, Fragmentation = IpV4Fragmentation.None,
Options = IpV4Options.None, HeaderChecksum = null, // Will be filled automatically.
Protocol = null, // Will be filled automatically. Identification = 123,
Ttl = 100, Options = IpV4Options.None,
TypeOfService = 0, Protocol = null, // Will be filled automatically.
}; Ttl = 100,
TypeOfService = 0,
IcmpEchoLayer icmpLayer = new IcmpEchoLayer };
{
Checksum = null, // Will be filled automatically. IcmpEchoLayer icmpLayer =
Identifier = 456, new IcmpEchoLayer
SequenceNumber = 800, {
}; Checksum = null, // Will be filled automatically.
Identifier = 456,
SequenceNumber = 800,
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, icmpLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, icmpLayer);
...@@ -279,30 +292,33 @@ namespace SendingASinglePacketWithSendPacket ...@@ -279,30 +292,33 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildIgmpPacket() private static Packet BuildIgmpPacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
IpV4Layer ipV4Layer = new IpV4Layer
{ IpV4Layer ipV4Layer =
Source = new IpV4Address("1.2.3.4"), new IpV4Layer
CurrentDestination = new IpV4Address("11.22.33.44"), {
Fragmentation = IpV4Fragmentation.None, Source = new IpV4Address("1.2.3.4"),
HeaderChecksum = null, // Will be filled automatically. CurrentDestination = new IpV4Address("11.22.33.44"),
Identification = 123, Fragmentation = IpV4Fragmentation.None,
Options = IpV4Options.None, HeaderChecksum = null, // Will be filled automatically.
Protocol = null, // Will be filled automatically. Identification = 123,
Ttl = 100, Options = IpV4Options.None,
TypeOfService = 0, Protocol = null, // Will be filled automatically.
}; Ttl = 100,
TypeOfService = 0,
IgmpQueryVersion1Layer igmpLayer = new IgmpQueryVersion1Layer };
{
GroupAddress = new IpV4Address("1.2.3.4"), IgmpQueryVersion1Layer igmpLayer =
}; new IgmpQueryVersion1Layer
{
GroupAddress = new IpV4Address("1.2.3.4"),
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, igmpLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, igmpLayer);
...@@ -314,54 +330,58 @@ namespace SendingASinglePacketWithSendPacket ...@@ -314,54 +330,58 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildGrePacket() private static Packet BuildGrePacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
IpV4Layer ipV4Layer = new IpV4Layer
{ IpV4Layer ipV4Layer =
Source = new IpV4Address("1.2.3.4"), new IpV4Layer
CurrentDestination = new IpV4Address("11.22.33.44"), {
Fragmentation = IpV4Fragmentation.None, Source = new IpV4Address("1.2.3.4"),
HeaderChecksum = null, // Will be filled automatically. CurrentDestination = new IpV4Address("11.22.33.44"),
Identification = 123, Fragmentation = IpV4Fragmentation.None,
Options = IpV4Options.None, HeaderChecksum = null, // Will be filled automatically.
Protocol = null, // Will be filled automatically. Identification = 123,
Ttl = 100, Options = IpV4Options.None,
TypeOfService = 0, Protocol = null, // Will be filled automatically.
}; Ttl = 100,
TypeOfService = 0,
GreLayer greLayer = new GreLayer };
{
Version = GreVersion.Gre, GreLayer greLayer =
ProtocolType = EthernetType.None, // Will be filled automatically. new GreLayer
RecursionControl = 0, {
FutureUseBits = 0, Version = GreVersion.Gre,
ChecksumPresent = true, ProtocolType = EthernetType.None, // Will be filled automatically.
Checksum = null, // Will be filled automatically. RecursionControl = 0,
Key = null, FutureUseBits = 0,
SequenceNumber = 123, ChecksumPresent = true,
AcknowledgmentSequenceNumber = null, Checksum = null, // Will be filled automatically.
RoutingOffset = null, Key = null,
Routing = null, SequenceNumber = 123,
StrictSourceRoute = false, AcknowledgmentSequenceNumber = null,
}; RoutingOffset = null,
Routing = null,
IpV4Layer innerIpV4Layer = new IpV4Layer StrictSourceRoute = false,
{ };
Source = new IpV4Address("100.200.201.202"),
CurrentDestination = new IpV4Address("123.254.132.40"), IpV4Layer innerIpV4Layer =
Fragmentation = IpV4Fragmentation.None, new IpV4Layer
HeaderChecksum = null, // Will be filled automatically. {
Identification = 123, Source = new IpV4Address("100.200.201.202"),
Options = IpV4Options.None, CurrentDestination = new IpV4Address("123.254.132.40"),
Protocol = IpV4Protocol.Udp, Fragmentation = IpV4Fragmentation.None,
Ttl = 120, HeaderChecksum = null, // Will be filled automatically.
TypeOfService = 0, Identification = 123,
}; Options = IpV4Options.None,
Protocol = IpV4Protocol.Udp,
Ttl = 120,
TypeOfService = 0,
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, greLayer, innerIpV4Layer); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, greLayer, innerIpV4Layer);
...@@ -373,38 +393,42 @@ namespace SendingASinglePacketWithSendPacket ...@@ -373,38 +393,42 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildUdpPacket() private static Packet BuildUdpPacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
IpV4Layer ipV4Layer = new IpV4Layer
{ IpV4Layer ipV4Layer =
Source = new IpV4Address("1.2.3.4"), new IpV4Layer
CurrentDestination = new IpV4Address("11.22.33.44"), {
Fragmentation = IpV4Fragmentation.None, Source = new IpV4Address("1.2.3.4"),
HeaderChecksum = null, // Will be filled automatically. CurrentDestination = new IpV4Address("11.22.33.44"),
Identification = 123, Fragmentation = IpV4Fragmentation.None,
Options = IpV4Options.None, HeaderChecksum = null, // Will be filled automatically.
Protocol = null, // Will be filled automatically. Identification = 123,
Ttl = 100, Options = IpV4Options.None,
TypeOfService = 0, Protocol = null, // Will be filled automatically.
}; Ttl = 100,
TypeOfService = 0,
UdpLayer udpLayer = new UdpLayer };
{
SourcePort = 4050, UdpLayer udpLayer =
DestinationPort = 25, new UdpLayer
Checksum = null, // Will be filled automatically. {
CalculateChecksumValue = true, SourcePort = 4050,
}; DestinationPort = 25,
Checksum = null, // Will be filled automatically.
PayloadLayer payloadLayer = new PayloadLayer CalculateChecksumValue = true,
{ };
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")),
}; PayloadLayer payloadLayer =
new PayloadLayer
{
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")),
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, payloadLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, payloadLayer);
...@@ -416,43 +440,47 @@ namespace SendingASinglePacketWithSendPacket ...@@ -416,43 +440,47 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildTcpPacket() private static Packet BuildTcpPacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
IpV4Layer ipV4Layer = new IpV4Layer
{ IpV4Layer ipV4Layer =
Source = new IpV4Address("1.2.3.4"), new IpV4Layer
CurrentDestination = new IpV4Address("11.22.33.44"), {
Fragmentation = IpV4Fragmentation.None, Source = new IpV4Address("1.2.3.4"),
HeaderChecksum = null, // Will be filled automatically. CurrentDestination = new IpV4Address("11.22.33.44"),
Identification = 123, Fragmentation = IpV4Fragmentation.None,
Options = IpV4Options.None, HeaderChecksum = null, // Will be filled automatically.
Protocol = null, // Will be filled automatically. Identification = 123,
Ttl = 100, Options = IpV4Options.None,
TypeOfService = 0, Protocol = null, // Will be filled automatically.
}; Ttl = 100,
TypeOfService = 0,
TcpLayer tcpLayer = new TcpLayer() };
{
SourcePort = 4050, TcpLayer tcpLayer =
DestinationPort = 25, new TcpLayer
Checksum = null, // Will be filled automatically. {
SequenceNumber = 100, SourcePort = 4050,
AcknowledgmentNumber = 50, DestinationPort = 25,
ControlBits = TcpControlBits.Acknowledgment, Checksum = null, // Will be filled automatically.
Window = 100, SequenceNumber = 100,
UrgentPointer = 0, AcknowledgmentNumber = 50,
Options = TcpOptions.None, ControlBits = TcpControlBits.Acknowledgment,
}; Window = 100,
UrgentPointer = 0,
PayloadLayer payloadLayer = new PayloadLayer Options = TcpOptions.None,
{ };
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")),
}; PayloadLayer payloadLayer =
new PayloadLayer
{
Data = new Datagram(Encoding.ASCII.GetBytes("hello world")),
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, tcpLayer, payloadLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, tcpLayer, payloadLayer);
...@@ -464,53 +492,62 @@ namespace SendingASinglePacketWithSendPacket ...@@ -464,53 +492,62 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildDnsPacket() private static Packet BuildDnsPacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
IpV4Layer ipV4Layer = new IpV4Layer
IpV4Layer ipV4Layer =
new IpV4Layer
{
Source = new IpV4Address("1.2.3.4"),
CurrentDestination = new IpV4Address("11.22.33.44"),
Fragmentation = IpV4Fragmentation.None,
HeaderChecksum = null, // Will be filled automatically.
Identification = 123,
Options = IpV4Options.None,
Protocol = null, // Will be filled automatically.
Ttl = 100,
TypeOfService = 0,
};
UdpLayer udpLayer =
new UdpLayer
{
SourcePort = 4050,
DestinationPort = 53,
Checksum = null, // Will be filled automatically.
CalculateChecksumValue = true,
};
DnsLayer dnsLayer =
new DnsLayer
{
Id = 100,
IsResponse = false,
OpCode = DnsOpCode.Query,
IsAuthoritativeAnswer = false,
IsTruncated = false,
IsRecursionDesired = true,
IsRecursionAvailable = false,
FutureUse = false,
IsAuthenticData = false,
IsCheckingDisabled = false,
ResponseCode = DnsResponseCode.NoError,
Queries = new[]
{ {
Source = new IpV4Address("1.2.3.4"), new DnsQueryResourceRecord(new DnsDomainName("pcapdot.net"),
CurrentDestination = new IpV4Address("11.22.33.44"), DnsType.A,
Fragmentation = IpV4Fragmentation.None, DnsClass.Internet),
HeaderChecksum = null, // Will be filled automatically. },
Identification = 123, Answers = null,
Options = IpV4Options.None, Authorities = null,
Protocol = null, // Will be filled automatically. Additionals = null,
Ttl = 100, DomainNameCompressionMode = DnsDomainNameCompressionMode.All,
TypeOfService = 0, };
};
UdpLayer udpLayer = new UdpLayer
{
SourcePort = 4050,
DestinationPort = 53,
Checksum = null, // Will be filled automatically.
CalculateChecksumValue = true,
};
DnsLayer dnsLayer = new DnsLayer
{
Id = 100,
IsResponse = false,
OpCode = DnsOpCode.Query,
IsAuthoritativeAnswer = false,
IsTruncated = false,
IsRecursionDesired = true,
IsRecursionAvailable = false,
FutureUse = false,
IsAuthenticData = false,
IsCheckingDisabled = false,
ResponseCode = DnsResponseCode.NoError,
Queries = new[] {new DnsQueryResourceRecord(new DnsDomainName("pcapdot.net"), DnsType.A, DnsClass.Internet),},
Answers = null,
Authorities = null,
Additionals = null,
DomainNameCompressionMode = DnsDomainNameCompressionMode.All,
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, dnsLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, dnsLayer);
...@@ -522,47 +559,51 @@ namespace SendingASinglePacketWithSendPacket ...@@ -522,47 +559,51 @@ namespace SendingASinglePacketWithSendPacket
/// </summary> /// </summary>
private static Packet BuildHttpPacket() private static Packet BuildHttpPacket()
{ {
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer =
{ new EthernetLayer
Source = new MacAddress("01:01:01:01:01:01"), {
Destination = new MacAddress("02:02:02:02:02:02"), Source = new MacAddress("01:01:01:01:01:01"),
EtherType = EthernetType.None, // Will be filled automatically. Destination = new MacAddress("02:02:02:02:02:02"),
}; EtherType = EthernetType.None, // Will be filled automatically.
};
IpV4Layer ipV4Layer = new IpV4Layer
{ IpV4Layer ipV4Layer =
Source = new IpV4Address("1.2.3.4"), new IpV4Layer
CurrentDestination = new IpV4Address("11.22.33.44"), {
Fragmentation = IpV4Fragmentation.None, Source = new IpV4Address("1.2.3.4"),
HeaderChecksum = null, // Will be filled automatically. CurrentDestination = new IpV4Address("11.22.33.44"),
Identification = 123, Fragmentation = IpV4Fragmentation.None,
Options = IpV4Options.None, HeaderChecksum = null, // Will be filled automatically.
Protocol = null, // Will be filled automatically. Identification = 123,
Ttl = 100, Options = IpV4Options.None,
TypeOfService = 0, Protocol = null, // Will be filled automatically.
}; Ttl = 100,
TypeOfService = 0,
TcpLayer tcpLayer = new TcpLayer };
{
SourcePort = 4050, TcpLayer tcpLayer =
DestinationPort = 80, new TcpLayer
Checksum = null, // Will be filled automatically. {
SequenceNumber = 100, SourcePort = 4050,
AcknowledgmentNumber = 50, DestinationPort = 80,
ControlBits = TcpControlBits.Acknowledgment, Checksum = null, // Will be filled automatically.
Window = 100, SequenceNumber = 100,
UrgentPointer = 0, AcknowledgmentNumber = 50,
Options = TcpOptions.None, ControlBits = TcpControlBits.Acknowledgment,
}; Window = 100,
UrgentPointer = 0,
HttpRequestLayer httpLayer = new HttpRequestLayer Options = TcpOptions.None,
{ };
Version = HttpVersion.Version11,
Header = new HttpHeader(new HttpContentLengthField(11)), HttpRequestLayer httpLayer =
Body = new Datagram(Encoding.ASCII.GetBytes("hello world")), new HttpRequestLayer
Method = new HttpRequestMethod(HttpRequestKnownMethod.Get), {
Uri = @"http://pcapdot.net/", Version = HttpVersion.Version11,
}; Header = new HttpHeader(new HttpContentLengthField(11)),
Body = new Datagram(Encoding.ASCII.GetBytes("hello world")),
Method = new HttpRequestMethod(HttpRequestKnownMethod.Get),
Uri = @"http://pcapdot.net/",
};
PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, tcpLayer, httpLayer); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, tcpLayer, httpLayer);
...@@ -613,11 +654,12 @@ namespace SendingASinglePacketWithSendPacket ...@@ -613,11 +654,12 @@ namespace SendingASinglePacketWithSendPacket
Fragmentation = IpV4Fragmentation.None, Fragmentation = IpV4Fragmentation.None,
HeaderChecksum = null, // Will be filled automatically. HeaderChecksum = null, // Will be filled automatically.
Identification = 456, Identification = 456,
Options = new IpV4Options(new IpV4OptionStrictSourceRouting(new[] Options = new IpV4Options(new IpV4OptionStrictSourceRouting(
{ new[]
new IpV4Address("100.200.100.200"), {
new IpV4Address("150.250.150.250") new IpV4Address("100.200.100.200"),
}, 1)), new IpV4Address("150.250.150.250")
}, 1)),
Protocol = null, // Will be filled automatically. Protocol = null, // Will be filled automatically.
Ttl = 200, Ttl = 200,
TypeOfService = 0, TypeOfService = 0,
...@@ -636,16 +678,18 @@ namespace SendingASinglePacketWithSendPacket ...@@ -636,16 +678,18 @@ namespace SendingASinglePacketWithSendPacket
RoutingOffset = null, RoutingOffset = null,
Routing = new[] Routing = new[]
{ {
new GreSourceRouteEntryIp(new[] new GreSourceRouteEntryIp(
{ new[]
new IpV4Address("10.20.30.40"), {
new IpV4Address("40.30.20.10") new IpV4Address("10.20.30.40"),
}.AsReadOnly(), 1), new IpV4Address("40.30.20.10")
new GreSourceRouteEntryIp(new[] }.AsReadOnly(), 1),
{ new GreSourceRouteEntryIp(
new IpV4Address("11.22.33.44"), new[]
new IpV4Address("44.33.22.11") {
}.AsReadOnly(), 0) new IpV4Address("11.22.33.44"),
new IpV4Address("44.33.22.11")
}.AsReadOnly(), 0)
}.Cast<GreSourceRouteEntry>().ToArray().AsReadOnly(), }.Cast<GreSourceRouteEntry>().ToArray().AsReadOnly(),
StrictSourceRoute = false, StrictSourceRoute = false,
}, },
...@@ -656,10 +700,11 @@ namespace SendingASinglePacketWithSendPacket ...@@ -656,10 +700,11 @@ namespace SendingASinglePacketWithSendPacket
Fragmentation = IpV4Fragmentation.None, Fragmentation = IpV4Fragmentation.None,
HeaderChecksum = null, // Will be filled automatically. HeaderChecksum = null, // Will be filled automatically.
Identification = 123, Identification = 123,
Options = new IpV4Options(new IpV4OptionTimestampOnly(0, 1, Options = new IpV4Options(
new IpV4TimeOfDay(new TimeSpan(1, 2, 3)), new IpV4OptionTimestampOnly(0, 1,
new IpV4TimeOfDay(new TimeSpan(15, 55, 59))), new IpV4TimeOfDay(new TimeSpan(1, 2, 3)),
new IpV4OptionQuickStart(IpV4OptionQuickStartFunction.RateRequest, 10, 200, 300)), new IpV4TimeOfDay(new TimeSpan(15, 55, 59))),
new IpV4OptionQuickStart(IpV4OptionQuickStartFunction.RateRequest, 10, 200, 300)),
Protocol = null, // Will be filled automatically. Protocol = null, // Will be filled automatically.
Ttl = 100, Ttl = 100,
TypeOfService = 0, TypeOfService = 0,
...@@ -684,25 +729,57 @@ namespace SendingASinglePacketWithSendPacket ...@@ -684,25 +729,57 @@ namespace SendingASinglePacketWithSendPacket
IsAuthenticData = true, IsAuthenticData = true,
IsCheckingDisabled = false, IsCheckingDisabled = false,
ResponseCode = DnsResponseCode.NoError, ResponseCode = DnsResponseCode.NoError,
Queries = new[] {new DnsQueryResourceRecord(new DnsDomainName("pcapdot.net"), DnsType.Any, DnsClass.Internet),}, Queries =
Answers = new[] new[]
{ {
new DnsDataResourceRecord(new DnsDomainName("pcapdot.net"), DnsType.A, DnsClass.Internet, 50000, new DnsQueryResourceRecord(
new DnsResourceDataIpV4(new IpV4Address("10.20.30.44"))), new DnsDomainName("pcapdot.net"),
new DnsDataResourceRecord(new DnsDomainName("pcapdot.net"), DnsType.Txt, DnsClass.Internet, 50000, DnsType.Any,
new DnsResourceDataText(new[] {new DataSegment(Encoding.ASCII.GetBytes("Pcap.Net"))}.AsReadOnly())) DnsClass.Internet),
}, },
Authorities = new[] Answers =
{ new[]
new DnsDataResourceRecord(new DnsDomainName("pcapdot.net"), DnsType.MailExchange, DnsClass.Internet, 100, {
new DnsResourceDataMailExchange(100, new DnsDomainName("pcapdot.net"))) new DnsDataResourceRecord(
}, new DnsDomainName("pcapdot.net"),
Additionals = new[] DnsType.A,
{ DnsClass.Internet
new DnsOptResourceRecord(new DnsDomainName("pcapdot.net"), 50000, 0, DnsOptVersion.Version0, DnsOptFlags.DnsSecOk, , 50000,
new DnsResourceDataOptions(new DnsOptions(new DnsOptionUpdateLease(100), new DnsResourceDataIpV4(new IpV4Address("10.20.30.44"))),
new DnsOptionLongLivedQuery(1, DnsLongLivedQueryOpCode.Refresh, DnsLongLivedQueryErrorCode.NoError, 10, 20)))) new DnsDataResourceRecord(
}, new DnsDomainName("pcapdot.net"),
DnsType.Txt,
DnsClass.Internet,
50000,
new DnsResourceDataText(new[] {new DataSegment(Encoding.ASCII.GetBytes("Pcap.Net"))}.AsReadOnly()))
},
Authorities =
new[]
{
new DnsDataResourceRecord(
new DnsDomainName("pcapdot.net"),
DnsType.MailExchange,
DnsClass.Internet,
100,
new DnsResourceDataMailExchange(100, new DnsDomainName("pcapdot.net")))
},
Additionals =
new[]
{
new DnsOptResourceRecord(
new DnsDomainName("pcapdot.net"),
50000,
0,
DnsOptVersion.Version0,
DnsOptFlags.DnsSecOk,
new DnsResourceDataOptions(
new DnsOptions(
new DnsOptionUpdateLease(100),
new DnsOptionLongLivedQuery(1,
DnsLongLivedQueryOpCode.Refresh,
DnsLongLivedQueryErrorCode.NoError,
10, 20))))
},
DomainNameCompressionMode = DnsDomainNameCompressionMode.All, DomainNameCompressionMode = DnsDomainNameCompressionMode.All,
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment