Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/sys/net Pull up recent changes to if_sppp*.[ch] (i4b co...



details:   https://anonhg.NetBSD.org/src/rev/df9617eb6052
branches:  netbsd-1-4
changeset: 468042:df9617eb6052
user:      explorer <explorer%NetBSD.org@localhost>
date:      Sun Apr 04 06:57:39 1999 +0000

description:
Pull up recent changes to if_sppp*.[ch] (i4b code) with RCS id fixes

diffstat:

 sys/net/Makefile      |     8 +-
 sys/net/if_sppp.h     |   181 +-
 sys/net/if_spppsubr.c |  4685 +++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 3964 insertions(+), 910 deletions(-)

diffs (truncated from 5355 to 300 lines):

diff -r d2bc4db7e7ea -r df9617eb6052 sys/net/Makefile
--- a/sys/net/Makefile  Sun Apr 04 04:30:18 1999 +0000
+++ b/sys/net/Makefile  Sun Apr 04 06:57:39 1999 +0000
@@ -1,12 +1,12 @@
-#      $NetBSD: Makefile,v 1.3 1999/03/22 22:27:41 bad Exp $
+#      $NetBSD: Makefile,v 1.3.2.1 1999/04/04 06:57:39 explorer Exp $
 
 KDIR=  /sys/net
 INCSDIR= /usr/include/net
 
 INCS=  bpf.h bpfdesc.h ethertypes.h if.h if_arc.h if_arp.h if_atm.h if_dl.h \
        if_ether.h if_fddi.h if_gre.h if_hippi.h if_llc.h if_media.h if_ppp.h \
-       if_pppvar.h if_slvar.h if_stripvar.h if_token.h if_tun.h if_types.h \
-       netisr.h pfil.h ppp-comp.h ppp_defs.h radix.h raw_cb.h route.h \
-       slcompress.h slip.h zlib.h
+       if_pppvar.h if_slvar.h if_sppp.h if_stripvar.h if_token.h if_tun.h \
+       if_types.h netisr.h pfil.h ppp-comp.h ppp_defs.h radix.h raw_cb.h \
+       route.h slcompress.h slip.h zlib.h
 
 .include <bsd.kinc.mk>
diff -r d2bc4db7e7ea -r df9617eb6052 sys/net/if_sppp.h
--- a/sys/net/if_sppp.h Sun Apr 04 04:30:18 1999 +0000
+++ b/sys/net/if_sppp.h Sun Apr 04 06:57:39 1999 +0000
@@ -1,10 +1,13 @@
-/*     $NetBSD: if_sppp.h,v 1.2 1999/03/25 05:25:42 explorer Exp $     */
+/*     $NetBSD: if_sppp.h,v 1.2.2.1 1999/04/04 06:57:39 explorer Exp $ */
 
 /*
  * Defines for synchronous PPP/Cisco link level subroutines.
  *
  * Copyright (C) 1994 Cronyx Ltd.
- * Author: Serge Vakulenko, <vak%zebub.msk.su@localhost>
+ * Author: Serge Vakulenko, <vak%cronyx.ru@localhost>
+ *
+ * Heavily revamped to conform to RFC 1661.
+ * Copyright (C) 1997, Joerg Wunsch.
  *
  * This software is distributed with NO WARRANTIES, not even the implied
  * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -13,60 +16,172 @@
  * or modify this software as long as this message is kept with the software,
  * all derivative works or modified versions.
  *
- * Version 1.7, Wed Jun  7 22:12:02 MSD 1995
+ * From: Version 2.0, Fri Oct  6 20:39:21 MSK 1995
+ *
+ * From: if_sppp.h,v 1.8 1997/10/11 11:25:20 joerg Exp
+ *
+ * From: Id: if_sppp.h,v 1.7 1998/12/01 20:20:19 hm Exp
  */
 
 #ifndef _NET_IF_HDLC_H_
 #define _NET_IF_HDLC_H_ 1
 
+#define IDX_LCP 0              /* idx into state table */
+
 struct slcp {
-       u_int16_t state;          /* state machine */
-       u_int32_t magic;          /* local magic number */
-       u_int8_t  echoid;         /* id of last keepalive echo request */
-       u_int8_t  confid;         /* id of last configuration request */
+       u_long  opts;           /* LCP options to send (bitfield) */
+       u_long  magic;          /* local magic number */
+       u_long  mru;            /* our max receive unit */
+       u_long  their_mru;      /* their max receive unit */
+       u_long  protos;         /* bitmask of protos that are started */
+       u_char  echoid;         /* id of last keepalive echo request */
+       /* restart max values, see RFC 1661 */
+       int     timeout;
+       int     max_terminate;
+       int     max_configure;
+       int     max_failure;
+};
+
+#define IDX_IPCP 1             /* idx into state table */
+
+struct sipcp {
+       u_long  opts;           /* IPCP options to send (bitfield) */
+       u_int   flags;
+#define IPCP_HISADDR_SEEN 1    /* have seen his address already */
+#define IPCP_MYADDR_DYN   2    /* my address is dynamically assigned */
+#define IPCP_MYADDR_SEEN  4    /* have seen his address already */
 };
 
-struct sipcp {
-       u_int16_t state;          /* state machine */
-       u_int8_t  confid;         /* id of last configuration request */
+#define AUTHNAMELEN    32
+#define AUTHKEYLEN     16
+
+struct sauth {
+       u_short proto;                  /* authentication protocol to use */
+       u_short flags;
+#define AUTHFLAG_NOCALLOUT     1       /* do not require authentication on */
+                                       /* callouts */
+#define AUTHFLAG_NORECHALLENGE 2       /* do not re-challenge CHAP */
+       u_char  name[AUTHNAMELEN];      /* system identification name */
+       u_char  secret[AUTHKEYLEN];     /* secret password */
+       u_char  challenge[AUTHKEYLEN];  /* random challenge */
+};
+
+#define IDX_PAP                2
+#define IDX_CHAP       3
+
+#define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
+
+/*
+ * Don't change the order of this.  Ordering the phases this way allows
+ * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
+ * know whether LCP is up.
+ */
+enum ppp_phase {
+       PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
+       PHASE_AUTHENTICATE, PHASE_NETWORK
 };
 
 struct sppp {
-       struct ifnet    pp_if;          /* network interface data */
-       struct ifqueue  pp_fastq;       /* fast output queue */
-       struct sppp    *pp_next;        /* next interface in keepalive list */
-       u_int           pp_flags;       /* use Cisco protocol instead of PPP */
-       u_int16_t       pp_alivecnt;    /* keepalive packets counter */
-       u_int16_t       pp_loopcnt;     /* loopback detection counter */
-       u_int32_t       pp_seq;         /* local sequence number */
-       u_int32_t       pp_rseq;        /* remote sequence number */
-       struct slcp     lcp;            /* LCP params */
-       struct sipcp    ipcp;           /* IPCP params */
+       /* NB: pp_if _must_ be first */
+       struct  ifnet pp_if;    /* network interface data */
+       struct  ifqueue pp_fastq; /* fast output queue */
+       struct  ifqueue pp_cpq; /* PPP control protocol queue */
+       struct  sppp *pp_next;  /* next interface in keepalive list */
+       u_int   pp_flags;       /* use Cisco protocol instead of PPP */
+       u_short pp_alivecnt;    /* keepalive packets counter */
+       u_short pp_loopcnt;     /* loopback detection counter */
+       u_long  pp_seq;         /* local sequence number */
+       u_long  pp_rseq;        /* remote sequence number */
+       enum ppp_phase pp_phase;        /* phase we're currently in */
+       int     state[IDX_COUNT];       /* state machine */
+       u_char  confid[IDX_COUNT];      /* id of last configuration request */
+       int     rst_counter[IDX_COUNT]; /* restart counter */
+       int     fail_counter[IDX_COUNT]; /* negotiation failure counter */
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+       struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */
+       struct callout_handle pap_my_to_ch; /* PAP needs one more... */
+#endif
+       struct slcp lcp;                /* LCP params */
+       struct sipcp ipcp;              /* IPCP params */
+       struct sauth myauth;            /* auth params, i'm peer */
+       struct sauth hisauth;           /* auth params, i'm authenticator */
+       /*
+        * These functions are filled in by sppp_attach(), and are
+        * expected to be used by the lower layer (hardware) drivers
+        * in order to communicate the (un)availability of the
+        * communication link.  Lower layer drivers that are always
+        * ready to communicate (like hardware HDLC) can shortcut
+        * pp_up from pp_tls, and pp_down from pp_tlf.
+        */
+       void    (*pp_up)(struct sppp *sp);
+       void    (*pp_down)(struct sppp *sp);
+       /*
+        * These functions need to be filled in by the lower layer
+        * (hardware) drivers if they request notification from the
+        * PPP layer whether the link is actually required.  They
+        * correspond to the tls and tlf actions.
+        */
+       void    (*pp_tls)(struct sppp *sp);
+       void    (*pp_tlf)(struct sppp *sp);
+       /*
+        * These (optional) functions may be filled by the hardware
+        * driver if any notification of established connections
+        * (currently: IPCP up) is desired (pp_con) or any internal
+        * state change of the interface state machine should be
+        * signaled for monitoring purposes (pp_chg).
+        */
+       void    (*pp_con)(struct sppp *sp);
+       void    (*pp_chg)(struct sppp *sp, int new_state);
 };
 
 #define PP_KEEPALIVE    0x01    /* use keepalive protocol */
 #define PP_CISCO        0x02    /* use Cisco protocol instead of PPP */
-#define PP_TIMO         0x04    /* cp_timeout routine active */
+                               /* 0x04 was PP_TIMO */
+#define PP_CALLIN      0x08    /* we are being called */
+#define PP_NEEDAUTH    0x10    /* remote requested authentication */
 
-#define PP_MTU          1500    /* max. transmit unit */
+
+#define PP_MTU          1500    /* default/minimal MRU */
+#define PP_MAX_MRU     2048    /* maximal MRU we want to negotiate */
 
-#define LCP_STATE_CLOSED        0       /* LCP state: closed (conf-req sent) */
-#define LCP_STATE_ACK_RCVD      1       /* LCP state: conf-ack received */
-#define LCP_STATE_ACK_SENT      2       /* LCP state: conf-ack sent */
-#define LCP_STATE_OPENED        3       /* LCP state: opened */
+/*
+ * Definitions to pass struct sppp data down into the kernel using the
+ * SIOC[SG]IFGENERIC ioctl interface.
+ *
+ * In order to use this, create a struct spppreq, fill in the cmd
+ * field with SPPPIOGDEFS, and put the address of this structure into
+ * the ifr_data portion of a struct ifreq.  Pass this struct to a
+ * SIOCGIFGENERIC ioctl.  Then replace the cmd field by SPPPIOCDEFS,
+ * modify the defs field as desired, and pass the struct ifreq now
+ * to a SIOCSIFGENERIC ioctl.
+ */
 
-#define IPCP_STATE_CLOSED       0       /* IPCP state: closed (conf-req sent) */
-#define IPCP_STATE_ACK_RCVD     1       /* IPCP state: conf-ack received */
-#define IPCP_STATE_ACK_SENT     2       /* IPCP state: conf-ack sent */
-#define IPCP_STATE_OPENED       3       /* IPCP state: opened */
+#define SPPPIOGDEFS  ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
+#define SPPPIOSDEFS  ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
+
+struct spppreq {
+       int     cmd;
+       struct sppp defs;
+};
 
-#ifdef _KERNEL
-void spppattach(void);
+#if (defined(__FreeBSD_version) && __FreeBSD_version < 300000)  ||     \
+    (defined(__FreeBSD__) && __FreeBSD__ < 3)                  ||      \
+    defined(__NetBSD__) || defined (__OpenBSD__)
+#define        SIOCSIFGENERIC   _IOW('i', 57, struct ifreq)    /* generic IF set op */
+#define        SIOCGIFGENERIC  _IOWR('i', 58, struct ifreq)    /* generic IF get op */
+#endif
+
+#if defined(KERNEL) || defined(_KERNEL)
 void sppp_attach (struct ifnet *ifp);
 void sppp_detach (struct ifnet *ifp);
 void sppp_input (struct ifnet *ifp, struct mbuf *m);
-int sppp_ioctl (struct ifnet *ifp, int cmd, void *data);
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 300003
+int sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data);
+#else
+int sppp_ioctl(struct ifnet *ifp, int cmd, void *data);
+#endif
 struct mbuf *sppp_dequeue (struct ifnet *ifp);
+struct mbuf *sppp_pick(struct ifnet *ifp);
 int sppp_isempty (struct ifnet *ifp);
 void sppp_flush (struct ifnet *ifp);
 #endif
diff -r d2bc4db7e7ea -r df9617eb6052 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Sun Apr 04 04:30:18 1999 +0000
+++ b/sys/net/if_spppsubr.c     Sun Apr 04 06:57:39 1999 +0000
@@ -1,11 +1,14 @@
-/*     $NetBSD: if_spppsubr.c,v 1.2 1999/03/25 05:25:42 explorer Exp $ */
+/*     $NetBSD: if_spppsubr.c,v 1.2.2.1 1999/04/04 06:57:39 explorer Exp $      */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
  * Keepalive protocol implemented in both Cisco and PPP modes.
  *
- * Copyright (C) 1994 Cronyx Ltd.
- * Author: Serge Vakulenko, <vak%zebub.msk.su@localhost>
+ * Copyright (C) 1994-1996 Cronyx Engineering Ltd.
+ * Author: Serge Vakulenko, <vak%cronyx.ru@localhost>
+ *
+ * Heavily revamped to conform to RFC 1661.
+ * Copyright (C) 1997, Joerg Wunsch.
  *
  * This software is distributed with NO WARRANTIES, not even the implied
  * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -14,25 +17,45 @@
  * or modify this software as long as this message is kept with the software,
  * all derivative works or modified versions.
  *
- * Version 1.9, Wed Oct  4 18:58:15 MSK 1995
+ * From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997
+ *
+ * From: if_spppsubr.c,v 1.39 1998/04/04 13:26:03 phk Exp
+ *
+ * From: Id: if_spppsubr.c,v 1.23 1999/02/23 14:47:50 hm Exp
  */
-#undef DEBUG
-
+
+#if defined(__NetBSD__) || (defined(__FreeBSD__) && __FreeBSD__ >= 3)
 #include "opt_inet.h"
-#include "opt_ns.h"
+#include "opt_ipx.h"
 #include "opt_iso.h"
-#include "opt_ipx.h"
+#include "opt_ns.h"
+#endif
 
 #include <sys/param.h>
+
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/ioctl.h>
+#include <sys/sockio.h>
 #include <sys/socket.h>
+#include <sys/syslog.h>
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#include <machine/random.h>
+#endif
+#include <sys/malloc.h>
 #include <sys/mbuf.h>



Home | Main Index | Thread Index | Old Index