Class: PacketGen::Header::IPv6::Options
- Inherits:
-
BinStruct::Array
- Object
- BinStruct::Array
- PacketGen::Header::IPv6::Options
- Defined in:
- lib/packetgen/header/ipv6/hop_by_hop.rb
Overview
Instance Method Summary collapse
-
#to_s ⇒ String
Get options as a binary string.
Instance Method Details
#to_s ⇒ String
Get options as a binary string. Add padding if needed.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/packetgen/header/ipv6/hop_by_hop.rb', line 64 def to_s str = super case (str.size + 2) % 8 when 0 return str when 7 # only on byte needed: use pad1 option self << Pad1.new str << [0].pack('C') else # use padn option len = 8 - 2 - (str.size % 8) - 2 padn = Option.new(type: 'padn', value: "\x00" * len) self << padn str << padn.to_s end str end |