Class: Netfilter::Packet
- Inherits:
-
Object
- Object
- Netfilter::Packet
- Defined in:
- lib/nfqueue.rb
Overview
This class represents a packet filtered by a Netfilter::Queue.
Defined Under Namespace
Classes: HardwareAddress, Header, Timeval
Constant Summary collapse
- DROP =
0- ACCEPT =
1- STOLEN =
2- QUEUE =
3- REPEAT =
4- STOP =
5
Instance Attribute Summary collapse
-
#data ⇒ Object
The packet contents.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#hw_addr ⇒ Object
The source hardware address.
-
#indev ⇒ Object
The index of the device the queued packet was received via.
-
#indev_name ⇒ Object
The name of the interface this packet was received through.
-
#initialize(nfad) ⇒ Packet
constructor
:nodoc:.
-
#outdev ⇒ Object
The index of the device the queued packet will be sent out.
-
#outdev_name ⇒ Object
The name of the interface this packet will be routed to.
-
#phys_indev ⇒ Object
The index of the physical device the queued packet was received via.
-
#phys_indev_name ⇒ Object
The name of the physical interface this packet was received through.
-
#phys_outdev ⇒ Object
The index of the physical device the queued packet will be sent out.
-
#phys_outdev_name ⇒ Object
The name of the physical interface this packet will be routed to.
-
#timestamp ⇒ Object
The packet timestamp.
Constructor Details
Instance Attribute Details
#data ⇒ Object
The packet contents.
164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/nfqueue.rb', line 164 def data if @data.nil? pdata = FFI::MemoryPointer.new(:pointer, 1) size = Queue.nfq_get_payload(@nfad, pdata) if size < 0 raise QueueError, "nfq_get_payload has failed" end @data = pdata.read_pointer.read_bytes(size) else @data end end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
64 65 66 |
# File 'lib/nfqueue.rb', line 64 def id @id end |
Instance Method Details
#hw_addr ⇒ Object
The source hardware address.
152 153 154 155 156 157 158 159 |
# File 'lib/nfqueue.rb', line 152 def hw_addr phw = Queue.nfq_get_packet_hw(@nfad) return nil if phw.null? hw = HardwareAddress.new(phw) hw_addrlen = [ hw[:hw_addrlen] ].pack('v').unpack('n')[0] hw[:hw_addr].to_ptr.read_bytes(hw_addrlen) end |
#indev ⇒ Object
The index of the device the queued packet was received via. If the return index is 0, the packet was locally generated or the input interface is not known (ie. POSTROUTING?).
93 94 95 |
# File 'lib/nfqueue.rb', line 93 def indev Queue.nfq_get_indev(@nfad) end |
#indev_name ⇒ Object
The name of the interface this packet was received through.
100 101 102 |
# File 'lib/nfqueue.rb', line 100 def indev_name get_interface_name(self.indev) end |
#outdev ⇒ Object
The index of the device the queued packet will be sent out. It the returned index is 0, the packet is destined for localhost or the output interface is not yet known (ie. PREROUTING?).
123 124 125 |
# File 'lib/nfqueue.rb', line 123 def outdev Queue.nfq_get_outdev(@nfad) end |
#outdev_name ⇒ Object
The name of the interface this packet will be routed to.
130 131 132 |
# File 'lib/nfqueue.rb', line 130 def outdev_name get_interface_name(self.outdev) end |
#phys_indev ⇒ Object
The index of the physical device the queued packet was received via. If the returned index is 0, the packet was locally generated or the physical input interface is no longer known (ie. POSTROUTING).
108 109 110 |
# File 'lib/nfqueue.rb', line 108 def phys_indev Queue.nfq_get_physindev(@nfad) end |
#phys_indev_name ⇒ Object
The name of the physical interface this packet was received through.
115 116 117 |
# File 'lib/nfqueue.rb', line 115 def phys_indev_name get_interface_name(self.phys_indev) end |
#phys_outdev ⇒ Object
The index of the physical device the queued packet will be sent out. If the returned index is 0, the packet is destined for localhost or the physical output interface is not yet known (ie. PREROUTING).
138 139 140 |
# File 'lib/nfqueue.rb', line 138 def phys_outdev Queue.nfq_get_physoutdev(@nfad) end |
#phys_outdev_name ⇒ Object
The name of the physical interface this packet will be routed to.
145 146 147 |
# File 'lib/nfqueue.rb', line 145 def phys_outdev_name get_interface_name(self.phys_outdev) end |