if_sppp.h revision 41687
14910Swollman/*
24910Swollman * Defines for synchronous PPP/Cisco link level subroutines.
34910Swollman *
44910Swollman * Copyright (C) 1994 Cronyx Ltd.
525944Sjoerg * Author: Serge Vakulenko, <vak@cronyx.ru>
64910Swollman *
725944Sjoerg * Heavily revamped to conform to RFC 1661.
825944Sjoerg * Copyright (C) 1997, Joerg Wunsch.
925944Sjoerg *
104910Swollman * This software is distributed with NO WARRANTIES, not even the implied
114910Swollman * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
124910Swollman *
1313765Smpp * Authors grant any other persons or organizations permission to use
144910Swollman * or modify this software as long as this message is kept with the software,
154910Swollman * all derivative works or modified versions.
164910Swollman *
1730300Sjoerg * From: Version 2.0, Fri Oct  6 20:39:21 MSK 1995
1825944Sjoerg *
1941687Sphk * $Id: if_sppp.h,v 1.10 1998/12/11 21:40:13 phk Exp $
204910Swollman */
214910Swollman
2241687Sphk#ifndef _NET_IF_SPPP_H_
2341687Sphk#define _NET_IF_SPPP_H_ 1
244910Swollman
2525944Sjoerg#define IDX_LCP 0		/* idx into state table */
2625944Sjoerg
274910Swollmanstruct slcp {
2825944Sjoerg	u_long	opts;		/* LCP options to send (bitfield) */
294910Swollman	u_long  magic;          /* local magic number */
3025944Sjoerg	u_long	mru;		/* our max receive unit */
3125944Sjoerg	u_long	their_mru;	/* their max receive unit */
3225944Sjoerg	u_long	protos;		/* bitmask of protos that are started */
3311189Sjkh	u_char  echoid;         /* id of last keepalive echo request */
3425944Sjoerg	/* restart max values, see RFC 1661 */
3525944Sjoerg	int	timeout;
3625944Sjoerg	int	max_terminate;
3725944Sjoerg	int	max_configure;
3825944Sjoerg	int	max_failure;
394910Swollman};
404910Swollman
4125944Sjoerg#define IDX_IPCP 1		/* idx into state table */
4225944Sjoerg
434910Swollmanstruct sipcp {
4425944Sjoerg	u_long	opts;		/* IPCP options to send (bitfield) */
4525944Sjoerg	u_int	flags;
4625944Sjoerg#define IPCP_HISADDR_SEEN 1	/* have seen his address already */
4725944Sjoerg#define IPCP_MYADDR_DYN   2	/* my address is dynamically assigned */
484910Swollman};
494910Swollman
5030300Sjoerg#define AUTHNAMELEN	32
5130300Sjoerg#define AUTHKEYLEN	16
5225944Sjoerg
5330300Sjoergstruct sauth {
5430300Sjoerg	u_short	proto;			/* authentication protocol to use */
5530300Sjoerg	u_short	flags;
5630300Sjoerg#define AUTHFLAG_NOCALLOUT	1	/* do not require authentication on */
5730300Sjoerg					/* callouts */
5830300Sjoerg#define AUTHFLAG_NORECHALLENGE	2	/* do not re-challenge CHAP */
5930300Sjoerg	u_char	name[AUTHNAMELEN];	/* system identification name */
6030300Sjoerg	u_char	secret[AUTHKEYLEN];	/* secret password */
6130300Sjoerg	u_char	challenge[AUTHKEYLEN];	/* random challenge */
6230300Sjoerg};
6330300Sjoerg
6430300Sjoerg#define IDX_PAP		2
6530300Sjoerg#define IDX_CHAP	3
6630300Sjoerg
6730300Sjoerg#define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
6830300Sjoerg
6925944Sjoerg/*
7025944Sjoerg * Don't change the order of this.  Ordering the phases this way allows
7125944Sjoerg * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
7225944Sjoerg * know whether LCP is up.
7325944Sjoerg */
7425944Sjoergenum ppp_phase {
7525944Sjoerg	PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
7625944Sjoerg	PHASE_AUTHENTICATE, PHASE_NETWORK
7725944Sjoerg};
7825944Sjoerg
794910Swollmanstruct sppp {
8025944Sjoerg	/* NB: pp_if _must_ be first */
814910Swollman	struct  ifnet pp_if;    /* network interface data */
824910Swollman	struct  ifqueue pp_fastq; /* fast output queue */
8326018Sjoerg	struct	ifqueue pp_cpq;	/* PPP control protocol queue */
844910Swollman	struct  sppp *pp_next;  /* next interface in keepalive list */
854910Swollman	u_int   pp_flags;       /* use Cisco protocol instead of PPP */
864910Swollman	u_short pp_alivecnt;    /* keepalive packets counter */
874910Swollman	u_short pp_loopcnt;     /* loopback detection counter */
884910Swollman	u_long  pp_seq;         /* local sequence number */
894910Swollman	u_long  pp_rseq;        /* remote sequence number */
9025944Sjoerg	enum ppp_phase pp_phase;	/* phase we're currently in */
9125944Sjoerg	int	state[IDX_COUNT];	/* state machine */
9225944Sjoerg	u_char  confid[IDX_COUNT];	/* id of last configuration request */
9325944Sjoerg	int	rst_counter[IDX_COUNT];	/* restart counter */
9425944Sjoerg	int	fail_counter[IDX_COUNT]; /* negotiation failure counter */
9530300Sjoerg	struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */
9630300Sjoerg	struct callout_handle pap_my_to_ch; /* PAP needs one more... */
9730300Sjoerg	struct slcp lcp;		/* LCP params */
9830300Sjoerg	struct sipcp ipcp;		/* IPCP params */
9930300Sjoerg	struct sauth myauth;		/* auth params, i'm peer */
10030300Sjoerg	struct sauth hisauth;		/* auth params, i'm authenticator */
10125944Sjoerg	/*
10225944Sjoerg	 * These functions are filled in by sppp_attach(), and are
10325944Sjoerg	 * expected to be used by the lower layer (hardware) drivers
10425944Sjoerg	 * in order to communicate the (un)availability of the
10525944Sjoerg	 * communication link.  Lower layer drivers that are always
10625944Sjoerg	 * ready to communicate (like hardware HDLC) can shortcut
10725944Sjoerg	 * pp_up from pp_tls, and pp_down from pp_tlf.
10825944Sjoerg	 */
10925944Sjoerg	void	(*pp_up)(struct sppp *sp);
11025944Sjoerg	void	(*pp_down)(struct sppp *sp);
11125944Sjoerg	/*
11225944Sjoerg	 * These functions need to be filled in by the lower layer
11325944Sjoerg	 * (hardware) drivers if they request notification from the
11425944Sjoerg	 * PPP layer whether the link is actually required.  They
11525944Sjoerg	 * correspond to the tls and tlf actions.
11625944Sjoerg	 */
11725944Sjoerg	void	(*pp_tls)(struct sppp *sp);
11825944Sjoerg	void	(*pp_tlf)(struct sppp *sp);
1194910Swollman};
1204910Swollman
1214910Swollman#define PP_KEEPALIVE    0x01    /* use keepalive protocol */
1224910Swollman#define PP_CISCO        0x02    /* use Cisco protocol instead of PPP */
12330300Sjoerg				/* 0x04 was PP_TIMO */
12430300Sjoerg#define PP_CALLIN	0x08	/* we are being called */
12530300Sjoerg#define PP_NEEDAUTH	0x10	/* remote requested authentication */
1264910Swollman
12730300Sjoerg
12825944Sjoerg#define PP_MTU          1500    /* default/minimal MRU */
12925944Sjoerg#define PP_MAX_MRU	2048	/* maximal MRU we want to negotiate */
1304910Swollman
13130300Sjoerg/*
13230300Sjoerg * Definitions to pass struct sppp data down into the kernel using the
13330300Sjoerg * SIOC[SG]IFGENERIC ioctl interface.
13430300Sjoerg *
13530300Sjoerg * In order to use this, create a struct spppreq, fill in the cmd
13630300Sjoerg * field with SPPPIOGDEFS, and put the address of this structure into
13730300Sjoerg * the ifr_data portion of a struct ifreq.  Pass this struct to a
13830300Sjoerg * SIOCGIFGENERIC ioctl.  Then replace the cmd field by SPPPIOCDEFS,
13930300Sjoerg * modify the defs field as desired, and pass the struct ifreq now
14030300Sjoerg * to a SIOCSIFGENERIC ioctl.
14130300Sjoerg */
14230300Sjoerg
14330300Sjoerg#define SPPPIOGDEFS  ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
14430300Sjoerg#define SPPPIOSDEFS  ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
14530300Sjoerg
14630300Sjoergstruct spppreq {
14730300Sjoerg	int	cmd;
14830300Sjoerg	struct sppp defs;
14930300Sjoerg};
15030300Sjoerg
1514910Swollman#ifdef KERNEL
1524910Swollmanvoid sppp_attach (struct ifnet *ifp);
1534910Swollmanvoid sppp_detach (struct ifnet *ifp);
1544910Swollmanvoid sppp_input (struct ifnet *ifp, struct mbuf *m);
15538343Sbdeint sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
1564910Swollmanstruct mbuf *sppp_dequeue (struct ifnet *ifp);
15730300Sjoergstruct mbuf *sppp_pick(struct ifnet *ifp);
15811189Sjkhint sppp_isempty (struct ifnet *ifp);
1594910Swollmanvoid sppp_flush (struct ifnet *ifp);
1604910Swollman#endif
1614910Swollman
16241687Sphk#endif /* _NET_IF_SPPP_H_ */
163