lib/packetgen/header/ip/options.rb in packetgen-2.8.7 vs lib/packetgen/header/ip/options.rb in packetgen-3.0.0

- old
+ new

@@ -13,41 +13,28 @@ class Options < Types::Array set_of Option HUMAN_SEPARATOR = ';' - # Read IP header options from a string - # @param [String] str binary string - # @return [self] - def read(str) - clear - return self if str.nil? - PacketGen.force_binary str - - i = 0 - types = Option.types - while i < str.to_s.length - type = str[i, 1].unpack('C').first - this_option = if types[type].nil? - Option.new - else - types[type].new - end - this_option.read str[i, str.size] - self << this_option - i += this_option.sz - end - self - end - # Get binary string # @return [String] def to_s str = super if str.length % 4 != 0 str += ([0] * (4 - (str.length % 4))).pack('C*') end str + end + + private + + def record_from_hash(hsh) + Option.build(hsh) + end + + def real_type(opt) + types = Option.types + types.value?(opt.type) ? IP.const_get(types.key(opt.type)) : opt.class end end end end end