ARPHeader is a complete ARP struct, used in ARPPacket.
ARP is used to discover the machine address of nearby devices.
See www.networksorcery.com/enp/protocol/arp.htm for details.
Header Definition
Int16 :arp_hw Default: 1 # Ethernet
Int16 :arp_proto, Default: 0x8000 # IP
Int8 :arp_hw_len, Default: 6
Int8 :arp_proto_len, Default: 4
Int16 :arp_opcode, Default: 1 # 1: Request, 2: Reply, 3: Request-Reverse, 4: Reply-Reverse
EthMac :arp_src_mac # From eth.rb
Octets :arp_src_ip # From ip.rb
EthMac :arp_dst_mac # From eth.rb
Octets :arp_dst_ip # From ip.rb
String :body
- A
-
- arp_daddr_ip,
- arp_daddr_ip=,
- arp_daddr_mac,
- arp_daddr_mac=,
- arp_dst_ip,
- arp_dst_ip=,
- arp_dst_ip_readable,
- arp_dst_mac,
- arp_dst_mac=,
- arp_dst_mac_readable,
- arp_hw,
- arp_hw=,
- arp_hw_len,
- arp_hw_len=,
- arp_opcode,
- arp_opcode=,
- arp_proto,
- arp_proto=,
- arp_proto_len,
- arp_proto_len=,
- arp_proto_readable,
- arp_saddr_ip,
- arp_saddr_ip=,
- arp_saddr_mac,
- arp_saddr_mac=,
- arp_src_ip,
- arp_src_ip=,
- arp_src_ip_readable,
- arp_src_mac,
- arp_src_mac=,
- arp_src_mac_readable
- N
- R
- T
- PacketFu START:includes
Source: show
# File lib/packetfu/protos/arp.rb, line 28 def initialize(args={}) src_mac = args[:arp_src_mac] || (args[:config][:eth_src] if args[:config]) src_ip_bin = args[:arp_src_ip] || (args[:config][:ip_src_bin] if args[:config]) super( Int16.new(args[:arp_hw] || 1), Int16.new(args[:arp_proto] ||0x0800), Int8.new(args[:arp_hw_len] || 6), Int8.new(args[:arp_proto_len] || 4), Int16.new(args[:arp_opcode] || 1), EthMac.new.read(src_mac), Octets.new.read(src_ip_bin), EthMac.new.read(args[:arp_dst_mac]), Octets.new.read(args[:arp_dst_ip]), StructFu::String.new.read(args[:body]) ) end
Get a more readable destination IP address.
Source: show
# File lib/packetfu/protos/arp.rb, line 145 def arp_daddr_ip self[:arp_dst_ip].to_x end
Set a more readable destination IP address.
Source: show
# File lib/packetfu/protos/arp.rb, line 140 def arp_daddr_ip=(addr) self[:arp_dst_ip].read_quad(addr) end
Get a more readable source MAC address.
Source: show
# File lib/packetfu/protos/arp.rb, line 125 def arp_daddr_mac EthHeader.str2mac(self[:arp_dst_mac].to_s) end
Set the destination MAC address in a more readable way.
Source: show
# File lib/packetfu/protos/arp.rb, line 118 def arp_daddr_mac=(mac) mac = EthHeader.mac2str(mac) self[:arp_dst_mac].read(mac) self.arp_dst_mac end
Getter for the ARP destination IP address.
Source: show
# File lib/packetfu/protos/arp.rb, line 103 def arp_dst_ip; self[:arp_dst_ip].to_s; end
Setter for the ARP destination IP address.
Source: show
# File lib/packetfu/protos/arp.rb, line 101 def arp_dst_ip=(i); typecast i; end
Alias for arp_daddr_ip
Setter for the ARP destination MAC address.
Source: show
# File lib/packetfu/protos/arp.rb, line 99 def arp_dst_mac; self[:arp_dst_mac].to_s; end
Setter for the ARP destination MAC address.
Source: show
# File lib/packetfu/protos/arp.rb, line 97 def arp_dst_mac=(i); typecast i; end
Alias for arp_daddr_mac
Getter for the ARP hardware type.
Source: show
# File lib/packetfu/protos/arp.rb, line 71 def arp_hw; self[:arp_hw].to_i; end
Setter for the ARP hardware type.
Source: show
# File lib/packetfu/protos/arp.rb, line 69 def arp_hw=(i); typecast i; end
Getter for the ARP hardware type length.
Source: show
# File lib/packetfu/protos/arp.rb, line 79 def arp_hw_len; self[:arp_hw_len].to_i; end
Setter for the ARP hardware type length.
Source: show
# File lib/packetfu/protos/arp.rb, line 77 def arp_hw_len=(i); typecast i; end
Getter for the ARP opcode.
Source: show
# File lib/packetfu/protos/arp.rb, line 87 def arp_opcode; self[:arp_opcode].to_i; end
Setter for the ARP opcode.
Source: show
# File lib/packetfu/protos/arp.rb, line 85 def arp_opcode=(i); typecast i; end
Getter for the ARP protocol.
Source: show
# File lib/packetfu/protos/arp.rb, line 75 def arp_proto; self[:arp_proto].to_i; end
Setter for the ARP protocol.
Source: show
# File lib/packetfu/protos/arp.rb, line 73 def arp_proto=(i); typecast i; end
Getter for the ARP protocol length.
Source: show
# File lib/packetfu/protos/arp.rb, line 83 def arp_proto_len; self[:arp_proto_len].to_i; end
Setter for the ARP protocol length.
Source: show
# File lib/packetfu/protos/arp.rb, line 81 def arp_proto_len=(i); typecast i; end
Source: show
# File lib/packetfu/protos/arp.rb, line 156 def arp_proto_readable "0x%04x" % arp_proto end
Get a more readable source IP address.
Source: show
# File lib/packetfu/protos/arp.rb, line 135 def arp_saddr_ip self[:arp_src_ip].to_x end
Set a more readable source IP address.
Source: show
# File lib/packetfu/protos/arp.rb, line 130 def arp_saddr_ip=(addr) self[:arp_src_ip].read_quad(addr) end
Get a more readable source MAC address.
Source: show
# File lib/packetfu/protos/arp.rb, line 113 def arp_saddr_mac EthHeader.str2mac(self[:arp_src_mac].to_s) end
Set the source MAC address in a more readable way.
Source: show
# File lib/packetfu/protos/arp.rb, line 106 def arp_saddr_mac=(mac) mac = EthHeader.mac2str(mac) self[:arp_src_mac].read(mac) self.arp_src_mac end
Setter for the ARP source IP address.
Source: show
# File lib/packetfu/protos/arp.rb, line 95 def arp_src_ip; self[:arp_src_ip].to_s; end
Getter for the ARP source IP address.
Source: show
# File lib/packetfu/protos/arp.rb, line 93 def arp_src_ip=(i); typecast i; end
Alias for arp_saddr_ip
Getter for the ARP source MAC address.
Source: show
# File lib/packetfu/protos/arp.rb, line 91 def arp_src_mac; self[:arp_src_mac].to_s; end
Setter for the ARP source MAC address.
Source: show
# File lib/packetfu/protos/arp.rb, line 89 def arp_src_mac=(i); typecast i; end
Alias for arp_saddr_mac
Reads a string to populate the object.
Source: show
# File lib/packetfu/protos/arp.rb, line 52 def read(str) force_binary(str) return self if str.nil? self[:arp_hw].read(str[0,2]) self[:arp_proto].read(str[2,2]) self[:arp_hw_len].read(str[4,1]) self[:arp_proto_len].read(str[5,1]) self[:arp_opcode].read(str[6,2]) self[:arp_src_mac].read(str[8,6]) self[:arp_src_ip].read(str[14,4]) self[:arp_dst_mac].read(str[18,6]) self[:arp_dst_ip].read(str[24,4]) self[:body].read(str[28,str.size]) self end
Returns the object in string form.
Source: show
# File lib/packetfu/protos/arp.rb, line 47 def to_s self.to_a.map {|x| x.to_s}.join end