C# Class NetworkPackets.IPPacket

Inheritance: NetworkPacket
Show file Open project: pstjuste/brunet Class Usage Examples

Public Properties

Property Type Description
BroadcastAddress MemBlock
DestinationIP MemBlock
Protocol Protocols
SourceIP MemBlock
ZeroAddress MemBlock

Public Methods

Method Description
GenerateChecksum ( MemBlock header ) : ushort

Generates an 16-bit IP (UDP, TCP) checksum based upon header and optional extra memory blocks placed into args.

IPPacket ( ) : Brunet
IPPacket ( MemBlock Packet ) : Brunet

Takes in a MemBlock and parses it into IP Header fields

IPPacket ( Protocols Protocol, MemBlock SourceIP, MemBlock DestinationIP, ICopyable Payload ) : Brunet

Takes in the IP Header fields and a payload to create an IP Packet. Unlisted fields are generated by this constructor automatically.

IPPacket ( Protocols Protocol, MemBlock SourceIP, MemBlock DestinationIP, MemBlock hdr, ICopyable Payload ) : Brunet

Takes in the IP Header fields and a payload to create an IP Packet. Unlisted fields are generated by this constructor automatically.

MakePseudoHeader ( MemBlock source_address, MemBlock destination_address, byte protocol, ushort length ) : MemBlock
Translate ( MemBlock Packet, MemBlock SourceIP, MemBlock DestinationIP ) : MemBlock

If we're not creating a packet from scratch, this will keep its integrity and transform UDP and TCP headers as well (due to their checksums being dependent on source and destination ip addresses.

Private Methods

Method Description
ChecksumTest ( ) : void

Method Details

GenerateChecksum() public static method

Generates an 16-bit IP (UDP, TCP) checksum based upon header and optional extra memory blocks placed into args.
public static GenerateChecksum ( MemBlock header ) : ushort
header MemBlock The Header to base the checksum on.
return ushort

IPPacket() public method

public IPPacket ( ) : Brunet
return Brunet

IPPacket() public method

Takes in a MemBlock and parses it into IP Header fields
public IPPacket ( MemBlock Packet ) : Brunet
Packet MemBlock The IP Packet to parse.
return Brunet

IPPacket() public method

Takes in the IP Header fields and a payload to create an IP Packet. Unlisted fields are generated by this constructor automatically.
public IPPacket ( Protocols Protocol, MemBlock SourceIP, MemBlock DestinationIP, ICopyable Payload ) : Brunet
Protocol Protocols The type of payload
SourceIP MemBlock The packets originating ip address
DestinationIP MemBlock The destination for the packet
Payload ICopyable The data stored in the IP Packet
return Brunet

IPPacket() public method

Takes in the IP Header fields and a payload to create an IP Packet. Unlisted fields are generated by this constructor automatically.
public IPPacket ( Protocols Protocol, MemBlock SourceIP, MemBlock DestinationIP, MemBlock hdr, ICopyable Payload ) : Brunet
Protocol Protocols The type of payload
SourceIP MemBlock The packets originating ip address
DestinationIP MemBlock The destination for the packet
hdr MemBlock The original header of the IPPacket
Payload ICopyable The data stored in the IP Packet
return Brunet

MakePseudoHeader() public static method

public static MakePseudoHeader ( MemBlock source_address, MemBlock destination_address, byte protocol, ushort length ) : MemBlock
source_address MemBlock
destination_address MemBlock
protocol byte
length ushort
return MemBlock

Translate() public static method

If we're not creating a packet from scratch, this will keep its integrity and transform UDP and TCP headers as well (due to their checksums being dependent on source and destination ip addresses.
public static Translate ( MemBlock Packet, MemBlock SourceIP, MemBlock DestinationIP ) : MemBlock
Packet MemBlock The packet to translate.
SourceIP MemBlock The new source ip.
DestinationIP MemBlock The new destination ip.
return MemBlock

Property Details

BroadcastAddress public static property

The default broadcast (multicast) address
public static MemBlock BroadcastAddress
return MemBlock

DestinationIP public property

The IP Address where the packet is going
public MemBlock DestinationIP
return MemBlock

Protocol public property

The protocol for this packet.
public Protocols Protocol
return Protocols

SourceIP public property

The IP Address where the packet originated
public MemBlock SourceIP
return MemBlock

ZeroAddress public static property

The zero address
public static MemBlock ZeroAddress
return MemBlock