SNMP agent attached to SPI slave

Dependencies:   mbed

Committer:
lorcansmith
Date:
Mon Aug 13 15:07:40 2012 +0000
Revision:
0:2a53a4c3238c
v1.1 release includes ioAlarm traps

Who changed what in which revision?

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