Class: PacketGen::Header::BOOTP
- Inherits:
-
Base
- Object
- Types::Fields
- Base
- 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 Types::Int8Enum),
-
a hardware address type (#htype of type Types::Int8),
-
a hardware address length (#hlen of type Types::Int8),
-
a #hops field (Types::Int8),
-
a transaction ID (#xid of type Types::Int32),
-
a #secs field ()Types::Int16),
-
a #flags field ()Types::Int16):
-
a #chaddr field (16-byte Types::String),
-
a #sname field (64-byte Types::CString),
-
a #file field (128-byte Types::CString),
-
and a body (Types::String).
Create a BOOTP header
# standalone
bootp = PacketGen::Header::BOOTP.new
# in a packet
pkt = PacketGen.gen('IP').add('BOOTP')
# access to BOOTP header
pkt.bootp # => PacketGen::Header::BOOTP
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
Methods inherited from Types::Fields
#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #initialize, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
Constructor Details
This class inherits a constructor from PacketGen::Header::Base
Instance Attribute Details
#b ⇒ Object
Broadcast flag, from #flags
132 |
# File 'lib/packetgen/header/bootp.rb', line 132 define_bit_fields_on :flags, :b, :mbz, 15 |
#body ⇒ String
124 |
# File 'lib/packetgen/header/bootp.rb', line 124 define_field :body, Types::String |
#chaddr ⇒ String
client hardware address
110 |
# File 'lib/packetgen/header/bootp.rb', line 110 define_field :chaddr, Types::String, static_length: 16 |
#ciaddr ⇒ String
client IP address
90 |
# File 'lib/packetgen/header/bootp.rb', line 90 define_field :ciaddr, IP::Addr |
#file ⇒ String
Boot file name, null terminated string
120 |
# File 'lib/packetgen/header/bootp.rb', line 120 define_field :file, Types::CString, static_length: 128 |
#flags ⇒ Integer
16-bit flag field
85 |
# File 'lib/packetgen/header/bootp.rb', line 85 define_field :flags, Types::Int16 |
#giaddr ⇒ String
Relay agent IP address, used in booting via a relay agent
105 |
# File 'lib/packetgen/header/bootp.rb', line 105 define_field :giaddr, IP::Addr |
#hlen ⇒ Integer
8-bit hardware address length
65 |
# File 'lib/packetgen/header/bootp.rb', line 65 define_field :hlen, Types::Int8, default: 6 |
#htype ⇒ Integer
8-bit hardware address type
60 |
# File 'lib/packetgen/header/bootp.rb', line 60 define_field :htype, Types::Int8, default: 1 |
#mbz ⇒ Object
15-bit Must Be Zero bits, from #flags
132 |
# File 'lib/packetgen/header/bootp.rb', line 132 define_bit_fields_on :flags, :b, :mbz, 15 |
#op ⇒ Integer
8-bit opcode
55 |
# File 'lib/packetgen/header/bootp.rb', line 55 define_field :op, Types::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_field :secs, Types::Int16 |
#siaddr ⇒ String
IP address of next server to use in bootstrap
100 |
# File 'lib/packetgen/header/bootp.rb', line 100 define_field :siaddr, IP::Addr |
#sname ⇒ String
optional server hostname, null-terminated string
115 |
# File 'lib/packetgen/header/bootp.rb', line 115 define_field :sname, Types::CString, static_length: 64 |
Instance Method Details
#inspect ⇒ String
135 136 137 138 139 140 141 |
# File 'lib/packetgen/header/bootp.rb', line 135 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
145 146 147 148 149 150 151 |
# File 'lib/packetgen/header/bootp.rb', line 145 def reply! case self.op when 1 then self.op = 2 when 2 then self.op = 1 end self end |