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