Class: FFI::PCap::Packets::TCP
- Inherits:
-
Struct
- Object
- Struct
- FFI::PCap::Packets::TCP
- Includes:
- Packet
- Defined in:
- lib/pcap/packets/tcp.rb
Constant Summary collapse
- FLAGS =
TCP flags
[ # Null flags NULL = 0x00, # Final packet flag FIN = 0x01, # Synchronization packet flag SYN = 0x02, # Reset packet flag RST = 0x04, # Push packet flag PUSH = 0x08, # Acknowledgement packet flag ACK = 0x10, # Urgent data packet flag URG = 0x20, # ECE packet flag ECE = 0x40, # CWR packet flag CWR = 0x80, # All combined flags XMAS = (FIN | SYN | RST | PUSH | ACK | URG | ECE | CWR) ]
Instance Method Summary collapse
-
#ack ⇒ Object
Returns the acknowledgement number of the packet.
-
#ack? ⇒ Boolean
Returns
true
if the packet has the ACK flag set, returnsfalse
otherwise. -
#cwr? ⇒ Boolean
Returns
true
if the packet has the CWR flag set, returnsfalse
otherwise. -
#dest_port ⇒ Object
Returns the destination port.
-
#ece? ⇒ Boolean
Returns
true
if the packet has the ECE flag set, returnsfalse
otherwise. -
#fin? ⇒ Boolean
Returns
true
if the packet has the FIN flag set, returnsfalse
otherwise. -
#null? ⇒ Boolean
Returns
true
if the packet has no flags set,false
otherwise. -
#offset ⇒ Object
Returns the data offset for the packet.
-
#push? ⇒ Boolean
Returns
true
if the packet has the PUSH flag set, returnsfalse
otherwise. -
#rst? ⇒ Boolean
Returns
true
if the packet has the RST flag set, returnsfalse
otherwise. -
#seq ⇒ Object
Returns the sequence number of the packet.
-
#src_port ⇒ Object
Returns the source port.
-
#syn? ⇒ Boolean
Returns
true
if the packet has the SYN flag set, returnsfalse
otherwise. -
#urg? ⇒ Boolean
Returns
true
if the packet has the URG flag set, returnsfalse
otherwise. -
#xmas? ⇒ Boolean
Returns
true
if the packet has all flags set,false
otherwise.
Instance Method Details
#ack ⇒ Object
Returns the acknowledgement number of the packet.
80 81 82 |
# File 'lib/pcap/packets/tcp.rb', line 80 def ack self[:th_ack] end |
#ack? ⇒ Boolean
Returns true
if the packet has the ACK flag set, returns false
otherwise.
134 135 136 |
# File 'lib/pcap/packets/tcp.rb', line 134 def ack? (self[:th_flags] & ACK) != 0 end |
#cwr? ⇒ Boolean
Returns true
if the packet has the CWR flag set, returns false
otherwise.
158 159 160 |
# File 'lib/pcap/packets/tcp.rb', line 158 def cwr? (self[:th_flags] & CWR) != 0 end |
#dest_port ⇒ Object
Returns the destination port.
66 67 68 |
# File 'lib/pcap/packets/tcp.rb', line 66 def dest_port self[:th_dport] end |
#ece? ⇒ Boolean
Returns true
if the packet has the ECE flag set, returns false
otherwise.
150 151 152 |
# File 'lib/pcap/packets/tcp.rb', line 150 def ece? (self[:th_flags] & ECE) != 0 end |
#fin? ⇒ Boolean
Returns true
if the packet has the FIN flag set, returns false
otherwise.
102 103 104 |
# File 'lib/pcap/packets/tcp.rb', line 102 def fin? (self[:th_flags] & FIN) != 0 end |
#null? ⇒ Boolean
Returns true
if the packet has no flags set, false
otherwise.
94 95 96 |
# File 'lib/pcap/packets/tcp.rb', line 94 def null? self[:th_flags] == NULL end |
#offset ⇒ Object
Returns the data offset for the packet.
87 88 89 |
# File 'lib/pcap/packets/tcp.rb', line 87 def offset (self[:th_offx2] & 0xf0) >> 4 end |
#push? ⇒ Boolean
Returns true
if the packet has the PUSH flag set, returns false
otherwise.
126 127 128 |
# File 'lib/pcap/packets/tcp.rb', line 126 def push? (self[:th_flags] & PUSH) != 0 end |
#rst? ⇒ Boolean
Returns true
if the packet has the RST flag set, returns false
otherwise.
118 119 120 |
# File 'lib/pcap/packets/tcp.rb', line 118 def rst? (self[:th_flags] & RST) != 0 end |
#seq ⇒ Object
Returns the sequence number of the packet.
73 74 75 |
# File 'lib/pcap/packets/tcp.rb', line 73 def seq self[:th_seq] end |
#src_port ⇒ Object
Returns the source port.
59 60 61 |
# File 'lib/pcap/packets/tcp.rb', line 59 def src_port self[:th_sport] end |
#syn? ⇒ Boolean
Returns true
if the packet has the SYN flag set, returns false
otherwise.
110 111 112 |
# File 'lib/pcap/packets/tcp.rb', line 110 def syn? (self[:th_flags] & SYN) != 0 end |
#urg? ⇒ Boolean
Returns true
if the packet has the URG flag set, returns false
otherwise.
142 143 144 |
# File 'lib/pcap/packets/tcp.rb', line 142 def urg? (self[:th_flags] & URG) != 0 end |
#xmas? ⇒ Boolean
Returns true
if the packet has all flags set, false
otherwise.
165 166 167 |
# File 'lib/pcap/packets/tcp.rb', line 165 def xmas? (self[:th_flags] & XMAS) == XMAS end |