Class: PacketGen::Header::BOOTP
- Defined in:
- lib/packetgen/header/bootp.rb
Overview
Bootstrap Protocol, RFC 951
A BOOTP header consists of:
-
an operation code field (#op of type
BinStruct::Int8Enum
), -
a hardware address type (#htype of type
BinStruct::Int8
), -
a hardware address length (#hlen of type
BinStruct::Int8
), -
a #hops field (
BinStruct::Int8
), -
a transaction ID (#xid of type
BinStruct::Int32
), -
a #secs field (
BinStruct::Int16
), -
a #flags field (
BinStruct::Int16
): -
a #chaddr field (16-byte
BinStruct::String
), -
a #sname field (64-byte
BinStruct::CString
), -
a #file field (128-byte
BinStruct::CString
), -
and a body (
BinStruct::String
).
Constant Summary collapse
- UDP_SERVER_PORT =
67
- UDP_CLIENT_PORT =
68
- OPCODES =
DHCP opcodes
{ 'BOOTREQUEST' => 1, 'BOOTREPLY' => 2 }.freeze
Instance Attribute Summary collapse
-
#b ⇒ Object
Broadcast flag, from #flags.
- #body ⇒ String
-
#chaddr ⇒ String
client hardware address.
-
#ciaddr ⇒ String
client IP address.
-
#file ⇒ String
Boot file name, null terminated string.
-
#flags ⇒ Integer
16-bit flag field.
-
#giaddr ⇒ String
Relay agent IP address, used in booting via a relay agent.
-
#hlen ⇒ Integer
8-bit hardware address length.
- #hops ⇒ Integer
-
#htype ⇒ Integer
8-bit hardware address type.
-
#mbz ⇒ Object
15-bit Must Be Zero bits, from #flags.
-
#op ⇒ Integer
8-bit opcode.
-
#secs ⇒ Integer
16-bit integer: number of seconds elapsed since client began address acquisition or renewal process.
-
#siaddr ⇒ String
IP address of next server to use in bootstrap.
-
#sname ⇒ String
optional server hostname, null-terminated string.
-
#xid ⇒ Integer
32-bit Transaction ID.
-
#yiaddr ⇒ String
‘your’ (client) IP address.
Instance Method Summary collapse
- #inspect ⇒ String
-
#reply! ⇒ self
Invert opcode, if known.
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, #ll_header
Methods included from PacketGen::Headerable
#added_to_packet, included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read, #to_s
Constructor Details
This class inherits a constructor from PacketGen::Header::Base
Instance Attribute Details
#b ⇒ Object
Broadcast flag, from #flags
91 |
# File 'lib/packetgen/header/bootp.rb', line 91 define_bit_attr :flags, b: 1, mbz: 15 |
#body ⇒ String
130 |
# File 'lib/packetgen/header/bootp.rb', line 130 define_attr :body, BinStruct::String |
#chaddr ⇒ String
client hardware address
116 |
# File 'lib/packetgen/header/bootp.rb', line 116 define_attr :chaddr, BinStruct::String, static_length: 16 |
#ciaddr ⇒ String
client IP address
96 |
# File 'lib/packetgen/header/bootp.rb', line 96 define_attr :ciaddr, IP::Addr |
#file ⇒ String
Boot file name, null terminated string
126 |
# File 'lib/packetgen/header/bootp.rb', line 126 define_attr :file, BinStruct::CString, static_length: 128 |
#flags ⇒ Integer
16-bit flag field
91 |
# File 'lib/packetgen/header/bootp.rb', line 91 define_bit_attr :flags, b: 1, mbz: 15 |
#giaddr ⇒ String
Relay agent IP address, used in booting via a relay agent
111 |
# File 'lib/packetgen/header/bootp.rb', line 111 define_attr :giaddr, IP::Addr |
#hlen ⇒ Integer
8-bit hardware address length
65 |
# File 'lib/packetgen/header/bootp.rb', line 65 define_attr :hlen, BinStruct::Int8, default: 6 |
#hops ⇒ Integer
69 |
# File 'lib/packetgen/header/bootp.rb', line 69 define_attr :hops, BinStruct::Int8 |
#htype ⇒ Integer
8-bit hardware address type
60 |
# File 'lib/packetgen/header/bootp.rb', line 60 define_attr :htype, BinStruct::Int8, default: 1 |
#mbz ⇒ Object
15-bit Must Be Zero bits, from #flags
91 |
# File 'lib/packetgen/header/bootp.rb', line 91 define_bit_attr :flags, b: 1, mbz: 15 |
#op ⇒ Integer
8-bit opcode
55 |
# File 'lib/packetgen/header/bootp.rb', line 55 define_attr :op, BinStruct::Int8Enum, enum: OPCODES |
#secs ⇒ Integer
16-bit integer: number of seconds elapsed since client began address acquisition or renewal process
80 |
# File 'lib/packetgen/header/bootp.rb', line 80 define_attr :secs, BinStruct::Int16 |
#siaddr ⇒ String
IP address of next server to use in bootstrap
106 |
# File 'lib/packetgen/header/bootp.rb', line 106 define_attr :siaddr, IP::Addr |
#sname ⇒ String
optional server hostname, null-terminated string
121 |
# File 'lib/packetgen/header/bootp.rb', line 121 define_attr :sname, BinStruct::CString, static_length: 64 |
#xid ⇒ Integer
32-bit Transaction ID
74 |
# File 'lib/packetgen/header/bootp.rb', line 74 define_attr :xid, BinStruct::Int32 |
Instance Method Details
#inspect ⇒ String
133 134 135 136 137 138 139 |
# File 'lib/packetgen/header/bootp.rb', line 133 def inspect super do |attr| next unless (attr == :chaddr) && (self.hlen == 6) Inspect.inspect_attribute(attr, Eth::MacAddr.new.read(self[:chaddr][0, 6])) end end |
#reply! ⇒ self
Invert opcode, if known
143 144 145 146 147 148 149 |
# File 'lib/packetgen/header/bootp.rb', line 143 def reply! case self.op when 1 then self.op = 2 when 2 then self.op = 1 end self end |