1994-12-02 23:23:01 +00:00
|
|
|
/*
|
2004-12-28 00:07:57 +00:00
|
|
|
* Defines for synchronous PPP/Cisco/Frame Relay link level subroutines.
|
1994-12-02 23:23:01 +00:00
|
|
|
*
|
2004-12-28 00:07:57 +00:00
|
|
|
* Copyright (C) 1994-2000 Cronyx Engineering.
|
1997-05-19 22:03:09 +00:00
|
|
|
* Author: Serge Vakulenko, <vak@cronyx.ru>
|
|
|
|
*
|
|
|
|
* Heavily revamped to conform to RFC 1661.
|
|
|
|
* Copyright (C) 1997, Joerg Wunsch.
|
1994-12-02 23:23:01 +00:00
|
|
|
*
|
|
|
|
* This software is distributed with NO WARRANTIES, not even the implied
|
|
|
|
* warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
1996-01-30 23:02:38 +00:00
|
|
|
* Authors grant any other persons or organizations permission to use
|
1994-12-02 23:23:01 +00:00
|
|
|
* or modify this software as long as this message is kept with the software,
|
|
|
|
* all derivative works or modified versions.
|
|
|
|
*
|
1997-10-11 11:25:28 +00:00
|
|
|
* From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995
|
1997-05-19 22:03:09 +00:00
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-12-02 23:23:01 +00:00
|
|
|
*/
|
|
|
|
|
1998-12-11 21:42:57 +00:00
|
|
|
#ifndef _NET_IF_SPPP_H_
|
|
|
|
#define _NET_IF_SPPP_H_ 1
|
1994-12-02 23:23:01 +00:00
|
|
|
|
1997-05-19 22:03:09 +00:00
|
|
|
#define IDX_LCP 0 /* idx into state table */
|
|
|
|
|
1994-12-02 23:23:01 +00:00
|
|
|
struct slcp {
|
1997-05-19 22:03:09 +00:00
|
|
|
u_long opts; /* LCP options to send (bitfield) */
|
1994-12-02 23:23:01 +00:00
|
|
|
u_long magic; /* local magic number */
|
1997-05-19 22:03:09 +00:00
|
|
|
u_long mru; /* our max receive unit */
|
|
|
|
u_long their_mru; /* their max receive unit */
|
|
|
|
u_long protos; /* bitmask of protos that are started */
|
1995-10-04 22:24:16 +00:00
|
|
|
u_char echoid; /* id of last keepalive echo request */
|
1997-05-19 22:03:09 +00:00
|
|
|
/* restart max values, see RFC 1661 */
|
|
|
|
int timeout;
|
|
|
|
int max_terminate;
|
|
|
|
int max_configure;
|
|
|
|
int max_failure;
|
1994-12-02 23:23:01 +00:00
|
|
|
};
|
|
|
|
|
1997-05-19 22:03:09 +00:00
|
|
|
#define IDX_IPCP 1 /* idx into state table */
|
2001-06-11 12:39:29 +00:00
|
|
|
#define IDX_IPV6CP 2 /* idx into state table */
|
1997-05-19 22:03:09 +00:00
|
|
|
|
1994-12-02 23:23:01 +00:00
|
|
|
struct sipcp {
|
1997-05-19 22:03:09 +00:00
|
|
|
u_long opts; /* IPCP options to send (bitfield) */
|
|
|
|
u_int flags;
|
|
|
|
#define IPCP_HISADDR_SEEN 1 /* have seen his address already */
|
|
|
|
#define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */
|
1998-12-27 21:30:44 +00:00
|
|
|
#define IPCP_MYADDR_SEEN 4 /* have seen his address already */
|
2001-06-11 12:39:29 +00:00
|
|
|
#ifdef notdef
|
2001-12-26 22:35:10 +00:00
|
|
|
#define IPV6CP_MYIFID_DYN 8 /* my ifid is dynamically assigned */
|
2001-06-11 12:39:29 +00:00
|
|
|
#endif
|
2001-12-26 22:35:10 +00:00
|
|
|
#define IPV6CP_MYIFID_SEEN 0x10 /* have seen his ifid already */
|
2001-12-27 16:49:31 +00:00
|
|
|
#define IPCP_VJ 0x20 /* can use VJ compression */
|
|
|
|
int max_state; /* VJ: Max-Slot-Id */
|
|
|
|
int compress_cid; /* VJ: Comp-Slot-Id */
|
1997-05-19 22:03:09 +00:00
|
|
|
};
|
|
|
|
|
2001-12-30 18:40:28 +00:00
|
|
|
#define AUTHNAMELEN 64
|
1997-10-11 11:25:28 +00:00
|
|
|
#define AUTHKEYLEN 16
|
|
|
|
|
|
|
|
struct sauth {
|
|
|
|
u_short proto; /* authentication protocol to use */
|
|
|
|
u_short flags;
|
|
|
|
#define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
|
|
|
|
/* callouts */
|
|
|
|
#define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */
|
|
|
|
u_char name[AUTHNAMELEN]; /* system identification name */
|
|
|
|
u_char secret[AUTHKEYLEN]; /* secret password */
|
|
|
|
u_char challenge[AUTHKEYLEN]; /* random challenge */
|
|
|
|
};
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
#define IDX_PAP 3
|
|
|
|
#define IDX_CHAP 4
|
1997-10-11 11:25:28 +00:00
|
|
|
|
|
|
|
#define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
|
1997-05-19 22:03:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't change the order of this. Ordering the phases this way allows
|
|
|
|
* for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
|
|
|
|
* know whether LCP is up.
|
|
|
|
*/
|
|
|
|
enum ppp_phase {
|
|
|
|
PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
|
|
|
|
PHASE_AUTHENTICATE, PHASE_NETWORK
|
1994-12-02 23:23:01 +00:00
|
|
|
};
|
|
|
|
|
2001-12-27 22:38:50 +00:00
|
|
|
#define PP_MTU 1500 /* default/minimal MRU */
|
|
|
|
#define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a cut down struct sppp (see below) that can easily be
|
|
|
|
* exported to/ imported from userland without the need to include
|
|
|
|
* dozens of kernel-internal header files. It is used by the
|
|
|
|
* SPPPIO[GS]DEFS ioctl commands below.
|
|
|
|
*/
|
|
|
|
struct sppp_parms {
|
|
|
|
enum ppp_phase pp_phase; /* phase we're currently in */
|
|
|
|
int enable_vj; /* VJ header compression enabled */
|
2001-12-30 20:42:29 +00:00
|
|
|
int enable_ipv6; /*
|
|
|
|
* Enable IPv6 negotiations -- only
|
|
|
|
* needed since each IPv4 i/f auto-
|
|
|
|
* matically gets an IPv6 address
|
|
|
|
* assigned, so we can't use this as
|
|
|
|
* a decision.
|
|
|
|
*/
|
2001-12-27 22:38:50 +00:00
|
|
|
struct slcp lcp; /* LCP params */
|
|
|
|
struct sipcp ipcp; /* IPCP params */
|
|
|
|
struct sipcp ipv6cp; /* IPv6CP params */
|
|
|
|
struct sauth myauth; /* auth params, i'm peer */
|
|
|
|
struct sauth hisauth; /* auth params, i'm authenticator */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions to pass struct sppp_parms data down into the kernel
|
|
|
|
* using the SIOC[SG]IFGENERIC ioctl interface.
|
|
|
|
*
|
|
|
|
* In order to use this, create a struct spppreq, fill in the cmd
|
|
|
|
* field with SPPPIOGDEFS, and put the address of this structure into
|
|
|
|
* the ifr_data portion of a struct ifreq. Pass this struct to a
|
|
|
|
* SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOSDEFS,
|
|
|
|
* modify the defs field as desired, and pass the struct ifreq now
|
|
|
|
* to a SIOCSIFGENERIC ioctl.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) +\
|
|
|
|
sizeof(struct sppp_parms)))
|
|
|
|
#define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) +\
|
|
|
|
sizeof(struct sppp_parms)))
|
|
|
|
|
|
|
|
struct spppreq {
|
|
|
|
int cmd;
|
|
|
|
struct sppp_parms defs;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
1994-12-02 23:23:01 +00:00
|
|
|
struct sppp {
|
1997-05-19 22:03:09 +00:00
|
|
|
/* NB: pp_if _must_ be first */
|
1994-12-02 23:23:01 +00:00
|
|
|
struct ifnet pp_if; /* network interface data */
|
|
|
|
struct ifqueue pp_fastq; /* fast output queue */
|
1997-05-22 22:15:39 +00:00
|
|
|
struct ifqueue pp_cpq; /* PPP control protocol queue */
|
1994-12-02 23:23:01 +00:00
|
|
|
struct sppp *pp_next; /* next interface in keepalive list */
|
1999-03-30 13:28:26 +00:00
|
|
|
u_int pp_mode; /* major protocol modes (cisco/ppp/...) */
|
|
|
|
u_int pp_flags; /* sub modes */
|
1994-12-02 23:23:01 +00:00
|
|
|
u_short pp_alivecnt; /* keepalive packets counter */
|
|
|
|
u_short pp_loopcnt; /* loopback detection counter */
|
2001-06-11 12:39:29 +00:00
|
|
|
u_long pp_seq[IDX_COUNT]; /* local sequence number */
|
|
|
|
u_long pp_rseq[IDX_COUNT]; /* remote sequence number */
|
1997-05-19 22:03:09 +00:00
|
|
|
enum ppp_phase pp_phase; /* phase we're currently in */
|
|
|
|
int state[IDX_COUNT]; /* state machine */
|
|
|
|
u_char confid[IDX_COUNT]; /* id of last configuration request */
|
|
|
|
int rst_counter[IDX_COUNT]; /* restart counter */
|
|
|
|
int fail_counter[IDX_COUNT]; /* negotiation failure counter */
|
2001-12-30 20:42:29 +00:00
|
|
|
int confflags; /* administrative configuration flags */
|
|
|
|
#define CONF_ENABLE_VJ 0x01 /* VJ header compression enabled */
|
|
|
|
#define CONF_ENABLE_IPV6 0x02 /* IPv6 administratively enabled */
|
2001-12-28 15:59:54 +00:00
|
|
|
time_t pp_last_recv; /* time last packet has been received */
|
|
|
|
time_t pp_last_sent; /* time last packet has been sent */
|
2004-12-12 14:54:15 +00:00
|
|
|
struct callout ch[IDX_COUNT]; /* per-proto and if callouts */
|
|
|
|
struct callout pap_my_to_ch; /* PAP needs one more... */
|
|
|
|
struct callout keepalive_callout; /* keepalive callout */
|
1997-10-11 11:25:28 +00:00
|
|
|
struct slcp lcp; /* LCP params */
|
|
|
|
struct sipcp ipcp; /* IPCP params */
|
2001-06-11 12:39:29 +00:00
|
|
|
struct sipcp ipv6cp; /* IPv6CP params */
|
1997-10-11 11:25:28 +00:00
|
|
|
struct sauth myauth; /* auth params, i'm peer */
|
|
|
|
struct sauth hisauth; /* auth params, i'm authenticator */
|
2001-12-28 23:20:12 +00:00
|
|
|
struct slcompress *pp_comp; /* for VJ compression */
|
2004-12-28 00:07:57 +00:00
|
|
|
u_short fr_dlci; /* Frame Relay DLCI number, 16..1023 */
|
|
|
|
u_char fr_status; /* PVC status, active/new/delete */
|
1997-05-19 22:03:09 +00:00
|
|
|
/*
|
|
|
|
* These functions are filled in by sppp_attach(), and are
|
|
|
|
* expected to be used by the lower layer (hardware) drivers
|
|
|
|
* in order to communicate the (un)availability of the
|
|
|
|
* communication link. Lower layer drivers that are always
|
|
|
|
* ready to communicate (like hardware HDLC) can shortcut
|
|
|
|
* pp_up from pp_tls, and pp_down from pp_tlf.
|
|
|
|
*/
|
|
|
|
void (*pp_up)(struct sppp *sp);
|
|
|
|
void (*pp_down)(struct sppp *sp);
|
|
|
|
/*
|
|
|
|
* These functions need to be filled in by the lower layer
|
|
|
|
* (hardware) drivers if they request notification from the
|
|
|
|
* PPP layer whether the link is actually required. They
|
|
|
|
* correspond to the tls and tlf actions.
|
|
|
|
*/
|
|
|
|
void (*pp_tls)(struct sppp *sp);
|
|
|
|
void (*pp_tlf)(struct sppp *sp);
|
1998-12-27 21:30:44 +00:00
|
|
|
/*
|
|
|
|
* These (optional) functions may be filled by the hardware
|
|
|
|
* driver if any notification of established connections
|
|
|
|
* (currently: IPCP up) is desired (pp_con) or any internal
|
|
|
|
* state change of the interface state machine should be
|
|
|
|
* signaled for monitoring purposes (pp_chg).
|
|
|
|
*/
|
|
|
|
void (*pp_con)(struct sppp *sp);
|
|
|
|
void (*pp_chg)(struct sppp *sp, int new_state);
|
1998-12-20 19:06:22 +00:00
|
|
|
/* These two fields are for use by the lower layer */
|
|
|
|
void *pp_lowerp;
|
|
|
|
int pp_loweri;
|
2004-12-12 14:54:15 +00:00
|
|
|
/* Lock */
|
|
|
|
struct mtx mtx;
|
|
|
|
/* if_start () wrapper */
|
|
|
|
void (*if_start) (struct ifnet *);
|
|
|
|
struct callout ifstart_callout; /* if_start () scheduler */
|
1994-12-02 23:23:01 +00:00
|
|
|
};
|
|
|
|
|
2001-12-27 22:38:50 +00:00
|
|
|
/* bits for pp_flags */
|
1994-12-02 23:23:01 +00:00
|
|
|
#define PP_KEEPALIVE 0x01 /* use keepalive protocol */
|
2004-12-28 00:07:57 +00:00
|
|
|
#define PP_FR 0x04 /* use Frame Relay protocol instead of PPP */
|
1997-10-11 11:25:28 +00:00
|
|
|
/* 0x04 was PP_TIMO */
|
|
|
|
#define PP_CALLIN 0x08 /* we are being called */
|
|
|
|
#define PP_NEEDAUTH 0x10 /* remote requested authentication */
|
|
|
|
|
1994-12-02 23:23:01 +00:00
|
|
|
void sppp_attach (struct ifnet *ifp);
|
|
|
|
void sppp_detach (struct ifnet *ifp);
|
|
|
|
void sppp_input (struct ifnet *ifp, struct mbuf *m);
|
1998-08-15 21:58:09 +00:00
|
|
|
int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
|
1994-12-02 23:23:01 +00:00
|
|
|
struct mbuf *sppp_dequeue (struct ifnet *ifp);
|
1997-10-11 11:25:28 +00:00
|
|
|
struct mbuf *sppp_pick(struct ifnet *ifp);
|
1995-10-04 22:24:16 +00:00
|
|
|
int sppp_isempty (struct ifnet *ifp);
|
1994-12-02 23:23:01 +00:00
|
|
|
void sppp_flush (struct ifnet *ifp);
|
2004-12-28 00:07:57 +00:00
|
|
|
|
|
|
|
/* Internal functions */
|
|
|
|
void sppp_fr_input (struct sppp *sp, struct mbuf *m);
|
|
|
|
struct mbuf *sppp_fr_header (struct sppp *sp, struct mbuf *m, int fam);
|
|
|
|
void sppp_fr_keepalive (struct sppp *sp);
|
|
|
|
void sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst,
|
|
|
|
u_long *srcmask);
|
|
|
|
|
1994-12-02 23:23:01 +00:00
|
|
|
#endif
|
|
|
|
|
1998-12-11 21:42:57 +00:00
|
|
|
#endif /* _NET_IF_SPPP_H_ */
|