Class: Pio::Dhcp::Frame

Inherits:
BinData::Record
  • Object
show all
Extended by:
Type::EthernetHeader, Type::IPv4Header, Type::UdpHeader
Includes:
CsumUtil, FieldUtil
Defined in:
lib/pio/dhcp/frame.rb

Overview

Dhcp frame parser.

Constant Summary collapse

ETHER_TYPE_IP =
0x0800
IP_PROTOCOL_UDP =
17
IP_HEADER_LENGTH =
20
UDP_HEADER_LENGTH =
8
DHCP_OPTION_FIELD_LENGTH =
60

Instance Method Summary collapse

Methods included from Type::EthernetHeader

ethernet_header

Methods included from Type::IPv4Header

ipv4_header

Methods included from Type::UdpHeader

udp_header

Methods included from FieldUtil

#bootp_flags, #client_identifier, #client_ip_address, #client_mac_address, #hops, #hw_addr_len, #hw_addr_type, #ip_address_lease_time, #message_type, #next_server_ip_address, #parameters_list, #rebinding_time_value, #relay_agent_ip_address, #renewal_time_value, #requested_ip_address, #seconds, #server_identifier, #subnet_mask, #transaction_id, #your_ip_address

Instance Method Details

#ip_lenObject



42
43
44
# File 'lib/pio/dhcp/frame.rb', line 42

def ip_len
  IP_HEADER_LENGTH + udp_len
end

#ip_sumObject



34
35
36
# File 'lib/pio/dhcp/frame.rb', line 34

def ip_sum
  ~((ip_csum & 0xffff) + (ip_csum >> 16)) & 0xffff
end

#to_binaryObject



50
51
52
# File 'lib/pio/dhcp/frame.rb', line 50

def to_binary
  to_binary_s + trail_data
end

#udp_lenObject



46
47
48
# File 'lib/pio/dhcp/frame.rb', line 46

def udp_len
  UDP_HEADER_LENGTH + dhcp_len
end

#udp_sumObject



38
39
40
# File 'lib/pio/dhcp/frame.rb', line 38

def udp_sum
  ~((udp_csum & 0xffff) + (udp_csum >> 16)) & 0xffff
end