### Home Classes Methods

### In Files

- lib/packetfu/config.rb

### Parent

Object

### Methods

- ::new
- #config

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

The Config class holds various bits of useful default information for packet creation. If initialized without arguments, @iface will be set to ENV or Pcap.lookupdev (or lo), and the @pcapfile will be set to "/tmp/out.pcap" # (yes, it's Linux-biased, sorry, fixing this is a TODO.)

Any number of instance variables can be passed in to the intialize function (as a hash), though only the expected network-related variables will be readable and writeable directly.

## Examples

    PacketFu::Config.new(:ip_saddr => "1.2.3.4").ip_saddr #=> "1.2.3.4"
    PacketFu::Config.new(:foo=>"bar").foo #=> NomethodError: undefined method `foo'...

The config() function, however, does provide access to custom variables:

    PacketFu::Config.new(:foo=>"bar").config[:foo] #=> "bar"
    obj = PacketFu::Config.new(:foo=>"bar")
    obj.config(:baz => "bat")
    obj.config #=> {:iface=>"eth0", :baz=>"bat", :pcapfile=>"/tmp/out.pcap", :foo=>"bar"}

### Attributes

eth_daddr[RW]
eth_dst[RW]
eth_saddr[RW]
eth_src[RW]
iface[RW]
ip_saddr[RW]
ip_src[RW]
pcapfile[RW]

### Public Class Methods

new(args={}) click to toggle source

    # File lib/packetfu/config.rb, line 34
    def initialize(args={})
            if Process.euid.zero?
                    @iface = args[:iface] || ENV['IFACE'] || Pcap.lookupdev || "lo"
            end
            @pcapfile = "/tmp/out.pcap"
            args.each_pair { |k,v| self.instance_variable_set(("@#{k}"),v) }
    end

### Public Instance Methods

config(arg=nil) click to toggle source

Returns all instance variables as a hash (including custom variables set at initialization).

    # File lib/packetfu/config.rb, line 43
    def config(arg=nil)
            if arg
                    arg.each_pair {|k,v| self.instance_variable_set(("@" + k.to_s).intern, v)}
            else
                    config_hash = {}
                    self.instance_variables.each do |v|
                            key = v.to_s.gsub(/^@/,"").to_sym
                            config_hash[key] = self.instance_variable_get(v)
                    end
                    config_hash
            end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.