]> git.ozlabs.org Git - ppp.git/commitdiff
extend protocol table; supply message on protocol close
authorPaul Mackerras <paulus@samba.org>
Mon, 18 Dec 1995 03:45:32 +0000 (03:45 +0000)
committerPaul Mackerras <paulus@samba.org>
Mon, 18 Dec 1995 03:45:32 +0000 (03:45 +0000)
pppd/ccp.h
pppd/fsm.c
pppd/fsm.h
pppd/lcp.c
pppd/lcp.h

index 12e27802892e8720866c89547e382e7a8c20a17e..9bcac4a99757ea95804b46246952dc4f6e88c82e 100644 (file)
@@ -24,7 +24,7 @@
  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
  * OR MODIFICATIONS.
  *
- * $Id: ccp.h,v 1.5 1995/10/27 03:43:11 paulus Exp $
+ * $Id: ccp.h,v 1.6 1995/12/18 03:44:41 paulus Exp $
  */
 
 typedef struct ccp_options {
@@ -44,7 +44,7 @@ extern ccp_options ccp_hisoptions[];
 
 void ccp_init __P((int unit));
 void ccp_open __P((int unit));
-void ccp_close __P((int unit));
+void ccp_close __P((int unit, char *));
 void ccp_lowerup __P((int unit));
 void ccp_lowerdown __P((int));
 void ccp_input __P((int unit, u_char *pkt, int len));
@@ -53,3 +53,5 @@ int  ccp_printpkt __P((u_char *pkt, int len,
                          void (*printer) __P((void *, char *, ...)),
                          void *arg));
 void ccp_datainput __P((int unit, u_char *pkt, int len));
+
+extern struct protent ccp_protent;
index 4ac0cb6b8dddb878956631b246f5ef03c607551f..a24c7c9116e23cb749a1b64e95ef2f42b49a8b65 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: fsm.c,v 1.9 1995/10/27 03:43:46 paulus Exp $";
+static char rcsid[] = "$Id: fsm.c,v 1.10 1995/12/18 03:44:42 paulus Exp $";
 #endif
 
 /*
@@ -67,6 +67,7 @@ fsm_init(f)
     f->maxconfreqtransmits = DEFMAXCONFREQS;
     f->maxtermtransmits = DEFMAXTERMREQS;
     f->maxnakloops = DEFMAXNAKLOOPS;
+    f->term_reason_len = 0;
 }
 
 
@@ -190,9 +191,12 @@ fsm_open(f)
  * the CLOSED state.
  */
 void
-fsm_close(f)
+fsm_close(f, reason)
     fsm *f;
+    char *reason;
 {
+    f->term_reason = reason;
+    f->term_reason_len = (reason == NULL? 0: strlen(reason));
     switch( f->state ){
     case STARTING:
        f->state = INITIAL;
@@ -215,7 +219,8 @@ fsm_close(f)
 
        /* Init restart counter, send Terminate-Request */
        f->retransmits = f->maxtermtransmits;
-       fsm_sdata(f, TERMREQ, f->reqid = ++f->id, NULL, 0);
+       fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
+                 (u_char *) f->term_reason, f->term_reason_len);
        TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime);
        --f->retransmits;
 
@@ -246,7 +251,8 @@ fsm_timeout(arg)
                (*f->callbacks->finished)(f);
        } else {
            /* Send Terminate-Request */
-           fsm_sdata(f, TERMREQ, f->reqid = ++f->id, NULL, 0);
+           fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
+                     (u_char *) f->term_reason, f->term_reason_len);
            TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime);
            --f->retransmits;
        }
@@ -686,7 +692,8 @@ fsm_protreject(f)
 
        /* Init restart counter, send Terminate-Request */
        f->retransmits = f->maxtermtransmits;
-       fsm_sdata(f, TERMREQ, f->reqid = ++f->id, NULL, 0);
+       fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
+                 (u_char *) f->term_reason, f->term_reason_len);
        TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime);
        --f->retransmits;
 
index efe18bf92f0011d919478c409dded94d3fe8a56b..56b0bd4549351231d301c74fb8fb9c69af8170c3 100644 (file)
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: fsm.h,v 1.5 1995/05/19 03:17:35 paulus Exp $
+ * $Id: fsm.h,v 1.6 1995/12/18 03:44:44 paulus Exp $
  */
 
 /*
@@ -74,6 +74,8 @@ typedef struct fsm {
     int nakloops;              /* Number of nak loops since last ack */
     int maxnakloops;           /* Maximum number of nak loops tolerated */
     fsm_callbacks *callbacks;  /* Callback routines */
+    char *term_reason;         /* Reason for closing protocol */
+    int term_reason_len;       /* Length of term_reason */
 } fsm;
 
 
@@ -116,7 +118,7 @@ void fsm_init __P((fsm *));
 void fsm_lowerup __P((fsm *));
 void fsm_lowerdown __P((fsm *));
 void fsm_open __P((fsm *));
-void fsm_close __P((fsm *));
+void fsm_close __P((fsm *, char *));
 void fsm_input __P((fsm *, u_char *, int));
 void fsm_protreject __P((fsm *));
 void fsm_sdata __P((fsm *, int, int, u_char *, int));
index ec1b911228be5505b0fba9489c4108f2c86b1011..e92639c4332cdb699fb5569f88657ba3486649a4 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: lcp.c,v 1.22 1995/10/27 03:42:09 paulus Exp $";
+static char rcsid[] = "$Id: lcp.c,v 1.23 1995/12/18 03:45:32 paulus Exp $";
 #endif
 
 /*
@@ -38,10 +38,8 @@ static char rcsid[] = "$Id: lcp.c,v 1.22 1995/10/27 03:42:09 paulus Exp $";
 #include "pppd.h"
 #include "fsm.h"
 #include "lcp.h"
-#include "magic.h"
 #include "chap.h"
-#include "upap.h"
-#include "ipcp.h"
+#include "magic.h"
 
 #ifdef _linux_         /* Needs ppp ioctls */
 #include <net/if.h>
@@ -113,6 +111,12 @@ static fsm_callbacks lcp_callbacks = {     /* LCP callback routines */
     "LCP"                      /* String name of protocol */
 };
 
+struct protent lcp_protent = {
+    PPP_LCP, lcp_init, lcp_input, lcp_protrej,
+    lcp_lowerup, lcp_lowerdown, lcp_open, lcp_close,
+    lcp_printpkt, NULL, 1, "LCP"
+};
+
 int lcp_loopbackfail = DEFLOOPBACKFAIL;
 
 /*
@@ -201,8 +205,9 @@ lcp_open(unit)
  * lcp_close - Take LCP down.
  */
 void
-lcp_close(unit)
+lcp_close(unit, reason)
     int unit;
+    char *reason;
 {
     fsm *f = &lcp_fsm[unit];
 
@@ -217,7 +222,7 @@ lcp_close(unit)
        lcp_finished(f);
 
     } else
-       fsm_close(&lcp_fsm[unit]);
+       fsm_close(&lcp_fsm[unit], reason);
 }
 
 #ifdef _linux_
@@ -247,7 +252,7 @@ RestartIdleTimer (f)
     delta = idle_time_limit - (u_long) ddinfo.recv_idle;
     if (((int) delta <= 0L) && (f->state == OPENED)) {
         syslog (LOG_NOTICE, "No IP frames received within idle time limit");
-       lcp_close(f->unit);             /* Reset connection */
+       lcp_close(f->unit, "Idle time limit expired");  /* Reset connection */
        phase = PHASE_TERMINATE;        /* Mark it down */
     } else {
         if ((int) delta <= 0L)
@@ -376,6 +381,8 @@ lcp_rprotrej(f, inp, len)
     u_char *inp;
     int len;
 {
+    int i;
+    struct protent *protp;
     u_short prot;
 
     LCPDEBUG((LOG_INFO, "lcp_rprotrej."));
@@ -402,7 +409,17 @@ lcp_rprotrej(f, inp, len)
        return;
     }
 
-    DEMUXPROTREJ(f->unit, prot);       /* Inform protocol */
+    /*
+     * Upcall the proper Protocol-Reject routine.
+     */
+    for (i = 0; (protp = protocols[i]) != NULL; ++i)
+       if (protp->protocol == prot && protp->enabled_flag) {
+           (*protp->protrej)(f->unit);
+           return;
+       }
+
+    syslog(LOG_WARNING, "Protocol-Reject for unsupported protocol 0x%x",
+          prot);
 }
 
 
@@ -940,7 +957,7 @@ lcp_nakci(f, p, len)
        if (looped_back) {
            if (++try.numloops >= lcp_loopbackfail) {
                syslog(LOG_NOTICE, "Serial line is looped back.");
-               lcp_close(f->unit);
+               lcp_close(f->unit, "Loopback detected");
            }
        } else
            try.numloops = 0;
@@ -1417,8 +1434,6 @@ endswitch:
 
 /*
  * lcp_up - LCP has come UP.
- *
- * Start UPAP, IPCP, etc.
  */
 static void
 lcp_up(f)
@@ -1455,10 +1470,6 @@ lcp_up(f)
     if (ho->neg_mru)
        peer_mru[f->unit] = ho->mru;
 
-    ChapLowerUp(f->unit);      /* Enable CHAP */
-    upap_lowerup(f->unit);     /* Enable UPAP */
-    ipcp_lowerup(f->unit);     /* Enable IPCP */
-    ccp_lowerup(f->unit);      /* Enable CCP */
     lcp_echo_lowerup(f->unit);  /* Enable echo messages */
 
     link_established(f->unit);
@@ -1477,10 +1488,6 @@ lcp_down(f)
     lcp_options *go = &lcp_gotoptions[f->unit];
 
     lcp_echo_lowerdown(f->unit);
-    ccp_lowerdown(f->unit);
-    ipcp_lowerdown(f->unit);
-    ChapLowerDown(f->unit);
-    upap_lowerdown(f->unit);
 
     sifdown(f->unit);
     ppp_send_config(f->unit, PPP_MRU, 0xffffffff, 0, 0);
@@ -1589,7 +1596,7 @@ lcp_printpkt(p, plen, printer, arg)
                    GETSHORT(cishort, p);
                    switch (cishort) {
                    case PPP_PAP:
-                       printer(arg, "upap");
+                       printer(arg, "pap");
                        break;
                    case PPP_CHAP:
                        printer(arg, "chap");
@@ -1661,7 +1668,8 @@ void LcpLinkFailure (f)
 {
     if (f->state == OPENED) {
         syslog (LOG_NOTICE, "Excessive lack of response to LCP echo frames.");
-        lcp_close(f->unit);            /* Reset connection */
+        lcp_close(f->unit, "Peer not responding");
+       phase = PHASE_TERMINATE;
     }
 }
 
index 271ddc5ef3b62431cef46d85bdc86345242b32f1..26dd6de7735717c668f65cfca299b20d0c053438 100644 (file)
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: lcp.h,v 1.8 1995/06/12 11:22:47 paulus Exp $
+ * $Id: lcp.h,v 1.9 1995/12/18 03:45:17 paulus Exp $
  */
 
 /*
@@ -74,7 +74,7 @@ extern u_int32_t xmit_accm[][8];
 
 void lcp_init __P((int));
 void lcp_open __P((int));
-void lcp_close __P((int));
+void lcp_close __P((int, char *));
 void lcp_lowerup __P((int));
 void lcp_lowerdown __P((int));
 void lcp_input __P((int, u_char *, int));
@@ -83,6 +83,8 @@ void lcp_sprotrej __P((int, u_char *, int));
 int  lcp_printpkt __P((u_char *, int,
                       void (*) __P((void *, char *, ...)), void *));
 
+extern struct protent lcp_protent;
+
 /* Default number of times we receive our magic number from the peer
    before deciding the link is looped-back. */
 #define DEFLOOPBACKFAIL        5