if_sppp.h revision 78064
11541Srgrimes/* 21541Srgrimes * Defines for synchronous PPP/Cisco link level subroutines. 31541Srgrimes * 41541Srgrimes * Copyright (C) 1994 Cronyx Ltd. 51541Srgrimes * Author: Serge Vakulenko, <vak@cronyx.ru> 61541Srgrimes * 71541Srgrimes * Heavily revamped to conform to RFC 1661. 81541Srgrimes * Copyright (C) 1997, Joerg Wunsch. 91541Srgrimes * 101541Srgrimes * This software is distributed with NO WARRANTIES, not even the implied 111541Srgrimes * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 121541Srgrimes * 131541Srgrimes * Authors grant any other persons or organizations permission to use 141541Srgrimes * or modify this software as long as this message is kept with the software, 151541Srgrimes * all derivative works or modified versions. 161541Srgrimes * 171541Srgrimes * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995 181541Srgrimes * 191541Srgrimes * $FreeBSD: head/sys/net/if_sppp.h 78064 2001-06-11 12:39:29Z ume $ 201541Srgrimes */ 211541Srgrimes 221541Srgrimes#ifndef _NET_IF_SPPP_H_ 231541Srgrimes#define _NET_IF_SPPP_H_ 1 241541Srgrimes 251541Srgrimes#define IDX_LCP 0 /* idx into state table */ 261541Srgrimes 271541Srgrimesstruct slcp { 281541Srgrimes u_long opts; /* LCP options to send (bitfield) */ 291541Srgrimes u_long magic; /* local magic number */ 301541Srgrimes u_long mru; /* our max receive unit */ 311541Srgrimes u_long their_mru; /* their max receive unit */ 321541Srgrimes u_long protos; /* bitmask of protos that are started */ 331541Srgrimes u_char echoid; /* id of last keepalive echo request */ 341541Srgrimes /* restart max values, see RFC 1661 */ 351541Srgrimes int timeout; 361541Srgrimes int max_terminate; 371541Srgrimes int max_configure; 38116181Sobrien int max_failure; 39116181Sobrien}; 40116181Sobrien 411541Srgrimes#define IDX_IPCP 1 /* idx into state table */ 422806Sbde#define IDX_IPV6CP 2 /* idx into state table */ 431541Srgrimes 4460041Sphkstruct sipcp { 451541Srgrimes u_long opts; /* IPCP options to send (bitfield) */ 461541Srgrimes u_int flags; 471541Srgrimes#define IPCP_HISADDR_SEEN 1 /* have seen his address already */ 481541Srgrimes#define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */ 49166639Srodrigc#define IPCP_MYADDR_SEEN 4 /* have seen his address already */ 50166639Srodrigc#ifdef notdef 51166639Srodrigc#define IPV6CP_MYIFID_DYN 2 /* my ifid is dynamically assigned */ 521541Srgrimes#endif 531541Srgrimes#define IPV6CP_MYIFID_SEEN 4 /* have seen his ifid already */ 541541Srgrimes}; 551541Srgrimes 5696755Strhodes#define AUTHNAMELEN 32 571541Srgrimes#define AUTHKEYLEN 16 581541Srgrimes 591541Srgrimesstruct sauth { 601541Srgrimes u_short proto; /* authentication protocol to use */ 611541Srgrimes u_short flags; 621541Srgrimes#define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */ 631541Srgrimes /* callouts */ 641541Srgrimes#define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */ 651541Srgrimes u_char name[AUTHNAMELEN]; /* system identification name */ 661541Srgrimes u_char secret[AUTHKEYLEN]; /* secret password */ 671541Srgrimes u_char challenge[AUTHKEYLEN]; /* random challenge */ 681541Srgrimes}; 691541Srgrimes 701541Srgrimes#define IDX_PAP 3 711541Srgrimes#define IDX_CHAP 4 721541Srgrimes 731541Srgrimes#define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */ 741541Srgrimes 751541Srgrimes/* 761541Srgrimes * Don't change the order of this. Ordering the phases this way allows 771541Srgrimes * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to 781541Srgrimes * know whether LCP is up. 791541Srgrimes */ 801541Srgrimesenum ppp_phase { 811541Srgrimes PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE, 821541Srgrimes PHASE_AUTHENTICATE, PHASE_NETWORK 831541Srgrimes}; 841541Srgrimes 851549Srgrimesstruct sppp { 861541Srgrimes /* NB: pp_if _must_ be first */ 8728787Sphk struct ifnet pp_if; /* network interface data */ 881541Srgrimes struct ifqueue pp_fastq; /* fast output queue */ 891541Srgrimes struct ifqueue pp_cpq; /* PPP control protocol queue */ 901541Srgrimes struct sppp *pp_next; /* next interface in keepalive list */ 911541Srgrimes u_int pp_mode; /* major protocol modes (cisco/ppp/...) */ 921541Srgrimes u_int pp_flags; /* sub modes */ 93131526Sphk u_short pp_alivecnt; /* keepalive packets counter */ 94131526Sphk u_short pp_loopcnt; /* loopback detection counter */ 95131526Sphk u_long pp_seq[IDX_COUNT]; /* local sequence number */ 961541Srgrimes u_long pp_rseq[IDX_COUNT]; /* remote sequence number */ 97187838Sjhb enum ppp_phase pp_phase; /* phase we're currently in */ 98187838Sjhb int state[IDX_COUNT]; /* state machine */ 991541Srgrimes u_char confid[IDX_COUNT]; /* id of last configuration request */ 1001549Srgrimes int rst_counter[IDX_COUNT]; /* restart counter */ 101187838Sjhb int fail_counter[IDX_COUNT]; /* negotiation failure counter */ 102187838Sjhb struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */ 1031541Srgrimes struct callout_handle pap_my_to_ch; /* PAP needs one more... */ 1041541Srgrimes struct slcp lcp; /* LCP params */ 10522521Sdyson struct sipcp ipcp; /* IPCP params */ 10622521Sdyson struct sipcp ipv6cp; /* IPv6CP params */ 10722521Sdyson struct sauth myauth; /* auth params, i'm peer */ 1081541Srgrimes struct sauth hisauth; /* auth params, i'm authenticator */ 109187838Sjhb /* 110187838Sjhb * These functions are filled in by sppp_attach(), and are 1111541Srgrimes * expected to be used by the lower layer (hardware) drivers 1125651Sjoerg * in order to communicate the (un)availability of the 1131541Srgrimes * communication link. Lower layer drivers that are always 1141541Srgrimes * ready to communicate (like hardware HDLC) can shortcut 1151541Srgrimes * pp_up from pp_tls, and pp_down from pp_tlf. 1161541Srgrimes */ 117187838Sjhb void (*pp_up)(struct sppp *sp); 1181541Srgrimes void (*pp_down)(struct sppp *sp); 1191541Srgrimes /* 1201541Srgrimes * These functions need to be filled in by the lower layer 1211541Srgrimes * (hardware) drivers if they request notification from the 1228876Srgrimes * PPP layer whether the link is actually required. They 123187838Sjhb * correspond to the tls and tlf actions. 1241541Srgrimes */ 1251541Srgrimes void (*pp_tls)(struct sppp *sp); 1261541Srgrimes void (*pp_tlf)(struct sppp *sp); 1271541Srgrimes /* 1281541Srgrimes * These (optional) functions may be filled by the hardware 1298876Srgrimes * driver if any notification of established connections 1301541Srgrimes * (currently: IPCP up) is desired (pp_con) or any internal 1311541Srgrimes * state change of the interface state machine should be 1321541Srgrimes * signaled for monitoring purposes (pp_chg). 133187838Sjhb */ 134187838Sjhb void (*pp_con)(struct sppp *sp); 1351541Srgrimes void (*pp_chg)(struct sppp *sp, int new_state); 1361541Srgrimes /* These two fields are for use by the lower layer */ 137187838Sjhb void *pp_lowerp; 1381541Srgrimes int pp_loweri; 1391541Srgrimes}; 1401541Srgrimes 1413106Sgpalmer#define PP_KEEPALIVE 0x01 /* use keepalive protocol */ 1423106Sgpalmer /* 0x04 was PP_TIMO */ 1431541Srgrimes#define PP_CALLIN 0x08 /* we are being called */ 1441541Srgrimes#define PP_NEEDAUTH 0x10 /* remote requested authentication */ 1451541Srgrimes 1468876Srgrimes 1471541Srgrimes#define PP_MTU 1500 /* default/minimal MRU */ 1481541Srgrimes#define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */ 1491541Srgrimes 1501541Srgrimes/* 1511541Srgrimes * Definitions to pass struct sppp data down into the kernel using the 1521541Srgrimes * SIOC[SG]IFGENERIC ioctl interface. 1531541Srgrimes * 1541541Srgrimes * In order to use this, create a struct spppreq, fill in the cmd 1551541Srgrimes * field with SPPPIOGDEFS, and put the address of this structure into 1561541Srgrimes * the ifr_data portion of a struct ifreq. Pass this struct to a 1571541Srgrimes * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS, 15822521Sdyson * modify the defs field as desired, and pass the struct ifreq now 159187838Sjhb * to a SIOCSIFGENERIC ioctl. 1601541Srgrimes */ 161187838Sjhb 1621541Srgrimes#define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp))) 1631541Srgrimes#define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp))) 164187838Sjhb 165187838Sjhbstruct spppreq { 166187838Sjhb int cmd; 1671541Srgrimes struct sppp defs; 1681541Srgrimes}; 16923527Sbde 1701541Srgrimes#ifdef _KERNEL 17122521Sdysonvoid sppp_attach (struct ifnet *ifp); 172131526Sphkvoid sppp_detach (struct ifnet *ifp); 1731541Srgrimesvoid sppp_input (struct ifnet *ifp, struct mbuf *m); 174187838Sjhbint sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data); 1751541Srgrimesstruct mbuf *sppp_dequeue (struct ifnet *ifp); 1761541Srgrimesstruct mbuf *sppp_pick(struct ifnet *ifp); 1771541Srgrimesint sppp_isempty (struct ifnet *ifp); 1781541Srgrimesvoid sppp_flush (struct ifnet *ifp); 1791541Srgrimes#endif 180187838Sjhb 1811541Srgrimes#endif /* _NET_IF_SPPP_H_ */ 1821541Srgrimes