Class: Scriptroute::IP

Inherits:
Object
  • Object
show all
Defined in:
lib/scriptroute/packets.rb

Overview

as strings to hand off to the interpreter.

Direct Known Subclasses

IPv4, IPv6

Constant Summary collapse

IPPROTO_TCP =

apply to both 4 and 6.

6
IPPROTO_UDP =
17

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.creator(str) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/scriptroute/packets.rb', line 11

def IP.creator(str) 
  ip_vhl = str.unpack("c")[0]
  ip_v = ((ip_vhl & 0xf0) >> 4)
  if(ip_v == 4) then
    IPv4.creator(str)
  elsif(ip_v == 6) then
    IPv6.creator(str)
  else
    raise "unknown IP version #%d in %s" % [ ip_v, str.unpack("C*").map { |c| "%x" % c }.join(' ') ]
  end
end

Instance Method Details

#to_bytesObject



8
9
10
# File 'lib/scriptroute/packets.rb', line 8

def to_bytes 
  marshal
end