diff --git a/lib/racket.rb b/lib/racket.rb index 8f956f9ca9..cac43240d8 100644 --- a/lib/racket.rb +++ b/lib/racket.rb @@ -1 +1,4 @@ +module Racket +end + require 'racket/racket' diff --git a/lib/racket/l2/eightotwodotthree.rb b/lib/racket/l2/eightotwodotthree.rb index d424b7b415..920b874603 100644 --- a/lib/racket/l2/eightotwodotthree.rb +++ b/lib/racket/l2/eightotwodotthree.rb @@ -26,6 +26,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # 802.3 Ethernet. Should always be followed by an LLC header +module Racket class EightOTwoDotThree < RacketPart # Destination MAC address hex_octets :dst_mac, 48 @@ -41,4 +42,5 @@ class EightOTwoDotThree < RacketPart self.length = self.payload.length end end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l2/ethernet.rb b/lib/racket/l2/ethernet.rb index facbaf6b69..9df2540fad 100644 --- a/lib/racket/l2/ethernet.rb +++ b/lib/racket/l2/ethernet.rb @@ -28,6 +28,7 @@ # Ethernet II (DIX v2.0) # # http://en.wikipedia.org/wiki/Ethernet_II_framing +module Racket class Ethernet < RacketPart ETHERTYPE_IPV4 = 0x0800 ETHERTYPE_ARP = 0x0806 @@ -55,4 +56,5 @@ class Ethernet < RacketPart # Payload rest :payload end +end #set ts=2 et sw=2: vim diff --git a/lib/racket/l2/llc.rb b/lib/racket/l2/llc.rb index b4cc5272d3..06e8982815 100644 --- a/lib/racket/l2/llc.rb +++ b/lib/racket/l2/llc.rb @@ -26,6 +26,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Logical Link Control (http://en.wikipedia.org/wiki/Logical_Link_Control) +module Racket class LLC < RacketPart LLC_IBM_SNA = 0x04 LLC_IP = 0x06 @@ -43,4 +44,5 @@ class LLC < RacketPart # Payload rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l2/snap.rb b/lib/racket/l2/snap.rb index 54871de35b..4eecf175be 100644 --- a/lib/racket/l2/snap.rb +++ b/lib/racket/l2/snap.rb @@ -26,6 +26,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Subnetwork Access Protocl (http://en.wikipedia.org/wiki/Subnetwork_Access_Protocol) +module Racket class SNAP < RacketPart # Organizational code unsigned :org, 24, { :default => 0x00000c } @@ -33,4 +34,5 @@ class SNAP < RacketPart unsigned :pid, 16 rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l2/vlan.rb b/lib/racket/l2/vlan.rb index f908a2e021..73a2c02576 100644 --- a/lib/racket/l2/vlan.rb +++ b/lib/racket/l2/vlan.rb @@ -26,6 +26,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # IEEE 802.1Q VLAN tag (http://en.wikipedia.org/wiki/IEEE_802.1Q) +module Racket class VLAN < RacketPart ETHERTYPE_IPV4 = 0x0800 ETHERTYPE_ARP = 0x0806 @@ -52,4 +53,5 @@ class VLAN < RacketPart unsigned :type, 16, { :default => ETHERTYPE_IPV4 } rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l3/arp.rb b/lib/racket/l3/arp.rb index e080cb05e6..c5c309719b 100644 --- a/lib/racket/l3/arp.rb +++ b/lib/racket/l3/arp.rb @@ -28,6 +28,7 @@ # Address Resolution Protocol: ARP # # RFC826 (http://www.faqs.org/rfcs/rfc826.html) +module Racket class ARP < RacketPart ARPOP_REQUEST = 0x0001 ARPOP_REPLY = 0x0002 @@ -57,4 +58,5 @@ class ARP < RacketPart # Payload rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l3/cdp.rb b/lib/racket/l3/cdp.rb index 960cd77130..328c039da9 100644 --- a/lib/racket/l3/cdp.rb +++ b/lib/racket/l3/cdp.rb @@ -27,6 +27,7 @@ # # CDP -- Cisco Discovery Protocol # http://www.cisco.biz/univercd/cc/td/doc/product/lan/trsrb/frames.htm#xtocid12 +module Racket class CDP < RacketPart # CDP Version (generally 1) unsigned :version, 8, { :default => 1 } @@ -72,5 +73,6 @@ private L3::Misc.checksum(pseudo.pack("nna*")) end# }}} +end end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l3/ipv4.rb b/lib/racket/l3/ipv4.rb index 33fe97e4d8..8e02a23801 100644 --- a/lib/racket/l3/ipv4.rb +++ b/lib/racket/l3/ipv4.rb @@ -28,6 +28,7 @@ # Internet Protcol Version 4 (IPV4) # # RFC791 (http://www.ietf.org/rfc/rfc791.txt) +module Racket class IPv4 < RacketPart # Version (defaults to 4) unsigned :version, 4, { :default => 4 } @@ -123,4 +124,5 @@ private L3::Misc.checksum(pseudo.pack("nnnnnnNN")) end end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l3/ipv6.rb b/lib/racket/l3/ipv6.rb index a8f207706c..243478fae6 100644 --- a/lib/racket/l3/ipv6.rb +++ b/lib/racket/l3/ipv6.rb @@ -28,6 +28,7 @@ # Internet Protocol Version 6 (IPV6) # RFC2460 # XXX: not tested, incomplete. +module Racket class IPv6 < RacketPart # IP Version (defaults to 6) unsigned :version, 4, { :default => 6 } @@ -48,4 +49,5 @@ class IPv6 < RacketPart # Payload rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l3/misc.rb b/lib/racket/l3/misc.rb index 21e8d07394..e31f0d626b 100644 --- a/lib/racket/l3/misc.rb +++ b/lib/racket/l3/misc.rb @@ -25,6 +25,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +module Racket module L3 module Misc # given an IPv4 address packed as an integer @@ -72,4 +73,5 @@ module L3 end end end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l3/stp.rb b/lib/racket/l3/stp.rb index c89b562593..65b2d49486 100644 --- a/lib/racket/l3/stp.rb +++ b/lib/racket/l3/stp.rb @@ -28,6 +28,7 @@ # Spanning Tree Protocol # # http://en.wikipedia.org/wiki/Spanning_tree_protocol +module Racket class STP < RacketPart # Protocol identifier unsigned :protocol, 16, { :default => 0 } @@ -74,4 +75,5 @@ class STP < RacketPart # Payload rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l4/gre.rb b/lib/racket/l4/gre.rb index cce9c06cae..d57fbd69ac 100644 --- a/lib/racket/l4/gre.rb +++ b/lib/racket/l4/gre.rb @@ -26,6 +26,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # XXX: currently broken. all of the "optional" fields must be made dynamic +module Racket class GRE < RacketPart # Is a checksum present? unsigned :checksum_present, 1 @@ -58,4 +59,5 @@ class GRE < RacketPart # Payload rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l4/icmp.rb b/lib/racket/l4/icmp.rb index 93ab50316b..2356403ad6 100644 --- a/lib/racket/l4/icmp.rb +++ b/lib/racket/l4/icmp.rb @@ -28,6 +28,7 @@ # Internet Control Message Protcol. # # RFC792 (http://www.faqs.org/rfcs/rfc792.html) +module Racket class ICMP < RacketPart ICMP_TYPE_ECHO_REPLY = 0 ICMP_TYPE_DESTINATION_UNREACHABLE = 3 @@ -81,5 +82,5 @@ private L3::Misc.checksum(pseudo.pack("CCnnna*")) end end - +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l4/igmpv1.rb b/lib/racket/l4/igmpv1.rb index 764441a08c..eccf5ffa45 100644 --- a/lib/racket/l4/igmpv1.rb +++ b/lib/racket/l4/igmpv1.rb @@ -29,6 +29,7 @@ # # RFC1112 (http://www.faqs.org/rfcs/rfc1112.html) # +module Racket class IGMPv1 < RacketPart # Version (defaults to 1) unsigned :version, 4 @@ -72,4 +73,5 @@ private L3::Misc.checksum(tmp.pack("nnNa*")) end end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l4/igmpv2.rb b/lib/racket/l4/igmpv2.rb index d53d6e4df6..a5d0b1a5dd 100644 --- a/lib/racket/l4/igmpv2.rb +++ b/lib/racket/l4/igmpv2.rb @@ -28,6 +28,7 @@ # Internet Group Management Protocol, Version 2: IGMPv2 # # RFC2236 (http://www.faqs.org/rfcs/rfc2236.html) +module Racket class IGMPv2 < RacketPart # Type unsigned :type, 8 @@ -69,4 +70,5 @@ private L3::Misc.checksum(tmp.pack("nnNa*")) end end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l4/igrp.rb b/lib/racket/l4/igrp.rb index d67c532de5..13f2885920 100644 --- a/lib/racket/l4/igrp.rb +++ b/lib/racket/l4/igrp.rb @@ -37,6 +37,7 @@ # uchar reliability; /* percent packets successfully tx/rx */ # uchar load; /* percent of channel occupied */ # uchar hopcount; /* hop count */ +module Racket class IGRP < RacketPart IGRP_UPDATE = 1 IGRP_REQUEST = 2 @@ -130,6 +131,6 @@ private L3::Misc.checksum(tmp.pack("Cnnnnnna*")) end end - +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l4/tcp.rb b/lib/racket/l4/tcp.rb index 9bf8cb7de2..3692e649f4 100644 --- a/lib/racket/l4/tcp.rb +++ b/lib/racket/l4/tcp.rb @@ -28,6 +28,7 @@ # Transmission Control Protocol: TCP # # RFC793 (http://www.faqs.org/rfcs/rfc793.html) +module Racket class TCP < RacketPart # Source port unsigned :src_port, 16 @@ -103,7 +104,6 @@ class TCP < RacketPart self.payload = newpayload + self.payload + next_payload self.offset = self.class.bit_length/32 + newpayload.length/4 self.checksum!(ip_src, ip_dst) - self.payload = newpayload end def initialize(*args) @@ -134,4 +134,5 @@ private L3::Misc.checksum((pseudo << header).flatten.pack("NNnnnnNNnnnna*")) end end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l4/udp.rb b/lib/racket/l4/udp.rb index 518372bfa4..18b314c642 100644 --- a/lib/racket/l4/udp.rb +++ b/lib/racket/l4/udp.rb @@ -28,6 +28,7 @@ # User Datagram Protocol: UDP # # RFC768 (http://www.faqs.org/rfcs/rfc768.html) +module Racket class UDP < RacketPart # Source Port unsigned :src_port, 16 @@ -73,5 +74,6 @@ private L3::Misc.checksum((pseudo << header).flatten.pack("NNnnnnnna*")) end +end end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l5/bootp.rb b/lib/racket/l5/bootp.rb index 8160800c4d..c8fd3a798a 100644 --- a/lib/racket/l5/bootp.rb +++ b/lib/racket/l5/bootp.rb @@ -28,6 +28,7 @@ # Bootstrap Protocol -- BOOTP # # RFC951 (http://www.faqs.org/rfcs/rfc951.html) +module Racket class BOOTP < RacketPart BOOTP_REQUEST = 1 BOOTP_REPLY = 2 @@ -98,5 +99,6 @@ class BOOTP < RacketPart @autofix = false end +end end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l5/dns.rb b/lib/racket/l5/dns.rb index 682f972972..ca433ba38e 100644 --- a/lib/racket/l5/dns.rb +++ b/lib/racket/l5/dns.rb @@ -26,6 +26,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Domain Name System +module Racket class DNS < RacketPart # Transaction ID unsigned :tx_id, 16 @@ -102,5 +103,6 @@ private q end +end end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l5/hsrp.rb b/lib/racket/l5/hsrp.rb index 955e56e5e5..7dba7e91be 100644 --- a/lib/racket/l5/hsrp.rb +++ b/lib/racket/l5/hsrp.rb @@ -28,6 +28,7 @@ # Hot Standby Router Protocol: HSRP # # RFC2281 (http://www.faqs.org/rfcs/rfc2281.html) +module Racket class HSRP < RacketPart HSRP_HELLO = 0 HSRP_COUP = 1 @@ -65,4 +66,5 @@ class HSRP < RacketPart # Payload. Generally unused. rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/l5/ntp.rb b/lib/racket/l5/ntp.rb index ecac708372..ececcf76a1 100644 --- a/lib/racket/l5/ntp.rb +++ b/lib/racket/l5/ntp.rb @@ -25,6 +25,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +module Racket class NTP < RacketPart # Leap Indicator unsigned :leap, 2 @@ -50,5 +51,6 @@ class NTP < RacketPart unsigned :tr_ts, 64 rest :payload end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/misc.rb b/lib/racket/misc.rb index 3457b34fca..ebfe3567f9 100644 --- a/lib/racket/misc.rb +++ b/lib/racket/misc.rb @@ -25,6 +25,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +module Racket module Misc # Return a number that is at most size bits long def Misc.randbits(size) @@ -63,5 +64,6 @@ module Misc end +end end # vim: set ts=2 et sw=2: diff --git a/lib/racket/orderedhash.rb b/lib/racket/orderedhash.rb index 106d4eeaa4..6776f6e87c 100644 --- a/lib/racket/orderedhash.rb +++ b/lib/racket/orderedhash.rb @@ -29,6 +29,7 @@ # # XXX: todo -- add a method for moving/shifting # members around +module Racket class OrderedHash < Hash def initialize @keys = [] @@ -56,5 +57,5 @@ class OrderedHash < Hash @keys.each { |k| yield self[k] } end end - +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/racket.rb b/lib/racket/racket.rb index 812c616cce..ef22a33bd7 100644 --- a/lib/racket/racket.rb +++ b/lib/racket/racket.rb @@ -29,6 +29,9 @@ require 'socket' require 'pcaprub' + + + require 'racket/racketpart' require 'racket/tlv' require 'racket/lv' @@ -39,6 +42,8 @@ require 'racket/l3' require 'racket/l4' require 'racket/l5' + +module Racket class Racket attr_accessor :iface, :mtu, :timeout @@ -146,4 +151,6 @@ class Racket end end +end + # vim: set ts=2 et sw=2: diff --git a/lib/racket/racketpart.rb b/lib/racket/racketpart.rb index 471b84c82d..2b8b2eceda 100644 --- a/lib/racket/racketpart.rb +++ b/lib/racket/racketpart.rb @@ -26,6 +26,8 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # require 'bit-struct' + +module Racket class RacketPart < BitStruct # Boolean indicating whether or not this instance should be @@ -57,4 +59,5 @@ class RacketPart < BitStruct def fix! end end +end # vim: set ts=2 et sw=2: diff --git a/lib/racket/tlv.rb b/lib/racket/tlv.rb index 28ef96b9cd..1c14ff0e95 100644 --- a/lib/racket/tlv.rb +++ b/lib/racket/tlv.rb @@ -27,6 +27,7 @@ # # Simple class for your average type, length, value datastructure. # Everything after the TLV is stuff into +rest+ +module Racket class TLV attr_accessor :type, :length, :value, :rest @@ -83,5 +84,6 @@ private end +end end # vim: set ts=2 et sw=2: diff --git a/lib/racket/vt.rb b/lib/racket/vt.rb index 5c198500bb..b7b0bc5825 100644 --- a/lib/racket/vt.rb +++ b/lib/racket/vt.rb @@ -53,6 +53,8 @@ # Simple class to represent a datastructure that is made up of a # null terminted string followed by an arbitrary number of # arbitrarily sized values, followed by a "rest" field. + +module Racket class VT # the value for this VT object attr_accessor :value @@ -132,5 +134,6 @@ private s end +end end # vim: set ts=2 et sw=2: