Class: Racket::L3::CDP

Inherits:
RacketPart show all
Defined in:
lib/racket/l3/cdp.rb

Overview

Instance Attribute Summary

Attributes inherited from RacketPart

#autofix

Instance Method Summary collapse

Methods inherited from RacketPart

#autofix?, #pretty

Constructor Details

#initialize(*args) ⇒ CDP

Returns a new instance of CDP.



43
44
45
# File 'lib/racket/l3/cdp.rb', line 43

def initialize(*args)
  super(*args)
end

Instance Method Details

#add_field(type, value) ⇒ Object

Add a new field to this CDP message.



48
49
50
51
52
53
54
# File 'lib/racket/l3/cdp.rb', line 48

def add_field(type, value) 
  t = Racket::Misc::TLV.new(2,2)
  t.type = type
  t.value = value
  t.length = 4 + value.length
  self.payload += t.encode   
end

#checksum!Object

Compute and set the checksum for this IP datagram



62
63
64
# File 'lib/racket/l3/cdp.rb', line 62

def checksum! 
  self.checksum = compute_checksum
end

#checksum?Boolean

Check the checksum for this IP datagram

Returns:

  • (Boolean)


57
58
59
# File 'lib/racket/l3/cdp.rb', line 57

def checksum? 
  self.checksum == compute_checksum
end

#fix!Object

Fix this CDP message up for sending.



67
68
69
# File 'lib/racket/l3/cdp.rb', line 67

def fix! 
  self.checksum!
end