if_sppp.h revision 88558
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 * 1950477Speter * $FreeBSD: head/sys/net/if_sppp.h 88558 2001-12-27 22:38:50Z joerg $ 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 */ 4278064Sume#define IDX_IPV6CP 2 /* idx into state table */ 4325944Sjoerg 444910Swollmanstruct sipcp { 4525944Sjoerg u_long opts; /* IPCP options to send (bitfield) */ 4625944Sjoerg u_int flags; 4725944Sjoerg#define IPCP_HISADDR_SEEN 1 /* have seen his address already */ 4825944Sjoerg#define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */ 4942104Sphk#define IPCP_MYADDR_SEEN 4 /* have seen his address already */ 5078064Sume#ifdef notdef 5188507Sjoerg#define IPV6CP_MYIFID_DYN 8 /* my ifid is dynamically assigned */ 5278064Sume#endif 5388507Sjoerg#define IPV6CP_MYIFID_SEEN 0x10 /* have seen his ifid already */ 5488534Sjoerg#define IPCP_VJ 0x20 /* can use VJ compression */ 5588534Sjoerg int max_state; /* VJ: Max-Slot-Id */ 5688534Sjoerg int compress_cid; /* VJ: Comp-Slot-Id */ 574910Swollman}; 584910Swollman 5930300Sjoerg#define AUTHNAMELEN 32 6030300Sjoerg#define AUTHKEYLEN 16 6125944Sjoerg 6230300Sjoergstruct sauth { 6330300Sjoerg u_short proto; /* authentication protocol to use */ 6430300Sjoerg u_short flags; 6530300Sjoerg#define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */ 6630300Sjoerg /* callouts */ 6730300Sjoerg#define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */ 6830300Sjoerg u_char name[AUTHNAMELEN]; /* system identification name */ 6930300Sjoerg u_char secret[AUTHKEYLEN]; /* secret password */ 7030300Sjoerg u_char challenge[AUTHKEYLEN]; /* random challenge */ 7130300Sjoerg}; 7230300Sjoerg 7378064Sume#define IDX_PAP 3 7478064Sume#define IDX_CHAP 4 7530300Sjoerg 7630300Sjoerg#define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */ 7730300Sjoerg 7825944Sjoerg/* 7925944Sjoerg * Don't change the order of this. Ordering the phases this way allows 8025944Sjoerg * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to 8125944Sjoerg * know whether LCP is up. 8225944Sjoerg */ 8325944Sjoergenum ppp_phase { 8425944Sjoerg PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE, 8525944Sjoerg PHASE_AUTHENTICATE, PHASE_NETWORK 8625944Sjoerg}; 8725944Sjoerg 8888558Sjoerg#define PP_MTU 1500 /* default/minimal MRU */ 8988558Sjoerg#define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */ 9088558Sjoerg 9188558Sjoerg/* 9288558Sjoerg * This is a cut down struct sppp (see below) that can easily be 9388558Sjoerg * exported to/ imported from userland without the need to include 9488558Sjoerg * dozens of kernel-internal header files. It is used by the 9588558Sjoerg * SPPPIO[GS]DEFS ioctl commands below. 9688558Sjoerg */ 9788558Sjoergstruct sppp_parms { 9888558Sjoerg enum ppp_phase pp_phase; /* phase we're currently in */ 9988558Sjoerg int enable_vj; /* VJ header compression enabled */ 10088558Sjoerg struct slcp lcp; /* LCP params */ 10188558Sjoerg struct sipcp ipcp; /* IPCP params */ 10288558Sjoerg struct sipcp ipv6cp; /* IPv6CP params */ 10388558Sjoerg struct sauth myauth; /* auth params, i'm peer */ 10488558Sjoerg struct sauth hisauth; /* auth params, i'm authenticator */ 10588558Sjoerg}; 10688558Sjoerg 10788558Sjoerg/* 10888558Sjoerg * Definitions to pass struct sppp_parms data down into the kernel 10988558Sjoerg * using the SIOC[SG]IFGENERIC ioctl interface. 11088558Sjoerg * 11188558Sjoerg * In order to use this, create a struct spppreq, fill in the cmd 11288558Sjoerg * field with SPPPIOGDEFS, and put the address of this structure into 11388558Sjoerg * the ifr_data portion of a struct ifreq. Pass this struct to a 11488558Sjoerg * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOSDEFS, 11588558Sjoerg * modify the defs field as desired, and pass the struct ifreq now 11688558Sjoerg * to a SIOCSIFGENERIC ioctl. 11788558Sjoerg */ 11888558Sjoerg 11988558Sjoerg#define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) +\ 12088558Sjoerg sizeof(struct sppp_parms))) 12188558Sjoerg#define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) +\ 12288558Sjoerg sizeof(struct sppp_parms))) 12388558Sjoerg 12488558Sjoergstruct spppreq { 12588558Sjoerg int cmd; 12688558Sjoerg struct sppp_parms defs; 12788558Sjoerg}; 12888558Sjoerg 12988558Sjoerg#ifdef _KERNEL 1304910Swollmanstruct sppp { 13125944Sjoerg /* NB: pp_if _must_ be first */ 1324910Swollman struct ifnet pp_if; /* network interface data */ 1334910Swollman struct ifqueue pp_fastq; /* fast output queue */ 13426018Sjoerg struct ifqueue pp_cpq; /* PPP control protocol queue */ 1354910Swollman struct sppp *pp_next; /* next interface in keepalive list */ 13645152Sphk u_int pp_mode; /* major protocol modes (cisco/ppp/...) */ 13745152Sphk u_int pp_flags; /* sub modes */ 1384910Swollman u_short pp_alivecnt; /* keepalive packets counter */ 1394910Swollman u_short pp_loopcnt; /* loopback detection counter */ 14078064Sume u_long pp_seq[IDX_COUNT]; /* local sequence number */ 14178064Sume u_long pp_rseq[IDX_COUNT]; /* remote sequence number */ 14225944Sjoerg enum ppp_phase pp_phase; /* phase we're currently in */ 14325944Sjoerg int state[IDX_COUNT]; /* state machine */ 14425944Sjoerg u_char confid[IDX_COUNT]; /* id of last configuration request */ 14525944Sjoerg int rst_counter[IDX_COUNT]; /* restart counter */ 14625944Sjoerg int fail_counter[IDX_COUNT]; /* negotiation failure counter */ 14788534Sjoerg int enable_vj; /* VJ header compression enabled */ 14830300Sjoerg struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */ 14930300Sjoerg struct callout_handle pap_my_to_ch; /* PAP needs one more... */ 15030300Sjoerg struct slcp lcp; /* LCP params */ 15130300Sjoerg struct sipcp ipcp; /* IPCP params */ 15278064Sume struct sipcp ipv6cp; /* IPv6CP params */ 15330300Sjoerg struct sauth myauth; /* auth params, i'm peer */ 15430300Sjoerg struct sauth hisauth; /* auth params, i'm authenticator */ 15588534Sjoerg struct slcompress pp_comp; /* for VJ compression */ 15625944Sjoerg /* 15725944Sjoerg * These functions are filled in by sppp_attach(), and are 15825944Sjoerg * expected to be used by the lower layer (hardware) drivers 15925944Sjoerg * in order to communicate the (un)availability of the 16025944Sjoerg * communication link. Lower layer drivers that are always 16125944Sjoerg * ready to communicate (like hardware HDLC) can shortcut 16225944Sjoerg * pp_up from pp_tls, and pp_down from pp_tlf. 16325944Sjoerg */ 16425944Sjoerg void (*pp_up)(struct sppp *sp); 16525944Sjoerg void (*pp_down)(struct sppp *sp); 16625944Sjoerg /* 16725944Sjoerg * These functions need to be filled in by the lower layer 16825944Sjoerg * (hardware) drivers if they request notification from the 16925944Sjoerg * PPP layer whether the link is actually required. They 17025944Sjoerg * correspond to the tls and tlf actions. 17125944Sjoerg */ 17225944Sjoerg void (*pp_tls)(struct sppp *sp); 17325944Sjoerg void (*pp_tlf)(struct sppp *sp); 17442104Sphk /* 17542104Sphk * These (optional) functions may be filled by the hardware 17642104Sphk * driver if any notification of established connections 17742104Sphk * (currently: IPCP up) is desired (pp_con) or any internal 17842104Sphk * state change of the interface state machine should be 17942104Sphk * signaled for monitoring purposes (pp_chg). 18042104Sphk */ 18142104Sphk void (*pp_con)(struct sppp *sp); 18242104Sphk void (*pp_chg)(struct sppp *sp, int new_state); 18341963Sphk /* These two fields are for use by the lower layer */ 18441963Sphk void *pp_lowerp; 18541963Sphk int pp_loweri; 1864910Swollman}; 1874910Swollman 18888558Sjoerg/* bits for pp_flags */ 1894910Swollman#define PP_KEEPALIVE 0x01 /* use keepalive protocol */ 19030300Sjoerg /* 0x04 was PP_TIMO */ 19130300Sjoerg#define PP_CALLIN 0x08 /* we are being called */ 19230300Sjoerg#define PP_NEEDAUTH 0x10 /* remote requested authentication */ 1934910Swollman 1944910Swollmanvoid sppp_attach (struct ifnet *ifp); 1954910Swollmanvoid sppp_detach (struct ifnet *ifp); 1964910Swollmanvoid sppp_input (struct ifnet *ifp, struct mbuf *m); 19738343Sbdeint sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data); 1984910Swollmanstruct mbuf *sppp_dequeue (struct ifnet *ifp); 19930300Sjoergstruct mbuf *sppp_pick(struct ifnet *ifp); 20011189Sjkhint sppp_isempty (struct ifnet *ifp); 2014910Swollmanvoid sppp_flush (struct ifnet *ifp); 2024910Swollman#endif 2034910Swollman 20441687Sphk#endif /* _NET_IF_SPPP_H_ */ 205