### Home Classes Methods

### In Files

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

### Parent

Struct.new(:a1, :a2, :a3, :a4)

### Methods

- ::new
- #read
- #read_x
- #to_i
- #to_s
- #to_x

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

AddrIpv6 handles addressing for IPv6Header

#### Header Definition

    Int32 :a1
    Int32 :a2
    Int32 :a3
    Int32 :a4

### Public Class Methods

new(args={}) click to toggle source

    # File lib/packetfu/protos/ipv6/header.rb, line 14
    def initialize(args={})
      super(
        Int32.new(args[:a1]),
        Int32.new(args[:a2]),
        Int32.new(args[:a3]),
        Int32.new(args[:a4]))
    end

### Public Instance Methods

read(str) click to toggle source

Reads in a string and casts it as an IPv6 address

    # File lib/packetfu/protos/ipv6/header.rb, line 38
    def read(str)
      force_binary(str)
      return self if str.nil?
      self[:a1].read str[0,4]
      self[:a2].read str[4,4]
      self[:a3].read str[8,4]
      self[:a4].read str[12,4]
      self
    end

read_x(str) click to toggle source

Reads in a colon-delimited hex string and casts it as an IPv6 address.

    # File lib/packetfu/protos/ipv6/header.rb, line 49
    def read_x(str)
      addr = IPAddr.new(str).to_i
      self[:a1]=Int32.new(addr >> 96)
      self[:a2]=Int32.new((addr & 0x00000000ffffffff0000000000000000) >> 64)
      self[:a3]=Int32.new((addr & 0x0000000000000000ffffffff00000000) >> 32)
      self[:a4]=Int32.new(addr & 0x000000000000000000000000ffffffff)
      self
    end

to_i() click to toggle source

Returns the address as a fairly ginormous integer.

    # File lib/packetfu/protos/ipv6/header.rb, line 28
    def to_i
      (a1.to_i << 96) + (a2.to_i << 64) + (a3.to_i << 32) + a4.to_i
    end

to_s() click to toggle source

Returns the address in string format.

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

to_x() click to toggle source

Returns the address as a colon-delimited hex string.

    # File lib/packetfu/protos/ipv6/header.rb, line 33
    def to_x
      IPAddr.new(self.to_i, Socket::AF_INET6).to_s
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.