HTTPClient using static IP

Dependencies:   mbed

Committer:
mr_q
Date:
Mon May 30 11:53:37 2011 +0000
Revision:
0:d8f2f7d5f31b
v0.01 Draft

Who changed what in which revision?

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