Class Racket::L4::UDP
In: lib/racket/l4/udp.rb  (CVS)
Parent: RacketPart

User Datagram Protocol: UDP

RFC768 (www.faqs.org/rfcs/rfc768.html)

Methods

checksum!   checksum?   fix!   new  

Attributes

checksum    Checksum
dst_port    Destination Port
len    Datagram Length
payload    Payload
src_port    Source Port

Public Class methods

[Source]

# File lib/racket/l4/udp.rb, line 64
  def initialize(*args)
    super
    @autofix = false
  end

Public Instance methods

Compute and set the checksum for this UDP datagram

[Source]

# 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

Check the checksum for this UDP datagram

[Source]

# 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 this packet up for proper sending. Sets the length and checksum properly.

[Source]

# 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

[Validate]