### Home Classes Methods

### In Files

- lib/packetfu/protos/arp/header.rb

### Parent

Struct.new(:arp_hw, :arp_proto, :arp_hw_len, :arp_proto_len, :arp_opcode, :arp_src_mac, :arp_src_ip, :arp_dst_mac, :arp_dst_ip, :body)

### Methods

- ::new
- #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
- #read
- #to_s

### Included Modules

- StructFu

### Files

- .document
- README.rdoc

### Class/Module Index

Quicksearch

- PacketFu
- PacketFu::ARPHeader
- PacketFu::ARPHeaderMixin
- PacketFu::ARPPacket
- PacketFu::AddrIpv6
- PacketFu::Capture
- PacketFu::Config
- PacketFu::EthHeader
- PacketFu::EthHeaderMixin
- PacketFu::EthMac
- PacketFu::EthNic
- PacketFu::EthOui
- PacketFu::EthPacket
- PacketFu::HSRPHeader
- PacketFu::HSRPHeaderMixin
- PacketFu::HSRPPacket
- PacketFu::ICMPHeader
- PacketFu::ICMPHeaderMixin
- PacketFu::ICMPPacket
- PacketFu::IPHeader
- PacketFu::IPHeaderMixin
- PacketFu::IPPacket
- PacketFu::IPv6Header
- PacketFu::IPv6HeaderMixin
- PacketFu::IPv6Packet
- PacketFu::Inject
- PacketFu::InvalidHeader
- PacketFu::InvalidPacket
- PacketFu::LLDPHeader
- PacketFu::LLDPHeaderMixin
- PacketFu::LLDPPacket
- PacketFu::Octets
- PacketFu::Packet
- PacketFu::PcapFile
- PacketFu::PcapHeader
- PacketFu::PcapPacket
- PacketFu::PcapPackets
- PacketFu::Read
- PacketFu::TCPHeader
- PacketFu::TCPHeaderMixin
- PacketFu::TCPPacket
- PacketFu::TcpEcn
- PacketFu::TcpFlags
- PacketFu::TcpHlen
- PacketFu::TcpOption
- PacketFu::TcpOption::ECHO
- PacketFu::TcpOption::ECHOREPLY
- PacketFu::TcpOption::EOL
- PacketFu::TcpOption::MSS
- PacketFu::TcpOption::NOP
- PacketFu::TcpOption::SACK
- PacketFu::TcpOption::SACKOK
- PacketFu::TcpOption::TS
- PacketFu::TcpOption::WS
- PacketFu::TcpOptions
- PacketFu::TcpReserved
- PacketFu::Timestamp
- PacketFu::UDPHeader
- PacketFu::UDPHeaderMixin
- PacketFu::UDPPacket
- PacketFu::Utils
- PacketFu::Write
- StructFu
- StructFu::Int
- StructFu::Int16
- StructFu::Int16be
- StructFu::Int16le
- StructFu::Int32
- StructFu::Int32be
- StructFu::Int32le
- StructFu::Int8
- StructFu::IntString
- StructFu::String
- Struct

No matching classes.

# PacketFu::ARPHeader

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

### Public Class Methods

new(args={}) click to toggle source

    # File lib/packetfu/protos/arp/header.rb, line 27
    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

### Public Instance Methods

arp_daddr_ip() click to toggle source

Get a more readable destination IP address.

    # File lib/packetfu/protos/arp/header.rb, line 144
    def arp_daddr_ip
      self[:arp_dst_ip].to_x
    end

Also aliased as: arp_dst_ip_readable
arp_daddr_ip=(addr) click to toggle source

Set a more readable destination IP address.

    # File lib/packetfu/protos/arp/header.rb, line 139
    def arp_daddr_ip=(addr)
      self[:arp_dst_ip].read_quad(addr)
    end

arp_daddr_mac() click to toggle source

Get a more readable source MAC address.

    # File lib/packetfu/protos/arp/header.rb, line 124
    def arp_daddr_mac
      EthHeader.str2mac(self[:arp_dst_mac].to_s)
    end

Also aliased as: arp_dst_mac_readable
arp_daddr_mac=(mac) click to toggle source

Set the destination MAC address in a more readable way.

    # File lib/packetfu/protos/arp/header.rb, line 117
    def arp_daddr_mac=(mac)
      mac = EthHeader.mac2str(mac)
      self[:arp_dst_mac].read(mac)
      self.arp_dst_mac
    end

arp_dst_ip() click to toggle source

Getter for the ARP destination IP address.

    # File lib/packetfu/protos/arp/header.rb, line 102
    def arp_dst_ip; self[:arp_dst_ip].to_s; end

arp_dst_ip=(i) click to toggle source

Setter for the ARP destination IP address.

    # File lib/packetfu/protos/arp/header.rb, line 100
    def arp_dst_ip=(i); typecast i; end

arp_dst_ip_readable() click to toggle source
Alias for: arp_daddr_ip
arp_dst_mac() click to toggle source

Setter for the ARP destination MAC address.

    # File lib/packetfu/protos/arp/header.rb, line 98
    def arp_dst_mac; self[:arp_dst_mac].to_s; end

arp_dst_mac=(i) click to toggle source

Setter for the ARP destination MAC address.

    # File lib/packetfu/protos/arp/header.rb, line 96
    def arp_dst_mac=(i); typecast i; end

arp_dst_mac_readable() click to toggle source
Alias for: arp_daddr_mac
arp_hw() click to toggle source

Getter for the ARP hardware type.

    # File lib/packetfu/protos/arp/header.rb, line 70
    def arp_hw; self[:arp_hw].to_i; end

arp_hw=(i) click to toggle source

Setter for the ARP hardware type.

    # File lib/packetfu/protos/arp/header.rb, line 68
    def arp_hw=(i); typecast i; end

arp_hw_len() click to toggle source

Getter for the ARP hardware type length.

    # File lib/packetfu/protos/arp/header.rb, line 78
    def arp_hw_len; self[:arp_hw_len].to_i; end

arp_hw_len=(i) click to toggle source

Setter for the ARP hardware type length.

    # File lib/packetfu/protos/arp/header.rb, line 76
    def arp_hw_len=(i); typecast i; end

arp_opcode() click to toggle source

Getter for the ARP opcode.

    # File lib/packetfu/protos/arp/header.rb, line 86
    def arp_opcode; self[:arp_opcode].to_i; end

arp_opcode=(i) click to toggle source

Setter for the ARP opcode.

    # File lib/packetfu/protos/arp/header.rb, line 84
    def arp_opcode=(i); typecast i; end

arp_proto() click to toggle source

Getter for the ARP protocol.

    # File lib/packetfu/protos/arp/header.rb, line 74
    def arp_proto; self[:arp_proto].to_i; end

arp_proto=(i) click to toggle source

Setter for the ARP protocol.

    # File lib/packetfu/protos/arp/header.rb, line 72
    def arp_proto=(i); typecast i; end

arp_proto_len() click to toggle source

Getter for the ARP protocol length.

    # File lib/packetfu/protos/arp/header.rb, line 82
    def arp_proto_len; self[:arp_proto_len].to_i; end

arp_proto_len=(i) click to toggle source

Setter for the ARP protocol length.

    # File lib/packetfu/protos/arp/header.rb, line 80
    def arp_proto_len=(i); typecast i; end

arp_proto_readable() click to toggle source

    # File lib/packetfu/protos/arp/header.rb, line 155
    def arp_proto_readable
      "0x%04x" % arp_proto
    end

arp_saddr_ip() click to toggle source

Get a more readable source IP address.

    # File lib/packetfu/protos/arp/header.rb, line 134
    def arp_saddr_ip
      self[:arp_src_ip].to_x
    end

Also aliased as: arp_src_ip_readable
arp_saddr_ip=(addr) click to toggle source

Set a more readable source IP address.

    # File lib/packetfu/protos/arp/header.rb, line 129
    def arp_saddr_ip=(addr)
      self[:arp_src_ip].read_quad(addr)
    end

arp_saddr_mac() click to toggle source

Get a more readable source MAC address.

    # File lib/packetfu/protos/arp/header.rb, line 112
    def arp_saddr_mac
      EthHeader.str2mac(self[:arp_src_mac].to_s)
    end

Also aliased as: arp_src_mac_readable
arp_saddr_mac=(mac) click to toggle source

Set the source MAC address in a more readable way.

    # File lib/packetfu/protos/arp/header.rb, line 105
    def arp_saddr_mac=(mac)
      mac = EthHeader.mac2str(mac)
      self[:arp_src_mac].read(mac)
      self.arp_src_mac
    end

arp_src_ip() click to toggle source

Setter for the ARP source IP address.

    # File lib/packetfu/protos/arp/header.rb, line 94
    def arp_src_ip; self[:arp_src_ip].to_s; end

arp_src_ip=(i) click to toggle source

Getter for the ARP source IP address.

    # File lib/packetfu/protos/arp/header.rb, line 92
    def arp_src_ip=(i); typecast i; end

arp_src_ip_readable() click to toggle source
Alias for: arp_saddr_ip
arp_src_mac() click to toggle source

Getter for the ARP source MAC address.

    # File lib/packetfu/protos/arp/header.rb, line 90
    def arp_src_mac; self[:arp_src_mac].to_s; end

arp_src_mac=(i) click to toggle source

Setter for the ARP source MAC address.

    # File lib/packetfu/protos/arp/header.rb, line 88
    def arp_src_mac=(i); typecast i; end

arp_src_mac_readable() click to toggle source

Readability aliases

Alias for: arp_saddr_mac
read(str) click to toggle source

Reads a string to populate the object.

    # File lib/packetfu/protos/arp/header.rb, line 51
    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

to_s() click to toggle source

Returns the object in string form.

    # File lib/packetfu/protos/arp/header.rb, line 46
    def to_s
      self.to_a.map {|x| x.to_s}.join
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.