Class: PacketGen::Header::SCTP::BaseChunk Abstract
- Includes:
- Padded32
- Defined in:
- lib/packetgen/header/sctp/chunk.rb
Overview
Subclass and add more fields
Base SCTP chunk class, defining SCTP chunk common fields.
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Chunk Type | Chunk Flags | Chunk Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Direct Known Subclasses
CookieAckChunk, CookieEchoChunk, DataChunk, ErrorChunk, HeartbeatChunk, InitChunk, SackChunk, ShutdownAckChunk, ShutdownChunk, ShutdownCompleteChunk, UnknownChunk
Constant Summary collapse
- TYPES =
SCTP chunk types, as per RFC9260
{ 'DATA' => 0, 'INIT' => 1, 'INIT_ACK' => 2, 'SACK' => 3, 'HEARTBEAT' => 4, 'HEARTBEAT_ACK' => 5, 'ABORT' => 6, 'SHUTDOWN' => 7, 'SHUTDOWN_ACK' => 8, 'ERROR' => 9, 'COOKIE_ECHO' => 10, 'COOKIE_ACK' => 11, 'SHUTDOWN_COMPLETE' => 14, }.freeze
Instance Attribute Summary collapse
-
#length ⇒ Integer
16-bit SCTP chunk length.
-
#type ⇒ Integer
8-bit SCTP chunk flags.
Instance Method Summary collapse
-
#calc_length ⇒ Integer
Calculate and set chunk #length.
-
#human_type ⇒ ::String, Integer
Get human-readable type.
-
#to_human ⇒ ::String
Get human-redable chunk.
Methods included from Padded32
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #initialize, #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
This class inherits a constructor from PacketGen::Header::Base
Instance Attribute Details
#length ⇒ Integer
16-bit SCTP chunk length
53 |
# File 'lib/packetgen/header/sctp/chunk.rb', line 53 define_attr :length, BinStruct::Int16 |
#type ⇒ Integer
8-bit SCTP chunk flags
45 |
# File 'lib/packetgen/header/sctp/chunk.rb', line 45 define_attr :type, BinStruct::Int8Enum, enum: TYPES |
Instance Method Details
#calc_length ⇒ Integer
Calculate and set chunk #length
72 73 74 |
# File 'lib/packetgen/header/sctp/chunk.rb', line 72 def calc_length self.length = to_s(no_padding: true).size end |
#human_type ⇒ ::String, Integer
Get human-readable type
66 67 68 |
# File 'lib/packetgen/header/sctp/chunk.rb', line 66 def human_type self[:type].to_human end |
#to_human ⇒ ::String
Get human-redable chunk
57 58 59 60 61 62 |
# File 'lib/packetgen/header/sctp/chunk.rb', line 57 def to_human str = "<chunk:#{human_type}" flags_str = flags_to_human str << ",flags:#{flags_str}" unless flags_str.empty? str << '>' end |