class Mu::Pcap::SCTP::Chunk::Init
Attributes
a_rwnd[RW]
i_streams[RW]
init_tag[RW]
init_tsn[RW]
o_streams[RW]
Public Class Methods
from_bytes(flags, size, bytes)
click to toggle source
# File lib/woolen_common/pcap/mu/pcap/sctp/chunk/init.rb, line 25 def self.from_bytes flags, size, bytes # Basic validation Pcap.assert(bytes.length >= 16, "Truncated init chunk header: 16 > #{bytes.length}") # Read init chunk header init_tag, a_rwnd, o_streams, i_streams, init_tsn = bytes.unpack('NNnnN') # Create init chunk init = Init.new init.flags = flags init.size = size init.init_tag = init_tag init.a_rwnd = a_rwnd init.o_streams = o_streams init.i_streams = i_streams init.init_tsn = init_tsn # Initialize the counter length = 16 # Collect the chunks while length < bytes.length # Parse new parameter from the bytes parameter = Parameter.from_bytes(bytes[length..-1]) # Get parameter size with padding length += parameter.padded_size # Add chunk to the list init << parameter end # Return the result return init end
new()
click to toggle source
Calls superclass method
Mu::Pcap::SCTP::Chunk::new
# File lib/woolen_common/pcap/mu/pcap/sctp/chunk/init.rb, line 13 def initialize super @type = CHUNK_INIT @init_tag = 0 @a_rwnd = 0 @o_streams = 0 @i_streams = 0 @init_tsn = 0 @payload = [] end
Public Instance Methods
<<(parameter)
click to toggle source
# File lib/woolen_common/pcap/mu/pcap/sctp/chunk/init.rb, line 80 def << parameter @payload << parameter end
to_s()
click to toggle source
# File lib/woolen_common/pcap/mu/pcap/sctp/chunk/init.rb, line 84 def to_s return "init(%d, %d, %d, %d, %d, %d, %s)" % [@size, @init_tag, @a_rwnd, @o_streams, @i_streams, @init_tsn, @payload.join(", ")] end
write(io, ip)
click to toggle source
# File lib/woolen_common/pcap/mu/pcap/sctp/chunk/init.rb, line 62 def write io, ip chunk_header = [@type, @flags, @size].pack('CCn') init_header = [@init_tag, @a_rwnd, @o_streams, @i_streams, @init_tsn].pack('NNnnN') # Write Chunk header followed by the Init chunk header io.write(chunk_header) io.write(init_header) # Write each parameter @payload.each do |parameter| parameter.write(io, ip) end end