Class: Racket::L4::SCTP

Inherits:
RacketPart show all
Defined in:
lib/racket/l4/sctp.rb

Instance Attribute Summary

Attributes inherited from RacketPart

#autofix

Instance Method Summary collapse

Methods inherited from RacketPart

#autofix?, #pretty

Constructor Details

#initialize(*args) ⇒ SCTP

Returns a new instance of SCTP.



66
67
68
69
# File 'lib/racket/l4/sctp.rb', line 66

def initialize(*args)
  @chunks = []
  super
end

Instance Method Details

#add_chunk(type, flags, length, data) ⇒ Object

Add a new SCTP chunk (see tools.ietf.org/html/rfc4960)



45
46
47
# File 'lib/racket/l4/sctp.rb', line 45

def add_chunk(type, flags, length, data)
  @chunks << [ type, flags, length, data ]
end

#checksum!Object



53
54
55
# File 'lib/racket/l4/sctp.rb', line 53

def checksum!
  self.checksum = compute_checksum
end

#checksum?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/racket/l4/sctp.rb', line 49

def checksum?
  self.checksum == compute_checksum
end

#fix!Object

(really, just set the checksum)



58
59
60
61
62
63
64
# File 'lib/racket/l4/sctp.rb', line 58

def fix!
  self.payload = ""
  @chunks.each do |c|
    self.payload += c.pack("CCna*")
  end
  self.checksum!
end