### Home Classes Methods

### In Files

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

### Parent

Struct.new(:hsrp_version, :hsrp_opcode, :hsrp_state, :hsrp_hellotime, :hsrp_holdtime, :hsrp_priority, :hsrp_group, :hsrp_reserved, :hsrp_password, :hsrp_vip, :body)

### Methods

- ::new
- #hsrp_addr
- #hsrp_addr=
- #hsrp_group
- #hsrp_group=
- #hsrp_hellotime
- #hsrp_hellotime=
- #hsrp_holdtime
- #hsrp_holdtime=
- #hsrp_opcode
- #hsrp_opcode=
- #hsrp_password_readable
- #hsrp_priority
- #hsrp_priority=
- #hsrp_reserved
- #hsrp_reserved=
- #hsrp_state
- #hsrp_state=
- #hsrp_version
- #hsrp_version=
- #hsrp_vip_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::HSRPHeader

HSRPHeader is a complete HSRP struct, used in HSRPPacket. HSRP is typically used for fault-tolerant default gateway in IP routing environment.

For more on HSRP packets, see www.networksorcery.com/enp/protocol/hsrp.htm

Submitted by fropert@packetfault.org. Thanks, Francois!

#### Header Definition

    Int8    :hsrp_version      Default: 0     # Version
    Int8    :hsrp_opcode                      # Opcode
    Int8    :hsrp_state                       # State
    Int8    :hsrp_hellotime    Default: 3     # Hello Time
    Int8    :hsrp_holdtime     Default: 10    # Hold Time
    Int8    :hsrp_priority                    # Priority
    Int8    :hsrp_group                       # Group
    Int8    :hsrp_reserved     Default: 0     # Reserved
    String  :hsrp_password                    # Authentication Data
    Octets  :hsrp_vip                         # Virtual IP Address
    String  :body

### Public Class Methods

new(args={}) click to toggle source

    # File lib/packetfu/protos/hsrp/header.rb, line 30
    def initialize(args={})
      super(
        Int8.new(args[:hsrp_version] || 0),
        Int8.new(args[:hsrp_opcode]),
        Int8.new(args[:hsrp_state]),
        Int8.new(args[:hsrp_hellotime] || 3),
        Int8.new(args[:hsrp_holdtime] || 10),
        Int8.new(args[:hsrp_priority]),
        Int8.new(args[:hsrp_group]),
        Int8.new(args[:hsrp_reserved] || 0),
        StructFu::String.new.read(args[:hsrp_password] || "cisco\x00\x00\x00"),
        Octets.new.read(args[:hsrp_vip] || ("\x00" * 4)),
        StructFu::String.new.read(args[:body])
      )
    end

### Public Instance Methods

hsrp_addr() click to toggle source

Returns a more readable IP source address.

    # File lib/packetfu/protos/hsrp/header.rb, line 107
    def hsrp_addr
      self[:hsrp_vip].to_x
    end

Also aliased as: hsrp_vip_readable
hsrp_addr=(addr) click to toggle source

    # File lib/packetfu/protos/hsrp/header.rb, line 102
    def hsrp_addr=(addr)
      self[:hsrp_vip].read_quad(addr)
    end

hsrp_group() click to toggle source

Getter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 96
    def hsrp_group; self[:hsrp_group].to_i; end

hsrp_group=(i) click to toggle source

Setter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 94
    def hsrp_group=(i); typecast i; end

hsrp_hellotime() click to toggle source

Getter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 84
    def hsrp_hellotime; self[:hsrp_hellotime].to_i; end

hsrp_hellotime=(i) click to toggle source

Setter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 82
    def hsrp_hellotime=(i); typecast i; end

hsrp_holdtime() click to toggle source

Getter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 88
    def hsrp_holdtime; self[:hsrp_holdtime].to_i; end

hsrp_holdtime=(i) click to toggle source

Setter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 86
    def hsrp_holdtime=(i); typecast i; end

hsrp_opcode() click to toggle source

Getter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 76
    def hsrp_opcode; self[:hsrp_opcode].to_i; end

hsrp_opcode=(i) click to toggle source

Setter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 74
    def hsrp_opcode=(i); typecast i; end

hsrp_password_readable() click to toggle source

    # File lib/packetfu/protos/hsrp/header.rb, line 115
    def hsrp_password_readable
      hsrp_password.to_s.inspect
    end

hsrp_priority() click to toggle source

Getter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 92
    def hsrp_priority; self[:hsrp_priority].to_i; end

hsrp_priority=(i) click to toggle source

Setter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 90
    def hsrp_priority=(i); typecast i; end

hsrp_reserved() click to toggle source

Getter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 100
    def hsrp_reserved; self[:hsrp_reserved].to_i; end

hsrp_reserved=(i) click to toggle source

Setter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 98
    def hsrp_reserved=(i); typecast i; end

hsrp_state() click to toggle source

Getter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 80
    def hsrp_state; self[:hsrp_state].to_i; end

hsrp_state=(i) click to toggle source

Setter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 78
    def hsrp_state=(i); typecast i; end

hsrp_version() click to toggle source

Getter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 72
    def hsrp_version; self[:hsrp_version].to_i; end

hsrp_version=(i) click to toggle source

Setter for the type.

    # File lib/packetfu/protos/hsrp/header.rb, line 70
    def hsrp_version=(i); typecast i; end

hsrp_vip_readable() click to toggle source

Readability aliases

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

Reads a string to populate the object.

    # File lib/packetfu/protos/hsrp/header.rb, line 52
    def read(str)
      force_binary(str)
      return self if str.nil?
      self[:hsrp_version].read(str[0,1])
      self[:hsrp_opcode].read(str[1,1])
      self[:hsrp_state].read(str[2,1])
      self[:hsrp_hellotime].read(str[3,1])
      self[:hsrp_holdtime].read(str[4,1])
      self[:hsrp_priority].read(str[5,1])
      self[:hsrp_group].read(str[6,1])
      self[:hsrp_reserved].read(str[7,1])
      self[:hsrp_password].read(str[8,8])
      self[:hsrp_vip].read(str[16,4])
      self[:body].read(str[20,str.size]) if str.size > 20
      self
    end

to_s() click to toggle source

Returns the object in string form.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.