[Gd-chatter] r11670 - in trunk/libraries: layer network/ip-stack/state-machines/ppp protocols utilities/state-machine

andreas at gwydiondylan.org andreas at gwydiondylan.org
Fri Feb 8 02:13:38 CET 2008


Author: andreas
Date: Fri Feb  8 02:13:36 2008
New Revision: 11670

Modified:
   trunk/libraries/layer/dhcp.dylan
   trunk/libraries/layer/module.dylan
   trunk/libraries/layer/ppp.dylan
   trunk/libraries/layer/tcp.dylan
   trunk/libraries/network/ip-stack/state-machines/ppp/library.dylan
   trunk/libraries/network/ip-stack/state-machines/ppp/ppp.dylan
   trunk/libraries/protocols/ppp.dylan
   trunk/libraries/protocols/protocols-library.dylan
   trunk/libraries/utilities/state-machine/state-machine.dylan
Log:
Job: 7299

* ppp state machine
* state transitions now have an event
* ppp (lcp) exports in protocols


Modified: trunk/libraries/layer/dhcp.dylan
==============================================================================
--- trunk/libraries/layer/dhcp.dylan	(original)
+++ trunk/libraries/layer/dhcp.dylan	Fri Feb  8 02:13:36 2008
@@ -44,6 +44,7 @@
 
 define method state-transition (state :: <dhcp-client>,
                                 old-state :: <init>,
+                                event,
                                 new-state :: <selecting>) => ()
   let random = random(2 ^ 16 - 1);
   let (r1, r2) = values(logand(#xff, ash(random, -2)), logand(#xff, random));
@@ -72,6 +73,7 @@
 
 define method state-transition (state :: <dhcp-client-state>,
                                 old-state :: <selecting>,
+                                event,
                                 new-state :: <requesting>) => ()
 //  if (matches-requirements?(state.offer))
   let server-option = find-option(state.offer, <dhcp-server-identifier-option>);

Modified: trunk/libraries/layer/module.dylan
==============================================================================
--- trunk/libraries/layer/module.dylan	(original)
+++ trunk/libraries/layer/module.dylan	Fri Feb  8 02:13:36 2008
@@ -27,6 +27,7 @@
   use dhcp-state-machine;
   use ppp-state-machine;
   use pppoe;
+  use ppp;
   use tcp;
   use icmp;
   use ethernet;

Modified: trunk/libraries/layer/ppp.dylan
==============================================================================
--- trunk/libraries/layer/ppp.dylan	(original)
+++ trunk/libraries/layer/ppp.dylan	Fri Feb  8 02:13:36 2008
@@ -34,7 +34,8 @@
 
 
 define method state-transition (node :: <pppoe-client>,
-                                old-state :: <closed>,
+                                old-state :: <down>,
+                                event,
                                 new-state :: <padi-sent>) => ()
   let id = as(<raw-frame>, list(random(2 ^ 8 - 1), random(2 ^ 8 - 1), 23, 42));
   node.host-id := id;
@@ -45,6 +46,7 @@
 end;
 define method state-transition (node :: <pppoe-client>,
                                 old-state :: <pado-received>,
+                                event,
                                 new-state :: <padr-sent>) => ()
   let pppoe = pppoe-discovery(pppoe-code: #"PADR (PPPoE Active Discovery Request)",
                               pppoe-tags: node.offer.pppoe-tags);
@@ -53,9 +55,182 @@
 
 define method state-transition (node :: <pppoe-client>,
                                 old-state :: <established>,
-                                new-state :: <closed>) => ()
+                                event,
+                                new-state :: <down>) => ()
   let pppoe = pppoe-discovery(pppoe-code: #"PADT (PPPoE Active Discovery Termination)",
                               session-id: node.my-session-id);
   send(node.send-socket, node.offer.parent.source-address, pppoe);
 end;
 
+define class <ppp-session> (<filter>, <ppp-abstract-state-machine>)
+  slot send-socket, init-keyword: send-socket:;
+  slot my-magic;
+  slot last-request;
+end;
+
+define function send-ppp (ppp :: <ppp-session>, frame :: <container-frame>)
+  format-out("sending %=\n", frame);
+end;
+define macro ppp-transition-definer
+  {
+    define ppp-transition (?old:expression ?ev:expression ?new:name)
+      ?actions:*
+    end
+  } => {
+    define method state-transition (?=ppp-session :: <ppp-session>,
+                                    ?=old-state :: ?old,
+                                    ?=event == ?ev,
+                                    ?=new-state :: ?new,
+                                    #next next-method) => ();
+      let ?=tlu = curry(this-layer-up, ?=ppp-session);
+      let ?=tld = curry(this-layer-down, ?=ppp-session);
+      let ?=tls = curry(this-layer-started, ?=ppp-session);
+      let ?=tlf = curry(this-layer-finished, ?=ppp-session);
+      let ?=irc = curry(initialize-restart-count, ?=ppp-session);
+      let ?=zrc = curry(zero-restart-count, ?=ppp-session);
+      let ?=scr = curry(send-configure-request, ?=ppp-session);
+      let ?=sca = curry(send-configure-ack, ?=ppp-session);
+      let ?=scn = curry(send-configure-nak, ?=ppp-session);
+      let ?=str = curry(send-terminate-request, ?=ppp-session);
+      let ?=sta = curry(send-terminate-ack, ?=ppp-session);
+      let ?=scj = curry(send-code-reject, ?=ppp-session);
+      let ?=ser = curry(send-echo-reply, ?=ppp-session);
+      do(method (x) x() end, list(?actions));
+      next-method();
+    end
+  }
+end;
+
+define function this-layer-up (session :: <ppp-session>)
+  format-out("PPP layer went up\n");
+end;
+
+define function this-layer-down (session :: <ppp-session>)
+  format-out("PPP layer went down\n");
+end;
+
+define function this-layer-started (session :: <ppp-session>)
+  format-out("PPP layer started\n");
+end;
+
+define function this-layer-finished (session :: <ppp-session>)
+  format-out("PPP layer finished\n");
+end;
+
+define function initialize-restart-count (session :: <ppp-session>)
+end;
+
+define function zero-restart-count (session :: <ppp-session>)
+end;
+
+define function send-configure-request (session :: <ppp-session>)
+  send-ppp(session, lcp-configure-request());
+end;
+
+define function send-configure-ack (session :: <ppp-session>)
+  send-ppp(session, lcp-configure-ack());
+end;
+
+define function send-configure-nak (session :: <ppp-session>)
+  send-ppp(session, lcp-configure-nak());
+end;
+
+define function send-terminate-request (session :: <ppp-session>)
+  send-ppp(session, lcp-terminate-request());
+end;
+
+define function send-terminate-ack (session :: <ppp-session>)
+  send-ppp(session, lcp-terminate-ack());
+end;
+
+define function send-code-reject (session :: <ppp-session>)
+  send-ppp(session, lcp-code-reject());
+end;
+
+define function send-echo-reply (session :: <ppp-session>)
+  send-ppp(session, lcp-echo-reply(magic-number: session.my-magic,
+                                   custom-data: session.last-request.custom-data));
+end;
+
+define ppp-transition ( <initial> #"administrative-open" <starting> ) tls end;
+
+define ppp-transition ( <starting> #"lower-layer-up" <request-sent> ) irc, scr end;
+define ppp-transition ( <starting> #"administrative-close" <initial> ) tlf end;
+
+define ppp-transition ( <closed> #"administrative-open" <request-sent> ) irc, scr end;
+define ppp-transition ( <closed> #"receive-configure-request-good" <closed> ) sta end;
+define ppp-transition ( <closed> #"receive-configure-request-bad" <closed> ) sta end;
+define ppp-transition ( <closed> #"receive-configure-ack" <closed> ) sta end;
+define ppp-transition ( <closed> #"receive-configure-nak" <closed> ) sta end;
+define ppp-transition ( <closed> #"receive-terminate-request" <closed> ) sta end;
+define ppp-transition ( <closed> #"receive-unknown-code" <closed> ) scj end;
+define ppp-transition ( <closed> #"receive-code-or-protocol-reject-catastrophic" <closed> ) tlf end;
+
+define ppp-transition ( <stopped> #"lower-layer-down" <starting> ) tls end;
+define ppp-transition ( <stopped> #"receive-configure-request-good" <ack-sent> ) irc, scr, sca end;
+define ppp-transition ( <stopped> #"receive-configure-request-bad" <request-sent> ) irc, scr, scn end;
+define ppp-transition ( <stopped> #"receive-configure-ack" <stopped> ) sta end;
+define ppp-transition ( <stopped> #"receive-configure-nak" <stopped> ) sta end;
+define ppp-transition ( <stopped> #"receive-terminate-request" <stopped> ) sta end;
+define ppp-transition ( <stopped> #"receive-unknown-code" <stopped> ) scj end;
+define ppp-transition ( <stopped> #"receive-code-or-protocol-reject-catastrophic" <stopped> ) tlf end;
+
+define ppp-transition ( <closing> #"timeout-with-counter->0" <closing> ) str end;
+define ppp-transition ( <closing> #"timeout-with-counter-expired" <closed> ) tlf end;
+define ppp-transition ( <closing> #"receive-terminate-request" <closing> ) sta end;
+define ppp-transition ( <closing> #"receive-terminate-ack" <closed> ) tlf end;
+define ppp-transition ( <closing> #"receive-unknown-code" <closing> ) scj end;
+define ppp-transition ( <closing> #"receive-code-or-protocol-reject-catastrophic" <closed> ) tlf end;
+
+define ppp-transition ( <stopping> #"timeout-with-counter->0" <stopping> ) str end;
+define ppp-transition ( <stopping> #"timeout-with-counter-expired" <stopped> ) tlf end;
+define ppp-transition ( <stopping> #"receive-terminate-request" <stopping> ) sta end;
+define ppp-transition ( <stopping> #"receive-terminate-ack" <stopped> ) tlf end;
+define ppp-transition ( <stopping> #"receive-unknown-code" <stopping> ) scj end;
+define ppp-transition ( <stopping> #"receive-code-or-protocol-reject-catastrophic" <stopped> ) tlf end;
+
+define ppp-transition ( <request-sent> #"administrative-close" <closing> ) irc, str end;
+define ppp-transition ( <request-sent> #"timeout-with-counter->0" <request-sent> ) scr end;
+define ppp-transition ( <request-sent> #"timeout-with-counter-expired" <stopped> ) tlf end;
+define ppp-transition ( <request-sent> #"receive-configure-request-good" <ack-sent> ) sca end;
+define ppp-transition ( <request-sent> #"receive-configure-request-bad" <request-sent> ) scn end;
+define ppp-transition ( <request-sent> #"receive-configure-ack" <ack-received> ) irc end;
+define ppp-transition ( <request-sent> #"receive-configure-nak" <request-sent> ) irc, scr end;
+define ppp-transition ( <request-sent> #"receive-terminate-request" <request-sent> ) sta end;
+define ppp-transition ( <request-sent> #"receive-unknown-code" <request-sent> ) scj end;
+define ppp-transition ( <request-sent> #"receive-code-or-protocol-reject-catastrophic" <stopped> ) tlf end;
+
+define ppp-transition ( <ack-received> #"administrative-close" <closing> ) irc, str end;
+define ppp-transition ( <ack-received> #"timeout-with-counter->0" <request-sent> ) scr end;
+define ppp-transition ( <ack-received> #"timeout-with-counter-expired" <stopped> ) tlf end;
+define ppp-transition ( <ack-received> #"receive-configure-request-good" <opened> ) sca, tlu end;
+define ppp-transition ( <ack-received> #"receive-configure-request-bad" <ack-received> ) scn end;
+define ppp-transition ( <ack-received> #"receive-configure-ack" <request-sent> ) scr end;
+define ppp-transition ( <ack-received> #"receive-configure-nak" <request-sent> ) scr end;
+define ppp-transition ( <ack-received> #"receive-terminate-request" <request-sent> ) sta end;
+define ppp-transition ( <ack-received> #"receive-unknown-code" <ack-received> ) scj end;
+define ppp-transition ( <ack-received> #"receive-code-or-protocol-reject-catastrophic" <stopped> ) tlf end;
+
+define ppp-transition ( <ack-sent> #"administrative-close" <closing> ) irc, str end;
+define ppp-transition ( <ack-sent> #"timeout-with-counter->0" <ack-sent> ) scr end;
+define ppp-transition ( <ack-sent> #"timeout-with-counter-expired" <stopped> ) tlf end;
+define ppp-transition ( <ack-sent> #"receive-configure-request-good" <ack-sent> ) sca end;
+define ppp-transition ( <ack-sent> #"receive-configure-request-bad" <request-sent> ) scn end;
+define ppp-transition ( <ack-sent> #"receive-configure-ack" <opened> ) irc, tlu end;
+define ppp-transition ( <ack-sent> #"receive-configure-nak" <ack-sent> ) irc, scr end;
+define ppp-transition ( <ack-sent> #"receive-terminate-request" <request-sent> ) sta end;
+define ppp-transition ( <ack-sent> #"receive-unknown-code" <ack-sent> ) scj end;
+define ppp-transition ( <ack-sent> #"receive-code-or-protocol-reject-catastrophic" <stopped> ) tlf end;
+
+define ppp-transition ( <opened> #"lower-layer-down" <starting> ) tld end;
+define ppp-transition ( <opened> #"administrative-close" <closing> ) tld, irc, str end;
+define ppp-transition ( <opened> #"receive-configure-request-good" <ack-sent> ) tld, scr, sca end;
+define ppp-transition ( <opened> #"receive-configure-request-bad" <request-sent> ) tld, scr, scn end;
+define ppp-transition ( <opened> #"receive-configure-ack" <request-sent> ) tld, scr end;
+define ppp-transition ( <opened> #"receive-configure-nak" <request-sent> ) tld, scr end;
+define ppp-transition ( <opened> #"receive-terminate-request" <stopping> ) tld, zrc, sta end;
+define ppp-transition ( <opened> #"receive-terminate-ack" <request-sent> ) tld, scr end;
+define ppp-transition ( <opened> #"receive-unknown-code" <opened> ) scj end;
+define ppp-transition ( <opened> #"receive-code-or-protocol-reject-catastrophic" <stopping> ) tld, irc, str end;
+define ppp-transition ( <opened> #"receive-echo-or-discard" <opened> ) ser end;
+

Modified: trunk/libraries/layer/tcp.dylan
==============================================================================
--- trunk/libraries/layer/tcp.dylan	(original)
+++ trunk/libraries/layer/tcp.dylan	Fri Feb  8 02:13:36 2008
@@ -240,6 +240,7 @@
   } => {
     define method state-transition (?=tcp-connection :: <tcp-connection>,
                                     ?=old-state :: ?old,
+                                    ?=event,
                                     ?=new-state :: ?new,
                                     #next next-method) => ();
       let ?=send = curry(send-via-tcp, ?=tcp-connection);

Modified: trunk/libraries/network/ip-stack/state-machines/ppp/library.dylan
==============================================================================
--- trunk/libraries/network/ip-stack/state-machines/ppp/library.dylan	(original)
+++ trunk/libraries/network/ip-stack/state-machines/ppp/library.dylan	Fri Feb  8 02:13:36 2008
@@ -15,7 +15,12 @@
 
   export <pppoe-client-abstract-state-machine>;
 
-  export <closed>,  <padi-sent>,
+  export <down>,  <padi-sent>,
     <pado-received>, <padr-sent>,
     <established>, <pppoe-state>;
+
+  export <ppp-abstract-state-machine>;
+
+  export <initial>, <starting>, <closed>, <stopped>, <closing>, <stopping>,
+    <request-sent>, <ack-received>, <ack-sent>, <opened>, <ppp-state>;
 end module;

Modified: trunk/libraries/network/ip-stack/state-machines/ppp/ppp.dylan
==============================================================================
--- trunk/libraries/network/ip-stack/state-machines/ppp/ppp.dylan	(original)
+++ trunk/libraries/network/ip-stack/state-machines/ppp/ppp.dylan	Fri Feb  8 02:13:36 2008
@@ -2,18 +2,18 @@
 Copyright: (c) 2008 Dylan Hackers
 
 define open class <pppoe-client-abstract-state-machine> (<protocol-state-encapsulation>)
-  inherited slot state = make(<closed>);
+  inherited slot state = make(<down>);
 end;
 
 define abstract class <pppoe-state> (<protocol-state>) end;
 
-states(<closed>, <padi-sent>, <pado-received>, <padr-sent>, <established>; <pppoe-state>);
+states(<down>, <padi-sent>, <pado-received>, <padr-sent>, <established>; <pppoe-state>);
 
 define constant <pppoe-events>
   = one-of(#"padi-sent", #"pado-received", #"padr-sent", #"valid-pads-received",
            #"invalid-pads-received", #"padt-received", #"abort");
 
-define state-transition-rule <closed> #"padi-sent" <padi-sent> end;
+define state-transition-rule <down> #"padi-sent" <padi-sent> end;
 
 define state-transition-rule <padi-sent> #"pado-received" <pado-received> end;
 
@@ -21,12 +21,160 @@
 
 define state-transition-rule <padr-sent> #"valid-pads-received" <established> end;
 
-define state-transition-rule <padr-sent> #"invalid-pads-received" <closed> end;
+define state-transition-rule <padr-sent> #"invalid-pads-received" <down> end;
 
-define state-transition-rule <established> #"padt-received" <closed> end;
+define state-transition-rule <established> #"padt-received" <down> end;
 
-define state-transition-rule <pppoe-state> #"abort" <closed> end;
+define state-transition-rule <pppoe-state> #"abort" <down> end;
 
 
+define open class <ppp-abstract-state-machine> (<protocol-state-encapsulation>)
+  inherited slot state = make(<initial>);
+end;
+
+define abstract class <ppp-state> (<protocol-state>) end;
+
+states(<initial>, <starting>, <closed>, <stopped>, <closing>, <stopping>,
+       <request-sent>, <ack-received>, <ack-sent>, <opened>; <ppp-state>);
 
+define constant <ppp-events>
+  = one-of(#"lower-layer-up", #"lower-layer-down", #"administrative-open", #"administrative-close",
+           #"timeout-with-counter->0", #"timeout-with-counter-expired", 
+           #"receive-configure-request-good", #"receive-configure-request-bad",
+           #"receive-configure-ack", #"receive-configure-nak",
+           #"receive-terminate-request", #"receive-terminate-ack",
+           #"receive-unknown-code",
+           #"receive-code-or-protocol-reject-permitted",
+           #"receive-code-or-protocol-reject-catastrophic",
+           #"receive-echo-or-discard");
+
+define state-transition-rule <initial> #"lower-layer-up" <closed> end;
+define state-transition-rule <initial> #"administrative-open" <starting> end;
+define state-transition-rule <initial> #"administrative-close" <initial> end;
+
+define state-transition-rule <starting> #"lower-layer-up" <request-sent> end;
+define state-transition-rule <starting> #"administrative-open" <starting> end;
+define state-transition-rule <starting> #"administrative-close" <initial> end;
+
+define state-transition-rule <closed> #"lower-layer-down" <initial> end;
+define state-transition-rule <closed> #"administrative-open" <request-sent> end;
+define state-transition-rule <closed> #"administrative-close" <closed> end;
+define state-transition-rule <closed> #"receive-configure-request-good" <closed> end;
+define state-transition-rule <closed> #"receive-configure-request-bad" <closed> end;
+define state-transition-rule <closed> #"receive-configure-ack" <closed> end;
+define state-transition-rule <closed> #"receive-configure-nak" <closed> end;
+define state-transition-rule <closed> #"receive-terminate-request" <closed> end;
+define state-transition-rule <closed> #"receive-terminate-ack" <closed> end;
+define state-transition-rule <closed> #"receive-unknown-code" <closed> end;
+define state-transition-rule <closed> #"receive-code-or-protocol-reject-permitted" <closed> end;
+define state-transition-rule <closed> #"receive-code-or-protocol-reject-catastrophic" <closed> end;
+define state-transition-rule <closed> #"receive-echo-or-discard" <closed> end;
+
+define state-transition-rule <stopped> #"lower-layer-down" <starting> end;
+define state-transition-rule <stopped> #"administrative-open" <stopped> end;
+define state-transition-rule <stopped> #"administrative-close" <closed> end;
+define state-transition-rule <stopped> #"receive-configure-request-good" <ack-sent> end;
+define state-transition-rule <stopped> #"receive-configure-request-bad" <request-sent> end;
+define state-transition-rule <stopped> #"receive-configure-ack" <stopped> end;
+define state-transition-rule <stopped> #"receive-configure-nak" <stopped> end;
+define state-transition-rule <stopped> #"receive-terminate-request" <stopped> end;
+define state-transition-rule <stopped> #"receive-terminate-ack" <stopped> end;
+define state-transition-rule <stopped> #"receive-unknown-code" <stopped> end;
+define state-transition-rule <stopped> #"receive-code-or-protocol-reject-permitted" <stopped> end;
+define state-transition-rule <stopped> #"receive-code-or-protocol-reject-catastrophic" <stopped> end;
+define state-transition-rule <stopped> #"receive-echo-or-discard" <stopped> end;
+
+define state-transition-rule <closing> #"lower-layer-down" <initial> end;
+define state-transition-rule <closing> #"administrative-open" <stopping> end;
+define state-transition-rule <closing> #"administrative-close" <closing> end;
+define state-transition-rule <closing> #"timeout-with-counter->0" <closing> end;
+define state-transition-rule <closing> #"timeout-with-counter-expired" <closed> end;
+define state-transition-rule <closing> #"receive-configure-request-good" <closing> end;
+define state-transition-rule <closing> #"receive-configure-request-bad" <closing> end;
+define state-transition-rule <closing> #"receive-configure-ack" <closing> end;
+define state-transition-rule <closing> #"receive-configure-nak" <closing> end;
+define state-transition-rule <closing> #"receive-terminate-request" <closing> end;
+define state-transition-rule <closing> #"receive-terminate-ack" <closed> end;
+define state-transition-rule <closing> #"receive-unknown-code" <closing> end;
+define state-transition-rule <closing> #"receive-code-or-protocol-reject-permitted" <closing> end;
+define state-transition-rule <closing> #"receive-code-or-protocol-reject-catastrophic" <closed> end;
+define state-transition-rule <closing> #"receive-echo-or-discard" <closing> end;
+
+define state-transition-rule <stopping> #"lower-layer-down" <starting> end;
+define state-transition-rule <stopping> #"administrative-open" <stopping> end;
+define state-transition-rule <stopping> #"administrative-close" <closing> end;
+define state-transition-rule <stopping> #"timeout-with-counter->0" <stopping> end;
+define state-transition-rule <stopping> #"timeout-with-counter-expired" <stopped> end;
+define state-transition-rule <stopping> #"receive-configure-request-good" <stopping> end;
+define state-transition-rule <stopping> #"receive-configure-request-bad" <stopping> end;
+define state-transition-rule <stopping> #"receive-configure-ack" <stopping> end;
+define state-transition-rule <stopping> #"receive-configure-nak" <stopping> end;
+define state-transition-rule <stopping> #"receive-terminate-request" <stopping> end;
+define state-transition-rule <stopping> #"receive-terminate-ack" <stopped> end;
+define state-transition-rule <stopping> #"receive-unknown-code" <stopping> end;
+define state-transition-rule <stopping> #"receive-code-or-protocol-reject-permitted" <stopping> end;
+define state-transition-rule <stopping> #"receive-code-or-protocol-reject-catastrophic" <stopped> end;
+define state-transition-rule <stopping> #"receive-echo-or-discard" <stopping> end;
+
+define state-transition-rule <request-sent> #"lower-layer-down" <starting> end;
+define state-transition-rule <request-sent> #"administrative-open" <request-sent> end;
+define state-transition-rule <request-sent> #"administrative-close" <closing> end;
+define state-transition-rule <request-sent> #"timeout-with-counter->0" <request-sent> end;
+define state-transition-rule <request-sent> #"timeout-with-counter-expired" <stopped> end;
+define state-transition-rule <request-sent> #"receive-configure-request-good" <ack-sent> end;
+define state-transition-rule <request-sent> #"receive-configure-request-bad" <request-sent> end;
+define state-transition-rule <request-sent> #"receive-configure-ack" <ack-received> end;
+define state-transition-rule <request-sent> #"receive-configure-nak" <request-sent> end;
+define state-transition-rule <request-sent> #"receive-terminate-request" <request-sent> end;
+define state-transition-rule <request-sent> #"receive-terminate-ack" <request-sent> end;
+define state-transition-rule <request-sent> #"receive-unknown-code" <request-sent> end;
+define state-transition-rule <request-sent> #"receive-code-or-protocol-reject-permitted" <request-sent> end;
+define state-transition-rule <request-sent> #"receive-code-or-protocol-reject-catastrophic" <stopped> end;
+define state-transition-rule <request-sent> #"receive-echo-or-discard" <request-sent> end;
+
+define state-transition-rule <ack-received> #"lower-layer-down" <starting> end;
+define state-transition-rule <ack-received> #"administrative-open" <ack-received> end;
+define state-transition-rule <ack-received> #"administrative-close" <closing> end;
+define state-transition-rule <ack-received> #"timeout-with-counter->0" <request-sent> end;
+define state-transition-rule <ack-received> #"timeout-with-counter-expired" <stopped> end;
+define state-transition-rule <ack-received> #"receive-configure-request-good" <opened> end;
+define state-transition-rule <ack-received> #"receive-configure-request-bad" <ack-received> end;
+define state-transition-rule <ack-received> #"receive-configure-ack" <request-sent> end;
+define state-transition-rule <ack-received> #"receive-configure-nak" <request-sent> end;
+define state-transition-rule <ack-received> #"receive-terminate-request" <request-sent> end;
+define state-transition-rule <ack-received> #"receive-terminate-ack" <request-sent> end;
+define state-transition-rule <ack-received> #"receive-unknown-code" <ack-received> end;
+define state-transition-rule <ack-received> #"receive-code-or-protocol-reject-permitted" <request-sent> end;
+define state-transition-rule <ack-received> #"receive-code-or-protocol-reject-catastrophic" <stopped> end;
+define state-transition-rule <ack-received> #"receive-echo-or-discard" <ack-received> end;
+
+define state-transition-rule <ack-sent> #"lower-layer-down" <starting> end;
+define state-transition-rule <ack-sent> #"administrative-open" <ack-sent> end;
+define state-transition-rule <ack-sent> #"administrative-close" <closing> end;
+define state-transition-rule <ack-sent> #"timeout-with-counter->0" <ack-sent> end;
+define state-transition-rule <ack-sent> #"timeout-with-counter-expired" <stopped> end;
+define state-transition-rule <ack-sent> #"receive-configure-request-good" <ack-sent> end;
+define state-transition-rule <ack-sent> #"receive-configure-request-bad" <request-sent> end;
+define state-transition-rule <ack-sent> #"receive-configure-ack" <opened> end;
+define state-transition-rule <ack-sent> #"receive-configure-nak" <ack-sent> end;
+define state-transition-rule <ack-sent> #"receive-terminate-request" <request-sent> end;
+define state-transition-rule <ack-sent> #"receive-terminate-ack" <ack-sent> end;
+define state-transition-rule <ack-sent> #"receive-unknown-code" <ack-sent> end;
+define state-transition-rule <ack-sent> #"receive-code-or-protocol-reject-permitted" <ack-sent> end;
+define state-transition-rule <ack-sent> #"receive-code-or-protocol-reject-catastrophic" <stopped> end;
+define state-transition-rule <ack-sent> #"receive-echo-or-discard" <ack-sent> end;
+
+define state-transition-rule <opened> #"lower-layer-down" <starting> end;
+define state-transition-rule <opened> #"administrative-open" <opened> end;
+define state-transition-rule <opened> #"administrative-close" <closing> end;
+define state-transition-rule <opened> #"receive-configure-request-good" <ack-sent> end;
+define state-transition-rule <opened> #"receive-configure-request-bad" <request-sent> end;
+define state-transition-rule <opened> #"receive-configure-ack" <request-sent> end;
+define state-transition-rule <opened> #"receive-configure-nak" <request-sent> end;
+define state-transition-rule <opened> #"receive-terminate-request" <stopping> end;
+define state-transition-rule <opened> #"receive-terminate-ack" <request-sent> end;
+define state-transition-rule <opened> #"receive-unknown-code" <opened> end;
+define state-transition-rule <opened> #"receive-code-or-protocol-reject-permitted" <opened> end;
+define state-transition-rule <opened> #"receive-code-or-protocol-reject-catastrophic" <stopping> end;
+define state-transition-rule <opened> #"receive-echo-or-discard" <opened> end;
 

Modified: trunk/libraries/protocols/ppp.dylan
==============================================================================
--- trunk/libraries/protocols/ppp.dylan	(original)
+++ trunk/libraries/protocols/ppp.dylan	Fri Feb  8 02:13:36 2008
@@ -31,25 +31,25 @@
     => {
 define protocol ?short ## "-configure-request" (?name)
   over "<" ## ?name ## ">" 1;
-  repeated field configuration-option :: "<" ## ?short ## "-option>",
+  repeated field configuration-options :: "<" ## ?short ## "-option>",
     reached-end?: #f;
 end;
 
 define protocol ?short ## "-configure-ack" (?name)
   over "<" ## ?name ## ">" 2;
-  repeated field configuration-option :: "<" ## ?short ## "-option>",
+  repeated field configuration-options :: "<" ## ?short ## "-option>",
     reached-end?: #f;
 end;
 
 define protocol ?short ## "-configure-nak" (?name)
   over "<" ## ?name ## ">" 3;
-  repeated field configuration-option :: "<" ## ?short ## "-option>",
+  repeated field configuration-options :: "<" ## ?short ## "-option>",
     reached-end?: #f;
 end;
 
 define protocol ?short ## "-configure-reject" (?name)
   over "<" ## ?name ## ">" 4;
-  repeated field configuration-option :: "<" ## ?short ## "-option>",
+  repeated field configuration-options :: "<" ## ?short ## "-option>",
     reached-end?: #f;
 end;
 

Modified: trunk/libraries/protocols/protocols-library.dylan
==============================================================================
--- trunk/libraries/protocols/protocols-library.dylan	(original)
+++ trunk/libraries/protocols/protocols-library.dylan	Fri Feb  8 02:13:36 2008
@@ -56,6 +56,27 @@
   use ethernet, import: { <ipv4-address> };
 
   export <ppp>;
+
+  export magic-number, custom-data;
+
+  export ppp, lcp-configure-request, configuration-options,
+    lcp-configure-ack, lcp-configure-nak, lcp-configure-reject,
+    lcp-terminate-request, lcp-terminate-ack, lcp-terminate-nak,
+    lcp-code-reject, lcp-protocol-reject,
+    lcp-echo-request, lcp-echo-reply, lcp-discard-request,
+    lcp-identification, lcp-time-remaining;
+
+  export lcp-authentication-protocol, authentication-protocol,
+    lcp-maximum-receive-unit, maximum-receive-unit,
+    lcp-quality-protocol, lcp-magic-number-option,
+    lcp-protocol-field-compression, lcp-address-and-control-field-compression,
+    lcp-fcs-alternative, lcp-self-describing-padding, lcp-numbered-mode,
+    lcp-callback, lcp-compound-frames;
+
+  export <pap>, pap-authenticate-request,
+    peer-id, password,
+    pap-autenticate-ack, pap-authenticate-nak;
+    
 end;
 
 define module pppoe

Modified: trunk/libraries/utilities/state-machine/state-machine.dylan
==============================================================================
--- trunk/libraries/utilities/state-machine/state-machine.dylan	(original)
+++ trunk/libraries/utilities/state-machine/state-machine.dylan	Fri Feb  8 02:13:36 2008
@@ -9,6 +9,7 @@
 define open abstract class <protocol-state-encapsulation> (<object>)
   constant slot lock :: <simple-lock> = make(<simple-lock>);
   slot state :: <protocol-state>;
+  slot debugging? :: <boolean> = #f, init-keyword: debugging?:;
 end;
 
 define macro singleton-class-definer
@@ -46,20 +47,24 @@
   with-lock (dingens.lock)
     let old-state = dingens.state;
     let new-state = next-state(old-state, event);
-    //format-out("State transition %= => %=\n", old-state, new-state);
+    if (dingens.debugging?)
+      format-out("Event %= triggers state transition %= => %=\n", event, old-state, new-state);
+    end;
     dingens.state := new-state;
-    state-transition(dingens, old-state, new-state);
+    state-transition(dingens, old-state, event, new-state);
   end;
 end;
 
 define open generic state-transition (dingens :: <protocol-state-encapsulation>,
                                       old-state :: <protocol-state>,
+                                      event,
                                       new-state :: <protocol-state>) => ();
 
 define method state-transition (dingens :: <protocol-state-encapsulation>,
                                 old-state :: <protocol-state>,
+                                event,
                                 new-state :: <protocol-state>) => ()
-  ignore(dingens, old-state, new-state)
+  ignore(dingens, old-state, event, new-state)
 end;  
 
 define macro state-transition-rule-definer



More information about the chatter mailing list