1 /** $MirOS: src/sys/net/if_sppp.h,v 1.4 2011/08/13 22:19:57 tg Exp $ */ 2 /* $OpenBSD: if_sppp.h,v 1.9 2005/03/23 00:26:06 canacar Exp $ */ 3 /* $NetBSD: if_sppp.h,v 1.2.2.1 1999/04/04 06:57:39 explorer Exp $ */ 4 5 /* 6 * Defines for synchronous PPP/Cisco link level subroutines. 7 * 8 * Copyright (C) 1994 Cronyx Ltd. 9 * Author: Serge Vakulenko, <vak@cronyx.ru> 10 * 11 * Heavily revamped to conform to RFC 1661. 12 * Copyright (C) 1997, Joerg Wunsch. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions are met: 16 * 1. Redistributions of source code must retain the above copyright notice, 17 * this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright notice, 19 * this list of conditions and the following disclaimer in the documentation 20 * and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY 23 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 * 34 * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995 35 * 36 * From: if_sppp.h,v 1.8 1997/10/11 11:25:20 joerg Exp 37 * 38 * From: Id: if_sppp.h,v 1.7 1998/12/01 20:20:19 hm Exp 39 */ 40 41 #ifndef _NET_IF_SPPP_H_ 42 #define _NET_IF_SPPP_H_ 43 44 #include <sys/timeout.h> 45 46 #define IDX_LCP 0 /* idx into state table */ 47 48 struct slcp { 49 u_long opts; /* LCP options to send (bitfield) */ 50 u_long magic; /* local magic number */ 51 u_long mru; /* our max receive unit */ 52 u_long their_mru; /* their max receive unit */ 53 u_long protos; /* bitmask of protos that are started */ 54 u_char echoid; /* id of last keepalive echo request */ 55 /* restart max values, see RFC 1661 */ 56 int timeout; 57 int max_terminate; 58 int max_configure; 59 int max_failure; 60 }; 61 62 #define IDX_IPCP 1 /* idx into state table */ 63 64 struct sipcp { 65 u_long opts; /* IPCP options to send (bitfield) */ 66 u_int flags; 67 #define IPCP_HISADDR_SEEN 1 /* have seen his address already */ 68 #define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */ 69 #define IPCP_MYADDR_SEEN 4 /* have seen his address already */ 70 }; 71 72 #define AUTHNAMELEN 64 73 #define AUTHKEYLEN 16 74 75 struct sauth { 76 u_short proto; /* authentication protocol to use */ 77 u_short flags; 78 #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */ 79 /* callouts */ 80 #define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */ 81 u_char name[AUTHNAMELEN]; /* system identification name */ 82 u_char secret[AUTHKEYLEN]; /* secret password */ 83 u_char challenge[AUTHKEYLEN]; /* random challenge */ 84 }; 85 86 #define IDX_PAP 2 87 #define IDX_CHAP 3 88 89 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */ 90 91 /* 92 * Don't change the order of this. Ordering the phases this way allows 93 * for a comparison of ``pp_phase >= PHASE_AUTHENTICATE'' in order to 94 * know whether LCP is up. 95 */ 96 enum ppp_phase { 97 PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE, 98 PHASE_AUTHENTICATE, PHASE_NETWORK 99 }; 100 101 struct sppp { 102 /* NB: pp_if _must_ be first */ 103 struct ifnet pp_if; /* network interface data */ 104 struct ifqueue pp_fastq; /* fast output queue */ 105 struct ifqueue pp_cpq; /* PPP control protocol queue */ 106 struct sppp *pp_next; /* next interface in keepalive list */ 107 u_int pp_flags; /* use Cisco protocol instead of PPP */ 108 u_int pp_framebytes; /* number of bytes added by hardware framing */ 109 u_short pp_alivecnt; /* keepalive packets counter */ 110 u_short pp_loopcnt; /* loopback detection counter */ 111 u_long pp_seq; /* local sequence number */ 112 u_long pp_rseq; /* remote sequence number */ 113 u_quad_t pp_saved_mtu; /* saved MTU value */ 114 time_t pp_last_receive; /* peer's last "sign of life" */ 115 time_t pp_last_activity; /* second of last payload data s/r */ 116 time_t pp_idle_timeout; /* idle seconds before auto-disconnect, 117 * 0 = disabled */ 118 int pp_auth_failures; /* authorization failures */ 119 int pp_max_auth_fail; /* max. allowed authorization failures */ 120 time_t pp_last_sent; 121 time_t pp_last_recv; 122 enum ppp_phase pp_phase; /* phase we're currently in */ 123 int query_dns; /* 1 if we want to know the dns addresses */ 124 u_int32_t dns_addrs[2]; 125 int state[IDX_COUNT]; /* state machine */ 126 u_char confid[IDX_COUNT]; /* id of last configuration request */ 127 int rst_counter[IDX_COUNT]; /* restart counter */ 128 int fail_counter[IDX_COUNT]; /* negotiation failure counter */ 129 struct timeout ch[IDX_COUNT]; 130 struct timeout pap_my_to_ch; 131 struct slcp lcp; /* LCP params */ 132 struct sipcp ipcp; /* IPCP params */ 133 struct sauth myauth; /* auth params, i'm peer */ 134 struct sauth hisauth; /* auth params, i'm authenticator */ 135 #ifdef SPPP_VJ 136 int enable_vj; /* enable VJ negotiation */ 137 struct slcompress pp_comp; /* for VJ compression */ 138 #endif 139 /* 140 * These functions are filled in by sppp_attach(), and are 141 * expected to be used by the lower layer (hardware) drivers 142 * in order to communicate the (un)availability of the 143 * communication link. Lower layer drivers that are always 144 * ready to communicate (like hardware HDLC) can shortcut 145 * pp_up from pp_tls, and pp_down from pp_tlf. 146 */ 147 void (*pp_up)(struct sppp *sp); 148 void (*pp_down)(struct sppp *sp); 149 /* 150 * These functions need to be filled in by the lower layer 151 * (hardware) drivers if they request notification from the 152 * PPP layer whether the link is actually required. They 153 * correspond to the tls and tlf actions. 154 */ 155 void (*pp_tls)(struct sppp *sp); 156 void (*pp_tlf)(struct sppp *sp); 157 /* 158 * These (optional) functions may be filled by the hardware 159 * driver if any notification of established connections 160 * (currently: IPCP up) is desired (pp_con) or any internal 161 * state change of the interface state machine should be 162 * signaled for monitoring purposes (pp_chg). 163 */ 164 void (*pp_con)(struct sppp *sp); 165 void (*pp_chg)(struct sppp *sp, int new_state); 166 /* These two fields are for use by the lower layer */ 167 void *pp_lowerp; 168 int pp_loweri; 169 }; 170 171 #define PP_KEEPALIVE 0x01 /* use keepalive protocol */ 172 #define PP_CISCO 0x02 /* use Cisco protocol instead of PPP */ 173 /* 0x04 was PP_TIMO */ 174 #define PP_CALLIN 0x08 /* we are being called */ 175 #define PP_NEEDAUTH 0x10 /* remote requested authentication */ 176 #define PP_NOFRAMING 0x20 /* do not add/expect encapsulation 177 around PPP frames (i.e. the serial 178 HDLC like encapsulation, RFC1662) */ 179 180 #define PP_MTU 1500 /* default/minimal MRU */ 181 #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */ 182 183 /* 184 * Definitions to pass struct sppp data down into the kernel using the 185 * SIOC[SG]IFGENERIC ioctl interface. 186 * 187 * In order to use this, create a struct spppreq, fill in the cmd 188 * field with SPPPIOGDEFS, and put the address of this structure into 189 * the ifr_data portion of a struct ifreq. Pass this struct to a 190 * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS, 191 * modify the defs field as desired, and pass the struct ifreq now 192 * to a SIOCSIFGENERIC ioctl. 193 */ 194 195 #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp))) 196 #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp))) 197 198 struct spppreq { 199 int cmd; 200 struct sppp defs; 201 }; 202 203 #if defined(_KERNEL) 204 void sppp_attach (struct ifnet *ifp); 205 void sppp_detach (struct ifnet *ifp); 206 void sppp_input (struct ifnet *ifp, struct mbuf *m); 207 208 /* Workaround */ 209 void spppattach (struct ifnet *ifp); 210 int sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data); 211 212 struct mbuf *sppp_dequeue (struct ifnet *ifp); 213 struct mbuf *sppp_pick(struct ifnet *ifp); 214 int sppp_isempty (struct ifnet *ifp); 215 void sppp_flush (struct ifnet *ifp); 216 #endif 217 #endif /* _NET_IF_SPPP_H_ */ 218