Class: Packetnom::Packet::Tcp
- Inherits:
-
Object
- Object
- Packetnom::Packet::Tcp
- Defined in:
- lib/packet/tcp.rb
Instance Attribute Summary collapse
-
#ack ⇒ Object
Returns the value of attribute ack.
-
#cbits ⇒ Object
(also: #controlbits, #control)
Returns the value of attribute cbits.
-
#dst_port ⇒ Object
(also: #dest_port, #dport)
Returns the value of attribute dst_port.
-
#ecn ⇒ Object
Returns the value of attribute ecn.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#reserved ⇒ Object
Returns the value of attribute reserved.
-
#seq ⇒ Object
Returns the value of attribute seq.
-
#src_port ⇒ Object
(also: #source_port, #sport)
Attributes.
-
#sum ⇒ Object
(also: #checksum)
Returns the value of attribute sum.
-
#uptr ⇒ Object
(also: #urgent)
Returns the value of attribute uptr.
-
#win ⇒ Object
(also: #window, #windowsize, #size)
Returns the value of attribute win.
Instance Method Summary collapse
-
#initialize(bytes) ⇒ Tcp
constructor
Initialize the packet.
Constructor Details
#initialize(bytes) ⇒ Tcp
Initialize the packet
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/packet/tcp.rb', line 21 def initialize( bytes ) @packet = bytes @src_port = bytes[34..35].join().to_i(16).to_s(10).to_i @dst_port = bytes[36..37].join().to_i(16).to_s(10).to_i @seq = bytes[38..41].join().to_i(16).to_s(10).to_i @ack = bytes[42..45].join().to_i(16).to_s(10).to_i @offset = bytes[46].split(//)[0].to_i(16).to_s(10) @reserved = bytes[46].split(//)[1].to_i(16).to_s(10) @ecn = bytes[47].split(//)[0].to_i(16).to_s(10) @cbits = bytes[47].split(//)[1].to_i(16).to_s(10) @win = bytes[48..49].join().to_i(16) @sum = bytes[50..51].join().to_i(16) @uptr = bytes[52..53].join().to_i(16) end |
Instance Attribute Details
#ack ⇒ Object
Returns the value of attribute ack.
11 12 13 |
# File 'lib/packet/tcp.rb', line 11 def ack @ack end |
#cbits ⇒ Object Also known as: controlbits, control
Returns the value of attribute cbits.
15 16 17 |
# File 'lib/packet/tcp.rb', line 15 def cbits @cbits end |
#dst_port ⇒ Object Also known as: dest_port, dport
Returns the value of attribute dst_port.
9 10 11 |
# File 'lib/packet/tcp.rb', line 9 def dst_port @dst_port end |
#ecn ⇒ Object
Returns the value of attribute ecn.
14 15 16 |
# File 'lib/packet/tcp.rb', line 14 def ecn @ecn end |
#offset ⇒ Object
Returns the value of attribute offset.
12 13 14 |
# File 'lib/packet/tcp.rb', line 12 def offset @offset end |
#reserved ⇒ Object
Returns the value of attribute reserved.
13 14 15 |
# File 'lib/packet/tcp.rb', line 13 def reserved @reserved end |
#seq ⇒ Object
Returns the value of attribute seq.
10 11 12 |
# File 'lib/packet/tcp.rb', line 10 def seq @seq end |
#src_port ⇒ Object Also known as: source_port, sport
Attributes
8 9 10 |
# File 'lib/packet/tcp.rb', line 8 def src_port @src_port end |
#sum ⇒ Object Also known as: checksum
Returns the value of attribute sum.
17 18 19 |
# File 'lib/packet/tcp.rb', line 17 def sum @sum end |
#uptr ⇒ Object Also known as: urgent
Returns the value of attribute uptr.
18 19 20 |
# File 'lib/packet/tcp.rb', line 18 def uptr @uptr end |
#win ⇒ Object Also known as: window, windowsize, size
Returns the value of attribute win.
16 17 18 |
# File 'lib/packet/tcp.rb', line 16 def win @win end |