Class: Racket::L4::UDP
- Inherits:
-
RacketPart
- Object
- BitStruct
- RacketPart
- Racket::L4::UDP
- Defined in:
- lib/racket/l4/udp.rb
Overview
RFC768 (www.faqs.org/rfcs/rfc768.html)
Instance Attribute Summary
Attributes inherited from RacketPart
Instance Method Summary collapse
-
#checksum!(src_ip, dst_ip) ⇒ Object
Compute and set the checksum for this UDP datagram.
-
#checksum?(src_ip, dst_ip) ⇒ Boolean
Check the checksum for this UDP datagram.
-
#fix!(src_ip, dst_ip) ⇒ Object
Fix this packet up for proper sending.
-
#initialize(*args) ⇒ UDP
constructor
A new instance of UDP.
Methods inherited from RacketPart
Constructor Details
#initialize(*args) ⇒ UDP
Returns a new instance of UDP.
64 65 66 67 |
# File 'lib/racket/l4/udp.rb', line 64 def initialize(*args) super @autofix = false end |
Instance Method Details
#checksum!(src_ip, dst_ip) ⇒ Object
Compute and set the checksum for this UDP datagram
51 52 53 54 55 |
# File 'lib/racket/l4/udp.rb', line 51 def checksum!(src_ip, dst_ip) # set the checksum to 0 for usage in the pseudo header... self.checksum = 0 self.checksum = compute_checksum(src_ip, dst_ip) end |
#checksum?(src_ip, dst_ip) ⇒ Boolean
Check the checksum for this UDP datagram
46 47 48 |
# File 'lib/racket/l4/udp.rb', line 46 def checksum?(src_ip, dst_ip) self.checksum == 0 || (self.checksum == compute_checksum(src_ip, dst_ip)) end |
#fix!(src_ip, dst_ip) ⇒ Object
Fix this packet up for proper sending. Sets the length and checksum properly.
59 60 61 62 |
# File 'lib/racket/l4/udp.rb', line 59 def fix!(src_ip, dst_ip) self.len = self.class.bit_length/8 + self.payload.length self.checksum!(src_ip, dst_ip) end |