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



44
45
46
# File 'lib/pio/dhcp/frame.rb', line 44

def ip_len
  IP_HEADER_LENGTH + udp_len
end

#ip_sumObject



36
37
38
# File 'lib/pio/dhcp/frame.rb', line 36

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

#to_binaryObject



52
53
54
# File 'lib/pio/dhcp/frame.rb', line 52

def to_binary
  to_binary_s + trail_data
end

#udp_lenObject



48
49
50
# File 'lib/pio/dhcp/frame.rb', line 48

def udp_len
  UDP_HEADER_LENGTH + dhcp_len
end

#udp_sumObject



40
41
42
# File 'lib/pio/dhcp/frame.rb', line 40

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