Many of ruby-libtrace's classes have a new method, so you can create a new object; this is most useful for handling encapsulated packets. The new methods take a single argument, which may be an existing object or a string of bytes. In most cases the argument will be something you have unpacked from an incoming package. This allows you to work on encapsulated packets, e.g.
trace.each_packet { |pkt|
trans = pkt.transport
next if trans.proto != 41 # IPv6 over IPv4
ip6 = IP6.new(trans)
... # Process the encapsulated packet
}
| Class Methods | |
| IP.new | IP.new(object or string) -> anIP |
| Makes a new IP (IPv4) object | |
| IP6.new | IP6.new(object or string) -> anIP6 |
| Makes a new IP6 (IPv6) object | |
| TCP.new | TCP.new(object or string) -> aTCP |
| Makes a new TCP object | |
| UDP.new | UDP.new(object or string) -> aUDPP |
| Makes a new UDP object | |
| ICMP.new | ICMP.new(object or string) -> anICMP |
| Makes a new ICMP object | |