### Home Classes Methods

### In Files

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

### Parent

Struct.new(:ipv6_v, :ipv6_class, :ipv6_label, :ipv6_len, :ipv6_next, :ipv6_hop, :ipv6_src, :ipv6_dst, :body)

### Methods

- ::new
- #ipv6_calc_len
- #ipv6_class
- #ipv6_class=
- #ipv6_daddr
- #ipv6_daddr=
- #ipv6_dst
- #ipv6_dst=
- #ipv6_dst_readable
- #ipv6_hop
- #ipv6_hop=
- #ipv6_label
- #ipv6_label=
- #ipv6_len
- #ipv6_len=
- #ipv6_next
- #ipv6_next=
- #ipv6_recalc
- #ipv6_saddr
- #ipv6_saddr=
- #ipv6_src
- #ipv6_src=
- #ipv6_src_readable
- #ipv6_v
- #ipv6_v=
- #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::IPv6Header

IPv6Header is complete IPv6 struct, used in IPv6Packet.

#### Header Definition

    Fixnum (4 bits)   :ipv6_v      Default: 6     # Versiom
    Fixnum (8 bits)   :ipv6_class  Defualt: 0     # Class
    Fixnum (20 bits)  :ipv6_label  Defualt: 0     # Label
    Int16             :ipv6_len    Default: calc  # Payload length
    Int8              :ipv6_next                  # Next Header
    Int8              :ipv6_hop    Default: 0xff  # Hop limit
    AddrIpv6          :ipv6_src
    AddrIpv6          :ipv6_dst
    String            :body

### Public Class Methods

new(args={}) click to toggle source

    # File lib/packetfu/protos/ipv6/header.rb, line 78
    def initialize(args={})
            super(
                    (args[:ipv6_v] || 6),
                    (args[:ipv6_class] || 0),
                    (args[:ipv6_label] || 0),
                    Int16.new(args[:ipv6_len]),
                    Int8.new(args[:ipv6_next]),
                    Int8.new(args[:ipv6_hop] || 0xff),
                    AddrIpv6.new.read(args[:ipv6_src] || ("\x00" * 16)),
                    AddrIpv6.new.read(args[:ipv6_dst] || ("\x00" * 16)),
                    StructFu::String.new.read(args[:body])
            )
    end

### Public Instance Methods

ipv6_calc_len() click to toggle source

Calculates the payload length.

    # File lib/packetfu/protos/ipv6/header.rb, line 150
    def ipv6_calc_len
            self[:ipv6_len] = body.to_s.length
    end

ipv6_class() click to toggle source

Getter for the traffic class.

    # File lib/packetfu/protos/ipv6/header.rb, line 123
    def ipv6_class; self[:ipv6_class].to_i; end

ipv6_class=(i) click to toggle source

Setter for the traffic class.

    # File lib/packetfu/protos/ipv6/header.rb, line 121
    def ipv6_class=(i); self[:ip_class] = i.to_i; end

ipv6_daddr() click to toggle source

Get the destination address in a more readable form.

    # File lib/packetfu/protos/ipv6/header.rb, line 175
    def ipv6_daddr
            self[:ipv6_dst].to_x
    end

Also aliased as: ipv6_dst_readable
ipv6_daddr=(str) click to toggle source

Set the destination address in a more readable form.

    # File lib/packetfu/protos/ipv6/header.rb, line 180
    def ipv6_daddr=(str)
            self[:ipv6_dst].read_x(str)
    end

ipv6_dst() click to toggle source

Getter for the destination address.

    # File lib/packetfu/protos/ipv6/header.rb, line 147
    def ipv6_dst; self[:ipv6_dst].to_i; end

ipv6_dst=(i) click to toggle source

Setter for the destination address.

    # File lib/packetfu/protos/ipv6/header.rb, line 145
    def ipv6_dst=(i); typecast i; end

ipv6_dst_readable() click to toggle source
Alias for: ipv6_daddr
ipv6_hop() click to toggle source

Getter for the hop limit.

    # File lib/packetfu/protos/ipv6/header.rb, line 139
    def ipv6_hop; self[:ipv6_hop].to_i; end

ipv6_hop=(i) click to toggle source

Setter for the hop limit.

    # File lib/packetfu/protos/ipv6/header.rb, line 137
    def ipv6_hop=(i); typecast i; end

ipv6_label() click to toggle source

Getter for the flow label.

    # File lib/packetfu/protos/ipv6/header.rb, line 127
    def ipv6_label; self[:ipv6_label].to_i; end

ipv6_label=(i) click to toggle source

Setter for the flow label.

    # File lib/packetfu/protos/ipv6/header.rb, line 125
    def ipv6_label=(i); self[:ip_label] = i.to_i; end

ipv6_len() click to toggle source

Getter for the payload length.

    # File lib/packetfu/protos/ipv6/header.rb, line 131
    def ipv6_len; self[:ipv6_len].to_i; end

ipv6_len=(i) click to toggle source

Setter for the payload length.

    # File lib/packetfu/protos/ipv6/header.rb, line 129
    def ipv6_len=(i); typecast i; end

ipv6_next() click to toggle source

Getter for the next protocol header.

    # File lib/packetfu/protos/ipv6/header.rb, line 135
    def ipv6_next; self[:ipv6_next].to_i; end

ipv6_next=(i) click to toggle source

Setter for the next protocol header.

    # File lib/packetfu/protos/ipv6/header.rb, line 133
    def ipv6_next=(i); typecast i; end

ipv6_recalc(arg=:all) click to toggle source

Recalculates the calculatable fields for this object.

    # File lib/packetfu/protos/ipv6/header.rb, line 155
    def ipv6_recalc(arg=:all)
            case arg
            when :ipv6_len
                    ipv6_calc_len
            when :all
                    ipv6_recalc(:len)
            end
    end

ipv6_saddr() click to toggle source

Get the source address in a more readable form.

    # File lib/packetfu/protos/ipv6/header.rb, line 165
    def ipv6_saddr
            self[:ipv6_src].to_x
    end

Also aliased as: ipv6_src_readable
ipv6_saddr=(str) click to toggle source

Set the source address in a more readable form.

    # File lib/packetfu/protos/ipv6/header.rb, line 170
    def ipv6_saddr=(str)
            self[:ipv6_src].read_x(str)
    end

ipv6_src() click to toggle source

Getter for the source address.

    # File lib/packetfu/protos/ipv6/header.rb, line 143
    def ipv6_src; self[:ipv6_src].to_i; end

ipv6_src=(i) click to toggle source

Setter for the source address.

    # File lib/packetfu/protos/ipv6/header.rb, line 141
    def ipv6_src=(i); typecast i; end

ipv6_src_readable() click to toggle source

Readability aliases

Alias for: ipv6_saddr
ipv6_v() click to toggle source

Getter for the version (usually, 6).

    # File lib/packetfu/protos/ipv6/header.rb, line 119
    def ipv6_v; self[:ipv6_v].to_i; end

ipv6_v=(i) click to toggle source

Setter for the version (usually, 6).

    # File lib/packetfu/protos/ipv6/header.rb, line 117
    def ipv6_v=(i); self[:ip_v] = i.to_i; end

read(str) click to toggle source

Reads a string to populate the object.

    # File lib/packetfu/protos/ipv6/header.rb, line 101
    def read(str)
            force_binary(str)
            return self if str.nil?
            self[:ipv6_v] = str[0,1].unpack("C").first >> 4
            self[:ipv6_class] = (str[0,2].unpack("n").first & 0x0ff0) >> 4
            self[:ipv6_label] = str[0,4].unpack("N").first & 0x000fffff
            self[:ipv6_len].read(str[4,2])
            self[:ipv6_next].read(str[6,1])
            self[:ipv6_hop].read(str[7,1])
            self[:ipv6_src].read(str[8,16])
            self[:ipv6_dst].read(str[24,16])
            self[:body].read(str[40,str.size]) if str.size > 40
            self
    end

to_s() click to toggle source

Returns the object in string form.

    # File lib/packetfu/protos/ipv6/header.rb, line 93
    def to_s
            bytes_v_class_label = [(self.ipv6_v << 28) +
             (self.ipv6_class << 20) +
             self.ipv6_label].pack("N")
            bytes_v_class_label + (self.to_a[3,6].map {|x| x.to_s}.join)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.