1 /* 2 * Defines for synchronous PPP/Cisco link level subroutines. 3 * 4 * Copyright (C) 1994 Cronyx Ltd. 5 * Author: Serge Vakulenko, <vak@cronyx.ru> 6 * 7 * Heavily revamped to conform to RFC 1661. 8 * Copyright (C) 1997, Joerg Wunsch. 9 * 10 * This software is distributed with NO WARRANTIES, not even the implied 11 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 * 13 * Authors grant any other persons or organizations permission to use 14 * or modify this software as long as this message is kept with the software, 15 * all derivative works or modified versions. 16 * 17 * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995 18 * 19 * $FreeBSD: src/sys/net/if_sppp.h,v 1.16.2.3 2002/04/24 18:45:25 joerg Exp $ 20 * $DragonFly: src/sys/net/sppp/if_sppp.h,v 1.3 2004/09/16 03:54:37 dillon Exp $ 21 */ 22 23 #ifndef _NET_IF_SPPP_H_ 24 #define _NET_IF_SPPP_H_ 1 25 26 #define IDX_LCP 0 /* idx into state table */ 27 28 struct slcp { 29 u_long opts; /* LCP options to send (bitfield) */ 30 u_long magic; /* local magic number */ 31 u_long mru; /* our max receive unit */ 32 u_long their_mru; /* their max receive unit */ 33 u_long protos; /* bitmask of protos that are started */ 34 u_char echoid; /* id of last keepalive echo request */ 35 /* restart max values, see RFC 1661 */ 36 int timeout; 37 int max_terminate; 38 int max_configure; 39 int max_failure; 40 }; 41 42 #define IDX_IPCP 1 /* idx into state table */ 43 #define IDX_IPV6CP 2 /* idx into state table */ 44 45 struct sipcp { 46 u_long opts; /* IPCP options to send (bitfield) */ 47 u_int flags; 48 #define IPCP_HISADDR_SEEN 1 /* have seen his address already */ 49 #define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */ 50 #define IPCP_MYADDR_SEEN 4 /* have seen his address already */ 51 #ifdef notdef 52 #define IPV6CP_MYIFID_DYN 8 /* my ifid is dynamically assigned */ 53 #endif 54 #define IPV6CP_MYIFID_SEEN 0x10 /* have seen his ifid already */ 55 #define IPCP_VJ 0x20 /* can use VJ compression */ 56 int max_state; /* VJ: Max-Slot-Id */ 57 int compress_cid; /* VJ: Comp-Slot-Id */ 58 }; 59 60 #define AUTHNAMELEN 64 61 #define AUTHKEYLEN 16 62 63 struct sauth { 64 u_short proto; /* authentication protocol to use */ 65 u_short flags; 66 #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */ 67 /* callouts */ 68 #define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */ 69 u_char name[AUTHNAMELEN]; /* system identification name */ 70 u_char secret[AUTHKEYLEN]; /* secret password */ 71 u_char challenge[AUTHKEYLEN]; /* random challenge */ 72 }; 73 74 #define IDX_PAP 3 75 #define IDX_CHAP 4 76 77 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */ 78 79 /* 80 * Don't change the order of this. Ordering the phases this way allows 81 * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to 82 * know whether LCP is up. 83 */ 84 enum ppp_phase { 85 PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE, 86 PHASE_AUTHENTICATE, PHASE_NETWORK 87 }; 88 89 #define PP_MTU 1500 /* default/minimal MRU */ 90 #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */ 91 92 /* 93 * This is a cut down struct sppp (see below) that can easily be 94 * exported to/ imported from userland without the need to include 95 * dozens of kernel-internal header files. It is used by the 96 * SPPPIO[GS]DEFS ioctl commands below. 97 */ 98 struct sppp_parms { 99 enum ppp_phase pp_phase; /* phase we're currently in */ 100 int enable_vj; /* VJ header compression enabled */ 101 int enable_ipv6; /* 102 * Enable IPv6 negotiations -- only 103 * needed since each IPv4 i/f auto- 104 * matically gets an IPv6 address 105 * assigned, so we can't use this as 106 * a decision. 107 */ 108 struct slcp lcp; /* LCP params */ 109 struct sipcp ipcp; /* IPCP params */ 110 struct sipcp ipv6cp; /* IPv6CP params */ 111 struct sauth myauth; /* auth params, i'm peer */ 112 struct sauth hisauth; /* auth params, i'm authenticator */ 113 }; 114 115 /* 116 * Definitions to pass struct sppp_parms data down into the kernel 117 * using the SIOC[SG]IFGENERIC ioctl interface. 118 * 119 * In order to use this, create a struct spppreq, fill in the cmd 120 * field with SPPPIOGDEFS, and put the address of this structure into 121 * the ifr_data portion of a struct ifreq. Pass this struct to a 122 * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOSDEFS, 123 * modify the defs field as desired, and pass the struct ifreq now 124 * to a SIOCSIFGENERIC ioctl. 125 */ 126 127 #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) +\ 128 sizeof(struct sppp_parms))) 129 #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) +\ 130 sizeof(struct sppp_parms))) 131 132 struct spppreq { 133 int cmd; 134 struct sppp_parms defs; 135 }; 136 137 #ifdef _KERNEL 138 struct sppp { 139 /* NB: pp_arpcom _must_ be first */ 140 struct arpcom pp_arpcom; /* network interface data */ 141 #define pp_if pp_arpcom.ac_if 142 struct ifqueue pp_fastq; /* fast output queue */ 143 struct ifqueue pp_cpq; /* PPP control protocol queue */ 144 struct sppp *pp_next; /* next interface in keepalive list */ 145 u_int pp_mode; /* major protocol modes (cisco/ppp/...) */ 146 u_int pp_flags; /* sub modes */ 147 u_short pp_alivecnt; /* keepalive packets counter */ 148 u_short pp_loopcnt; /* loopback detection counter */ 149 u_long pp_seq[IDX_COUNT]; /* local sequence number */ 150 u_long pp_rseq[IDX_COUNT]; /* remote sequence number */ 151 enum ppp_phase pp_phase; /* phase we're currently in */ 152 int state[IDX_COUNT]; /* state machine */ 153 u_char confid[IDX_COUNT]; /* id of last configuration request */ 154 int rst_counter[IDX_COUNT]; /* restart counter */ 155 int fail_counter[IDX_COUNT]; /* negotiation failure counter */ 156 int confflags; /* administrative configuration flags */ 157 #define CONF_ENABLE_VJ 0x01 /* VJ header compression enabled */ 158 #define CONF_ENABLE_IPV6 0x02 /* IPv6 administratively enabled */ 159 time_t pp_last_recv; /* time last packet has been received */ 160 time_t pp_last_sent; /* time last packet has been sent */ 161 struct callout timeout[IDX_COUNT]; /* per-proto and if callouts */ 162 struct callout pap_my_to; /* PAP needs one more... */ 163 struct slcp lcp; /* LCP params */ 164 struct sipcp ipcp; /* IPCP params */ 165 struct sipcp ipv6cp; /* IPv6CP params */ 166 struct sauth myauth; /* auth params, i'm peer */ 167 struct sauth hisauth; /* auth params, i'm authenticator */ 168 struct slcompress *pp_comp; /* for VJ compression */ 169 /* 170 * These functions are filled in by sppp_attach(), and are 171 * expected to be used by the lower layer (hardware) drivers 172 * in order to communicate the (un)availability of the 173 * communication link. Lower layer drivers that are always 174 * ready to communicate (like hardware HDLC) can shortcut 175 * pp_up from pp_tls, and pp_down from pp_tlf. 176 */ 177 void (*pp_up)(struct sppp *sp); 178 void (*pp_down)(struct sppp *sp); 179 /* 180 * These functions need to be filled in by the lower layer 181 * (hardware) drivers if they request notification from the 182 * PPP layer whether the link is actually required. They 183 * correspond to the tls and tlf actions. 184 */ 185 void (*pp_tls)(struct sppp *sp); 186 void (*pp_tlf)(struct sppp *sp); 187 /* 188 * These (optional) functions may be filled by the hardware 189 * driver if any notification of established connections 190 * (currently: IPCP up) is desired (pp_con) or any internal 191 * state change of the interface state machine should be 192 * signaled for monitoring purposes (pp_chg). 193 */ 194 void (*pp_con)(struct sppp *sp); 195 void (*pp_chg)(struct sppp *sp, int new_state); 196 /* These two fields are for use by the lower layer */ 197 void *pp_lowerp; 198 int pp_loweri; 199 }; 200 201 /* bits for pp_flags */ 202 #define PP_KEEPALIVE 0x01 /* use keepalive protocol */ 203 /* 0x04 was PP_TIMO */ 204 #define PP_CALLIN 0x08 /* we are being called */ 205 #define PP_NEEDAUTH 0x10 /* remote requested authentication */ 206 207 void sppp_attach (struct ifnet *ifp); 208 void sppp_detach (struct ifnet *ifp); 209 void sppp_input (struct ifnet *ifp, struct mbuf *m); 210 int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data); 211 struct mbuf *sppp_dequeue (struct ifnet *ifp); 212 struct mbuf *sppp_pick(struct ifnet *ifp); 213 int sppp_isempty (struct ifnet *ifp); 214 void sppp_flush (struct ifnet *ifp); 215 #endif 216 217 #endif /* _NET_IF_SPPP_H_ */ 218