Force the Racket library to live under the Racket:: namespace, fixes a bug where tcp.payload was overwritten during fix!()

git-svn-id: file:///home/svn/framework3/trunk@6821 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
HD Moore 2009-07-17 18:12:18 +00:00
parent 9db072b2e4
commit ed05516b9f
29 changed files with 66 additions and 4 deletions

View File

@ -1 +1,4 @@
module Racket
end
require 'racket/racket'

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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: