| Class | PacketFu::IPHeader |
| In: |
lib/packetfu/ip.rb
|
| Parent: | Struct.new(:ip_v, :ip_hl, :ip_tos, :ip_len, :ip_id, :ip_frag, :ip_ttl, :ip_proto, :ip_sum, :ip_src, :ip_dst, :body) |
IPHeader is a complete IP struct, used in IPPacket. Most traffic on most networks today is IP-based.
For more on IP packets, see www.networksorcery.com/enp/protocol/ip.htm
Fixnum (4 bits) :ip_v, Default: 4 Fixnum (4 bits) :ip_hl, Default: 5 Int8 :ip_tos, Default: 0 # TODO: Break out the bits Int16 :ip_len, Default: calculated Int16 :ip_id, Default: calculated # IRL, hardly random. Int16 :ip_frag, Default: 0 # TODO: Break out the bits Int8 :ip_ttl, Default: 0xff # Changes per flavor Int8 :ip_proto, Default: 0x01 # TCP: 0x06, UDP 0x11, ICMP 0x01 Int16 :ip_sum, Default: calculated Octets :ip_src Octets :ip_dst String :body
Note that IPPackets will always be somewhat incorrect upon initalization, and want an IPHeader#recalc() to become correct before a Packet#to_f or Packet#to_w.
Calculate the true checksum of the packet. (Yes, this is the long way to do it, but it‘s e-z-2-read for mathtards like me.)