Major overhaul of the SyncPPP layer. Basically, this comprises now a

full implementation of the sate machine as described in RFC1661, and
provides support for plugging in various control protocols.  I needed
this to provide PPP support for the BISDN project (right now).

Unfortunatley, while the existing API was almost up to the point, i
needed one minor API change in order to decouple the this-layer-
started and this-layer-finished actions from the respective Up and
Down events of the lower layer.  This requires two additional lines in
the attach routines of all existing lower layer interface drivers that
are using syncPPP (shortcutting these actions and events).  Apart from
this, i believe i didn't change the API of all this, so everything
should plug in without too many hassles.  Please report if i broke
something in the existing drivers.

For a list of features (including new ones like dial-on-demand), and
things still to be done, please refer to the man page i'll commit asap.

Encouraged by:	Serge Vakulenko <vak@cronyx.ru>
This commit is contained in:
joerg 1997-05-19 22:03:09 +00:00
parent 13206dfe73
commit 27ddec53f7
9 changed files with 2157 additions and 824 deletions

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: if_ar.c,v 1.14 1997/02/22 09:36:15 peter Exp $
*/
/*
@ -349,6 +349,13 @@ arattach(struct isa_device *id)
sppp_attach((struct ifnet *)&sc->ifsppp);
if_attach(ifp);
/*
* Shortcut the sppp tls/tlf actions to up/down events
* since our lower layer is always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
#if NBPFILTER > 0
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
#endif

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: if_ar.c,v 1.14 1997/02/22 09:36:15 peter Exp $
*/
/*
@ -349,6 +349,13 @@ arattach(struct isa_device *id)
sppp_attach((struct ifnet *)&sc->ifsppp);
if_attach(ifp);
/*
* Shortcut the sppp tls/tlf actions to up/down events
* since our lower layer is always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
#if NBPFILTER > 0
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
#endif

View File

@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: if_sr.c,v 1.6 1997/02/22 09:36:35 peter Exp $
*/
/*
@ -1304,6 +1304,14 @@ srioctl(struct ifnet *ifp, int cmd, caddr_t data)
default:
sc->ifsppp.pp_flags = PP_KEEPALIVE;
sppp_attach(&sc->ifsppp.pp_if);
/*
* Shortcut the sppp tls/tlf actions to
* up/down events since our lower layer is
* always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
}
sc->attached = sc->protocol;
@ -1487,7 +1495,15 @@ sr_up(struct sr_softc *sc)
default:
sc->ifsppp.pp_flags = PP_KEEPALIVE;
sppp_attach(&sc->ifsppp.pp_if);
}
/*
* Shortcut the sppp tls/tlf actions to
* up/down events since our lower layer is
* always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
}
sc->attached = sc->protocol;
}

View File

@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: if_sr.c,v 1.6 1997/02/22 09:36:35 peter Exp $
*/
/*
@ -1304,6 +1304,14 @@ srioctl(struct ifnet *ifp, int cmd, caddr_t data)
default:
sc->ifsppp.pp_flags = PP_KEEPALIVE;
sppp_attach(&sc->ifsppp.pp_if);
/*
* Shortcut the sppp tls/tlf actions to
* up/down events since our lower layer is
* always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
}
sc->attached = sc->protocol;
@ -1487,7 +1495,15 @@ sr_up(struct sr_softc *sc)
default:
sc->ifsppp.pp_flags = PP_KEEPALIVE;
sppp_attach(&sc->ifsppp.pp_if);
}
/*
* Shortcut the sppp tls/tlf actions to
* up/down events since our lower layer is
* always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
}
sc->attached = sc->protocol;
}

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: if_ar.c,v 1.14 1997/02/22 09:36:15 peter Exp $
*/
/*
@ -349,6 +349,13 @@ arattach(struct isa_device *id)
sppp_attach((struct ifnet *)&sc->ifsppp);
if_attach(ifp);
/*
* Shortcut the sppp tls/tlf actions to up/down events
* since our lower layer is always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
#if NBPFILTER > 0
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
#endif

View File

@ -224,6 +224,7 @@ cxattach (struct isa_device *id)
int drq = id->id_drq;
cx_board_t *b = cxboard + unit;
int i;
struct sppp *sp;
/* Initialize the board structure. */
cx_init (b, unit, iobase, ffs(irq)-1, drq);
@ -276,6 +277,13 @@ cxattach (struct isa_device *id)
/* Init routine is never called by upper level? */
sppp_attach (c->ifp);
if_attach (c->ifp);
/*
* Shortcut the sppp tls/tlf actions to up/down
* events since our lower layer is always ready.
*/
sp = (struct sppp*) c->ifp;
sp->pp_tls = sp->pp_up;
sp->pp_tlf = sp->pp_down;
#if NBPFILTER > 0
/* If BPF is in the kernel, call the attach for it. */
bpfattach (c->ifp, DLT_PPP, PPP_HEADER_LEN);

View File

@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: if_sr.c,v 1.6 1997/02/22 09:36:35 peter Exp $
*/
/*
@ -1304,6 +1304,14 @@ srioctl(struct ifnet *ifp, int cmd, caddr_t data)
default:
sc->ifsppp.pp_flags = PP_KEEPALIVE;
sppp_attach(&sc->ifsppp.pp_if);
/*
* Shortcut the sppp tls/tlf actions to
* up/down events since our lower layer is
* always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
}
sc->attached = sc->protocol;
@ -1487,7 +1495,15 @@ sr_up(struct sr_softc *sc)
default:
sc->ifsppp.pp_flags = PP_KEEPALIVE;
sppp_attach(&sc->ifsppp.pp_if);
}
/*
* Shortcut the sppp tls/tlf actions to
* up/down events since our lower layer is
* always ready.
*/
sc->ifsppp.pp_tls = sc->ifsppp.pp_up;
sc->ifsppp.pp_tlf = sc->ifsppp.pp_down;
}
sc->attached = sc->protocol;
}

View File

@ -2,7 +2,10 @@
* Defines for synchronous PPP/Cisco link level subroutines.
*
* Copyright (C) 1994 Cronyx Ltd.
* Author: Serge Vakulenko, <vak@zebub.msk.su>
* Author: Serge Vakulenko, <vak@cronyx.ru>
*
* 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.
@ -11,25 +14,53 @@
* 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 1.7, Wed Jun 7 22:12:02 MSD 1995
*
* $Id$
*/
#ifndef _NET_IF_HDLC_H_
#define _NET_IF_HDLC_H_ 1
#define IDX_LCP 0 /* idx into state table */
struct slcp {
u_short state; /* state machine */
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 */
u_char confid; /* id of last configuration 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_short state; /* state machine */
u_char confid; /* id of last configuration request */
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 IDX_COUNT (IDX_IPCP + 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 {
/* NB: pp_if _must_ be first */
struct ifnet pp_if; /* network interface data */
struct ifqueue pp_fastq; /* fast output queue */
struct sppp *pp_next; /* next interface in keepalive list */
@ -38,25 +69,38 @@ struct sppp {
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 */
struct slcp lcp; /* LCP params */
struct sipcp ipcp; /* IPCP params */
/*
* 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);
};
#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 */
#define PP_MTU 1500 /* max. transmit unit */
#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 */
#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 PP_MTU 1500 /* default/minimal MRU */
#define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
#ifdef KERNEL
void sppp_attach (struct ifnet *ifp);

File diff suppressed because it is too large Load Diff