This short program illustrates how to use the DS130x_I2C library. My objective is to share the same RTC with Microchip 18F MCU.
Dependencies: mbed DebugLibrary
NetServices/lwip/netif/ppp/pap.c@0:f30e2135b0db, 2011-02-09 (annotated)
- Committer:
- Yann
- Date:
- Wed Feb 09 13:57:49 2011 +0000
- Revision:
- 0:f30e2135b0db
V0.0.0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Yann | 0:f30e2135b0db | 1 | /***************************************************************************** |
Yann | 0:f30e2135b0db | 2 | * pap.c - Network Password Authentication Protocol program file. |
Yann | 0:f30e2135b0db | 3 | * |
Yann | 0:f30e2135b0db | 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. |
Yann | 0:f30e2135b0db | 5 | * portions Copyright (c) 1997 by Global Election Systems Inc. |
Yann | 0:f30e2135b0db | 6 | * |
Yann | 0:f30e2135b0db | 7 | * The authors hereby grant permission to use, copy, modify, distribute, |
Yann | 0:f30e2135b0db | 8 | * and license this software and its documentation for any purpose, provided |
Yann | 0:f30e2135b0db | 9 | * that existing copyright notices are retained in all copies and that this |
Yann | 0:f30e2135b0db | 10 | * notice and the following disclaimer are included verbatim in any |
Yann | 0:f30e2135b0db | 11 | * distributions. No written agreement, license, or royalty fee is required |
Yann | 0:f30e2135b0db | 12 | * for any of the authorized uses. |
Yann | 0:f30e2135b0db | 13 | * |
Yann | 0:f30e2135b0db | 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR |
Yann | 0:f30e2135b0db | 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
Yann | 0:f30e2135b0db | 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
Yann | 0:f30e2135b0db | 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
Yann | 0:f30e2135b0db | 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
Yann | 0:f30e2135b0db | 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
Yann | 0:f30e2135b0db | 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
Yann | 0:f30e2135b0db | 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Yann | 0:f30e2135b0db | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
Yann | 0:f30e2135b0db | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Yann | 0:f30e2135b0db | 24 | * |
Yann | 0:f30e2135b0db | 25 | ****************************************************************************** |
Yann | 0:f30e2135b0db | 26 | * REVISION HISTORY |
Yann | 0:f30e2135b0db | 27 | * |
Yann | 0:f30e2135b0db | 28 | * 03-01-01 Marc Boucher <marc@mbsi.ca> |
Yann | 0:f30e2135b0db | 29 | * Ported to lwIP. |
Yann | 0:f30e2135b0db | 30 | * 97-12-12 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc. |
Yann | 0:f30e2135b0db | 31 | * Original. |
Yann | 0:f30e2135b0db | 32 | *****************************************************************************/ |
Yann | 0:f30e2135b0db | 33 | /* |
Yann | 0:f30e2135b0db | 34 | * upap.c - User/Password Authentication Protocol. |
Yann | 0:f30e2135b0db | 35 | * |
Yann | 0:f30e2135b0db | 36 | * Copyright (c) 1989 Carnegie Mellon University. |
Yann | 0:f30e2135b0db | 37 | * All rights reserved. |
Yann | 0:f30e2135b0db | 38 | * |
Yann | 0:f30e2135b0db | 39 | * Redistribution and use in source and binary forms are permitted |
Yann | 0:f30e2135b0db | 40 | * provided that the above copyright notice and this paragraph are |
Yann | 0:f30e2135b0db | 41 | * duplicated in all such forms and that any documentation, |
Yann | 0:f30e2135b0db | 42 | * advertising materials, and other materials related to such |
Yann | 0:f30e2135b0db | 43 | * distribution and use acknowledge that the software was developed |
Yann | 0:f30e2135b0db | 44 | * by Carnegie Mellon University. The name of the |
Yann | 0:f30e2135b0db | 45 | * University may not be used to endorse or promote products derived |
Yann | 0:f30e2135b0db | 46 | * from this software without specific prior written permission. |
Yann | 0:f30e2135b0db | 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
Yann | 0:f30e2135b0db | 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
Yann | 0:f30e2135b0db | 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
Yann | 0:f30e2135b0db | 50 | */ |
Yann | 0:f30e2135b0db | 51 | |
Yann | 0:f30e2135b0db | 52 | #include "lwip/opt.h" |
Yann | 0:f30e2135b0db | 53 | |
Yann | 0:f30e2135b0db | 54 | #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ |
Yann | 0:f30e2135b0db | 55 | |
Yann | 0:f30e2135b0db | 56 | #if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ |
Yann | 0:f30e2135b0db | 57 | |
Yann | 0:f30e2135b0db | 58 | #include "ppp.h" |
Yann | 0:f30e2135b0db | 59 | #include "pppdebug.h" |
Yann | 0:f30e2135b0db | 60 | |
Yann | 0:f30e2135b0db | 61 | #include "auth.h" |
Yann | 0:f30e2135b0db | 62 | #include "pap.h" |
Yann | 0:f30e2135b0db | 63 | |
Yann | 0:f30e2135b0db | 64 | #include <string.h> |
Yann | 0:f30e2135b0db | 65 | |
Yann | 0:f30e2135b0db | 66 | #if 0 /* UNUSED */ |
Yann | 0:f30e2135b0db | 67 | static bool hide_password = 1; |
Yann | 0:f30e2135b0db | 68 | |
Yann | 0:f30e2135b0db | 69 | /* |
Yann | 0:f30e2135b0db | 70 | * Command-line options. |
Yann | 0:f30e2135b0db | 71 | */ |
Yann | 0:f30e2135b0db | 72 | static option_t pap_option_list[] = { |
Yann | 0:f30e2135b0db | 73 | { "hide-password", o_bool, &hide_password, |
Yann | 0:f30e2135b0db | 74 | "Don't output passwords to log", 1 }, |
Yann | 0:f30e2135b0db | 75 | { "show-password", o_bool, &hide_password, |
Yann | 0:f30e2135b0db | 76 | "Show password string in debug log messages", 0 }, |
Yann | 0:f30e2135b0db | 77 | { "pap-restart", o_int, &upap[0].us_timeouttime, |
Yann | 0:f30e2135b0db | 78 | "Set retransmit timeout for PAP" }, |
Yann | 0:f30e2135b0db | 79 | { "pap-max-authreq", o_int, &upap[0].us_maxtransmits, |
Yann | 0:f30e2135b0db | 80 | "Set max number of transmissions for auth-reqs" }, |
Yann | 0:f30e2135b0db | 81 | { "pap-timeout", o_int, &upap[0].us_reqtimeout, |
Yann | 0:f30e2135b0db | 82 | "Set time limit for peer PAP authentication" }, |
Yann | 0:f30e2135b0db | 83 | { NULL } |
Yann | 0:f30e2135b0db | 84 | }; |
Yann | 0:f30e2135b0db | 85 | #endif |
Yann | 0:f30e2135b0db | 86 | |
Yann | 0:f30e2135b0db | 87 | /* |
Yann | 0:f30e2135b0db | 88 | * Protocol entry points. |
Yann | 0:f30e2135b0db | 89 | */ |
Yann | 0:f30e2135b0db | 90 | static void upap_init (int); |
Yann | 0:f30e2135b0db | 91 | static void upap_lowerup (int); |
Yann | 0:f30e2135b0db | 92 | static void upap_lowerdown (int); |
Yann | 0:f30e2135b0db | 93 | static void upap_input (int, u_char *, int); |
Yann | 0:f30e2135b0db | 94 | static void upap_protrej (int); |
Yann | 0:f30e2135b0db | 95 | #if PPP_ADDITIONAL_CALLBACKS |
Yann | 0:f30e2135b0db | 96 | static int upap_printpkt (u_char *, int, void (*)(void *, char *, ...), void *); |
Yann | 0:f30e2135b0db | 97 | #endif /* PPP_ADDITIONAL_CALLBACKS */ |
Yann | 0:f30e2135b0db | 98 | |
Yann | 0:f30e2135b0db | 99 | struct protent pap_protent = { |
Yann | 0:f30e2135b0db | 100 | PPP_PAP, |
Yann | 0:f30e2135b0db | 101 | upap_init, |
Yann | 0:f30e2135b0db | 102 | upap_input, |
Yann | 0:f30e2135b0db | 103 | upap_protrej, |
Yann | 0:f30e2135b0db | 104 | upap_lowerup, |
Yann | 0:f30e2135b0db | 105 | upap_lowerdown, |
Yann | 0:f30e2135b0db | 106 | NULL, |
Yann | 0:f30e2135b0db | 107 | NULL, |
Yann | 0:f30e2135b0db | 108 | #if PPP_ADDITIONAL_CALLBACKS |
Yann | 0:f30e2135b0db | 109 | upap_printpkt, |
Yann | 0:f30e2135b0db | 110 | NULL, |
Yann | 0:f30e2135b0db | 111 | #endif /* PPP_ADDITIONAL_CALLBACKS */ |
Yann | 0:f30e2135b0db | 112 | 1, |
Yann | 0:f30e2135b0db | 113 | "PAP", |
Yann | 0:f30e2135b0db | 114 | #if PPP_ADDITIONAL_CALLBACKS |
Yann | 0:f30e2135b0db | 115 | NULL, |
Yann | 0:f30e2135b0db | 116 | NULL, |
Yann | 0:f30e2135b0db | 117 | NULL |
Yann | 0:f30e2135b0db | 118 | #endif /* PPP_ADDITIONAL_CALLBACKS */ |
Yann | 0:f30e2135b0db | 119 | }; |
Yann | 0:f30e2135b0db | 120 | |
Yann | 0:f30e2135b0db | 121 | upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */ |
Yann | 0:f30e2135b0db | 122 | |
Yann | 0:f30e2135b0db | 123 | static void upap_timeout (void *); |
Yann | 0:f30e2135b0db | 124 | static void upap_reqtimeout(void *); |
Yann | 0:f30e2135b0db | 125 | static void upap_rauthreq (upap_state *, u_char *, u_char, int); |
Yann | 0:f30e2135b0db | 126 | static void upap_rauthack (upap_state *, u_char *, int, int); |
Yann | 0:f30e2135b0db | 127 | static void upap_rauthnak (upap_state *, u_char *, int, int); |
Yann | 0:f30e2135b0db | 128 | static void upap_sauthreq (upap_state *); |
Yann | 0:f30e2135b0db | 129 | static void upap_sresp (upap_state *, u_char, u_char, char *, int); |
Yann | 0:f30e2135b0db | 130 | |
Yann | 0:f30e2135b0db | 131 | |
Yann | 0:f30e2135b0db | 132 | /* |
Yann | 0:f30e2135b0db | 133 | * upap_init - Initialize a UPAP unit. |
Yann | 0:f30e2135b0db | 134 | */ |
Yann | 0:f30e2135b0db | 135 | static void |
Yann | 0:f30e2135b0db | 136 | upap_init(int unit) |
Yann | 0:f30e2135b0db | 137 | { |
Yann | 0:f30e2135b0db | 138 | upap_state *u = &upap[unit]; |
Yann | 0:f30e2135b0db | 139 | |
Yann | 0:f30e2135b0db | 140 | UPAPDEBUG(LOG_INFO, ("upap_init: %d\n", unit)); |
Yann | 0:f30e2135b0db | 141 | u->us_unit = unit; |
Yann | 0:f30e2135b0db | 142 | u->us_user = NULL; |
Yann | 0:f30e2135b0db | 143 | u->us_userlen = 0; |
Yann | 0:f30e2135b0db | 144 | u->us_passwd = NULL; |
Yann | 0:f30e2135b0db | 145 | u->us_passwdlen = 0; |
Yann | 0:f30e2135b0db | 146 | u->us_clientstate = UPAPCS_INITIAL; |
Yann | 0:f30e2135b0db | 147 | u->us_serverstate = UPAPSS_INITIAL; |
Yann | 0:f30e2135b0db | 148 | u->us_id = 0; |
Yann | 0:f30e2135b0db | 149 | u->us_timeouttime = UPAP_DEFTIMEOUT; |
Yann | 0:f30e2135b0db | 150 | u->us_maxtransmits = 10; |
Yann | 0:f30e2135b0db | 151 | u->us_reqtimeout = UPAP_DEFREQTIME; |
Yann | 0:f30e2135b0db | 152 | } |
Yann | 0:f30e2135b0db | 153 | |
Yann | 0:f30e2135b0db | 154 | /* |
Yann | 0:f30e2135b0db | 155 | * upap_authwithpeer - Authenticate us with our peer (start client). |
Yann | 0:f30e2135b0db | 156 | * |
Yann | 0:f30e2135b0db | 157 | * Set new state and send authenticate's. |
Yann | 0:f30e2135b0db | 158 | */ |
Yann | 0:f30e2135b0db | 159 | void |
Yann | 0:f30e2135b0db | 160 | upap_authwithpeer(int unit, char *user, char *password) |
Yann | 0:f30e2135b0db | 161 | { |
Yann | 0:f30e2135b0db | 162 | upap_state *u = &upap[unit]; |
Yann | 0:f30e2135b0db | 163 | |
Yann | 0:f30e2135b0db | 164 | UPAPDEBUG(LOG_INFO, ("upap_authwithpeer: %d user=%s password=%s s=%d\n", |
Yann | 0:f30e2135b0db | 165 | unit, user, password, u->us_clientstate)); |
Yann | 0:f30e2135b0db | 166 | |
Yann | 0:f30e2135b0db | 167 | /* Save the username and password we're given */ |
Yann | 0:f30e2135b0db | 168 | u->us_user = user; |
Yann | 0:f30e2135b0db | 169 | u->us_userlen = (int)strlen(user); |
Yann | 0:f30e2135b0db | 170 | u->us_passwd = password; |
Yann | 0:f30e2135b0db | 171 | u->us_passwdlen = (int)strlen(password); |
Yann | 0:f30e2135b0db | 172 | |
Yann | 0:f30e2135b0db | 173 | u->us_transmits = 0; |
Yann | 0:f30e2135b0db | 174 | |
Yann | 0:f30e2135b0db | 175 | /* Lower layer up yet? */ |
Yann | 0:f30e2135b0db | 176 | if (u->us_clientstate == UPAPCS_INITIAL || |
Yann | 0:f30e2135b0db | 177 | u->us_clientstate == UPAPCS_PENDING) { |
Yann | 0:f30e2135b0db | 178 | u->us_clientstate = UPAPCS_PENDING; |
Yann | 0:f30e2135b0db | 179 | return; |
Yann | 0:f30e2135b0db | 180 | } |
Yann | 0:f30e2135b0db | 181 | |
Yann | 0:f30e2135b0db | 182 | upap_sauthreq(u); /* Start protocol */ |
Yann | 0:f30e2135b0db | 183 | } |
Yann | 0:f30e2135b0db | 184 | |
Yann | 0:f30e2135b0db | 185 | |
Yann | 0:f30e2135b0db | 186 | /* |
Yann | 0:f30e2135b0db | 187 | * upap_authpeer - Authenticate our peer (start server). |
Yann | 0:f30e2135b0db | 188 | * |
Yann | 0:f30e2135b0db | 189 | * Set new state. |
Yann | 0:f30e2135b0db | 190 | */ |
Yann | 0:f30e2135b0db | 191 | void |
Yann | 0:f30e2135b0db | 192 | upap_authpeer(int unit) |
Yann | 0:f30e2135b0db | 193 | { |
Yann | 0:f30e2135b0db | 194 | upap_state *u = &upap[unit]; |
Yann | 0:f30e2135b0db | 195 | |
Yann | 0:f30e2135b0db | 196 | /* Lower layer up yet? */ |
Yann | 0:f30e2135b0db | 197 | if (u->us_serverstate == UPAPSS_INITIAL || |
Yann | 0:f30e2135b0db | 198 | u->us_serverstate == UPAPSS_PENDING) { |
Yann | 0:f30e2135b0db | 199 | u->us_serverstate = UPAPSS_PENDING; |
Yann | 0:f30e2135b0db | 200 | return; |
Yann | 0:f30e2135b0db | 201 | } |
Yann | 0:f30e2135b0db | 202 | |
Yann | 0:f30e2135b0db | 203 | u->us_serverstate = UPAPSS_LISTEN; |
Yann | 0:f30e2135b0db | 204 | if (u->us_reqtimeout > 0) { |
Yann | 0:f30e2135b0db | 205 | TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); |
Yann | 0:f30e2135b0db | 206 | } |
Yann | 0:f30e2135b0db | 207 | } |
Yann | 0:f30e2135b0db | 208 | |
Yann | 0:f30e2135b0db | 209 | /* |
Yann | 0:f30e2135b0db | 210 | * upap_timeout - Retransmission timer for sending auth-reqs expired. |
Yann | 0:f30e2135b0db | 211 | */ |
Yann | 0:f30e2135b0db | 212 | static void |
Yann | 0:f30e2135b0db | 213 | upap_timeout(void *arg) |
Yann | 0:f30e2135b0db | 214 | { |
Yann | 0:f30e2135b0db | 215 | upap_state *u = (upap_state *) arg; |
Yann | 0:f30e2135b0db | 216 | |
Yann | 0:f30e2135b0db | 217 | UPAPDEBUG(LOG_INFO, ("upap_timeout: %d timeout %d expired s=%d\n", |
Yann | 0:f30e2135b0db | 218 | u->us_unit, u->us_timeouttime, u->us_clientstate)); |
Yann | 0:f30e2135b0db | 219 | |
Yann | 0:f30e2135b0db | 220 | if (u->us_clientstate != UPAPCS_AUTHREQ) { |
Yann | 0:f30e2135b0db | 221 | UPAPDEBUG(LOG_INFO, ("upap_timeout: not in AUTHREQ state!\n")); |
Yann | 0:f30e2135b0db | 222 | return; |
Yann | 0:f30e2135b0db | 223 | } |
Yann | 0:f30e2135b0db | 224 | |
Yann | 0:f30e2135b0db | 225 | if (u->us_transmits >= u->us_maxtransmits) { |
Yann | 0:f30e2135b0db | 226 | /* give up in disgust */ |
Yann | 0:f30e2135b0db | 227 | UPAPDEBUG(LOG_ERR, ("No response to PAP authenticate-requests\n")); |
Yann | 0:f30e2135b0db | 228 | u->us_clientstate = UPAPCS_BADAUTH; |
Yann | 0:f30e2135b0db | 229 | auth_withpeer_fail(u->us_unit, PPP_PAP); |
Yann | 0:f30e2135b0db | 230 | return; |
Yann | 0:f30e2135b0db | 231 | } |
Yann | 0:f30e2135b0db | 232 | |
Yann | 0:f30e2135b0db | 233 | upap_sauthreq(u); /* Send Authenticate-Request and set upap timeout*/ |
Yann | 0:f30e2135b0db | 234 | } |
Yann | 0:f30e2135b0db | 235 | |
Yann | 0:f30e2135b0db | 236 | |
Yann | 0:f30e2135b0db | 237 | /* |
Yann | 0:f30e2135b0db | 238 | * upap_reqtimeout - Give up waiting for the peer to send an auth-req. |
Yann | 0:f30e2135b0db | 239 | */ |
Yann | 0:f30e2135b0db | 240 | static void |
Yann | 0:f30e2135b0db | 241 | upap_reqtimeout(void *arg) |
Yann | 0:f30e2135b0db | 242 | { |
Yann | 0:f30e2135b0db | 243 | upap_state *u = (upap_state *) arg; |
Yann | 0:f30e2135b0db | 244 | |
Yann | 0:f30e2135b0db | 245 | if (u->us_serverstate != UPAPSS_LISTEN) { |
Yann | 0:f30e2135b0db | 246 | return; /* huh?? */ |
Yann | 0:f30e2135b0db | 247 | } |
Yann | 0:f30e2135b0db | 248 | |
Yann | 0:f30e2135b0db | 249 | auth_peer_fail(u->us_unit, PPP_PAP); |
Yann | 0:f30e2135b0db | 250 | u->us_serverstate = UPAPSS_BADAUTH; |
Yann | 0:f30e2135b0db | 251 | } |
Yann | 0:f30e2135b0db | 252 | |
Yann | 0:f30e2135b0db | 253 | |
Yann | 0:f30e2135b0db | 254 | /* |
Yann | 0:f30e2135b0db | 255 | * upap_lowerup - The lower layer is up. |
Yann | 0:f30e2135b0db | 256 | * |
Yann | 0:f30e2135b0db | 257 | * Start authenticating if pending. |
Yann | 0:f30e2135b0db | 258 | */ |
Yann | 0:f30e2135b0db | 259 | static void |
Yann | 0:f30e2135b0db | 260 | upap_lowerup(int unit) |
Yann | 0:f30e2135b0db | 261 | { |
Yann | 0:f30e2135b0db | 262 | upap_state *u = &upap[unit]; |
Yann | 0:f30e2135b0db | 263 | |
Yann | 0:f30e2135b0db | 264 | UPAPDEBUG(LOG_INFO, ("upap_lowerup: init %d clientstate s=%d\n", unit, u->us_clientstate)); |
Yann | 0:f30e2135b0db | 265 | |
Yann | 0:f30e2135b0db | 266 | if (u->us_clientstate == UPAPCS_INITIAL) { |
Yann | 0:f30e2135b0db | 267 | u->us_clientstate = UPAPCS_CLOSED; |
Yann | 0:f30e2135b0db | 268 | } else if (u->us_clientstate == UPAPCS_PENDING) { |
Yann | 0:f30e2135b0db | 269 | upap_sauthreq(u); /* send an auth-request */ |
Yann | 0:f30e2135b0db | 270 | /* now client state is UPAPCS__AUTHREQ */ |
Yann | 0:f30e2135b0db | 271 | } |
Yann | 0:f30e2135b0db | 272 | |
Yann | 0:f30e2135b0db | 273 | if (u->us_serverstate == UPAPSS_INITIAL) { |
Yann | 0:f30e2135b0db | 274 | u->us_serverstate = UPAPSS_CLOSED; |
Yann | 0:f30e2135b0db | 275 | } else if (u->us_serverstate == UPAPSS_PENDING) { |
Yann | 0:f30e2135b0db | 276 | u->us_serverstate = UPAPSS_LISTEN; |
Yann | 0:f30e2135b0db | 277 | if (u->us_reqtimeout > 0) { |
Yann | 0:f30e2135b0db | 278 | TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); |
Yann | 0:f30e2135b0db | 279 | } |
Yann | 0:f30e2135b0db | 280 | } |
Yann | 0:f30e2135b0db | 281 | } |
Yann | 0:f30e2135b0db | 282 | |
Yann | 0:f30e2135b0db | 283 | |
Yann | 0:f30e2135b0db | 284 | /* |
Yann | 0:f30e2135b0db | 285 | * upap_lowerdown - The lower layer is down. |
Yann | 0:f30e2135b0db | 286 | * |
Yann | 0:f30e2135b0db | 287 | * Cancel all timeouts. |
Yann | 0:f30e2135b0db | 288 | */ |
Yann | 0:f30e2135b0db | 289 | static void |
Yann | 0:f30e2135b0db | 290 | upap_lowerdown(int unit) |
Yann | 0:f30e2135b0db | 291 | { |
Yann | 0:f30e2135b0db | 292 | upap_state *u = &upap[unit]; |
Yann | 0:f30e2135b0db | 293 | |
Yann | 0:f30e2135b0db | 294 | UPAPDEBUG(LOG_INFO, ("upap_lowerdown: %d s=%d\n", unit, u->us_clientstate)); |
Yann | 0:f30e2135b0db | 295 | |
Yann | 0:f30e2135b0db | 296 | if (u->us_clientstate == UPAPCS_AUTHREQ) { /* Timeout pending? */ |
Yann | 0:f30e2135b0db | 297 | UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ |
Yann | 0:f30e2135b0db | 298 | } |
Yann | 0:f30e2135b0db | 299 | if (u->us_serverstate == UPAPSS_LISTEN && u->us_reqtimeout > 0) { |
Yann | 0:f30e2135b0db | 300 | UNTIMEOUT(upap_reqtimeout, u); |
Yann | 0:f30e2135b0db | 301 | } |
Yann | 0:f30e2135b0db | 302 | |
Yann | 0:f30e2135b0db | 303 | u->us_clientstate = UPAPCS_INITIAL; |
Yann | 0:f30e2135b0db | 304 | u->us_serverstate = UPAPSS_INITIAL; |
Yann | 0:f30e2135b0db | 305 | } |
Yann | 0:f30e2135b0db | 306 | |
Yann | 0:f30e2135b0db | 307 | |
Yann | 0:f30e2135b0db | 308 | /* |
Yann | 0:f30e2135b0db | 309 | * upap_protrej - Peer doesn't speak this protocol. |
Yann | 0:f30e2135b0db | 310 | * |
Yann | 0:f30e2135b0db | 311 | * This shouldn't happen. In any case, pretend lower layer went down. |
Yann | 0:f30e2135b0db | 312 | */ |
Yann | 0:f30e2135b0db | 313 | static void |
Yann | 0:f30e2135b0db | 314 | upap_protrej(int unit) |
Yann | 0:f30e2135b0db | 315 | { |
Yann | 0:f30e2135b0db | 316 | upap_state *u = &upap[unit]; |
Yann | 0:f30e2135b0db | 317 | |
Yann | 0:f30e2135b0db | 318 | if (u->us_clientstate == UPAPCS_AUTHREQ) { |
Yann | 0:f30e2135b0db | 319 | UPAPDEBUG(LOG_ERR, ("PAP authentication failed due to protocol-reject\n")); |
Yann | 0:f30e2135b0db | 320 | auth_withpeer_fail(unit, PPP_PAP); |
Yann | 0:f30e2135b0db | 321 | } |
Yann | 0:f30e2135b0db | 322 | if (u->us_serverstate == UPAPSS_LISTEN) { |
Yann | 0:f30e2135b0db | 323 | UPAPDEBUG(LOG_ERR, ("PAP authentication of peer failed (protocol-reject)\n")); |
Yann | 0:f30e2135b0db | 324 | auth_peer_fail(unit, PPP_PAP); |
Yann | 0:f30e2135b0db | 325 | } |
Yann | 0:f30e2135b0db | 326 | upap_lowerdown(unit); |
Yann | 0:f30e2135b0db | 327 | } |
Yann | 0:f30e2135b0db | 328 | |
Yann | 0:f30e2135b0db | 329 | |
Yann | 0:f30e2135b0db | 330 | /* |
Yann | 0:f30e2135b0db | 331 | * upap_input - Input UPAP packet. |
Yann | 0:f30e2135b0db | 332 | */ |
Yann | 0:f30e2135b0db | 333 | static void |
Yann | 0:f30e2135b0db | 334 | upap_input(int unit, u_char *inpacket, int l) |
Yann | 0:f30e2135b0db | 335 | { |
Yann | 0:f30e2135b0db | 336 | upap_state *u = &upap[unit]; |
Yann | 0:f30e2135b0db | 337 | u_char *inp; |
Yann | 0:f30e2135b0db | 338 | u_char code, id; |
Yann | 0:f30e2135b0db | 339 | int len; |
Yann | 0:f30e2135b0db | 340 | |
Yann | 0:f30e2135b0db | 341 | /* |
Yann | 0:f30e2135b0db | 342 | * Parse header (code, id and length). |
Yann | 0:f30e2135b0db | 343 | * If packet too short, drop it. |
Yann | 0:f30e2135b0db | 344 | */ |
Yann | 0:f30e2135b0db | 345 | inp = inpacket; |
Yann | 0:f30e2135b0db | 346 | if (l < (int)UPAP_HEADERLEN) { |
Yann | 0:f30e2135b0db | 347 | UPAPDEBUG(LOG_INFO, ("pap_input: rcvd short header.\n")); |
Yann | 0:f30e2135b0db | 348 | return; |
Yann | 0:f30e2135b0db | 349 | } |
Yann | 0:f30e2135b0db | 350 | GETCHAR(code, inp); |
Yann | 0:f30e2135b0db | 351 | GETCHAR(id, inp); |
Yann | 0:f30e2135b0db | 352 | GETSHORT(len, inp); |
Yann | 0:f30e2135b0db | 353 | if (len < (int)UPAP_HEADERLEN) { |
Yann | 0:f30e2135b0db | 354 | UPAPDEBUG(LOG_INFO, ("pap_input: rcvd illegal length.\n")); |
Yann | 0:f30e2135b0db | 355 | return; |
Yann | 0:f30e2135b0db | 356 | } |
Yann | 0:f30e2135b0db | 357 | if (len > l) { |
Yann | 0:f30e2135b0db | 358 | UPAPDEBUG(LOG_INFO, ("pap_input: rcvd short packet.\n")); |
Yann | 0:f30e2135b0db | 359 | return; |
Yann | 0:f30e2135b0db | 360 | } |
Yann | 0:f30e2135b0db | 361 | len -= UPAP_HEADERLEN; |
Yann | 0:f30e2135b0db | 362 | |
Yann | 0:f30e2135b0db | 363 | /* |
Yann | 0:f30e2135b0db | 364 | * Action depends on code. |
Yann | 0:f30e2135b0db | 365 | */ |
Yann | 0:f30e2135b0db | 366 | switch (code) { |
Yann | 0:f30e2135b0db | 367 | case UPAP_AUTHREQ: |
Yann | 0:f30e2135b0db | 368 | upap_rauthreq(u, inp, id, len); |
Yann | 0:f30e2135b0db | 369 | break; |
Yann | 0:f30e2135b0db | 370 | |
Yann | 0:f30e2135b0db | 371 | case UPAP_AUTHACK: |
Yann | 0:f30e2135b0db | 372 | upap_rauthack(u, inp, id, len); |
Yann | 0:f30e2135b0db | 373 | break; |
Yann | 0:f30e2135b0db | 374 | |
Yann | 0:f30e2135b0db | 375 | case UPAP_AUTHNAK: |
Yann | 0:f30e2135b0db | 376 | upap_rauthnak(u, inp, id, len); |
Yann | 0:f30e2135b0db | 377 | break; |
Yann | 0:f30e2135b0db | 378 | |
Yann | 0:f30e2135b0db | 379 | default: /* XXX Need code reject */ |
Yann | 0:f30e2135b0db | 380 | UPAPDEBUG(LOG_INFO, ("pap_input: UNHANDLED default: code: %d, id: %d, len: %d.\n", code, id, len)); |
Yann | 0:f30e2135b0db | 381 | break; |
Yann | 0:f30e2135b0db | 382 | } |
Yann | 0:f30e2135b0db | 383 | } |
Yann | 0:f30e2135b0db | 384 | |
Yann | 0:f30e2135b0db | 385 | |
Yann | 0:f30e2135b0db | 386 | /* |
Yann | 0:f30e2135b0db | 387 | * upap_rauth - Receive Authenticate. |
Yann | 0:f30e2135b0db | 388 | */ |
Yann | 0:f30e2135b0db | 389 | static void |
Yann | 0:f30e2135b0db | 390 | upap_rauthreq(upap_state *u, u_char *inp, u_char id, int len) |
Yann | 0:f30e2135b0db | 391 | { |
Yann | 0:f30e2135b0db | 392 | u_char ruserlen, rpasswdlen; |
Yann | 0:f30e2135b0db | 393 | char *ruser, *rpasswd; |
Yann | 0:f30e2135b0db | 394 | u_char retcode; |
Yann | 0:f30e2135b0db | 395 | char *msg; |
Yann | 0:f30e2135b0db | 396 | int msglen; |
Yann | 0:f30e2135b0db | 397 | |
Yann | 0:f30e2135b0db | 398 | UPAPDEBUG(LOG_INFO, ("pap_rauth: Rcvd id %d.\n", id)); |
Yann | 0:f30e2135b0db | 399 | |
Yann | 0:f30e2135b0db | 400 | if (u->us_serverstate < UPAPSS_LISTEN) { |
Yann | 0:f30e2135b0db | 401 | return; |
Yann | 0:f30e2135b0db | 402 | } |
Yann | 0:f30e2135b0db | 403 | |
Yann | 0:f30e2135b0db | 404 | /* |
Yann | 0:f30e2135b0db | 405 | * If we receive a duplicate authenticate-request, we are |
Yann | 0:f30e2135b0db | 406 | * supposed to return the same status as for the first request. |
Yann | 0:f30e2135b0db | 407 | */ |
Yann | 0:f30e2135b0db | 408 | if (u->us_serverstate == UPAPSS_OPEN) { |
Yann | 0:f30e2135b0db | 409 | upap_sresp(u, UPAP_AUTHACK, id, "", 0); /* return auth-ack */ |
Yann | 0:f30e2135b0db | 410 | return; |
Yann | 0:f30e2135b0db | 411 | } |
Yann | 0:f30e2135b0db | 412 | if (u->us_serverstate == UPAPSS_BADAUTH) { |
Yann | 0:f30e2135b0db | 413 | upap_sresp(u, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */ |
Yann | 0:f30e2135b0db | 414 | return; |
Yann | 0:f30e2135b0db | 415 | } |
Yann | 0:f30e2135b0db | 416 | |
Yann | 0:f30e2135b0db | 417 | /* |
Yann | 0:f30e2135b0db | 418 | * Parse user/passwd. |
Yann | 0:f30e2135b0db | 419 | */ |
Yann | 0:f30e2135b0db | 420 | if (len < (int)sizeof (u_char)) { |
Yann | 0:f30e2135b0db | 421 | UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); |
Yann | 0:f30e2135b0db | 422 | return; |
Yann | 0:f30e2135b0db | 423 | } |
Yann | 0:f30e2135b0db | 424 | GETCHAR(ruserlen, inp); |
Yann | 0:f30e2135b0db | 425 | len -= sizeof (u_char) + ruserlen + sizeof (u_char); |
Yann | 0:f30e2135b0db | 426 | if (len < 0) { |
Yann | 0:f30e2135b0db | 427 | UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); |
Yann | 0:f30e2135b0db | 428 | return; |
Yann | 0:f30e2135b0db | 429 | } |
Yann | 0:f30e2135b0db | 430 | ruser = (char *) inp; |
Yann | 0:f30e2135b0db | 431 | INCPTR(ruserlen, inp); |
Yann | 0:f30e2135b0db | 432 | GETCHAR(rpasswdlen, inp); |
Yann | 0:f30e2135b0db | 433 | if (len < rpasswdlen) { |
Yann | 0:f30e2135b0db | 434 | UPAPDEBUG(LOG_INFO, ("pap_rauth: rcvd short packet.\n")); |
Yann | 0:f30e2135b0db | 435 | return; |
Yann | 0:f30e2135b0db | 436 | } |
Yann | 0:f30e2135b0db | 437 | rpasswd = (char *) inp; |
Yann | 0:f30e2135b0db | 438 | |
Yann | 0:f30e2135b0db | 439 | /* |
Yann | 0:f30e2135b0db | 440 | * Check the username and password given. |
Yann | 0:f30e2135b0db | 441 | */ |
Yann | 0:f30e2135b0db | 442 | retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd, rpasswdlen, &msg, &msglen); |
Yann | 0:f30e2135b0db | 443 | /* lwip: currently retcode is always UPAP_AUTHACK */ |
Yann | 0:f30e2135b0db | 444 | BZERO(rpasswd, rpasswdlen); |
Yann | 0:f30e2135b0db | 445 | |
Yann | 0:f30e2135b0db | 446 | upap_sresp(u, retcode, id, msg, msglen); |
Yann | 0:f30e2135b0db | 447 | |
Yann | 0:f30e2135b0db | 448 | if (retcode == UPAP_AUTHACK) { |
Yann | 0:f30e2135b0db | 449 | u->us_serverstate = UPAPSS_OPEN; |
Yann | 0:f30e2135b0db | 450 | auth_peer_success(u->us_unit, PPP_PAP, ruser, ruserlen); |
Yann | 0:f30e2135b0db | 451 | } else { |
Yann | 0:f30e2135b0db | 452 | u->us_serverstate = UPAPSS_BADAUTH; |
Yann | 0:f30e2135b0db | 453 | auth_peer_fail(u->us_unit, PPP_PAP); |
Yann | 0:f30e2135b0db | 454 | } |
Yann | 0:f30e2135b0db | 455 | |
Yann | 0:f30e2135b0db | 456 | if (u->us_reqtimeout > 0) { |
Yann | 0:f30e2135b0db | 457 | UNTIMEOUT(upap_reqtimeout, u); |
Yann | 0:f30e2135b0db | 458 | } |
Yann | 0:f30e2135b0db | 459 | } |
Yann | 0:f30e2135b0db | 460 | |
Yann | 0:f30e2135b0db | 461 | |
Yann | 0:f30e2135b0db | 462 | /* |
Yann | 0:f30e2135b0db | 463 | * upap_rauthack - Receive Authenticate-Ack. |
Yann | 0:f30e2135b0db | 464 | */ |
Yann | 0:f30e2135b0db | 465 | static void |
Yann | 0:f30e2135b0db | 466 | upap_rauthack(upap_state *u, u_char *inp, int id, int len) |
Yann | 0:f30e2135b0db | 467 | { |
Yann | 0:f30e2135b0db | 468 | u_char msglen; |
Yann | 0:f30e2135b0db | 469 | char *msg; |
Yann | 0:f30e2135b0db | 470 | |
Yann | 0:f30e2135b0db | 471 | LWIP_UNUSED_ARG(id); |
Yann | 0:f30e2135b0db | 472 | |
Yann | 0:f30e2135b0db | 473 | UPAPDEBUG(LOG_INFO, ("pap_rauthack: Rcvd id %d s=%d\n", id, u->us_clientstate)); |
Yann | 0:f30e2135b0db | 474 | |
Yann | 0:f30e2135b0db | 475 | if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */ |
Yann | 0:f30e2135b0db | 476 | UPAPDEBUG(LOG_INFO, ("pap_rauthack: us_clientstate != UPAPCS_AUTHREQ\n")); |
Yann | 0:f30e2135b0db | 477 | return; |
Yann | 0:f30e2135b0db | 478 | } |
Yann | 0:f30e2135b0db | 479 | |
Yann | 0:f30e2135b0db | 480 | /* |
Yann | 0:f30e2135b0db | 481 | * Parse message. |
Yann | 0:f30e2135b0db | 482 | */ |
Yann | 0:f30e2135b0db | 483 | if (len < (int)sizeof (u_char)) { |
Yann | 0:f30e2135b0db | 484 | UPAPDEBUG(LOG_INFO, ("pap_rauthack: ignoring missing msg-length.\n")); |
Yann | 0:f30e2135b0db | 485 | } else { |
Yann | 0:f30e2135b0db | 486 | GETCHAR(msglen, inp); |
Yann | 0:f30e2135b0db | 487 | if (msglen > 0) { |
Yann | 0:f30e2135b0db | 488 | len -= sizeof (u_char); |
Yann | 0:f30e2135b0db | 489 | if (len < msglen) { |
Yann | 0:f30e2135b0db | 490 | UPAPDEBUG(LOG_INFO, ("pap_rauthack: rcvd short packet.\n")); |
Yann | 0:f30e2135b0db | 491 | return; |
Yann | 0:f30e2135b0db | 492 | } |
Yann | 0:f30e2135b0db | 493 | msg = (char *) inp; |
Yann | 0:f30e2135b0db | 494 | PRINTMSG(msg, msglen); |
Yann | 0:f30e2135b0db | 495 | } |
Yann | 0:f30e2135b0db | 496 | } |
Yann | 0:f30e2135b0db | 497 | UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ |
Yann | 0:f30e2135b0db | 498 | u->us_clientstate = UPAPCS_OPEN; |
Yann | 0:f30e2135b0db | 499 | |
Yann | 0:f30e2135b0db | 500 | auth_withpeer_success(u->us_unit, PPP_PAP); |
Yann | 0:f30e2135b0db | 501 | } |
Yann | 0:f30e2135b0db | 502 | |
Yann | 0:f30e2135b0db | 503 | |
Yann | 0:f30e2135b0db | 504 | /* |
Yann | 0:f30e2135b0db | 505 | * upap_rauthnak - Receive Authenticate-Nak. |
Yann | 0:f30e2135b0db | 506 | */ |
Yann | 0:f30e2135b0db | 507 | static void |
Yann | 0:f30e2135b0db | 508 | upap_rauthnak(upap_state *u, u_char *inp, int id, int len) |
Yann | 0:f30e2135b0db | 509 | { |
Yann | 0:f30e2135b0db | 510 | u_char msglen; |
Yann | 0:f30e2135b0db | 511 | char *msg; |
Yann | 0:f30e2135b0db | 512 | |
Yann | 0:f30e2135b0db | 513 | LWIP_UNUSED_ARG(id); |
Yann | 0:f30e2135b0db | 514 | |
Yann | 0:f30e2135b0db | 515 | UPAPDEBUG(LOG_INFO, ("pap_rauthnak: Rcvd id %d s=%d\n", id, u->us_clientstate)); |
Yann | 0:f30e2135b0db | 516 | |
Yann | 0:f30e2135b0db | 517 | if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */ |
Yann | 0:f30e2135b0db | 518 | return; |
Yann | 0:f30e2135b0db | 519 | } |
Yann | 0:f30e2135b0db | 520 | |
Yann | 0:f30e2135b0db | 521 | /* |
Yann | 0:f30e2135b0db | 522 | * Parse message. |
Yann | 0:f30e2135b0db | 523 | */ |
Yann | 0:f30e2135b0db | 524 | if (len < sizeof (u_char)) { |
Yann | 0:f30e2135b0db | 525 | UPAPDEBUG(LOG_INFO, ("pap_rauthnak: ignoring missing msg-length.\n")); |
Yann | 0:f30e2135b0db | 526 | } else { |
Yann | 0:f30e2135b0db | 527 | GETCHAR(msglen, inp); |
Yann | 0:f30e2135b0db | 528 | if(msglen > 0) { |
Yann | 0:f30e2135b0db | 529 | len -= sizeof (u_char); |
Yann | 0:f30e2135b0db | 530 | if (len < msglen) { |
Yann | 0:f30e2135b0db | 531 | UPAPDEBUG(LOG_INFO, ("pap_rauthnak: rcvd short packet.\n")); |
Yann | 0:f30e2135b0db | 532 | return; |
Yann | 0:f30e2135b0db | 533 | } |
Yann | 0:f30e2135b0db | 534 | msg = (char *) inp; |
Yann | 0:f30e2135b0db | 535 | PRINTMSG(msg, msglen); |
Yann | 0:f30e2135b0db | 536 | } |
Yann | 0:f30e2135b0db | 537 | } |
Yann | 0:f30e2135b0db | 538 | |
Yann | 0:f30e2135b0db | 539 | u->us_clientstate = UPAPCS_BADAUTH; |
Yann | 0:f30e2135b0db | 540 | |
Yann | 0:f30e2135b0db | 541 | UPAPDEBUG(LOG_ERR, ("PAP authentication failed\n")); |
Yann | 0:f30e2135b0db | 542 | auth_withpeer_fail(u->us_unit, PPP_PAP); |
Yann | 0:f30e2135b0db | 543 | } |
Yann | 0:f30e2135b0db | 544 | |
Yann | 0:f30e2135b0db | 545 | |
Yann | 0:f30e2135b0db | 546 | /* |
Yann | 0:f30e2135b0db | 547 | * upap_sauthreq - Send an Authenticate-Request. |
Yann | 0:f30e2135b0db | 548 | */ |
Yann | 0:f30e2135b0db | 549 | static void |
Yann | 0:f30e2135b0db | 550 | upap_sauthreq(upap_state *u) |
Yann | 0:f30e2135b0db | 551 | { |
Yann | 0:f30e2135b0db | 552 | u_char *outp; |
Yann | 0:f30e2135b0db | 553 | int outlen; |
Yann | 0:f30e2135b0db | 554 | |
Yann | 0:f30e2135b0db | 555 | outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) |
Yann | 0:f30e2135b0db | 556 | + u->us_userlen + u->us_passwdlen; |
Yann | 0:f30e2135b0db | 557 | outp = outpacket_buf[u->us_unit]; |
Yann | 0:f30e2135b0db | 558 | |
Yann | 0:f30e2135b0db | 559 | MAKEHEADER(outp, PPP_PAP); |
Yann | 0:f30e2135b0db | 560 | |
Yann | 0:f30e2135b0db | 561 | PUTCHAR(UPAP_AUTHREQ, outp); |
Yann | 0:f30e2135b0db | 562 | PUTCHAR(++u->us_id, outp); |
Yann | 0:f30e2135b0db | 563 | PUTSHORT(outlen, outp); |
Yann | 0:f30e2135b0db | 564 | PUTCHAR(u->us_userlen, outp); |
Yann | 0:f30e2135b0db | 565 | BCOPY(u->us_user, outp, u->us_userlen); |
Yann | 0:f30e2135b0db | 566 | INCPTR(u->us_userlen, outp); |
Yann | 0:f30e2135b0db | 567 | PUTCHAR(u->us_passwdlen, outp); |
Yann | 0:f30e2135b0db | 568 | BCOPY(u->us_passwd, outp, u->us_passwdlen); |
Yann | 0:f30e2135b0db | 569 | |
Yann | 0:f30e2135b0db | 570 | pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); |
Yann | 0:f30e2135b0db | 571 | |
Yann | 0:f30e2135b0db | 572 | UPAPDEBUG(LOG_INFO, ("pap_sauth: Sent id %d\n", u->us_id)); |
Yann | 0:f30e2135b0db | 573 | |
Yann | 0:f30e2135b0db | 574 | TIMEOUT(upap_timeout, u, u->us_timeouttime); |
Yann | 0:f30e2135b0db | 575 | ++u->us_transmits; |
Yann | 0:f30e2135b0db | 576 | u->us_clientstate = UPAPCS_AUTHREQ; |
Yann | 0:f30e2135b0db | 577 | } |
Yann | 0:f30e2135b0db | 578 | |
Yann | 0:f30e2135b0db | 579 | |
Yann | 0:f30e2135b0db | 580 | /* |
Yann | 0:f30e2135b0db | 581 | * upap_sresp - Send a response (ack or nak). |
Yann | 0:f30e2135b0db | 582 | */ |
Yann | 0:f30e2135b0db | 583 | static void |
Yann | 0:f30e2135b0db | 584 | upap_sresp(upap_state *u, u_char code, u_char id, char *msg, int msglen) |
Yann | 0:f30e2135b0db | 585 | { |
Yann | 0:f30e2135b0db | 586 | u_char *outp; |
Yann | 0:f30e2135b0db | 587 | int outlen; |
Yann | 0:f30e2135b0db | 588 | |
Yann | 0:f30e2135b0db | 589 | outlen = UPAP_HEADERLEN + sizeof (u_char) + msglen; |
Yann | 0:f30e2135b0db | 590 | outp = outpacket_buf[u->us_unit]; |
Yann | 0:f30e2135b0db | 591 | MAKEHEADER(outp, PPP_PAP); |
Yann | 0:f30e2135b0db | 592 | |
Yann | 0:f30e2135b0db | 593 | PUTCHAR(code, outp); |
Yann | 0:f30e2135b0db | 594 | PUTCHAR(id, outp); |
Yann | 0:f30e2135b0db | 595 | PUTSHORT(outlen, outp); |
Yann | 0:f30e2135b0db | 596 | PUTCHAR(msglen, outp); |
Yann | 0:f30e2135b0db | 597 | BCOPY(msg, outp, msglen); |
Yann | 0:f30e2135b0db | 598 | pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); |
Yann | 0:f30e2135b0db | 599 | |
Yann | 0:f30e2135b0db | 600 | UPAPDEBUG(LOG_INFO, ("pap_sresp: Sent code %d, id %d s=%d\n", code, id, u->us_clientstate)); |
Yann | 0:f30e2135b0db | 601 | } |
Yann | 0:f30e2135b0db | 602 | |
Yann | 0:f30e2135b0db | 603 | #if PPP_ADDITIONAL_CALLBACKS |
Yann | 0:f30e2135b0db | 604 | static char *upap_codenames[] = { |
Yann | 0:f30e2135b0db | 605 | "AuthReq", "AuthAck", "AuthNak" |
Yann | 0:f30e2135b0db | 606 | }; |
Yann | 0:f30e2135b0db | 607 | |
Yann | 0:f30e2135b0db | 608 | /* |
Yann | 0:f30e2135b0db | 609 | * upap_printpkt - print the contents of a PAP packet. |
Yann | 0:f30e2135b0db | 610 | */ |
Yann | 0:f30e2135b0db | 611 | static int upap_printpkt( |
Yann | 0:f30e2135b0db | 612 | u_char *p, |
Yann | 0:f30e2135b0db | 613 | int plen, |
Yann | 0:f30e2135b0db | 614 | void (*printer) (void *, char *, ...), |
Yann | 0:f30e2135b0db | 615 | void *arg |
Yann | 0:f30e2135b0db | 616 | ) |
Yann | 0:f30e2135b0db | 617 | { |
Yann | 0:f30e2135b0db | 618 | LWIP_UNUSED_ARG(p); |
Yann | 0:f30e2135b0db | 619 | LWIP_UNUSED_ARG(plen); |
Yann | 0:f30e2135b0db | 620 | LWIP_UNUSED_ARG(printer); |
Yann | 0:f30e2135b0db | 621 | LWIP_UNUSED_ARG(arg); |
Yann | 0:f30e2135b0db | 622 | return 0; |
Yann | 0:f30e2135b0db | 623 | } |
Yann | 0:f30e2135b0db | 624 | #endif /* PPP_ADDITIONAL_CALLBACKS */ |
Yann | 0:f30e2135b0db | 625 | |
Yann | 0:f30e2135b0db | 626 | #endif /* PAP_SUPPORT */ |
Yann | 0:f30e2135b0db | 627 | |
Yann | 0:f30e2135b0db | 628 | #endif /* PPP_SUPPORT */ |