Class: Scriptroute::TCP
- Defined in:
- lib/scriptroute/packets.rb,
lib/scriptroute/packets.rb
Constant Summary collapse
- TH_FIN =
0x01
- TH_SYN =
0x02
- TH_RST =
0x04
- TH_PUSH =
0x08
- TH_ACK =
0x10
- TH_URG =
0x20
Constants inherited from IPv4
Constants inherited from IP
IP::IPPROTO_TCP, IP::IPPROTO_UDP
Instance Attribute Summary collapse
-
#flag_ack ⇒ Object
flags don’t work.
-
#flag_fin ⇒ Object
flags don’t work.
-
#flag_push ⇒ Object
flags don’t work.
-
#flag_rst ⇒ Object
flags don’t work.
-
#flag_syn ⇒ Object
flags don’t work.
-
#flag_urg ⇒ Object
flags don’t work.
- #ip_p ⇒ Fixnum readonly
- #ip_payload_len ⇒ Fixnum readonly
-
#th_ack ⇒ Object
Returns the value of attribute th_ack.
-
#th_dport ⇒ Object
Returns the value of attribute th_dport.
-
#th_flags ⇒ Object
Returns the value of attribute th_flags.
-
#th_seq ⇒ Object
Returns the value of attribute th_seq.
-
#th_sport ⇒ Object
readonly
Returns the value of attribute th_sport.
-
#th_sum ⇒ Object
Returns the value of attribute th_sum.
-
#th_urp ⇒ Object
readonly
Returns the value of attribute th_urp.
-
#th_win ⇒ Object
Returns the value of attribute th_win.
Attributes inherited from IPv4
#ip_dst, #ip_hl, #ip_id, #ip_len, #ip_off, #ip_options, #ip_src, #ip_sum, #ip_tos, #ip_ttl, #ip_v
Instance Method Summary collapse
-
#initialize(paylen_or_str = 0) ⇒ TCP
constructor
A new instance of TCP.
-
#marshal ⇒ String
The packet in string form.
Methods inherited from IPv4
#add_option, #calculate_header_len, #calculate_packet_len, creator, #ipv4_unmarshal, #to_s
Methods inherited from IP
Constructor Details
#initialize(paylen_or_str = 0) ⇒ TCP
Returns a new instance of TCP.
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
# File 'lib/scriptroute/packets.rb', line 639 def initialize(paylen_or_str = 0) if(paylen_or_str.is_a?(Fixnum)) then @ip_payload_len = paylen_or_str + 20 # tcp header @ip_p = IPPROTO_TCP @th_dport = 80 @th_sport = 0 # should be set by the daemon @th_seq = 0 # should be set by the user, rand likely @th_ack = 0 # should be set by the user, rand likely @th_flags = TH_ACK # should be left alone, but could be set. @th_win = 5180 # linux default. @th_urp = 0 # not supported @th_sum = 0 # should be set by the daemon super(IPPROTO_TCP) else @th_sport, @th_dport, @th_seq, @th_ack, reserved, @th_flags, @th_win, @th_sum, @th_urp = paylen_or_str.unpack("nnNNCCnnn") end end |
Instance Attribute Details
#flag_ack ⇒ Object
flags don’t work
625 626 627 |
# File 'lib/scriptroute/packets.rb', line 625 def flag_ack @flag_ack end |
#flag_fin ⇒ Object
flags don’t work
625 626 627 |
# File 'lib/scriptroute/packets.rb', line 625 def flag_fin @flag_fin end |
#flag_push ⇒ Object
flags don’t work
625 626 627 |
# File 'lib/scriptroute/packets.rb', line 625 def flag_push @flag_push end |
#flag_rst ⇒ Object
flags don’t work
625 626 627 |
# File 'lib/scriptroute/packets.rb', line 625 def flag_rst @flag_rst end |
#flag_syn ⇒ Object
flags don’t work
625 626 627 |
# File 'lib/scriptroute/packets.rb', line 625 def flag_syn @flag_syn end |
#flag_urg ⇒ Object
flags don’t work
625 626 627 |
# File 'lib/scriptroute/packets.rb', line 625 def flag_urg @flag_urg end |
#ip_p ⇒ Fixnum (readonly)
633 634 635 |
# File 'lib/scriptroute/packets.rb', line 633 def ip_p @ip_p end |
#ip_payload_len ⇒ Fixnum (readonly)
633 634 635 |
# File 'lib/scriptroute/packets.rb', line 633 def ip_payload_len @ip_payload_len end |
#th_ack ⇒ Object
Returns the value of attribute th_ack.
622 623 624 |
# File 'lib/scriptroute/packets.rb', line 622 def th_ack @th_ack end |
#th_dport ⇒ Object
Returns the value of attribute th_dport.
622 623 624 |
# File 'lib/scriptroute/packets.rb', line 622 def th_dport @th_dport end |
#th_flags ⇒ Object
Returns the value of attribute th_flags.
622 623 624 |
# File 'lib/scriptroute/packets.rb', line 622 def th_flags @th_flags end |
#th_seq ⇒ Object
Returns the value of attribute th_seq.
622 623 624 |
# File 'lib/scriptroute/packets.rb', line 622 def th_seq @th_seq end |
#th_sport ⇒ Object (readonly)
Returns the value of attribute th_sport.
622 623 624 |
# File 'lib/scriptroute/packets.rb', line 622 def th_sport @th_sport end |
#th_sum ⇒ Object
Returns the value of attribute th_sum.
622 623 624 |
# File 'lib/scriptroute/packets.rb', line 622 def th_sum @th_sum end |
#th_urp ⇒ Object (readonly)
Returns the value of attribute th_urp.
622 623 624 |
# File 'lib/scriptroute/packets.rb', line 622 def th_urp @th_urp end |
#th_win ⇒ Object
Returns the value of attribute th_win.
622 623 624 |
# File 'lib/scriptroute/packets.rb', line 622 def th_win @th_win end |
Instance Method Details
#marshal ⇒ String
Returns The packet in string form.
657 658 659 660 661 662 |
# File 'lib/scriptroute/packets.rb', line 657 def marshal array_of_elements = [ @th_sport, @th_dport, @th_seq, @th_ack, 0x50, @th_flags, @th_win, @th_sum, @th_urp ] raise "a TCP header field #{array_of_elements.index(nil)} was unset" if array_of_elements.include?(nil) super + array_of_elements.pack("nnNNCCnnn") # TODO plus payload length end |