Class: Mu::Pcap::SCTP::Chunk::InitAck

Inherits:
Init show all
Defined in:
lib/mu/pcap/sctp/chunk/init_ack.rb

Constant Summary

Constants inherited from Packet

Packet::IGNORE_UDP_PORTS

Instance Attribute Summary

Attributes inherited from Init

#a_rwnd, #i_streams, #init_tag, #init_tsn, #o_streams

Attributes inherited from Mu::Pcap::SCTP::Chunk

#flags, #size, #type

Attributes inherited from Packet

#payload, #payload_raw

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Init

#<<, #write

Methods inherited from Mu::Pcap::SCTP::Chunk

dummy_chunk, #padded_size, #write

Methods inherited from Packet

#==, #deepdup, #flow_id, isolate_l7, normalize, #payload_bytes, #to_bytes

Constructor Details

#initializeInitAck

Returns a new instance of InitAck.



11
12
13
14
15
# File 'lib/mu/pcap/sctp/chunk/init_ack.rb', line 11

def initialize
    super
    
    @type = CHUNK_INIT_ACK
end

Class Method Details

.from_bytes(flags, size, bytes) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mu/pcap/sctp/chunk/init_ack.rb', line 17

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

Instance Method Details

#to_sObject



54
55
56
57
58
59
60
61
62
# File 'lib/mu/pcap/sctp/chunk/init_ack.rb', line 54

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