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

hannes at gwydiondylan.org hannes at gwydiondylan.org
Sat Feb 2 07:14:11 CET 2008


Author: hannes
Date: Sat Feb  2 07:14:09 2008
New Revision: 11660

Added:
   trunk/libraries/protocols/ppp.dylan   (contents, props changed)
   trunk/libraries/protocols/pppoe.dylan   (contents, props changed)
Modified:
   trunk/libraries/protocols/ipv4.dylan
   trunk/libraries/protocols/protocols-library.dylan
   trunk/libraries/protocols/protocols.hdp
Log:
Job: 7299

support for pppoe and ppp (ipcp and ccp is missing)


Modified: trunk/libraries/protocols/ipv4.dylan
==============================================================================
--- trunk/libraries/protocols/ipv4.dylan	(original)
+++ trunk/libraries/protocols/ipv4.dylan	Sat Feb  2 07:14:09 2008
@@ -73,9 +73,13 @@
   summary "IP SRC %= DST %=", source-address, destination-address;
   over <ethernet-frame> #x800;
   over <link-control> #x800;
+  over <ppp> #x21;
   field version :: <4bit-unsigned-integer> = 4;
   field header-length :: <4bit-unsigned-integer>,
-    fixup: ceiling/(reduce(\+, 20, map(method(x) byte-offset(frame-size(x)) end, frame.options)), 4);
+    fixup: ceiling/(reduce(\+, 20,
+                           map(compose(byte-offset, frame-size),
+                               frame.options)),
+                    4);
   field type-of-service :: <unsigned-byte> = 0;
   field total-length :: <2byte-big-endian-unsigned-integer>,
     fixup: frame.header-length * 4 + byte-offset(frame-size(frame.payload));

Added: trunk/libraries/protocols/ppp.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/protocols/ppp.dylan	Sat Feb  2 07:14:09 2008
@@ -0,0 +1,246 @@
+module: ppp
+Author: Hannes Mehnert
+Copyright: (C) 2008,  All rights reserved. Free for non-commercial use.
+
+define protocol ppp (header-frame)
+  layering field protocol :: <2byte-big-endian-unsigned-integer>;
+  variably-typed-field payload,
+    type-function: payload-type(frame);
+end;
+
+define abstract protocol link-control-protocol (variably-typed-container-frame)
+  length frame.lcp-length * 8;
+  over <ppp> #xc021;
+  layering field lcp-code :: <unsigned-byte>;
+  field lcp-identifier :: <unsigned-byte>;
+  field lcp-length :: <2byte-big-endian-unsigned-integer>,
+    fixup: byte-offset(frame-size(frame));
+end;
+
+define protocol lcp-configure-request (link-control-protocol)
+  over <link-control-protocol> 1;
+  repeated field configuration-option :: <lcp-option>,
+    reached-end?: #f;
+end;
+
+define protocol lcp-configure-ack (link-control-protocol)
+  over <link-control-protocol> 2;
+  repeated field configuration-option :: <lcp-option>,
+    reached-end?: #f;
+end;
+
+define protocol lcp-configure-nak (link-control-protocol)
+  over <link-control-protocol> 3;
+  repeated field configuration-option :: <lcp-option>,
+    reached-end?: #f;
+end;
+
+define protocol lcp-configure-reject (link-control-protocol)
+  over <link-control-protocol> 4;
+  repeated field configuration-option :: <lcp-option>,
+    reached-end?: #f;
+end;
+
+define protocol lcp-terminate-request (link-control-protocol)
+  over <link-control-protocol> 5;
+  field custom-data :: <raw-frame>;
+end;
+
+define protocol lcp-terminate-ack (link-control-protocol)
+  over <link-control-protocol> 6;
+  field custom-data :: <raw-frame>;
+end;
+
+define protocol lcp-code-reject (link-control-protocol)
+  over <link-control-protocol> 7;
+  field rejected-packet :: <raw-frame>; //? <link-control-protocol>;
+end;
+
+define protocol lcp-protocol-reject (link-control-protocol)
+  over <link-control-protocol> 8;
+  //?field rejected-packet :: <ppp>;
+  field rejected-protocol :: <2byte-big-endian-unsigned-integer>;
+  field rejected-information :: <raw-frame>; //? <link-control-protocol>;
+end;
+
+define protocol lcp-magic-custom (link-control-protocol)
+  field magic-number :: <big-endian-unsigned-integer-4byte>;
+  field custom-data :: <raw-frame>;
+end;
+
+define protocol lcp-echo-request (lcp-magic-custom)
+  over <link-control-protocol> 9;
+end;
+
+define protocol lcp-echo-reply (lcp-magic-custom)
+  over <link-control-protocol> 10;
+end;
+
+define protocol lcp-discard-request (lcp-magic-custom)
+  over <link-control-protocol> 11;
+end;
+
+define protocol lcp-identification (link-control-protocol)
+  over <link-control-protocol> 12;
+  field magic-number :: <big-endian-unsigned-integer-4byte>;
+  field message :: <externally-delimited-string>;
+end;
+
+define protocol lcp-time-remaining (link-control-protocol)
+  over <link-control-protocol> 13;
+  field magic-number :: <big-endian-unsigned-integer-4byte>;
+  field seconds-remaining :: <big-endian-unsigned-integer-4byte>;
+  field message :: <externally-delimited-string>;
+end;
+
+define abstract protocol lcp-option (variably-typed-container-frame)
+  length frame.lcp-option-length * 8;
+  layering field lcp-option-type :: <unsigned-byte>;
+  field lcp-option-length :: <unsigned-byte>,
+    fixup: byte-offset(frame-size(frame));
+end;
+
+define protocol lcp-reserved (lcp-option)
+  over <lcp-option> 0;
+end;
+
+define protocol lcp-maximum-receive-unit (lcp-option)
+  over <lcp-option> 1;
+  field maximum-receive-unit :: <2byte-big-endian-unsigned-integer>;
+end;
+
+define protocol lcp-authentication-protocol (lcp-option)
+  over <lcp-option> 3;
+  enum field authentication-protocol :: <2byte-big-endian-unsigned-integer>,
+    mappings: { #xc023 <=> #"password authentication protocol",
+                #xc223 <=> #"challenge handshake authentication protocol" };
+  field custom-data :: <raw-frame>;
+end;
+
+define protocol lcp-quality-protocol (lcp-option)
+  over <lcp-option> 4;
+  enum field quality-protocol :: <2byte-big-endian-unsigned-integer>,
+    mappings: { #xc025 <=> #"link quality report" };
+  field custom-data :: <raw-frame>;
+end;
+
+define protocol lcp-magic-number-option (lcp-option)
+  over <lcp-option> 5;
+  field lcp-magic-number :: <big-endian-unsigned-integer-4byte>;
+end;
+
+define protocol lcp-protocol-field-compression (lcp-option)
+  over <lcp-option> 7;
+end;
+
+define protocol lcp-address-and-control-field-compression (lcp-option)
+  over <lcp-option> 8;
+end;
+
+define protocol lcp-fcs-alternatives (lcp-option)
+  over <lcp-option> 9;
+  field null-fcs :: <boolean-bit>;
+  field ccitt-16 :: <boolean-bit>;
+  field ccitt-32 :: <boolean-bit>;
+  field reserved :: <5bit-unsigned-integer> = 0;
+end;
+
+define protocol lcp-self-describing-padding (lcp-option)
+  over <lcp-option> 10;
+  field maximum :: <unsigned-byte>;
+end;
+
+define protocol lcp-numbered-mode (lcp-option)
+  over <lcp-option> 11;
+  field window :: <unsigned-byte>;
+  field hdlc-address :: <raw-frame>;
+end;
+
+define protocol lcp-callback (lcp-option)
+  over <lcp-option> 13;
+  enum field operation :: <unsigned-byte>,
+    mappings: { 0 <=> #"location by user authentication",
+                1 <=> #"dialing string",
+                2 <=> #"location identifier",
+                3 <=> #"e.164 number",
+                4 <=> #"distinguished name" };
+  field message :: <raw-frame>;
+end;
+
+define protocol lcp-compound-frames (lcp-option)
+  over <lcp-option> 15;
+end;
+
+
+define abstract protocol pap (variably-typed-container-frame)
+  over <ppp> #xc023;
+  length pap-length * 8;
+  layering field pap-code :: <unsigned-byte>;
+  field pap-identifier :: <unsigned-byte>;
+  field pap-length :: <2byte-big-endian-unsigned-integer>,
+    fixup: byte-offset(frame-size(frame));
+end;
+
+define protocol pap-authenticate-request (pap)
+  over <pap> 1;
+  field peer-id-length :: <unsigned-byte>,
+    fixup: byte-offset(frame-size(frame.peer-id));
+  field peer-id :: <externally-delimited-string>,
+    length: frame.peer-id-length * 8;
+  field password-length :: <unsigned-byte>,
+    fixup: byte-offset(frame-size(frame.password));
+  field password :: <raw-frame>,
+    length: frame.password-length * 8;
+end;
+
+define protocol pap-authenticate-ack (pap)
+  over <pap> 2;
+  field message-length :: <unsigned-byte>,
+    fixup: byte-offset(frame.message);
+  field message :: <externally-delimited-string>,
+    length: field.message-length * 8;
+end;
+
+define protocol pap-authenticate-nak (pap)
+  over <pap> 3;
+  field message-length :: <unsigned-byte>,
+    fixup: byte-offset(frame.message);
+  field message :: <externally-delimited-string>,
+    length: field.message-length * 8;
+end;
+
+define abstract protocol chap (variably-typed-container-frame)
+  over <ppp> #xc223;
+  length frame.chap-length * 8;
+  layering field chap-code :: <unsigned-byte>;
+  field chap-identifier :: <unsigned-byte>;
+  field chap-length :: <2byte-big-endian-unsigned-integer>;
+end;
+
+define protocol chap-challenge (chap)
+  over <chap> 1;
+  field chap-value-size :: <unsigned-byte>,
+    fixup: byte-offset(frame-size(frame.chap-value));
+  field chap-value :: <raw-frame>,
+    length: frame.chap-value-size * 8;
+  field chap-name :: <externally-delimited-string>;
+end;
+
+define protocol chap-response (chap)
+  over <chap> 2;
+  field chap-value-size :: <unsigned-byte>,
+    fixup: byte-offset(frame-size(frame.chap-value));
+  field chap-value :: <raw-frame>,
+    length: frame.chap-value-size * 8;
+  field chap-name :: <externally-delimited-string>;
+end;
+
+define protocol chap-success (chap)
+  over <chap> 3;
+  field chap-message :: <externally-delimited-string>;
+end;
+
+define protocol chap-failure (chap)
+  over <chap> 4;
+  field chap-message :: <externally-delimited-string>;
+end;

Added: trunk/libraries/protocols/pppoe.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/protocols/pppoe.dylan	Sat Feb  2 07:14:09 2008
@@ -0,0 +1,98 @@
+module: pppoe
+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;
+  field pppoe-type :: <4bit-unsigned-integer> = 1;
+  field pppoe-code :: <unsigned-byte> = 0;
+  field session-id :: <2byte-big-endian-unsigned-integer> = 0;
+  field pppoe-length :: <2byte-big-endian-unsigned-integer>,
+    fixup: byte-offset(frame-size(frame.payload));
+  field payload :: <ppp>;
+end;
+
+define protocol pppoe-discovery (container-frame)
+  over <ethernet-frame> #x8863;
+  field pppoe-version :: <4bit-unsigned-integer> = 1;
+  field pppoe-type :: <4bit-unsigned-integer> = 1;
+  enum field pppoe-code :: <unsigned-byte> = 0,
+    mappings: { #x0 <=> #"session data",
+                #x7 <=> #"PADO (PPPoE Active Discovery Offer)",
+                #x9 <=> #"PADI (PPPoE Active Discovery Initiation)",
+                #x19 <=> #"PADR (PPPoE Active Discovery Request)",
+                #x65 <=> #"PADS (PPPoE Active Discovery Session-confirmation)",
+                #xa7 <=> #"PADT (PPPoE Active Discovery Termination" };
+  field session-id :: <2byte-big-endian-unsigned-integer> = 0;
+  field pppoe-length :: <2byte-big-endian-unsigned-integer>,
+    fixup: reduce1(\+, map(compose(byte-offset, frame-size),
+                           frame.pppoe-tags));
+  repeated field pppoe-tags :: <pppoe-tag>,
+    reached-end?: instance?(frame, <pppoe-end-of-list>);
+end;
+
+define abstract protocol pppoe-tag (variably-typed-container-frame)
+  length (frame.tag-length + 4) * 8;
+  layering field tag-type :: <2byte-big-endian-unsigned-integer>;
+  field tag-length :: <2byte-big-endian-unsigned-integer>,
+    fixup: byte-offset(frame-size(frame)) - 4;
+end;
+
+define protocol pppoe-end-of-list (pppoe-tag)
+  over <pppoe-tag> #x0;
+end;
+
+define protocol pppoe-service-name (pppoe-tag)
+  over <pppoe-tag> #x0101;
+  field service-name :: <externally-delimited-string>;
+end;
+
+define protocol pppoe-access-contentrator-name (pppoe-tag)
+  over <pppoe-tag> #x0102;
+  field access-concentrator-name :: <externally-delimited-string>;
+end;
+
+define protocol pppoe-host-uniq (pppoe-tag)
+  over <pppoe-tag> #x0103;
+  field custom-data :: <raw-frame>;
+end;
+
+define protocol pppoe-access-concentrator-cookie (pppoe-tag)
+  over <pppoe-tag> #x0104;
+  field custom-data :: <raw-frame>;  
+end;
+
+define protocol pppoe-vendor-specific (pppoe-tag)
+  over <pppoe-tag> #x0105;
+  field reserved :: <unsigned-byte> = 0;
+  field vendor-id :: <3byte-big-endian-unsigned-integer>;
+  field custom-data :: <raw-frame>;
+end;
+
+define protocol pppoe-relay-session-id (pppoe-tag)
+  over <pppoe-tag> #x0110;
+  field custom-data :: <raw-frame>;
+end;
+
+define protocol pppoe-hurl (pppoe-tag)
+  over <pppoe-tag> #x0111;
+  field pppoe-url :: <externally-delimited-string>;
+end;
+
+define protocol pppoe-service-name-error (pppoe-tag)
+  over <pppoe-tag> #x0201;
+  field error-message :: <raw-frame>;
+end;
+
+define protocol pppoe-access-concentrator-system-error (pppoe-tag)
+  over <pppoe-tag> #x0202;
+  field error-message :: <raw-frame>;
+end;
+
+define protocol pppoe-generic-error (pppoe-tag)
+  over <pppoe-tag> #x0203;
+  field error-message :: <externally-delimited-string>;
+end;
+

Modified: trunk/libraries/protocols/protocols-library.dylan
==============================================================================
--- trunk/libraries/protocols/protocols-library.dylan	(original)
+++ trunk/libraries/protocols/protocols-library.dylan	Sat Feb  2 07:14:09 2008
@@ -18,7 +18,9 @@
     dns,
     rip,
     cidr,
-    ieee80211;
+    ieee80211,
+    ppp,
+    pppoe;
 end;
 
 define module logical-link
@@ -45,6 +47,23 @@
   export <mac-address>, mac-address;
 end;
 
+define module ppp
+  use common-dylan;
+  use packetizer;
+
+  export <ppp>;
+end;
+
+define module pppoe
+  use common-dylan;
+  use packetizer;
+
+  use ethernet, import: { <ethernet-frame> };
+  use ppp, import: { <ppp> };
+
+  export <pppoe>;
+end;
+
 define module ieee80211
   use dylan;
   use packetizer;
@@ -192,6 +211,7 @@
 
   use ethernet, import: { <ethernet-frame>, <mac-address> };
   use logical-link, import: { <link-control> };
+  use ppp, import: { <ppp> };
 
   export <ip-option-frame>,
     copy-flag, copy-flag-setter,

Modified: trunk/libraries/protocols/protocols.hdp
==============================================================================
--- trunk/libraries/protocols/protocols.hdp	(original)
+++ trunk/libraries/protocols/protocols.hdp	Sat Feb  2 07:14:09 2008
@@ -2,6 +2,8 @@
 files:	protocols-library
 	logical-link
 	ethernet
+	ppp
+	pppoe
 	ipv4
 	ipv6
 	icmp



More information about the chatter mailing list