Class: PacketGen::Header::SCTP::BaseChunk Abstract
- Inherits:
-
Base
- Object
- Types::Fields
- Base
- PacketGen::Header::SCTP::BaseChunk
- Includes:
- Padded32
- Defined in:
- lib/packetgen/header/sctp/chunk.rb
Overview
Subclass and add more fields
BaseChunk 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
-
#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
Methods inherited from Types::Fields
#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #initialize, #inspect, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
Constructor Details
This class inherits a constructor from PacketGen::Header::Base
Instance Attribute Details
Instance Method Details
#calc_length ⇒ Integer
do not count last parameter padding
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
65 66 67 |
# File 'lib/packetgen/header/sctp/chunk.rb', line 65 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 |