Class PacketFu::UDPPacket
In: lib/packetfu/udp.rb
Parent: Packet

UDPPacket is used to construct UDP Packets. They contain an EthHeader, an IPHeader, and a UDPHeader.

Example

  udp_pkt = PacketFu::UDPPacket.new
  udp_pkt.udp_src=rand(0xffff-1024) + 1024
  udp_pkt.udp_dst=53

  udp_pkt.ip_saddr="1.2.3.4"
  udp_pkt.ip_daddr="10.20.30.40"

  udp_pkt.recalc
  udp_pkt.to_f('/tmp/udp.pcap')

Parameters

 :eth
   A pre-generated EthHeader object.
 :ip
   A pre-generated IPHeader object.
 :flavor
   TODO: Sets the "flavor" of the UDP packet. UDP packets don't tend have a lot of
   flavor, but their underlying ip headers do.
 :config
  A hash of return address details, often the output of Utils.whoami?

Methods

new   peek   udp_calc_sum   udp_recalc  

Attributes

eth_header  [RW] 
ip_header  [RW] 
udp_header  [RW] 

Public Class methods

Public Instance methods

Peek provides summary data on packet contents.

udp_calc_sum() computes the UDP checksum, and is called upon intialization. It usually should be called just prior to dropping packets to a file or on the wire.

udp_recalc() recalculates various fields of the UDP packet. Valid arguments are:

  :all
    Recomputes all calculated fields.
  :udp_sum
    Recomputes the UDP checksum.
  :udp_len
    Recomputes the UDP length.

[Validate]