Home | History | Annotate | Line # | Download | only in net
if_sppp.h revision 1.7.2.2
      1  1.7.2.2   nathanw /*	$NetBSD: if_sppp.h,v 1.7.2.2 2001/06/21 20:08:12 nathanw Exp $	*/
      2      1.4  explorer 
      3      1.1  explorer /*
      4      1.1  explorer  * Defines for synchronous PPP/Cisco link level subroutines.
      5      1.1  explorer  *
      6      1.1  explorer  * Copyright (C) 1994 Cronyx Ltd.
      7      1.3  explorer  * Author: Serge Vakulenko, <vak (at) cronyx.ru>
      8      1.3  explorer  *
      9      1.3  explorer  * Heavily revamped to conform to RFC 1661.
     10      1.3  explorer  * Copyright (C) 1997, Joerg Wunsch.
     11      1.1  explorer  *
     12      1.1  explorer  * This software is distributed with NO WARRANTIES, not even the implied
     13      1.1  explorer  * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     14      1.1  explorer  *
     15      1.1  explorer  * Authors grant any other persons or organizations permission to use
     16      1.1  explorer  * or modify this software as long as this message is kept with the software,
     17      1.1  explorer  * all derivative works or modified versions.
     18      1.1  explorer  *
     19      1.3  explorer  * From: Version 2.0, Fri Oct  6 20:39:21 MSK 1995
     20      1.3  explorer  *
     21      1.3  explorer  * From: if_sppp.h,v 1.8 1997/10/11 11:25:20 joerg Exp
     22      1.3  explorer  *
     23      1.4  explorer  * From: Id: if_sppp.h,v 1.7 1998/12/01 20:20:19 hm Exp
     24      1.1  explorer  */
     25      1.1  explorer 
     26      1.1  explorer #ifndef _NET_IF_HDLC_H_
     27      1.1  explorer #define _NET_IF_HDLC_H_ 1
     28      1.1  explorer 
     29      1.5   thorpej #include <sys/callout.h>
     30      1.5   thorpej 
     31      1.3  explorer #define IDX_LCP 0		/* idx into state table */
     32      1.3  explorer 
     33      1.1  explorer struct slcp {
     34      1.3  explorer 	u_long	opts;		/* LCP options to send (bitfield) */
     35      1.3  explorer 	u_long  magic;          /* local magic number */
     36      1.3  explorer 	u_long	mru;		/* our max receive unit */
     37      1.3  explorer 	u_long	their_mru;	/* their max receive unit */
     38      1.3  explorer 	u_long	protos;		/* bitmask of protos that are started */
     39      1.3  explorer 	u_char  echoid;         /* id of last keepalive echo request */
     40      1.3  explorer 	/* restart max values, see RFC 1661 */
     41      1.3  explorer 	int	timeout;
     42      1.3  explorer 	int	max_terminate;
     43      1.3  explorer 	int	max_configure;
     44      1.3  explorer 	int	max_failure;
     45      1.1  explorer };
     46      1.1  explorer 
     47      1.3  explorer #define IDX_IPCP 1		/* idx into state table */
     48      1.6    itojun #define IDX_IPV6CP 2		/* idx into state table */
     49      1.3  explorer 
     50      1.1  explorer struct sipcp {
     51      1.3  explorer 	u_long	opts;		/* IPCP options to send (bitfield) */
     52      1.3  explorer 	u_int	flags;
     53      1.3  explorer #define IPCP_HISADDR_SEEN 1	/* have seen his address already */
     54      1.3  explorer #define IPCP_MYADDR_DYN   2	/* my address is dynamically assigned */
     55      1.3  explorer #define IPCP_MYADDR_SEEN  4	/* have seen his address already */
     56      1.6    itojun #ifdef notdef
     57      1.6    itojun #define IPV6CP_MYIFID_DYN   2	/* my ifid is dynamically assigned */
     58      1.6    itojun #endif
     59      1.6    itojun #define IPV6CP_MYIFID_SEEN  4	/* have seen his ifid already */
     60      1.3  explorer };
     61      1.3  explorer 
     62  1.7.2.2   nathanw #define AUTHNAMELEN	48
     63      1.3  explorer #define AUTHKEYLEN	16
     64      1.3  explorer 
     65      1.3  explorer struct sauth {
     66      1.3  explorer 	u_short	proto;			/* authentication protocol to use */
     67      1.3  explorer 	u_short	flags;
     68      1.3  explorer #define AUTHFLAG_NOCALLOUT	1	/* do not require authentication on */
     69      1.3  explorer 					/* callouts */
     70      1.3  explorer #define AUTHFLAG_NORECHALLENGE	2	/* do not re-challenge CHAP */
     71      1.3  explorer 	u_char	name[AUTHNAMELEN];	/* system identification name */
     72      1.3  explorer 	u_char	secret[AUTHKEYLEN];	/* secret password */
     73      1.3  explorer 	u_char	challenge[AUTHKEYLEN];	/* random challenge */
     74      1.3  explorer };
     75      1.3  explorer 
     76      1.6    itojun #define IDX_PAP		3
     77      1.6    itojun #define IDX_CHAP	4
     78      1.3  explorer 
     79      1.3  explorer #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
     80      1.3  explorer 
     81      1.3  explorer /*
     82      1.3  explorer  * Don't change the order of this.  Ordering the phases this way allows
     83      1.3  explorer  * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
     84      1.3  explorer  * know whether LCP is up.
     85      1.3  explorer  */
     86      1.3  explorer enum ppp_phase {
     87      1.3  explorer 	PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
     88      1.3  explorer 	PHASE_AUTHENTICATE, PHASE_NETWORK
     89      1.1  explorer };
     90      1.1  explorer 
     91      1.1  explorer struct sppp {
     92      1.3  explorer 	/* NB: pp_if _must_ be first */
     93      1.3  explorer 	struct  ifnet pp_if;    /* network interface data */
     94      1.3  explorer 	struct  ifqueue pp_fastq; /* fast output queue */
     95      1.3  explorer 	struct	ifqueue pp_cpq;	/* PPP control protocol queue */
     96      1.3  explorer 	struct  sppp *pp_next;  /* next interface in keepalive list */
     97      1.3  explorer 	u_int   pp_flags;       /* use Cisco protocol instead of PPP */
     98  1.7.2.2   nathanw 	u_int	pp_framebytes;	/* number of bytes added by (hardware) framing */
     99      1.3  explorer 	u_short pp_alivecnt;    /* keepalive packets counter */
    100      1.3  explorer 	u_short pp_loopcnt;     /* loopback detection counter */
    101      1.6    itojun 	u_long  pp_seq[IDX_COUNT];	/* local sequence number */
    102      1.6    itojun 	u_long  pp_rseq[IDX_COUNT];	/* remote sequence number */
    103      1.3  explorer 	enum ppp_phase pp_phase;	/* phase we're currently in */
    104      1.3  explorer 	int	state[IDX_COUNT];	/* state machine */
    105      1.3  explorer 	u_char  confid[IDX_COUNT];	/* id of last configuration request */
    106      1.3  explorer 	int	rst_counter[IDX_COUNT];	/* restart counter */
    107      1.3  explorer 	int	fail_counter[IDX_COUNT]; /* negotiation failure counter */
    108      1.5   thorpej #if defined(__NetBSD__)
    109      1.5   thorpej 	struct	callout ch[IDX_COUNT];	/* per-proto and if callouts */
    110      1.5   thorpej 	struct	callout pap_my_to_ch;	/* PAP needs one more... */
    111      1.5   thorpej #endif
    112      1.3  explorer #if defined(__FreeBSD__) && __FreeBSD__ >= 3
    113      1.3  explorer 	struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */
    114      1.3  explorer 	struct callout_handle pap_my_to_ch; /* PAP needs one more... */
    115      1.3  explorer #endif
    116      1.3  explorer 	struct slcp lcp;		/* LCP params */
    117      1.3  explorer 	struct sipcp ipcp;		/* IPCP params */
    118      1.6    itojun 	struct sipcp ipv6cp;		/* IPv6CP params */
    119      1.3  explorer 	struct sauth myauth;		/* auth params, i'm peer */
    120      1.3  explorer 	struct sauth hisauth;		/* auth params, i'm authenticator */
    121      1.3  explorer 	/*
    122      1.3  explorer 	 * These functions are filled in by sppp_attach(), and are
    123      1.3  explorer 	 * expected to be used by the lower layer (hardware) drivers
    124      1.3  explorer 	 * in order to communicate the (un)availability of the
    125      1.3  explorer 	 * communication link.  Lower layer drivers that are always
    126      1.3  explorer 	 * ready to communicate (like hardware HDLC) can shortcut
    127      1.3  explorer 	 * pp_up from pp_tls, and pp_down from pp_tlf.
    128      1.3  explorer 	 */
    129      1.3  explorer 	void	(*pp_up)(struct sppp *sp);
    130      1.3  explorer 	void	(*pp_down)(struct sppp *sp);
    131      1.3  explorer 	/*
    132      1.3  explorer 	 * These functions need to be filled in by the lower layer
    133      1.3  explorer 	 * (hardware) drivers if they request notification from the
    134      1.3  explorer 	 * PPP layer whether the link is actually required.  They
    135      1.3  explorer 	 * correspond to the tls and tlf actions.
    136      1.3  explorer 	 */
    137      1.3  explorer 	void	(*pp_tls)(struct sppp *sp);
    138      1.3  explorer 	void	(*pp_tlf)(struct sppp *sp);
    139      1.3  explorer 	/*
    140      1.3  explorer 	 * These (optional) functions may be filled by the hardware
    141      1.3  explorer 	 * driver if any notification of established connections
    142      1.3  explorer 	 * (currently: IPCP up) is desired (pp_con) or any internal
    143      1.3  explorer 	 * state change of the interface state machine should be
    144      1.3  explorer 	 * signaled for monitoring purposes (pp_chg).
    145      1.3  explorer 	 */
    146      1.3  explorer 	void	(*pp_con)(struct sppp *sp);
    147      1.3  explorer 	void	(*pp_chg)(struct sppp *sp, int new_state);
    148      1.1  explorer };
    149      1.1  explorer 
    150      1.1  explorer #define PP_KEEPALIVE    0x01    /* use keepalive protocol */
    151      1.1  explorer #define PP_CISCO        0x02    /* use Cisco protocol instead of PPP */
    152      1.3  explorer 				/* 0x04 was PP_TIMO */
    153      1.3  explorer #define PP_CALLIN	0x08	/* we are being called */
    154      1.3  explorer #define PP_NEEDAUTH	0x10	/* remote requested authentication */
    155  1.7.2.2   nathanw #define	PP_NOFRAMING	0x20	/* do not add/expect encapsulation
    156  1.7.2.2   nathanw 				   around PPP frames (i.e. the serial
    157  1.7.2.2   nathanw 				   HDLC like encapsulation, RFC1662) */
    158      1.1  explorer 
    159      1.1  explorer 
    160      1.3  explorer #define PP_MTU          1500    /* default/minimal MRU */
    161      1.3  explorer #define PP_MAX_MRU	2048	/* maximal MRU we want to negotiate */
    162      1.3  explorer 
    163      1.3  explorer /*
    164      1.3  explorer  * Definitions to pass struct sppp data down into the kernel using the
    165      1.3  explorer  * SIOC[SG]IFGENERIC ioctl interface.
    166      1.3  explorer  *
    167      1.3  explorer  * In order to use this, create a struct spppreq, fill in the cmd
    168      1.3  explorer  * field with SPPPIOGDEFS, and put the address of this structure into
    169      1.3  explorer  * the ifr_data portion of a struct ifreq.  Pass this struct to a
    170      1.3  explorer  * SIOCGIFGENERIC ioctl.  Then replace the cmd field by SPPPIOCDEFS,
    171      1.3  explorer  * modify the defs field as desired, and pass the struct ifreq now
    172      1.3  explorer  * to a SIOCSIFGENERIC ioctl.
    173      1.3  explorer  */
    174      1.3  explorer 
    175      1.3  explorer #define SPPPIOGDEFS  ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
    176      1.3  explorer #define SPPPIOSDEFS  ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
    177      1.3  explorer 
    178      1.3  explorer struct spppreq {
    179      1.3  explorer 	int	cmd;
    180      1.3  explorer 	struct sppp defs;
    181      1.3  explorer };
    182      1.3  explorer 
    183      1.3  explorer #if (defined(__FreeBSD_version) && __FreeBSD_version < 300000)  ||	\
    184      1.7        ad     (defined(__FreeBSD__) && __FreeBSD__ < 3)
    185      1.3  explorer #define	SIOCSIFGENERIC	 _IOW('i', 57, struct ifreq)	/* generic IF set op */
    186      1.3  explorer #define	SIOCGIFGENERIC	_IOWR('i', 58, struct ifreq)	/* generic IF get op */
    187      1.3  explorer #endif
    188      1.1  explorer 
    189      1.3  explorer #if defined(KERNEL) || defined(_KERNEL)
    190      1.1  explorer void sppp_attach (struct ifnet *ifp);
    191      1.1  explorer void sppp_detach (struct ifnet *ifp);
    192      1.1  explorer void sppp_input (struct ifnet *ifp, struct mbuf *m);
    193      1.3  explorer int sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data);
    194      1.1  explorer struct mbuf *sppp_dequeue (struct ifnet *ifp);
    195      1.3  explorer struct mbuf *sppp_pick(struct ifnet *ifp);
    196      1.1  explorer int sppp_isempty (struct ifnet *ifp);
    197      1.1  explorer void sppp_flush (struct ifnet *ifp);
    198      1.1  explorer #endif
    199      1.1  explorer 
    200      1.1  explorer #endif /* _NET_IF_HDLC_H_ */
    201