Home | History | Annotate | Line # | Download | only in net
if_spppvar.h revision 1.2
      1  1.2  martin /*	$NetBSD: if_spppvar.h,v 1.2 2002/01/06 20:14:30 martin Exp $	*/
      2  1.1  martin 
      3  1.1  martin /*
      4  1.1  martin  * Defines for synchronous PPP/Cisco link level subroutines.
      5  1.1  martin  *
      6  1.1  martin  * Copyright (C) 1994 Cronyx Ltd.
      7  1.1  martin  * Author: Serge Vakulenko, <vak (at) cronyx.ru>
      8  1.1  martin  *
      9  1.1  martin  * Heavily revamped to conform to RFC 1661.
     10  1.1  martin  * Copyright (C) 1997, Joerg Wunsch.
     11  1.1  martin  *
     12  1.1  martin  * This software is distributed with NO WARRANTIES, not even the implied
     13  1.1  martin  * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     14  1.1  martin  *
     15  1.1  martin  * Authors grant any other persons or organizations permission to use
     16  1.1  martin  * or modify this software as long as this message is kept with the software,
     17  1.1  martin  * all derivative works or modified versions.
     18  1.1  martin  *
     19  1.1  martin  * From: Version 2.0, Fri Oct  6 20:39:21 MSK 1995
     20  1.1  martin  *
     21  1.1  martin  * From: if_sppp.h,v 1.8 1997/10/11 11:25:20 joerg Exp
     22  1.1  martin  *
     23  1.1  martin  * From: Id: if_sppp.h,v 1.7 1998/12/01 20:20:19 hm Exp
     24  1.1  martin  */
     25  1.1  martin 
     26  1.1  martin #define IDX_LCP 0		/* idx into state table */
     27  1.1  martin 
     28  1.1  martin struct slcp {
     29  1.1  martin 	u_long	opts;		/* LCP options to send (bitfield) */
     30  1.1  martin 	u_long  magic;          /* local magic number */
     31  1.1  martin 	u_long	mru;		/* our max receive unit */
     32  1.1  martin 	u_long	their_mru;	/* their max receive unit */
     33  1.1  martin 	u_long	protos;		/* bitmask of protos that are started */
     34  1.1  martin 	u_char  echoid;         /* id of last keepalive echo request */
     35  1.1  martin 	/* restart max values, see RFC 1661 */
     36  1.1  martin 	int	timeout;
     37  1.1  martin 	int	max_terminate;
     38  1.1  martin 	int	max_configure;
     39  1.1  martin 	int	max_failure;
     40  1.1  martin };
     41  1.1  martin 
     42  1.1  martin #define IDX_IPCP 1		/* idx into state table */
     43  1.1  martin #define IDX_IPV6CP 2		/* idx into state table */
     44  1.1  martin 
     45  1.1  martin struct sipcp {
     46  1.1  martin 	u_long	opts;		/* IPCP options to send (bitfield) */
     47  1.1  martin 	u_int	flags;
     48  1.1  martin #define IPCP_HISADDR_SEEN 1	/* have seen his address already */
     49  1.1  martin #define IPCP_MYADDR_SEEN  2	/* have a local address assigned already */
     50  1.1  martin #define IPCP_MYADDR_DYN   4	/* my address is dynamically assigned */
     51  1.1  martin #define	IPCP_HISADDR_DYN  8	/* his address is dynamically assigned */
     52  1.1  martin #ifdef notdef
     53  1.1  martin #define IPV6CP_MYIFID_DYN   2	/* my ifid is dynamically assigned */
     54  1.1  martin #endif
     55  1.1  martin #define IPV6CP_MYIFID_SEEN  4	/* have seen his ifid already */
     56  1.1  martin 	u_int32_t saved_hisaddr;/* if hisaddr (IPv4) is dynamic, save original one here, in network byte order */
     57  1.1  martin 	u_int32_t req_hisaddr;	/* remote address requested */
     58  1.1  martin 	u_int32_t req_myaddr;	/* local address requested */
     59  1.1  martin };
     60  1.1  martin 
     61  1.1  martin struct sauth {
     62  1.1  martin 	u_short	proto;			/* authentication protocol to use */
     63  1.1  martin 	u_short	flags;
     64  1.1  martin 	char	*name;			/* system identification name */
     65  1.1  martin 	char	*secret;		/* secret password */
     66  1.1  martin 	char	challenge[16];		/* random challenge [don't change size! it's realy hardcoded!] */
     67  1.1  martin };
     68  1.1  martin 
     69  1.1  martin #define IDX_PAP		3
     70  1.1  martin #define IDX_CHAP	4
     71  1.1  martin 
     72  1.1  martin #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
     73  1.1  martin 
     74  1.1  martin struct sppp {
     75  1.1  martin 	/* NB: pp_if _must_ be first */
     76  1.1  martin 	struct  ifnet pp_if;    /* network interface data */
     77  1.1  martin 	struct  ifqueue pp_fastq; /* fast output queue */
     78  1.1  martin 	struct	ifqueue pp_cpq;	/* PPP control protocol queue */
     79  1.1  martin 	struct  sppp *pp_next;  /* next interface in keepalive list */
     80  1.1  martin 	u_int   pp_flags;       /* use Cisco protocol instead of PPP */
     81  1.1  martin 	u_int	pp_framebytes;	/* number of bytes added by (hardware) framing */
     82  1.1  martin 	u_short pp_alivecnt;    /* keepalive packets counter */
     83  1.1  martin 	u_short pp_loopcnt;     /* loopback detection counter */
     84  1.1  martin 	u_long  pp_seq[IDX_COUNT];	/* local sequence number */
     85  1.1  martin 	u_long  pp_rseq[IDX_COUNT];	/* remote sequence number */
     86  1.2  martin 	time_t	pp_last_activity;	/* second of last payload data s/r */
     87  1.2  martin 	time_t	pp_idle_timeout;	/* idle seconds before auto-disconnect,
     88  1.2  martin 					 * 0 = disabled */
     89  1.1  martin 	int	pp_phase;	/* phase we're currently in */
     90  1.1  martin 	int	state[IDX_COUNT];	/* state machine */
     91  1.1  martin 	u_char  confid[IDX_COUNT];	/* id of last configuration request */
     92  1.1  martin 	int	rst_counter[IDX_COUNT];	/* restart counter */
     93  1.1  martin 	int	fail_counter[IDX_COUNT]; /* negotiation failure counter */
     94  1.1  martin #if defined(__NetBSD__)
     95  1.1  martin 	struct	callout ch[IDX_COUNT];	/* per-proto and if callouts */
     96  1.1  martin 	struct	callout pap_my_to_ch;	/* PAP needs one more... */
     97  1.1  martin #endif
     98  1.1  martin #if defined(__FreeBSD__) && __FreeBSD__ >= 3
     99  1.1  martin 	struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */
    100  1.1  martin 	struct callout_handle pap_my_to_ch; /* PAP needs one more... */
    101  1.1  martin #endif
    102  1.1  martin 	struct slcp lcp;		/* LCP params */
    103  1.1  martin 	struct sipcp ipcp;		/* IPCP params */
    104  1.1  martin 	struct sipcp ipv6cp;		/* IPv6CP params */
    105  1.1  martin 	struct sauth myauth;		/* auth params, i'm peer */
    106  1.1  martin 	struct sauth hisauth;		/* auth params, i'm authenticator */
    107  1.1  martin 	/*
    108  1.1  martin 	 * These functions are filled in by sppp_attach(), and are
    109  1.1  martin 	 * expected to be used by the lower layer (hardware) drivers
    110  1.1  martin 	 * in order to communicate the (un)availability of the
    111  1.1  martin 	 * communication link.  Lower layer drivers that are always
    112  1.1  martin 	 * ready to communicate (like hardware HDLC) can shortcut
    113  1.1  martin 	 * pp_up from pp_tls, and pp_down from pp_tlf.
    114  1.1  martin 	 */
    115  1.1  martin 	void	(*pp_up)(struct sppp *sp);
    116  1.1  martin 	void	(*pp_down)(struct sppp *sp);
    117  1.1  martin 	/*
    118  1.1  martin 	 * These functions need to be filled in by the lower layer
    119  1.1  martin 	 * (hardware) drivers if they request notification from the
    120  1.1  martin 	 * PPP layer whether the link is actually required.  They
    121  1.1  martin 	 * correspond to the tls and tlf actions.
    122  1.1  martin 	 */
    123  1.1  martin 	void	(*pp_tls)(struct sppp *sp);
    124  1.1  martin 	void	(*pp_tlf)(struct sppp *sp);
    125  1.1  martin 	/*
    126  1.1  martin 	 * These (optional) functions may be filled by the hardware
    127  1.1  martin 	 * driver if any notification of established connections
    128  1.1  martin 	 * (currently: IPCP up) is desired (pp_con) or any internal
    129  1.1  martin 	 * state change of the interface state machine should be
    130  1.1  martin 	 * signaled for monitoring purposes (pp_chg).
    131  1.1  martin 	 */
    132  1.1  martin 	void	(*pp_con)(struct sppp *sp);
    133  1.1  martin 	void	(*pp_chg)(struct sppp *sp, int new_state);
    134  1.1  martin };
    135  1.1  martin 
    136  1.1  martin #define PP_KEEPALIVE    0x01    /* use keepalive protocol */
    137  1.1  martin #define PP_CISCO        0x02    /* use Cisco protocol instead of PPP */
    138  1.1  martin 				/* 0x04 was PP_TIMO */
    139  1.1  martin #define PP_CALLIN	0x08	/* we are being called */
    140  1.1  martin #define PP_NEEDAUTH	0x10	/* remote requested authentication */
    141  1.1  martin #define	PP_NOFRAMING	0x20	/* do not add/expect encapsulation
    142  1.1  martin 				   around PPP frames (i.e. the serial
    143  1.1  martin 				   HDLC like encapsulation, RFC1662) */
    144  1.1  martin 
    145  1.1  martin 
    146  1.1  martin #define PP_MTU          1500    /* default/minimal MRU */
    147  1.1  martin #define PP_MAX_MRU	2048	/* maximal MRU we want to negotiate */
    148  1.1  martin 
    149  1.1  martin #ifdef _KERNEL
    150  1.1  martin void sppp_attach (struct ifnet *ifp);
    151  1.1  martin void sppp_detach (struct ifnet *ifp);
    152  1.1  martin void sppp_input (struct ifnet *ifp, struct mbuf *m);
    153  1.1  martin int sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data);
    154  1.1  martin struct mbuf *sppp_dequeue (struct ifnet *ifp);
    155  1.1  martin struct mbuf *sppp_pick(struct ifnet *ifp);
    156  1.1  martin int sppp_isempty (struct ifnet *ifp);
    157  1.1  martin void sppp_flush (struct ifnet *ifp);
    158  1.1  martin #endif
    159