if_sppp.h revision 45152
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 *
1945152Sphk * $Id: if_sppp.h,v 1.13 1998/12/27 21:30:44 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 */
4842104Sphk#define IPCP_MYADDR_SEEN  4	/* have seen his address already */
494910Swollman};
504910Swollman
5130300Sjoerg#define AUTHNAMELEN	32
5230300Sjoerg#define AUTHKEYLEN	16
5325944Sjoerg
5430300Sjoergstruct sauth {
5530300Sjoerg	u_short	proto;			/* authentication protocol to use */
5630300Sjoerg	u_short	flags;
5730300Sjoerg#define AUTHFLAG_NOCALLOUT	1	/* do not require authentication on */
5830300Sjoerg					/* callouts */
5930300Sjoerg#define AUTHFLAG_NORECHALLENGE	2	/* do not re-challenge CHAP */
6030300Sjoerg	u_char	name[AUTHNAMELEN];	/* system identification name */
6130300Sjoerg	u_char	secret[AUTHKEYLEN];	/* secret password */
6230300Sjoerg	u_char	challenge[AUTHKEYLEN];	/* random challenge */
6330300Sjoerg};
6430300Sjoerg
6530300Sjoerg#define IDX_PAP		2
6630300Sjoerg#define IDX_CHAP	3
6730300Sjoerg
6830300Sjoerg#define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
6930300Sjoerg
7025944Sjoerg/*
7125944Sjoerg * Don't change the order of this.  Ordering the phases this way allows
7225944Sjoerg * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
7325944Sjoerg * know whether LCP is up.
7425944Sjoerg */
7525944Sjoergenum ppp_phase {
7625944Sjoerg	PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
7725944Sjoerg	PHASE_AUTHENTICATE, PHASE_NETWORK
7825944Sjoerg};
7925944Sjoerg
804910Swollmanstruct sppp {
8125944Sjoerg	/* NB: pp_if _must_ be first */
824910Swollman	struct  ifnet pp_if;    /* network interface data */
834910Swollman	struct  ifqueue pp_fastq; /* fast output queue */
8426018Sjoerg	struct	ifqueue pp_cpq;	/* PPP control protocol queue */
854910Swollman	struct  sppp *pp_next;  /* next interface in keepalive list */
8645152Sphk	u_int   pp_mode;        /* major protocol modes (cisco/ppp/...) */
8745152Sphk	u_int   pp_flags;       /* sub modes */
884910Swollman	u_short pp_alivecnt;    /* keepalive packets counter */
894910Swollman	u_short pp_loopcnt;     /* loopback detection counter */
904910Swollman	u_long  pp_seq;         /* local sequence number */
914910Swollman	u_long  pp_rseq;        /* remote sequence number */
9225944Sjoerg	enum ppp_phase pp_phase;	/* phase we're currently in */
9325944Sjoerg	int	state[IDX_COUNT];	/* state machine */
9425944Sjoerg	u_char  confid[IDX_COUNT];	/* id of last configuration request */
9525944Sjoerg	int	rst_counter[IDX_COUNT];	/* restart counter */
9625944Sjoerg	int	fail_counter[IDX_COUNT]; /* negotiation failure counter */
9730300Sjoerg	struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */
9830300Sjoerg	struct callout_handle pap_my_to_ch; /* PAP needs one more... */
9930300Sjoerg	struct slcp lcp;		/* LCP params */
10030300Sjoerg	struct sipcp ipcp;		/* IPCP params */
10130300Sjoerg	struct sauth myauth;		/* auth params, i'm peer */
10230300Sjoerg	struct sauth hisauth;		/* auth params, i'm authenticator */
10325944Sjoerg	/*
10425944Sjoerg	 * These functions are filled in by sppp_attach(), and are
10525944Sjoerg	 * expected to be used by the lower layer (hardware) drivers
10625944Sjoerg	 * in order to communicate the (un)availability of the
10725944Sjoerg	 * communication link.  Lower layer drivers that are always
10825944Sjoerg	 * ready to communicate (like hardware HDLC) can shortcut
10925944Sjoerg	 * pp_up from pp_tls, and pp_down from pp_tlf.
11025944Sjoerg	 */
11125944Sjoerg	void	(*pp_up)(struct sppp *sp);
11225944Sjoerg	void	(*pp_down)(struct sppp *sp);
11325944Sjoerg	/*
11425944Sjoerg	 * These functions need to be filled in by the lower layer
11525944Sjoerg	 * (hardware) drivers if they request notification from the
11625944Sjoerg	 * PPP layer whether the link is actually required.  They
11725944Sjoerg	 * correspond to the tls and tlf actions.
11825944Sjoerg	 */
11925944Sjoerg	void	(*pp_tls)(struct sppp *sp);
12025944Sjoerg	void	(*pp_tlf)(struct sppp *sp);
12142104Sphk	/*
12242104Sphk	 * These (optional) functions may be filled by the hardware
12342104Sphk	 * driver if any notification of established connections
12442104Sphk	 * (currently: IPCP up) is desired (pp_con) or any internal
12542104Sphk	 * state change of the interface state machine should be
12642104Sphk	 * signaled for monitoring purposes (pp_chg).
12742104Sphk	 */
12842104Sphk	void	(*pp_con)(struct sppp *sp);
12942104Sphk	void	(*pp_chg)(struct sppp *sp, int new_state);
13041963Sphk	/* These two fields are for use by the lower layer */
13141963Sphk	void    *pp_lowerp;
13241963Sphk	int     pp_loweri;
1334910Swollman};
1344910Swollman
1354910Swollman#define PP_KEEPALIVE    0x01    /* use keepalive protocol */
13630300Sjoerg				/* 0x04 was PP_TIMO */
13730300Sjoerg#define PP_CALLIN	0x08	/* we are being called */
13830300Sjoerg#define PP_NEEDAUTH	0x10	/* remote requested authentication */
1394910Swollman
14030300Sjoerg
14125944Sjoerg#define PP_MTU          1500    /* default/minimal MRU */
14225944Sjoerg#define PP_MAX_MRU	2048	/* maximal MRU we want to negotiate */
1434910Swollman
14430300Sjoerg/*
14530300Sjoerg * Definitions to pass struct sppp data down into the kernel using the
14630300Sjoerg * SIOC[SG]IFGENERIC ioctl interface.
14730300Sjoerg *
14830300Sjoerg * In order to use this, create a struct spppreq, fill in the cmd
14930300Sjoerg * field with SPPPIOGDEFS, and put the address of this structure into
15030300Sjoerg * the ifr_data portion of a struct ifreq.  Pass this struct to a
15130300Sjoerg * SIOCGIFGENERIC ioctl.  Then replace the cmd field by SPPPIOCDEFS,
15230300Sjoerg * modify the defs field as desired, and pass the struct ifreq now
15330300Sjoerg * to a SIOCSIFGENERIC ioctl.
15430300Sjoerg */
15530300Sjoerg
15630300Sjoerg#define SPPPIOGDEFS  ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
15730300Sjoerg#define SPPPIOSDEFS  ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
15830300Sjoerg
15930300Sjoergstruct spppreq {
16030300Sjoerg	int	cmd;
16130300Sjoerg	struct sppp defs;
16230300Sjoerg};
16330300Sjoerg
1644910Swollman#ifdef KERNEL
1654910Swollmanvoid sppp_attach (struct ifnet *ifp);
1664910Swollmanvoid sppp_detach (struct ifnet *ifp);
1674910Swollmanvoid sppp_input (struct ifnet *ifp, struct mbuf *m);
16838343Sbdeint sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
1694910Swollmanstruct mbuf *sppp_dequeue (struct ifnet *ifp);
17030300Sjoergstruct mbuf *sppp_pick(struct ifnet *ifp);
17111189Sjkhint sppp_isempty (struct ifnet *ifp);
1724910Swollmanvoid sppp_flush (struct ifnet *ifp);
1734910Swollman#endif
1744910Swollman
17541687Sphk#endif /* _NET_IF_SPPP_H_ */
176