if_sppp.h revision 26018
11823Sphk/*
245943Sobrien * Defines for synchronous PPP/Cisco link level subroutines.
31823Sphk *
41823Sphk * Copyright (C) 1994 Cronyx Ltd.
545763Sobrien * Author: Serge Vakulenko, <vak@cronyx.ru>
645763Sobrien *
718390Speter * Heavily revamped to conform to RFC 1661.
818390Speter * Copyright (C) 1997, Joerg Wunsch.
945299Sobrien *
102375Sbde * This software is distributed with NO WARRANTIES, not even the implied
1118390Speter * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1218390Speter *
1345943Sobrien * Authors grant any other persons or organizations permission to use
1445943Sobrien * or modify this software as long as this message is kept with the software,
1545943Sobrien * all derivative works or modified versions.
1645943Sobrien *
1745943Sobrien * From: Version 1.7, Wed Jun  7 22:12:02 MSD 1995
1845943Sobrien *
1918390Speter * $Id: if_sppp.h,v 1.5 1997/05/19 22:03:08 joerg Exp $
2045943Sobrien */
2145943Sobrien
2245943Sobrien#ifndef _NET_IF_HDLC_H_
2334229Speter#define _NET_IF_HDLC_H_ 1
2445299Sobrien
2545299Sobrien#define IDX_LCP 0		/* idx into state table */
2645943Sobrien
2745299Sobrienstruct slcp {
2845299Sobrien	u_long	opts;		/* LCP options to send (bitfield) */
2945299Sobrien	u_long  magic;          /* local magic number */
3018390Speter	u_long	mru;		/* our max receive unit */
3145299Sobrien	u_long	their_mru;	/* their max receive unit */
3218390Speter	u_long	protos;		/* bitmask of protos that are started */
3318390Speter	u_char  echoid;         /* id of last keepalive echo request */
3445765Sobrien	/* restart max values, see RFC 1661 */
3518390Speter	int	timeout;
3618390Speter	int	max_terminate;
3718390Speter	int	max_configure;
3845299Sobrien	int	max_failure;
3945299Sobrien};
4045299Sobrien
4145299Sobrien#define IDX_IPCP 1		/* idx into state table */
4245943Sobrien
4345943Sobrienstruct sipcp {
4445943Sobrien	u_long	opts;		/* IPCP options to send (bitfield) */
4545943Sobrien	u_int	flags;
4645943Sobrien#define IPCP_HISADDR_SEEN 1	/* have seen his address already */
4745943Sobrien#define IPCP_MYADDR_DYN   2	/* my address is dynamically assigned */
4845943Sobrien};
4945943Sobrien
5018390Speter#define IDX_COUNT (IDX_IPCP + 1) /* bump this when adding cp's! */
5118390Speter
5245301Sobrien/*
5318390Speter * Don't change the order of this.  Ordering the phases this way allows
5418390Speter * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
5516663Sjkh * know whether LCP is up.
5616663Sjkh */
5745299Sobrienenum ppp_phase {
582375Sbde	PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
592375Sbde	PHASE_AUTHENTICATE, PHASE_NETWORK
6045299Sobrien};
612375Sbde
622375Sbdestruct sppp {
632907Swollman	/* NB: pp_if _must_ be first */
6418390Speter	struct  ifnet pp_if;    /* network interface data */
6545299Sobrien	struct  ifqueue pp_fastq; /* fast output queue */
66	struct	ifqueue pp_cpq;	/* PPP control protocol queue */
67	struct  sppp *pp_next;  /* next interface in keepalive list */
68	u_int   pp_flags;       /* use Cisco protocol instead of PPP */
69	u_short pp_alivecnt;    /* keepalive packets counter */
70	u_short pp_loopcnt;     /* loopback detection counter */
71	u_long  pp_seq;         /* local sequence number */
72	u_long  pp_rseq;        /* remote sequence number */
73	enum ppp_phase pp_phase;	/* phase we're currently in */
74	int	state[IDX_COUNT];	/* state machine */
75	u_char  confid[IDX_COUNT];	/* id of last configuration request */
76	int	rst_counter[IDX_COUNT];	/* restart counter */
77	int	fail_counter[IDX_COUNT]; /* negotiation failure counter */
78	struct slcp lcp;        /* LCP params */
79	struct sipcp ipcp;      /* IPCP params */
80	/*
81	 * These functions are filled in by sppp_attach(), and are
82	 * expected to be used by the lower layer (hardware) drivers
83	 * in order to communicate the (un)availability of the
84	 * communication link.  Lower layer drivers that are always
85	 * ready to communicate (like hardware HDLC) can shortcut
86	 * pp_up from pp_tls, and pp_down from pp_tlf.
87	 */
88	void	(*pp_up)(struct sppp *sp);
89	void	(*pp_down)(struct sppp *sp);
90	/*
91	 * These functions need to be filled in by the lower layer
92	 * (hardware) drivers if they request notification from the
93	 * PPP layer whether the link is actually required.  They
94	 * correspond to the tls and tlf actions.
95	 */
96	void	(*pp_tls)(struct sppp *sp);
97	void	(*pp_tlf)(struct sppp *sp);
98};
99
100#define PP_KEEPALIVE    0x01    /* use keepalive protocol */
101#define PP_CISCO        0x02    /* use Cisco protocol instead of PPP */
102
103#define PP_MTU          1500    /* default/minimal MRU */
104#define PP_MAX_MRU	2048	/* maximal MRU we want to negotiate */
105
106#ifdef KERNEL
107void sppp_attach (struct ifnet *ifp);
108void sppp_detach (struct ifnet *ifp);
109void sppp_input (struct ifnet *ifp, struct mbuf *m);
110int sppp_ioctl (struct ifnet *ifp, int cmd, void *data);
111struct mbuf *sppp_dequeue (struct ifnet *ifp);
112int sppp_isempty (struct ifnet *ifp);
113void sppp_flush (struct ifnet *ifp);
114#endif
115
116#endif /* _NET_IF_HDLC_H_ */
117