| Class | Racket::L4::TCP |
| In: |
lib/racket/l4/tcp.rb
(CVS)
|
| Parent: | RacketPart |
Transmission Control Protocol: TCP
RFC793 (www.faqs.org/rfcs/rfc793.html)
| ack | Acknowledgement number | |
| checksum | Checksum | |
| dst_port | Destination port | |
| flag_ack | ACK | |
| flag_cwr | CWR | |
| flag_ece | ECE | |
| flag_fin | FIN | |
| flag_psh | PSH | |
| flag_rst | RST | |
| flag_syn | SYN | |
| flag_urg | URG | |
| offset | Data Offset | |
| payload | Payload | |
| reserved | Reserved | |
| seq | Sequence number | |
| src_port | Source port | |
| urg | Urgent pointer | |
| window | Window size |
# File lib/racket/l4/tcp.rb, line 122 def initialize(*args) @options = [] super @autofix = false end
Add an TCP option to this TCP object. All rejiggering will happen when the call to fix! happens automagically. If the result is not on a 32-bit boundry, pad with NOPs.
# File lib/racket/l4/tcp.rb, line 75 def add_option(number, value) t = Misc::TLV.new(1,1) t.type = number t.value = value t.length = value.length + 2 opts = t.encode opts += ("\x01" * (4-(opts.size % 4))) if (opts.size % 4) != 0 @options << opts end
Fix this packet up for proper sending. Sets the length and checksum properly.
# File lib/racket/l4/tcp.rb, line 104 def fix!(ip_src, ip_dst, next_payload) newpayload = @options.join # pad to a multiple of 32 bits if ((self.class.bit_length/8 + newpayload.length) % 4 != 0) # fill the beginning as needed with NOPs while ((self.class.bit_length/8 + newpayload.length) % 4 != 4) puts (self.class.bit_length/8 + newpayload.length) % 4 newpayload = "\x01#{newpayload}" end end self.payload = newpayload + self.payload + next_payload self.offset = self.class.bit_length/32 + newpayload.length/4 self.checksum!(ip_src, ip_dst) self.payload = newpayload end