[Gd-chatter] r11693 - trunk/libraries/protocols

hannes at gwydiondylan.org hannes at gwydiondylan.org
Sat Feb 23 22:09:17 CET 2008


Author: hannes
Date: Sat Feb 23 22:09:16 2008
New Revision: 11693

Added:
   trunk/libraries/protocols/socks.dylan   (contents, props changed)
Modified:
   trunk/libraries/protocols/pppoe.dylan
   trunk/libraries/protocols/protocols-library.dylan
   trunk/libraries/protocols/protocols.hdp
Log:
Job: 7299
implement socks (4, 4a, 5) packet format
  - not yet finished for prime time
remove "use udp" from bittorrent, there's no udp module yet!


Modified: trunk/libraries/protocols/pppoe.dylan
==============================================================================
--- trunk/libraries/protocols/pppoe.dylan	(original)
+++ trunk/libraries/protocols/pppoe.dylan	Sat Feb 23 22:09:16 2008
@@ -2,7 +2,6 @@
 Author: Hannes Mehnert
 Copyright: (C) 2008,  All rights reserved. Free for non-commercial use.
 
-
 define protocol pppoe-session (header-frame)
   over <ethernet-frame> #x8864;
   field pppoe-version :: <4bit-unsigned-integer> = 1;
@@ -47,7 +46,8 @@
 
 define protocol pppoe-service-name (pppoe-tag)
   over <pppoe-tag> #x0101;
-  field service-name :: <externally-delimited-string> = $empty-externally-delimited-string;
+  field service-name :: <externally-delimited-string>
+    = $empty-externally-delimited-string;
 end;
 
 define protocol pppoe-access-contentrator-name (pppoe-tag)

Modified: trunk/libraries/protocols/protocols-library.dylan
==============================================================================
--- trunk/libraries/protocols/protocols-library.dylan	(original)
+++ trunk/libraries/protocols/protocols-library.dylan	Sat Feb 23 22:09:16 2008
@@ -22,7 +22,8 @@
     ppp,
     pppoe,
     bittorrent,
-    hdlc;
+    hdlc,
+    socks;
 end;
 
 define module logical-link
@@ -322,7 +323,6 @@
   use common-dylan;
   use packetizer;
   use ipv4;
-  use udp;
 
   export <bittorrent-announce>;
 end;
@@ -336,7 +336,7 @@
   use ethernet, import: { <ethernet-frame>, <mac-address> };
   use logical-link, import: { <link-control> };
 
-  export <ipv6-frame>;
+  export <ipv6-frame>, <ipv6-address>, ipv6-address;
 end;
 
 define module tcp
@@ -554,3 +554,11 @@
   use ipv4, import: { ipv4-address, <ipv4-address>, <udp-frame> };
   use pcap, import: { <unix-time-value>, make-unix-time };
 end;
+
+define module socks
+  use dylan;
+  use packetizer;
+  use ipv4, import: { <ipv4-address> };
+  use ipv6, import: { <ipv6-address> };
+  use dns, import: { <domain-name> };
+end;
\ No newline at end of file

Modified: trunk/libraries/protocols/protocols.hdp
==============================================================================
--- trunk/libraries/protocols/protocols.hdp	(original)
+++ trunk/libraries/protocols/protocols.hdp	Sat Feb 23 22:09:16 2008
@@ -19,3 +19,4 @@
 	cidr
 	hsrp
 	ntp
+	socks
\ No newline at end of file

Added: trunk/libraries/protocols/socks.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/protocols/socks.dylan	Sat Feb 23 22:09:16 2008
@@ -0,0 +1,138 @@
+module: socks
+author: Hannes Mehnert
+
+//rfc1928
+define protocol socks5-version/method-selection (container-frame)
+  field version-number :: <unsigned-byte> = 5;
+  field number-methods :: <unsigned-byte>,
+    fixup: frame.methods.size;
+  repeated field methods :: <unsigned-byte>,
+    count: frame.number-methods;
+end;
+
+define protocol socks5-version-selection (container-frame)
+  field version-number :: <unsigned-byte> = 5;
+  field method-to-use :: <unsigned-byte>;
+end;
+
+/*
+current methods:
+o  X'00' NO AUTHENTICATION REQUIRED
+o  X'01' GSSAPI
+o  X'02' USERNAME/PASSWORD
+o  X'03' to X'7F' IANA ASSIGNED
+o  X'80' to X'FE' RESERVED FOR PRIVATE METHODS
+o  X'FF' NO ACCEPTABLE METHODS
+*/
+
+define protocol socks5-request (container-frame)
+  field version-number :: <unsigned-byte> = 5;
+  enum field command :: <unsigned-byte> = 0,
+    mappings: { 1 <=> #"connect",
+                2 <=> #"bind",
+                3 <=> #"udp associate" };
+  field reserved :: <unsigned-byte> = 0;
+  enum field address-type :: <unsigned-byte>,
+    mappings: { 1 <=> #"ipv4 address",
+                3 <=> #"domainname",
+                4 <=> #"ipv6 address" };
+  variably-typed-field bind-address, type-function:
+    if (frame.address-type == #"ipv4 address")
+      <ipv4-address>
+    elseif (frame.address-type == #"domainname")
+      <domain-name>
+    elseif (frame.address-type == #"ipv6 address")
+      <ipv6-address>
+    end;
+  field bind-port :: <2byte-big-endian-unsigned-integer>;
+end;
+
+
+define protocol socks5-reply (container-frame)
+  field version-number :: <unsigned-byte> = 5;
+  enum field reply-field :: <unsigned-byte> = 0,
+    mappings: { 0 <=> #"succeeded",
+                1 <=> #"general SOCKS server failure",
+                2 <=> #"connection not allowed by ruleset",
+                3 <=> #"Network unreachable",
+                4 <=> #"Host unreachable",
+                5 <=> #"Connection refused",
+                6 <=> #"TTL expired",
+                7 <=> #"Command not supported",
+                8 <=> #" Address type not supported" };
+  field reserved :: <unsigned-byte> = 0;
+  enum field address-type :: <unsigned-byte>,
+    mappings: { 1 <=> #"ipv4 address",
+                3 <=> #"domainname",
+                4 <=> #"ipv6 address" };
+  variably-typed-field bind-address, type-function:
+    if (frame.address-type == #"ipv4 address")
+      <ipv4-address>
+    elseif (frame.address-type == #"domainname")
+      <domain-name>
+    elseif (frame.address-type == #"ipv6 address")
+      <ipv6-address>
+    end;
+  field bind-port :: <2byte-big-endian-unsigned-integer>;
+end;
+
+define protocol socks5-udp-associate (container-frame)
+  field reserved :: <2byte-big-endian-unsigned-integer> = 0;
+  field fragment-number :: <unsigned-byte> = 0;
+  enum field address-type :: <unsigned-byte>,
+    mappings: { 1 <=> #"ipv4 address",
+                3 <=> #"domainname",
+                4 <=> #"ipv6 address" };
+  variably-typed-field destination-address, type-function:
+    if (frame.address-type == #"ipv4 address")
+      <ipv4-address>
+    elseif (frame.address-type == #"domainname")
+      <domain-name>
+    elseif (frame.address-type == #"ipv6 address")
+      <ipv6-address>
+    end;
+  field destination-port :: <2byte-big-endian-unsigned-integer>;
+  field user-data :: <raw-frame>;
+end;
+
+define protocol null-terminated-string (container-frame)
+  repeated field characters :: <unsigned-byte>,
+    reached-end?: frame == 0;
+end;
+
+define protocol socks4-connection-request (container-frame)
+  field version-number :: <unsigned-byte> = 4;
+  enum field command-code :: <unsigned-byte> = 1,
+    mappings: { 1 <=> #"TCP/IP stream connection",
+                2 <=> #"TCP/IP port binding" };
+  field port-number :: <2byte-big-endian-unsigned-integer> = 0;
+  field ip-address :: <ipv4-address>;
+  field user-id :: <null-terminated-string>;
+end;
+
+define protocol socks4-response (container-frame)
+  field null-byte :: <unsigned-byte> = 0;
+  enum field status :: <unsigned-byte>,
+    mappings: { #x5a <=> #"request granted",
+                #x5b <=> #"request rejected or failed",
+                #x5c <=> #"request failed, client has no identd",
+                #x5d <=> #"request failed, clients identd no confirmation" };
+  field arbitrary-bytes-1 :: <2byte-big-endian-unsigned-integer> = 0;
+  field arbitrary-bytes-2 :: <big-endian-unsigned-integer-4byte>;
+end;
+
+define protocol socks4a-connection-request (socks4-connection-request)
+  field domain-name :: <null-terminated-string>;
+end;
+
+define protocol socks4a-response (container-frame)
+  field null-byte :: <unsigned-byte> = 0;
+  enum field status :: <unsigned-byte>,
+    mappings: { #x5a <=> #"request granted",
+                #x5b <=> #"request rejected or failed",
+                #x5c <=> #"request failed, client has no identd",
+                #x5d <=> #"request failed, clients identd no confirmation" };
+  field port-number :: <2byte-big-endian-unsigned-integer> = 0;
+  field ip-address :: <ipv4-address>;
+end;
+



More information about the chatter mailing list