Forked from STM32F7 internet for nucleo F746ZG

Dependents:   Nucleo_F746ZG_Ethernet_MQTT_Ultrasound

Fork of F7_Ethernet by Dieter Graef

Committer:
EmbeddedSam
Date:
Mon Oct 24 12:59:21 2016 +0000
Revision:
2:b4727195c450
Parent:
0:d26c1b55cfca
working with 1 ultrasound sensor approx 10hz update rate on mqtt

Who changed what in which revision?

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