C# Class NetworkPackets.Dhcp.DhcpPacket

Encapsulates a Dhcp Packet in an immutable object providing both a byte array and a parsed version of the dhcp information
The outline of a Dhcp Packet: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | op (1) | htype (1) | hlen (1) | hops (1) | +---------------+---------------+---------------+---------------+ | xid (4) | +-------------------------------+-------------------------------+ | secs (2) | flags (2) | +-------------------------------+-------------------------------+ | ciaddr (4) | +---------------------------------------------------------------+ | yiaddr (4) | +---------------------------------------------------------------+ | siaddr (4) | +---------------------------------------------------------------+ | giaddr (4) | +---------------------------------------------------------------+ | | | chaddr (16) | | | | | +---------------------------------------------------------------+ | | | sname (64) | +---------------------------------------------------------------+ | | | file (128) | +---------------------------------------------------------------+ | | | options (variable) | +---------------------------------------------------------------+ Field Description OP 1 for request, 2 for response htype hardware address type - leave at 1 hlen hardware address length - 6 for ethernet mac address hops optional - leave at 0, no relay agents xid transaction id secs seconds since beginning renewal flags ciaddr clients currrent ip (client in bound, renew, or rebinding state) yiaddr ip address server is giving to client siaddr server address giaddr leave at zero, no relay agents chaddr client hardware address sname optional server hostname file optional magic cookie yuuuum! - byte[4] = {99, 130, 83, 99} options starts at 240!
Inheritance: DataPacket
Show file Open project: pstjuste/brunet Class Usage Examples

Public Properties

Property Type Description
Options MemBlock>.Dictionary
chaddr MemBlock
ciaddr MemBlock
magic_key MemBlock
op byte
siaddr MemBlock
xid MemBlock
yiaddr MemBlock

Public Methods

Method Description
DhcpPacket ( MemBlock Packet ) : Brunet

Parse a MemBlock packet into a Dhcp Packet

DhcpPacket ( byte op, MemBlock xid, MemBlock ciaddr, MemBlock yiaddr, MemBlock siaddr, MemBlock chaddr, MemBlock>.Dictionary Options ) : Brunet

Method Details

DhcpPacket() public method

Parse a MemBlock packet into a Dhcp Packet
public DhcpPacket ( MemBlock Packet ) : Brunet
Packet MemBlock The dhcp packet to parse
return Brunet

DhcpPacket() public method

public DhcpPacket ( byte op, MemBlock xid, MemBlock ciaddr, MemBlock yiaddr, MemBlock siaddr, MemBlock chaddr, MemBlock>.Dictionary Options ) : Brunet
op byte
xid MemBlock
ciaddr MemBlock
yiaddr MemBlock
siaddr MemBlock
chaddr MemBlock
Options MemBlock>.Dictionary
return Brunet

Property Details

Options public property

A hashtable indexed by OptionTypes and numbers of options
public Dictionary Options
return MemBlock>.Dictionary

chaddr public property

clients hardware address
public MemBlock chaddr
return MemBlock

ciaddr public property

clients current ip address
public MemBlock ciaddr
return MemBlock

magic_key public static property

Embedded right before the options.
public static MemBlock magic_key
return MemBlock

op public property

1 for boot request, 2 for boot response
public byte op
return byte

siaddr public property

server address
public MemBlock siaddr
return MemBlock

xid public property

unique packet id
public MemBlock xid
return MemBlock

yiaddr public property

ip address server is giving to the client
public MemBlock yiaddr
return MemBlock