Method: PacketFu::Packet#recalc
- Defined in:
- lib/packetfu/packet.rb
#recalc(arg = :all) ⇒ Object
Recalculates all the calcuated fields for all headers in the packet. This is important since read() wipes out all the calculated fields such as length and checksum and what all.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/packetfu/packet.rb', line 119 def recalc(arg=:all) case arg when :ip ip_recalc(:all) when :ipv6 ipv6_recalc(:all) when :icmp icmp_recalc(:all) when :udp udp_recalc(:all) when :tcp tcp_recalc(:all) when :all ip_recalc(:all) if @ip_header ipv6_recalc(:all) if @ipv6_header icmp_recalc(:all) if @icmp_header udp_recalc(:all) if @udp_header tcp_recalc(:all) if @tcp_header else raise ArgumentError, "Recalculating `#{arg}' unsupported. Try :all" end @headers[0] end |