Module: PacketFu::IPHeaderMixin

Included in:
HSRPPacket, ICMPPacket, IPPacket, TCPPacket, UDPPacket
Defined in:
lib/packetfu/protos/ip/mixin.rb

Overview

This Mixin simplifies access to the IPHeaders. Mix this in with your packet interface, and it will add methods that essentially delegate to the ‘ip_header’ method (assuming that it is a IPHeader object)

Instance Method Summary collapse

Instance Method Details

#ip_calc_idObject



8
# File 'lib/packetfu/protos/ip/mixin.rb', line 8

def ip_calc_id; self.ip_header.ip_calc_id ; end

#ip_calc_lenObject



9
# File 'lib/packetfu/protos/ip/mixin.rb', line 9

def ip_calc_len; self.ip_header.ip_calc_len ; end

#ip_calc_sumObject



10
# File 'lib/packetfu/protos/ip/mixin.rb', line 10

def ip_calc_sum; self.ip_header.ip_calc_sum ; end

#ip_calc_sum_on_addr(cksum = 0) ⇒ Object

Add method to each packet class on IP to ease checksum computation



45
46
47
48
49
50
51
# File 'lib/packetfu/protos/ip/mixin.rb', line 45

def ip_calc_sum_on_addr(cksum=0)
  checksum = cksum
  checksum += (ip_src.to_i >> 16)
  checksum += (ip_src.to_i & 0xffff)
  checksum += (ip_dst.to_i >> 16)
  checksum += (ip_dst.to_i & 0xffff)
end

#ip_daddrObject



11
# File 'lib/packetfu/protos/ip/mixin.rb', line 11

def ip_daddr; self.ip_header.ip_daddr ; end

#ip_daddr=(v) ⇒ Object



12
# File 'lib/packetfu/protos/ip/mixin.rb', line 12

def ip_daddr=(v); self.ip_header.ip_daddr= v; end

#ip_dstObject



13
# File 'lib/packetfu/protos/ip/mixin.rb', line 13

def ip_dst; self.ip_header.ip_dst ; end

#ip_dst=(v) ⇒ Object



14
# File 'lib/packetfu/protos/ip/mixin.rb', line 14

def ip_dst=(v); self.ip_header.ip_dst= v; end

#ip_dst_readableObject



15
# File 'lib/packetfu/protos/ip/mixin.rb', line 15

def ip_dst_readable; self.ip_header.ip_dst_readable ; end

#ip_fragObject



16
# File 'lib/packetfu/protos/ip/mixin.rb', line 16

def ip_frag; self.ip_header.ip_frag ; end

#ip_frag=(v) ⇒ Object



17
# File 'lib/packetfu/protos/ip/mixin.rb', line 17

def ip_frag=(v); self.ip_header.ip_frag= v; end

#ip_hlObject



18
# File 'lib/packetfu/protos/ip/mixin.rb', line 18

def ip_hl; self.ip_header.ip_hl ; end

#ip_hl=(v) ⇒ Object



19
# File 'lib/packetfu/protos/ip/mixin.rb', line 19

def ip_hl=(v); self.ip_header.ip_hl= v; end

#ip_hlenObject



20
# File 'lib/packetfu/protos/ip/mixin.rb', line 20

def ip_hlen; self.ip_header.ip_hlen ; end

#ip_idObject



21
# File 'lib/packetfu/protos/ip/mixin.rb', line 21

def ip_id; self.ip_header.ip_id ; end

#ip_id=(v) ⇒ Object



22
# File 'lib/packetfu/protos/ip/mixin.rb', line 22

def ip_id=(v); self.ip_header.ip_id= v; end

#ip_id_readableObject



23
# File 'lib/packetfu/protos/ip/mixin.rb', line 23

def ip_id_readable; self.ip_header.ip_id_readable ; end

#ip_lenObject



24
# File 'lib/packetfu/protos/ip/mixin.rb', line 24

def ip_len; self.ip_header.ip_len ; end

#ip_len=(v) ⇒ Object



25
# File 'lib/packetfu/protos/ip/mixin.rb', line 25

def ip_len=(v); self.ip_header.ip_len= v; end

#ip_protoObject



26
# File 'lib/packetfu/protos/ip/mixin.rb', line 26

def ip_proto; self.ip_header.ip_proto ; end

#ip_proto=(v) ⇒ Object



27
# File 'lib/packetfu/protos/ip/mixin.rb', line 27

def ip_proto=(v); self.ip_header.ip_proto= v; end

#ip_recalc(*args) ⇒ Object



28
# File 'lib/packetfu/protos/ip/mixin.rb', line 28

def ip_recalc(*args); self.ip_header.ip_recalc(*args) ; end

#ip_saddrObject



29
# File 'lib/packetfu/protos/ip/mixin.rb', line 29

def ip_saddr; self.ip_header.ip_saddr ; end

#ip_saddr=(v) ⇒ Object



30
# File 'lib/packetfu/protos/ip/mixin.rb', line 30

def ip_saddr=(v); self.ip_header.ip_saddr= v; end

#ip_srcObject



31
# File 'lib/packetfu/protos/ip/mixin.rb', line 31

def ip_src; self.ip_header.ip_src ; end

#ip_src=(v) ⇒ Object



32
# File 'lib/packetfu/protos/ip/mixin.rb', line 32

def ip_src=(v); self.ip_header.ip_src= v; end

#ip_src_readableObject



33
# File 'lib/packetfu/protos/ip/mixin.rb', line 33

def ip_src_readable; self.ip_header.ip_src_readable ; end

#ip_sumObject



34
# File 'lib/packetfu/protos/ip/mixin.rb', line 34

def ip_sum; self.ip_header.ip_sum ; end

#ip_sum=(v) ⇒ Object



35
# File 'lib/packetfu/protos/ip/mixin.rb', line 35

def ip_sum=(v); self.ip_header.ip_sum= v; end

#ip_sum_readableObject



36
# File 'lib/packetfu/protos/ip/mixin.rb', line 36

def ip_sum_readable; self.ip_header.ip_sum_readable ; end

#ip_tosObject



37
# File 'lib/packetfu/protos/ip/mixin.rb', line 37

def ip_tos; self.ip_header.ip_tos ; end

#ip_tos=(v) ⇒ Object



38
# File 'lib/packetfu/protos/ip/mixin.rb', line 38

def ip_tos=(v); self.ip_header.ip_tos= v; end

#ip_ttlObject



39
# File 'lib/packetfu/protos/ip/mixin.rb', line 39

def ip_ttl; self.ip_header.ip_ttl ; end

#ip_ttl=(v) ⇒ Object



40
# File 'lib/packetfu/protos/ip/mixin.rb', line 40

def ip_ttl=(v); self.ip_header.ip_ttl= v; end

#ip_vObject



41
# File 'lib/packetfu/protos/ip/mixin.rb', line 41

def ip_v; self.ip_header.ip_v ; end

#ip_v=(v) ⇒ Object



42
# File 'lib/packetfu/protos/ip/mixin.rb', line 42

def ip_v=(v); self.ip_header.ip_v= v; end