]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/ipxcp.c
fix compilation problems
[ppp.git] / pppd / ipxcp.c
index fcae076007895180774cfe90779117b217cba86b..542ad85a967303136459c3d615352e4dc122f00c 100644 (file)
@@ -19,7 +19,7 @@
 
 #ifdef IPX_CHANGE
 #ifndef lint
-static char rcsid[] = "$Id: ipxcp.c,v 1.1 1995/12/18 03:32:59 paulus Exp $";
+static char rcsid[] = "$Id: ipxcp.c,v 1.4 1996/10/08 06:43:36 paulus Exp $";
 #endif
 
 /*
@@ -83,10 +83,36 @@ static fsm_callbacks ipxcp_callbacks = { /* IPXCP callback routines */
     "IPXCP"                    /* String name of protocol */
 };
 
+/*
+ * Protocol entry points.
+ */
+
+static void ipxcp_init __P((int));
+static void ipxcp_open __P((int));
+static void ipxcp_close __P((int, char *));
+static void ipxcp_lowerup __P((int));
+static void ipxcp_lowerdown __P((int));
+static void ipxcp_input __P((int, u_char *, int));
+static void ipxcp_protrej __P((int));
+static int  ipxcp_printpkt __P((u_char *, int,
+                               void (*) __P((void *, char *, ...)), void *));
+
 struct protent ipxcp_protent = {
-    PPP_IPXCP, ipxcp_init, ipxcp_input, ipxcp_protrej,
-    ipxcp_lowerup, ipxcp_lowerdown, ipxcp_open, ipxcp_close,
-    ipxcp_printpkt, NULL, 0, "IPXCP"
+    PPP_IPXCP,
+    ipxcp_init,
+    ipxcp_input,
+    ipxcp_protrej,
+    ipxcp_lowerup,
+    ipxcp_lowerdown,
+    ipxcp_open,
+    ipxcp_close,
+    ipxcp_printpkt,
+    NULL,
+    0,
+    "IPXCP",
+    NULL,
+    NULL,
+    NULL
 };
 
 
@@ -128,7 +154,7 @@ u_int32_t ipxaddr;
 /*
  * ipxcp_init - Initialize IPXCP.
  */
-void
+static void
 ipxcp_init(unit)
     int unit;
 {
@@ -216,7 +242,7 @@ u_char *node;
 /*
  * ipxcp_open - IPXCP is allowed to come up.
  */
-void
+static void
 ipxcp_open(unit)
     int unit;
 {
@@ -226,7 +252,7 @@ ipxcp_open(unit)
 /*
  * ipxcp_close - Take IPXCP down.
  */
-void
+static void
 ipxcp_close(unit, reason)
     int unit;
     char *reason;
@@ -238,20 +264,18 @@ ipxcp_close(unit, reason)
 /*
  * ipxcp_lowerup - The lower layer is up.
  */
-void
+static void
 ipxcp_lowerup(unit)
     int unit;
 {
-    extern int ipx_enabled;
-
-    fsm_lowerup(&ipxcp_fsm[unit], ipx_enabled);
+    fsm_lowerup(&ipxcp_fsm[unit]);
 }
 
 
 /*
  * ipxcp_lowerdown - The lower layer is down.
  */
-void
+static void
 ipxcp_lowerdown(unit)
     int unit;
 {
@@ -262,7 +286,7 @@ ipxcp_lowerdown(unit)
 /*
  * ipxcp_input - Input IPXCP packet.
  */
-void
+static void
 ipxcp_input(unit, p, len)
     int unit;
     u_char *p;
@@ -277,7 +301,7 @@ ipxcp_input(unit, p, len)
  *
  * Pretend the lower layer went down, so we shut up.
  */
-void
+static void
 ipxcp_protrej(unit)
     int unit;
 {
@@ -404,23 +428,9 @@ ipxcp_addci(f, ucp, lenp)
     }
 
     if (go->neg_router && (go->router & (BIT(0) | BIT(2) | BIT(4)))) {
-       if (go->router & BIT(0)) {
-           PUTCHAR  (IPX_ROUTER_PROTOCOL, ucp);
-           PUTCHAR  (CILEN_PROTOCOL,      ucp);
-           PUTSHORT (0,                   ucp);
-       } else {
-           if (go->router & BIT(2)) {
-               PUTCHAR  (IPX_ROUTER_PROTOCOL, ucp);
-               PUTCHAR  (CILEN_PROTOCOL,      ucp);
-               PUTSHORT (2,                   ucp);
-           }
-           
-           if (go->router & BIT(4)) {
-               PUTCHAR  (IPX_ROUTER_PROTOCOL, ucp);
-               PUTCHAR  (CILEN_PROTOCOL,      ucp);
-               PUTSHORT (4,                   ucp);
-           }
-       }
+        PUTCHAR  (IPX_ROUTER_PROTOCOL, ucp);
+       PUTCHAR  (CILEN_PROTOCOL,      ucp);
+       PUTSHORT (go->router,          ucp);
     }
 
     if (go->neg_complete) {
@@ -497,20 +507,13 @@ ipxcp_ackci(f, p, len)
            break; \
     }
 
-#define ACKCIPROTO(opt, neg, val, bit) \
-    if (neg && (val & BIT(bit))) \
+#define ACKCIPROTO(opt, neg, val) \
+    if (neg && p[1] == CILEN_PROTOCOL && len >= p[1] && p[0] == opt) \
       { \
-       if (len < 2) \
-           break; \
-       GETCHAR(citype, p); \
-       GETCHAR(cilen, p); \
-       if (cilen != CILEN_PROTOCOL || citype != opt) \
-           break; \
-       len -= cilen; \
-       if (len < 0) \
-           break; \
+       INCPTR(2, p); \
+       len -= CILEN_PROTOCOL; \
        GETSHORT(cishort, p); \
-       if (cishort != (bit)) \
+       if (cishort != (val)) \
            break; \
       }
 /*
@@ -520,9 +523,7 @@ ipxcp_ackci(f, p, len)
        ACKCINETWORK  (IPX_NETWORK_NUMBER,  go->neg_nn,     go->our_network);
        ACKCINODE     (IPX_NODE_NUMBER,     go->neg_node,   go->our_node);
        ACKCINAME     (IPX_ROUTER_NAME,     go->neg_name,   go->name);
-       ACKCIPROTO    (IPX_ROUTER_PROTOCOL, go->neg_router, go->router, 0);
-       ACKCIPROTO    (IPX_ROUTER_PROTOCOL, go->neg_router, go->router, 2);
-       ACKCIPROTO    (IPX_ROUTER_PROTOCOL, go->neg_router, go->router, 4);
+       ACKCIPROTO    (IPX_ROUTER_PROTOCOL, go->neg_router, go->router);
        ACKCICOMPLETE (IPX_COMPLETE,        go->neg_complete);
 /*
  * This is the end of the record.
@@ -676,33 +677,22 @@ ipxcp_rejci(f, p, len)
     ipxcp_options try;         /* options to request next time */
 
 #define REJCINETWORK(opt, neg, val) \
-    if (neg) { \
+    if (neg && p[1] == CILEN_NETN && len >= p[1] && p[0] == opt) { \
        neg = 0; \
-       if ((len -= CILEN_NETN) < 0) \
-           break; \
-       GETCHAR(citype, p); \
-       GETCHAR(cilen, p); \
-       if (cilen != CILEN_NETN || \
-           citype != opt) \
-           break; \
+       INCPTR(2, p); \
+       len -= CILEN_NETN; \
        GETLONG(cilong, p); \
        if (cilong != val) \
            break; \
-       IPXCPDEBUG((LOG_INFO,"ipxcp_rejci rejected long opt %d", opt)); \
+       IPXCPDEBUG((LOG_INFO,"ipxcp_rejci rejected network 0x%08x", val)); \
     }
 
 #define REJCICHARS(opt, neg, val, cnt) \
-    if (neg) { \
+    if (neg && p[1] == cnt + 2 && p[1] >= len && p[0] == opt) { \
        int indx, count = cnt; \
        neg = 0; \
-       len -= (count + 2); \
-       if (len < 0) \
-           break; \
-       GETCHAR(citype, p); \
-       GETCHAR(cilen, p); \
-       if (cilen != (count + 2) || \
-           citype != opt) \
-           break; \
+       INCPTR(2, p); \
+       len -= (cnt + 2); \
        for (indx = 0; indx < count; ++indx) {\
            GETCHAR(cichar, p); \
            if (cichar != ((u_char *) &val)[indx]) \
@@ -717,34 +707,23 @@ ipxcp_rejci(f, p, len)
 #define REJCINAME(opt,neg,val) REJCICHARS(opt,neg,val,strlen(val))
 
 #define REJCIVOID(opt, neg) \
-    if (neg) { \
+    if (neg && p[1] == CILEN_VOID && len >= p[1] && p[0] == opt) { \
        neg = 0; \
-       if ((len -= CILEN_VOID) < 0) \
-           break; \
-       GETCHAR(citype, p); \
-       GETCHAR(cilen, p); \
-       if (cilen != CILEN_VOID || citype != opt) \
-           break; \
+       INCPTR(2, p); \
+       len -= CILEN_VOID; \
        IPXCPDEBUG((LOG_INFO, "ipxcp_rejci rejected void opt %d", opt)); \
     }
 
-#define REJCIPROTO(opt, neg, val, bit) \
-    if (neg && (val & BIT(bit))) \
+#define REJCIPROTO(opt, neg, val) \
+    if (neg && p[1] == CILEN_PROTOCOL && len >= p[1] && p[0] == opt) \
       { \
-       if (len < 2) \
-           break; \
-       GETCHAR(citype, p); \
-       GETCHAR(cilen, p); \
-       if (cilen != CILEN_PROTOCOL || citype != opt) \
-           break; \
-       len -= cilen; \
-       if (len < 0) \
-           break; \
+       INCPTR(2, p); \
+       len -= CILEN_PROTOCOL; \
        GETSHORT(cishort, p); \
-       if (cishort != (bit)) \
+       IPXCPDEBUG((LOG_INFO, "ipxcp_rejci rejected router proto 0x%04x", cishort)); \
+        if ((cishort & val) == 0) \
            break; \
-       IPXCPDEBUG((LOG_INFO, "ipxcp_rejci rejected router proto %d", bit)); \
-       val &= ~BIT(bit); \
+       val &= ~cishort; \
        if (val == 0) \
            neg = 0; \
       }
@@ -759,9 +738,7 @@ ipxcp_rejci(f, p, len)
     do {
        REJCINETWORK (IPX_NETWORK_NUMBER,  try.neg_nn,     try.our_network);
        REJCINODE    (IPX_NODE_NUMBER,     try.neg_node,   try.our_node);
-       REJCIPROTO   (IPX_ROUTER_PROTOCOL, try.neg_router, try.router, 0);
-       REJCIPROTO   (IPX_ROUTER_PROTOCOL, try.neg_router, try.router, 2);
-       REJCIPROTO   (IPX_ROUTER_PROTOCOL, try.neg_router, try.router, 4);
+       REJCIPROTO   (IPX_ROUTER_PROTOCOL, try.neg_router, try.router);
        REJCINAME    (IPX_ROUTER_NAME,     try.neg_name,   try.name);
        REJCIVOID    (IPX_COMPLETE,        try.neg_complete);
 /*
@@ -1139,7 +1116,7 @@ ipxcp_up(f)
      * /etc/ppp/ipx-up interface tty speed local-IPX remote-IPX
      */
 
-    ipxcp_script (f, "/etc/ppp/ipx-up");
+    ipxcp_script (f, _PATH_IPXUP);
 }
 
 /*
@@ -1159,7 +1136,7 @@ ipxcp_down(f)
 
     cipxfaddr (f->unit);
     sifdown(f->unit);
-    ipxcp_script (f, "/etc/ppp/ipx-down");
+    ipxcp_script (f, _PATH_IPXDOWN);
 }
 
 
@@ -1236,16 +1213,16 @@ ipxcp_script(f, script)
 /*
  * ipxcp_printpkt - print the contents of an IPXCP packet.
  */
-char *ipxcp_codenames[] = {
+static char *ipxcp_codenames[] = {
     "ConfReq", "ConfAck", "ConfNak", "ConfRej",
     "TermReq", "TermAck", "CodeRej"
 };
 
-int
+static int
 ipxcp_printpkt(p, plen, printer, arg)
     u_char *p;
     int plen;
-    void (*printer)();
+    void (*printer) __P((void *, char *, ...));
     void *arg;
 {
     int code, id, len, olen;
@@ -1347,6 +1324,16 @@ ipxcp_printpkt(p, plen, printer, arg)
            printer(arg, ">");
        }
        break;
+
+    case TERMACK:
+    case TERMREQ:
+       if (len > 0 && *p >= ' ' && *p < 0x7f) {
+           printer(arg, " ");
+           print_string(p, len, printer, arg);
+           p += len;
+           len = 0;
+       }
+       break;
     }
 
     /* print the rest of the bytes in the packet */