Module: PacketGen::Header::SCTP::Padded32
- Included in:
- BaseChunk, ErrorMixin, ParameterMixin
- Defined in:
- lib/packetgen/header/sctp/padded32.rb
Overview
Mixin to handle 32-bit padding in SCTP classes
Instance Method Summary collapse
-
#padded? ⇒ bool
Say if binary string is padded.
-
#to_s(no_padding: false) ⇒ ::String
Handle padding.
Instance Method Details
#padded? ⇒ bool
Say if binary string is padded
27 28 29 30 |
# File 'lib/packetgen/header/sctp/padded32.rb', line 27 def padded? str = to_s(no_padding: true) (str.size % 4).positive? end |
#to_s(no_padding: false) ⇒ ::String
Handle padding
17 18 19 20 21 22 23 |
# File 'lib/packetgen/header/sctp/padded32.rb', line 17 def to_s(no_padding: false) s = super() return s if no_padding padlen = -(s.size % -4) s << force_binary("\x00" * padlen) end |