Class: PacketGen::Header::SCTP::InitChunk

Inherits:
BaseChunk
  • Object
show all
Defined in:
lib/packetgen/header/sctp/chunk.rb

Overview

Init Chunk. This chunk is used to initiate an SCTP association. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 1 | Chunk Flags | Chunk Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Initiate Tag | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Advertised Receiver Window Credit (a_rwnd) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Number of Outbound Streams | Number of Inbound Streams | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Initial TSN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ \
/ Optional/Variable-Length Parameters / \
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Author:

  • Sylvain Daubert

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin

Direct Known Subclasses

InitAckChunk

Constant Summary

Constants inherited from BaseChunk

BaseChunk::TYPES

Instance Attribute Summary collapse

Attributes inherited from BaseChunk

#length, #type

Instance Method Summary collapse

Methods inherited from BaseChunk

#human_type

Methods included from Padded32

#padded?, #to_s

Methods inherited from Base

bind, calculate_and_set_length, #header_id, inherited, #ip_header, #ll_header

Methods included from PacketGen::Headerable

#added_to_packet, included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read, #to_s

Constructor Details

#initialize(options = {}) ⇒ InitChunk

Returns a new instance of InitChunk.

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin



238
239
240
241
# File 'lib/packetgen/header/sctp/chunk.rb', line 238

def initialize(options={})
  options[:type] = BaseChunk::TYPES['INIT'] unless options.key?(:type)
  super
end

Instance Attribute Details

#a_wrnd ⇒ Integer

32-bit Advertised Receiver Window Credit (a_rwnd)

Returns:

  • (Integer)


220
# File 'lib/packetgen/header/sctp/chunk.rb', line 220

define_attr :a_rwnd, BinStruct::Int32

#initial_tsn ⇒ Integer

32-bit Initial TSN

Returns:

  • (Integer)


232
# File 'lib/packetgen/header/sctp/chunk.rb', line 232

define_attr :initial_tsn, BinStruct::Int32

#initiate_tag ⇒ Integer

32-bit Initiate Tag

Returns:

  • (Integer)


216
# File 'lib/packetgen/header/sctp/chunk.rb', line 216

define_attr :initiate_tag, BinStruct::Int32

#nis ⇒ Integer

16-bit Number of Inbound Streams

Returns:

  • (Integer)


228
# File 'lib/packetgen/header/sctp/chunk.rb', line 228

define_attr :nis, BinStruct::Int16

#nos ⇒ Integer

16-bit Number of Outbound Streams

Returns:

  • (Integer)


224
# File 'lib/packetgen/header/sctp/chunk.rb', line 224

define_attr :nos, BinStruct::Int16

#parameters ⇒ ArrayOfParameter

List of parameters

Returns:



236
# File 'lib/packetgen/header/sctp/chunk.rb', line 236

define_attr :parameters, ArrayOfParameter

Instance Method Details

#calc_length ⇒ Integer

Calculate lengths, including parameters ones.

Returns:

  • (Integer) —

    chunk length

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin



245
246
247
248
# File 'lib/packetgen/header/sctp/chunk.rb', line 245

def calc_length
  parameters.each(&:calc_length)
  super
end

#to_human ⇒ String

Get human-redable description.

Returns:

  • (String)

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin



252
253
254
255
256
257
258
# File 'lib/packetgen/header/sctp/chunk.rb', line 252

def to_human
  str = "<chunk:#{human_type}"
  flags_str = flags_to_human
  str << ",flags:#{flags_str}" unless flags_str.empty?
  str << ",param:#{parameters.map(&:to_human).join(',')}" unless parameters.empty?
  str << '>'
end