### Home Classes Methods

### In Files

- lib/packetfu/protos/hsrp.rb

### Parent

PacketFu::Packet

### Methods

- ::can_parse?
- ::new
- #peek_format
- #read

### Included Modules

- PacketFu::EthHeaderMixin
- PacketFu::IPHeaderMixin
- PacketFu::UDPHeaderMixin
- PacketFu::HSRPHeaderMixin

### 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::HSRPPacket

HSRPPacket is used to construct HSRP Packets. They contain an EthHeader, an IPHeader, and a UDPHeader.

## Example

    hsrp_pkt.new
    hsrp_pkt.hsrp_opcode = 0
    hsrp_pkt.hsrp_state = 16
    hsrp_pkt.hsrp_priority = 254
    hsrp_pkt.hsrp_group = 1
    hsrp_pkt.hsrp_vip = 10.100.100.254
    hsrp_pkt.recalc
    hsrp_pkt.to_f('/tmp/hsrp.pcap')

## Parameters

    :eth
     A pre-generated EthHeader object.
    :ip
     A pre-generated IPHeader object.
    :udp
     A pre-generated UDPHeader object.
    :flavor
     TODO: HSRP packets don't tend have any flavor.
    :config
     A hash of return address details, often the output of Utils.whoami?

### Attributes

eth_header[RW]
hsrp_header[RW]
ip_header[RW]
udp_header[RW]

### Public Class Methods

can_parse?(str) click to toggle source

    # File lib/packetfu/protos/hsrp.rb, line 47
    def self.can_parse?(str)
      return false unless str.size >= 54
      return false unless EthPacket.can_parse? str
      return false unless IPPacket.can_parse? str
      return false unless UDPPacket.can_parse? str
      temp_packet = UDPPacket.new
      temp_packet.read(str)
      if temp_packet.ip_ttl == 1 and [temp_packet.udp_sport,temp_packet.udp_dport] == [1985,1985]
        return true
      else
        return false
      end
    end

new(args={}) click to toggle source

    # File lib/packetfu/protos/hsrp.rb, line 68
    def initialize(args={})
      @eth_header = EthHeader.new(args).read(args[:eth])
      @ip_header = IPHeader.new(args).read(args[:ip])
      @ip_header.ip_proto = 0x11
      @udp_header = UDPHeader.new(args).read(args[:udp])
      @hsrp_header = HSRPHeader.new(args).read(args[:hsrp])
      @udp_header.body = @hsrp_header
      @ip_header.body = @udp_header
      @eth_header.body = @ip_header
      @headers = [@eth_header, @ip_header, @udp_header, @hsrp_header]
      super
    end

### Public Instance Methods

peek_format() click to toggle source

Peek provides summary data on packet contents.

    # File lib/packetfu/protos/hsrp.rb, line 82
    def peek_format
      peek_data = ["UH "]
      peek_data << "%-5d" % self.to_s.size
      peek_data << "%-16s" % self.hsrp_addr
      peek_data << "%-4d" % self.hsrp_group
      peek_data << "%-35s" % self.hsrp_password_readable
      peek_data << "%-15s" % self.ip_saddr
      peek_data.join
    end

read(str=nil, args={}) click to toggle source

    # File lib/packetfu/protos/hsrp.rb, line 61
    def read(str=nil, args={})
      raise "Cannot parse `#{str}'" unless self.class.can_parse?(str)
      @eth_header.read(str)
      super(args)
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.