Sha256: 27e3db84a77ec4804c3c0e570c6251fe33f8da00dd9f8683fde6c68a4713f636

Contents?: true

Size: 1.95 KB

Versions: 17

Compression:

Stored size: 1.95 KB

Contents

# http://www.mudynamics.com
# http://labs.mudynamics.com
# http://www.pcapr.net

module Mu
class Pcap
class SCTP
class Chunk

class InitAck < Init
    def initialize
        super
        
        @type = CHUNK_INIT_ACK
    end
    
    def self.from_bytes flags, size, bytes
        # Basic validation
        Pcap.assert(bytes.length >= 16,
                    "Truncated init_ack chunk header: 16 > #{bytes.length}")
        
        # Read init_ack chunk header
        init_tag, a_rwnd, o_streams, i_streams, init_tsn = bytes.unpack('NNnnN')
        
        # Create init chunk
        init_ack           = InitAck.new
        init_ack.flags     = flags
        init_ack.size      = size
        init_ack.init_tag  = init_tag
        init_ack.a_rwnd    = a_rwnd
        init_ack.o_streams = o_streams
        init_ack.i_streams = i_streams
        init_ack.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_ack << parameter
        end
        
        # Return the result
        return init_ack
    end

    def to_s
        return "init_ack(%d, %d, %d, %d, %d, %d, %s)" % [@size,
                                                         @init_tag,
                                                         @a_rwnd,
                                                         @o_streams,
                                                         @i_streams,
                                                         @init_tsn,
                                                         @payload.join(", ")]
    end
end # class InitAck

end # class Chunk
end # class SCTP
end # class Pcap
end # module Mu

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
DIY-pcap-0.4.1 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.3.8 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.3.6 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.3.5 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.3.4 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.3.3 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.3.2 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.3.1 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.3.0 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.2.8 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.2.7 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
DIY-pcap-0.2.6 lib/diy/parser/mu/pcap/sctp/chunk/init_ack.rb
pcapr-local-0.2.0 lib/mu/pcap/sctp/chunk/init_ack.rb
pcapr-local-0.1.13 lib/mu/pcap/sctp/chunk/init_ack.rb
pcapr-local-0.1.12 lib/mu/pcap/sctp/chunk/init_ack.rb
pcapr-local-0.1.11 lib/mu/pcap/sctp/chunk/init_ack.rb
pcapr-local-0.1.10 lib/mu/pcap/sctp/chunk/init_ack.rb