Skovbrynet / Mbed 2 deprecated TankCounter

Dependencies:   EthernetInterface NTPClient SDFileSystem TextLCD WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip FATFileSystem

Committer:
Tuxitheone
Date:
Mon Feb 29 18:59:15 2016 +0000
Revision:
0:ecaf3e593122
TankCounter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Tuxitheone 0:ecaf3e593122 1 /*****************************************************************************
Tuxitheone 0:ecaf3e593122 2 * lcp.c - Network Link Control Protocol program file.
Tuxitheone 0:ecaf3e593122 3 *
Tuxitheone 0:ecaf3e593122 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
Tuxitheone 0:ecaf3e593122 5 * portions Copyright (c) 1997 by Global Election Systems Inc.
Tuxitheone 0:ecaf3e593122 6 *
Tuxitheone 0:ecaf3e593122 7 * The authors hereby grant permission to use, copy, modify, distribute,
Tuxitheone 0:ecaf3e593122 8 * and license this software and its documentation for any purpose, provided
Tuxitheone 0:ecaf3e593122 9 * that existing copyright notices are retained in all copies and that this
Tuxitheone 0:ecaf3e593122 10 * notice and the following disclaimer are included verbatim in any
Tuxitheone 0:ecaf3e593122 11 * distributions. No written agreement, license, or royalty fee is required
Tuxitheone 0:ecaf3e593122 12 * for any of the authorized uses.
Tuxitheone 0:ecaf3e593122 13 *
Tuxitheone 0:ecaf3e593122 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
Tuxitheone 0:ecaf3e593122 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Tuxitheone 0:ecaf3e593122 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Tuxitheone 0:ecaf3e593122 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
Tuxitheone 0:ecaf3e593122 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Tuxitheone 0:ecaf3e593122 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Tuxitheone 0:ecaf3e593122 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Tuxitheone 0:ecaf3e593122 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Tuxitheone 0:ecaf3e593122 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Tuxitheone 0:ecaf3e593122 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Tuxitheone 0:ecaf3e593122 24 *
Tuxitheone 0:ecaf3e593122 25 ******************************************************************************
Tuxitheone 0:ecaf3e593122 26 * REVISION HISTORY
Tuxitheone 0:ecaf3e593122 27 *
Tuxitheone 0:ecaf3e593122 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
Tuxitheone 0:ecaf3e593122 29 * Ported to lwIP.
Tuxitheone 0:ecaf3e593122 30 * 97-12-01 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc.
Tuxitheone 0:ecaf3e593122 31 * Original.
Tuxitheone 0:ecaf3e593122 32 *****************************************************************************/
Tuxitheone 0:ecaf3e593122 33
Tuxitheone 0:ecaf3e593122 34 /*
Tuxitheone 0:ecaf3e593122 35 * lcp.c - PPP Link Control Protocol.
Tuxitheone 0:ecaf3e593122 36 *
Tuxitheone 0:ecaf3e593122 37 * Copyright (c) 1989 Carnegie Mellon University.
Tuxitheone 0:ecaf3e593122 38 * All rights reserved.
Tuxitheone 0:ecaf3e593122 39 *
Tuxitheone 0:ecaf3e593122 40 * Redistribution and use in source and binary forms are permitted
Tuxitheone 0:ecaf3e593122 41 * provided that the above copyright notice and this paragraph are
Tuxitheone 0:ecaf3e593122 42 * duplicated in all such forms and that any documentation,
Tuxitheone 0:ecaf3e593122 43 * advertising materials, and other materials related to such
Tuxitheone 0:ecaf3e593122 44 * distribution and use acknowledge that the software was developed
Tuxitheone 0:ecaf3e593122 45 * by Carnegie Mellon University. The name of the
Tuxitheone 0:ecaf3e593122 46 * University may not be used to endorse or promote products derived
Tuxitheone 0:ecaf3e593122 47 * from this software without specific prior written permission.
Tuxitheone 0:ecaf3e593122 48 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
Tuxitheone 0:ecaf3e593122 49 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
Tuxitheone 0:ecaf3e593122 50 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Tuxitheone 0:ecaf3e593122 51 */
Tuxitheone 0:ecaf3e593122 52
Tuxitheone 0:ecaf3e593122 53
Tuxitheone 0:ecaf3e593122 54 #include "lwip/opt.h"
Tuxitheone 0:ecaf3e593122 55
Tuxitheone 0:ecaf3e593122 56 #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
Tuxitheone 0:ecaf3e593122 57
Tuxitheone 0:ecaf3e593122 58 #include "ppp.h"
Tuxitheone 0:ecaf3e593122 59 #include "pppdebug.h"
Tuxitheone 0:ecaf3e593122 60
Tuxitheone 0:ecaf3e593122 61 #include "fsm.h"
Tuxitheone 0:ecaf3e593122 62 #include "chap.h"
Tuxitheone 0:ecaf3e593122 63 #include "magic.h"
Tuxitheone 0:ecaf3e593122 64 #include "auth.h"
Tuxitheone 0:ecaf3e593122 65 #include "lcp.h"
Tuxitheone 0:ecaf3e593122 66
Tuxitheone 0:ecaf3e593122 67 #include <string.h>
Tuxitheone 0:ecaf3e593122 68
Tuxitheone 0:ecaf3e593122 69 #if PPPOE_SUPPORT
Tuxitheone 0:ecaf3e593122 70 #include "netif/ppp_oe.h"
Tuxitheone 0:ecaf3e593122 71 #else
Tuxitheone 0:ecaf3e593122 72 #define PPPOE_MAXMTU PPP_MAXMRU
Tuxitheone 0:ecaf3e593122 73 #endif
Tuxitheone 0:ecaf3e593122 74
Tuxitheone 0:ecaf3e593122 75 #if 0 /* UNUSED */
Tuxitheone 0:ecaf3e593122 76 /*
Tuxitheone 0:ecaf3e593122 77 * LCP-related command-line options.
Tuxitheone 0:ecaf3e593122 78 */
Tuxitheone 0:ecaf3e593122 79 int lcp_echo_interval = 0; /* Interval between LCP echo-requests */
Tuxitheone 0:ecaf3e593122 80 int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */
Tuxitheone 0:ecaf3e593122 81 bool lax_recv = 0; /* accept control chars in asyncmap */
Tuxitheone 0:ecaf3e593122 82
Tuxitheone 0:ecaf3e593122 83 static int setescape (char **);
Tuxitheone 0:ecaf3e593122 84
Tuxitheone 0:ecaf3e593122 85 static option_t lcp_option_list[] = {
Tuxitheone 0:ecaf3e593122 86 /* LCP options */
Tuxitheone 0:ecaf3e593122 87 /* list stripped for simplicity */
Tuxitheone 0:ecaf3e593122 88 {NULL}
Tuxitheone 0:ecaf3e593122 89 };
Tuxitheone 0:ecaf3e593122 90 #endif /* UNUSED */
Tuxitheone 0:ecaf3e593122 91
Tuxitheone 0:ecaf3e593122 92 /* options */
Tuxitheone 0:ecaf3e593122 93 LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */
Tuxitheone 0:ecaf3e593122 94 static u_int lcp_echo_interval = LCP_ECHOINTERVAL; /* Interval between LCP echo-requests */
Tuxitheone 0:ecaf3e593122 95 static u_int lcp_echo_fails = LCP_MAXECHOFAILS; /* Tolerance to unanswered echo-requests */
Tuxitheone 0:ecaf3e593122 96
Tuxitheone 0:ecaf3e593122 97 /* global vars */
Tuxitheone 0:ecaf3e593122 98 static fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/
Tuxitheone 0:ecaf3e593122 99 lcp_options lcp_wantoptions[NUM_PPP]; /* Options that we want to request */
Tuxitheone 0:ecaf3e593122 100 lcp_options lcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */
Tuxitheone 0:ecaf3e593122 101 lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
Tuxitheone 0:ecaf3e593122 102 lcp_options lcp_hisoptions[NUM_PPP]; /* Options that we ack'd */
Tuxitheone 0:ecaf3e593122 103 ext_accm xmit_accm[NUM_PPP]; /* extended transmit ACCM */
Tuxitheone 0:ecaf3e593122 104
Tuxitheone 0:ecaf3e593122 105 static u32_t lcp_echos_pending = 0; /* Number of outstanding echo msgs */
Tuxitheone 0:ecaf3e593122 106 static u32_t lcp_echo_number = 0; /* ID number of next echo frame */
Tuxitheone 0:ecaf3e593122 107 static u32_t lcp_echo_timer_running = 0; /* TRUE if a timer is running */
Tuxitheone 0:ecaf3e593122 108
Tuxitheone 0:ecaf3e593122 109 /* @todo: do we really need such a large buffer? The typical 1500 bytes seem too much. */
Tuxitheone 0:ecaf3e593122 110 static u_char nak_buffer[PPP_MRU] __attribute((section("AHBSRAM1"))); /* where we construct a nak packet */
Tuxitheone 0:ecaf3e593122 111
Tuxitheone 0:ecaf3e593122 112 /*
Tuxitheone 0:ecaf3e593122 113 * Callbacks for fsm code. (CI = Configuration Information)
Tuxitheone 0:ecaf3e593122 114 */
Tuxitheone 0:ecaf3e593122 115 static void lcp_resetci (fsm*); /* Reset our CI */
Tuxitheone 0:ecaf3e593122 116 static int lcp_cilen (fsm*); /* Return length of our CI */
Tuxitheone 0:ecaf3e593122 117 static void lcp_addci (fsm*, u_char*, int*); /* Add our CI to pkt */
Tuxitheone 0:ecaf3e593122 118 static int lcp_ackci (fsm*, u_char*, int); /* Peer ack'd our CI */
Tuxitheone 0:ecaf3e593122 119 static int lcp_nakci (fsm*, u_char*, int); /* Peer nak'd our CI */
Tuxitheone 0:ecaf3e593122 120 static int lcp_rejci (fsm*, u_char*, int); /* Peer rej'd our CI */
Tuxitheone 0:ecaf3e593122 121 static int lcp_reqci (fsm*, u_char*, int*, int); /* Rcv peer CI */
Tuxitheone 0:ecaf3e593122 122 static void lcp_up (fsm*); /* We're UP */
Tuxitheone 0:ecaf3e593122 123 static void lcp_down (fsm*); /* We're DOWN */
Tuxitheone 0:ecaf3e593122 124 static void lcp_starting (fsm*); /* We need lower layer up */
Tuxitheone 0:ecaf3e593122 125 static void lcp_finished (fsm*); /* We need lower layer down */
Tuxitheone 0:ecaf3e593122 126 static int lcp_extcode (fsm*, int, u_char, u_char*, int);
Tuxitheone 0:ecaf3e593122 127 static void lcp_rprotrej (fsm*, u_char*, int);
Tuxitheone 0:ecaf3e593122 128
Tuxitheone 0:ecaf3e593122 129 /*
Tuxitheone 0:ecaf3e593122 130 * routines to send LCP echos to peer
Tuxitheone 0:ecaf3e593122 131 */
Tuxitheone 0:ecaf3e593122 132
Tuxitheone 0:ecaf3e593122 133 static void lcp_echo_lowerup (int);
Tuxitheone 0:ecaf3e593122 134 static void lcp_echo_lowerdown (int);
Tuxitheone 0:ecaf3e593122 135 static void LcpEchoTimeout (void*);
Tuxitheone 0:ecaf3e593122 136 static void lcp_received_echo_reply (fsm*, int, u_char*, int);
Tuxitheone 0:ecaf3e593122 137 static void LcpSendEchoRequest (fsm*);
Tuxitheone 0:ecaf3e593122 138 static void LcpLinkFailure (fsm*);
Tuxitheone 0:ecaf3e593122 139 static void LcpEchoCheck (fsm*);
Tuxitheone 0:ecaf3e593122 140
Tuxitheone 0:ecaf3e593122 141 static fsm_callbacks lcp_callbacks = { /* LCP callback routines */
Tuxitheone 0:ecaf3e593122 142 lcp_resetci, /* Reset our Configuration Information */
Tuxitheone 0:ecaf3e593122 143 lcp_cilen, /* Length of our Configuration Information */
Tuxitheone 0:ecaf3e593122 144 lcp_addci, /* Add our Configuration Information */
Tuxitheone 0:ecaf3e593122 145 lcp_ackci, /* ACK our Configuration Information */
Tuxitheone 0:ecaf3e593122 146 lcp_nakci, /* NAK our Configuration Information */
Tuxitheone 0:ecaf3e593122 147 lcp_rejci, /* Reject our Configuration Information */
Tuxitheone 0:ecaf3e593122 148 lcp_reqci, /* Request peer's Configuration Information */
Tuxitheone 0:ecaf3e593122 149 lcp_up, /* Called when fsm reaches LS_OPENED state */
Tuxitheone 0:ecaf3e593122 150 lcp_down, /* Called when fsm leaves LS_OPENED state */
Tuxitheone 0:ecaf3e593122 151 lcp_starting, /* Called when we want the lower layer up */
Tuxitheone 0:ecaf3e593122 152 lcp_finished, /* Called when we want the lower layer down */
Tuxitheone 0:ecaf3e593122 153 NULL, /* Called when Protocol-Reject received */
Tuxitheone 0:ecaf3e593122 154 NULL, /* Retransmission is necessary */
Tuxitheone 0:ecaf3e593122 155 lcp_extcode, /* Called to handle LCP-specific codes */
Tuxitheone 0:ecaf3e593122 156 "LCP" /* String name of protocol */
Tuxitheone 0:ecaf3e593122 157 };
Tuxitheone 0:ecaf3e593122 158
Tuxitheone 0:ecaf3e593122 159 /*
Tuxitheone 0:ecaf3e593122 160 * Protocol entry points.
Tuxitheone 0:ecaf3e593122 161 * Some of these are called directly.
Tuxitheone 0:ecaf3e593122 162 */
Tuxitheone 0:ecaf3e593122 163
Tuxitheone 0:ecaf3e593122 164 static void lcp_input (int, u_char *, int);
Tuxitheone 0:ecaf3e593122 165 static void lcp_protrej (int);
Tuxitheone 0:ecaf3e593122 166
Tuxitheone 0:ecaf3e593122 167 struct protent lcp_protent = {
Tuxitheone 0:ecaf3e593122 168 PPP_LCP,
Tuxitheone 0:ecaf3e593122 169 lcp_init,
Tuxitheone 0:ecaf3e593122 170 lcp_input,
Tuxitheone 0:ecaf3e593122 171 lcp_protrej,
Tuxitheone 0:ecaf3e593122 172 lcp_lowerup,
Tuxitheone 0:ecaf3e593122 173 lcp_lowerdown,
Tuxitheone 0:ecaf3e593122 174 lcp_open,
Tuxitheone 0:ecaf3e593122 175 lcp_close,
Tuxitheone 0:ecaf3e593122 176 #if PPP_ADDITIONAL_CALLBACKS
Tuxitheone 0:ecaf3e593122 177 lcp_printpkt,
Tuxitheone 0:ecaf3e593122 178 NULL,
Tuxitheone 0:ecaf3e593122 179 #endif /* PPP_ADDITIONAL_CALLBACKS */
Tuxitheone 0:ecaf3e593122 180 1,
Tuxitheone 0:ecaf3e593122 181 "LCP",
Tuxitheone 0:ecaf3e593122 182 #if PPP_ADDITIONAL_CALLBACKS
Tuxitheone 0:ecaf3e593122 183 NULL,
Tuxitheone 0:ecaf3e593122 184 NULL,
Tuxitheone 0:ecaf3e593122 185 NULL
Tuxitheone 0:ecaf3e593122 186 #endif /* PPP_ADDITIONAL_CALLBACKS */
Tuxitheone 0:ecaf3e593122 187 };
Tuxitheone 0:ecaf3e593122 188
Tuxitheone 0:ecaf3e593122 189 int lcp_loopbackfail = DEFLOOPBACKFAIL;
Tuxitheone 0:ecaf3e593122 190
Tuxitheone 0:ecaf3e593122 191 /*
Tuxitheone 0:ecaf3e593122 192 * Length of each type of configuration option (in octets)
Tuxitheone 0:ecaf3e593122 193 */
Tuxitheone 0:ecaf3e593122 194 #define CILEN_VOID 2
Tuxitheone 0:ecaf3e593122 195 #define CILEN_CHAR 3
Tuxitheone 0:ecaf3e593122 196 #define CILEN_SHORT 4 /* CILEN_VOID + sizeof(short) */
Tuxitheone 0:ecaf3e593122 197 #define CILEN_CHAP 5 /* CILEN_VOID + sizeof(short) + 1 */
Tuxitheone 0:ecaf3e593122 198 #define CILEN_LONG 6 /* CILEN_VOID + sizeof(long) */
Tuxitheone 0:ecaf3e593122 199 #define CILEN_LQR 8 /* CILEN_VOID + sizeof(short) + sizeof(long) */
Tuxitheone 0:ecaf3e593122 200 #define CILEN_CBCP 3
Tuxitheone 0:ecaf3e593122 201
Tuxitheone 0:ecaf3e593122 202 #define CODENAME(x) ((x) == CONFACK ? "ACK" : (x) == CONFNAK ? "NAK" : "REJ")
Tuxitheone 0:ecaf3e593122 203
Tuxitheone 0:ecaf3e593122 204 #if 0 /* UNUSED */
Tuxitheone 0:ecaf3e593122 205 /*
Tuxitheone 0:ecaf3e593122 206 * setescape - add chars to the set we escape on transmission.
Tuxitheone 0:ecaf3e593122 207 */
Tuxitheone 0:ecaf3e593122 208 static int
Tuxitheone 0:ecaf3e593122 209 setescape(argv)
Tuxitheone 0:ecaf3e593122 210 char **argv;
Tuxitheone 0:ecaf3e593122 211 {
Tuxitheone 0:ecaf3e593122 212 int n, ret;
Tuxitheone 0:ecaf3e593122 213 char *p, *endp;
Tuxitheone 0:ecaf3e593122 214
Tuxitheone 0:ecaf3e593122 215 p = *argv;
Tuxitheone 0:ecaf3e593122 216 ret = 1;
Tuxitheone 0:ecaf3e593122 217 while (*p) {
Tuxitheone 0:ecaf3e593122 218 n = strtol(p, &endp, 16);
Tuxitheone 0:ecaf3e593122 219 if (p == endp) {
Tuxitheone 0:ecaf3e593122 220 option_error("escape parameter contains invalid hex number '%s'", p);
Tuxitheone 0:ecaf3e593122 221 return 0;
Tuxitheone 0:ecaf3e593122 222 }
Tuxitheone 0:ecaf3e593122 223 p = endp;
Tuxitheone 0:ecaf3e593122 224 if (n < 0 || n == 0x5E || n > 0xFF) {
Tuxitheone 0:ecaf3e593122 225 option_error("can't escape character 0x%x", n);
Tuxitheone 0:ecaf3e593122 226 ret = 0;
Tuxitheone 0:ecaf3e593122 227 } else
Tuxitheone 0:ecaf3e593122 228 xmit_accm[0][n >> 5] |= 1 << (n & 0x1F);
Tuxitheone 0:ecaf3e593122 229 while (*p == ',' || *p == ' ')
Tuxitheone 0:ecaf3e593122 230 ++p;
Tuxitheone 0:ecaf3e593122 231 }
Tuxitheone 0:ecaf3e593122 232 return ret;
Tuxitheone 0:ecaf3e593122 233 }
Tuxitheone 0:ecaf3e593122 234 #endif /* UNUSED */
Tuxitheone 0:ecaf3e593122 235
Tuxitheone 0:ecaf3e593122 236 /*
Tuxitheone 0:ecaf3e593122 237 * lcp_init - Initialize LCP.
Tuxitheone 0:ecaf3e593122 238 */
Tuxitheone 0:ecaf3e593122 239 void
Tuxitheone 0:ecaf3e593122 240 lcp_init(int unit)
Tuxitheone 0:ecaf3e593122 241 {
Tuxitheone 0:ecaf3e593122 242 fsm *f = &lcp_fsm[unit];
Tuxitheone 0:ecaf3e593122 243 lcp_options *wo = &lcp_wantoptions[unit];
Tuxitheone 0:ecaf3e593122 244 lcp_options *ao = &lcp_allowoptions[unit];
Tuxitheone 0:ecaf3e593122 245
Tuxitheone 0:ecaf3e593122 246 f->unit = unit;
Tuxitheone 0:ecaf3e593122 247 f->protocol = PPP_LCP;
Tuxitheone 0:ecaf3e593122 248 f->callbacks = &lcp_callbacks;
Tuxitheone 0:ecaf3e593122 249
Tuxitheone 0:ecaf3e593122 250 fsm_init(f);
Tuxitheone 0:ecaf3e593122 251
Tuxitheone 0:ecaf3e593122 252 wo->passive = 0;
Tuxitheone 0:ecaf3e593122 253 wo->silent = 0;
Tuxitheone 0:ecaf3e593122 254 wo->restart = 0; /* Set to 1 in kernels or multi-line implementations */
Tuxitheone 0:ecaf3e593122 255 wo->neg_mru = 1;
Tuxitheone 0:ecaf3e593122 256 wo->mru = PPP_DEFMRU;
Tuxitheone 0:ecaf3e593122 257 wo->neg_asyncmap = 1;
Tuxitheone 0:ecaf3e593122 258 wo->asyncmap = 0x00000000l; /* Assume don't need to escape any ctl chars. */
Tuxitheone 0:ecaf3e593122 259 wo->neg_chap = 0; /* Set to 1 on server */
Tuxitheone 0:ecaf3e593122 260 wo->neg_upap = 0; /* Set to 1 on server */
Tuxitheone 0:ecaf3e593122 261 wo->chap_mdtype = CHAP_DIGEST_MD5;
Tuxitheone 0:ecaf3e593122 262 wo->neg_magicnumber = 1;
Tuxitheone 0:ecaf3e593122 263 wo->neg_pcompression = 1;
Tuxitheone 0:ecaf3e593122 264 wo->neg_accompression = 1;
Tuxitheone 0:ecaf3e593122 265 wo->neg_lqr = 0; /* no LQR implementation yet */
Tuxitheone 0:ecaf3e593122 266 wo->neg_cbcp = 0;
Tuxitheone 0:ecaf3e593122 267
Tuxitheone 0:ecaf3e593122 268 ao->neg_mru = 1;
Tuxitheone 0:ecaf3e593122 269 ao->mru = PPP_MAXMRU;
Tuxitheone 0:ecaf3e593122 270 ao->neg_asyncmap = 1;
Tuxitheone 0:ecaf3e593122 271 ao->asyncmap = 0x00000000l; /* Assume don't need to escape any ctl chars. */
Tuxitheone 0:ecaf3e593122 272 ao->neg_chap = (CHAP_SUPPORT != 0);
Tuxitheone 0:ecaf3e593122 273 ao->chap_mdtype = CHAP_DIGEST_MD5;
Tuxitheone 0:ecaf3e593122 274 ao->neg_upap = (PAP_SUPPORT != 0);
Tuxitheone 0:ecaf3e593122 275 ao->neg_magicnumber = 1;
Tuxitheone 0:ecaf3e593122 276 ao->neg_pcompression = 1;
Tuxitheone 0:ecaf3e593122 277 ao->neg_accompression = 1;
Tuxitheone 0:ecaf3e593122 278 ao->neg_lqr = 0; /* no LQR implementation yet */
Tuxitheone 0:ecaf3e593122 279 ao->neg_cbcp = (CBCP_SUPPORT != 0);
Tuxitheone 0:ecaf3e593122 280
Tuxitheone 0:ecaf3e593122 281 /*
Tuxitheone 0:ecaf3e593122 282 * Set transmit escape for the flag and escape characters plus anything
Tuxitheone 0:ecaf3e593122 283 * set for the allowable options.
Tuxitheone 0:ecaf3e593122 284 */
Tuxitheone 0:ecaf3e593122 285 memset(xmit_accm[unit], 0, sizeof(xmit_accm[0]));
Tuxitheone 0:ecaf3e593122 286 xmit_accm[unit][15] = 0x60;
Tuxitheone 0:ecaf3e593122 287 xmit_accm[unit][0] = (u_char)((ao->asyncmap & 0xFF));
Tuxitheone 0:ecaf3e593122 288 xmit_accm[unit][1] = (u_char)((ao->asyncmap >> 8) & 0xFF);
Tuxitheone 0:ecaf3e593122 289 xmit_accm[unit][2] = (u_char)((ao->asyncmap >> 16) & 0xFF);
Tuxitheone 0:ecaf3e593122 290 xmit_accm[unit][3] = (u_char)((ao->asyncmap >> 24) & 0xFF);
Tuxitheone 0:ecaf3e593122 291 LCPDEBUG(LOG_INFO, ("lcp_init: xmit_accm=%X %X %X %X\n",
Tuxitheone 0:ecaf3e593122 292 xmit_accm[unit][0],
Tuxitheone 0:ecaf3e593122 293 xmit_accm[unit][1],
Tuxitheone 0:ecaf3e593122 294 xmit_accm[unit][2],
Tuxitheone 0:ecaf3e593122 295 xmit_accm[unit][3]));
Tuxitheone 0:ecaf3e593122 296
Tuxitheone 0:ecaf3e593122 297 lcp_phase[unit] = PHASE_INITIALIZE;
Tuxitheone 0:ecaf3e593122 298 }
Tuxitheone 0:ecaf3e593122 299
Tuxitheone 0:ecaf3e593122 300
Tuxitheone 0:ecaf3e593122 301 /*
Tuxitheone 0:ecaf3e593122 302 * lcp_open - LCP is allowed to come up.
Tuxitheone 0:ecaf3e593122 303 */
Tuxitheone 0:ecaf3e593122 304 void
Tuxitheone 0:ecaf3e593122 305 lcp_open(int unit)
Tuxitheone 0:ecaf3e593122 306 {
Tuxitheone 0:ecaf3e593122 307 fsm *f = &lcp_fsm[unit];
Tuxitheone 0:ecaf3e593122 308 lcp_options *wo = &lcp_wantoptions[unit];
Tuxitheone 0:ecaf3e593122 309
Tuxitheone 0:ecaf3e593122 310 f->flags = 0;
Tuxitheone 0:ecaf3e593122 311 if (wo->passive) {
Tuxitheone 0:ecaf3e593122 312 f->flags |= OPT_PASSIVE;
Tuxitheone 0:ecaf3e593122 313 }
Tuxitheone 0:ecaf3e593122 314 if (wo->silent) {
Tuxitheone 0:ecaf3e593122 315 f->flags |= OPT_SILENT;
Tuxitheone 0:ecaf3e593122 316 }
Tuxitheone 0:ecaf3e593122 317 fsm_open(f);
Tuxitheone 0:ecaf3e593122 318
Tuxitheone 0:ecaf3e593122 319 lcp_phase[unit] = PHASE_ESTABLISH;
Tuxitheone 0:ecaf3e593122 320 }
Tuxitheone 0:ecaf3e593122 321
Tuxitheone 0:ecaf3e593122 322
Tuxitheone 0:ecaf3e593122 323 /*
Tuxitheone 0:ecaf3e593122 324 * lcp_close - Take LCP down.
Tuxitheone 0:ecaf3e593122 325 */
Tuxitheone 0:ecaf3e593122 326 void
Tuxitheone 0:ecaf3e593122 327 lcp_close(int unit, char *reason)
Tuxitheone 0:ecaf3e593122 328 {
Tuxitheone 0:ecaf3e593122 329 fsm *f = &lcp_fsm[unit];
Tuxitheone 0:ecaf3e593122 330
Tuxitheone 0:ecaf3e593122 331 if (lcp_phase[unit] != PHASE_DEAD) {
Tuxitheone 0:ecaf3e593122 332 lcp_phase[unit] = PHASE_TERMINATE;
Tuxitheone 0:ecaf3e593122 333 }
Tuxitheone 0:ecaf3e593122 334 if (f->state == LS_STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) {
Tuxitheone 0:ecaf3e593122 335 /*
Tuxitheone 0:ecaf3e593122 336 * This action is not strictly according to the FSM in RFC1548,
Tuxitheone 0:ecaf3e593122 337 * but it does mean that the program terminates if you do an
Tuxitheone 0:ecaf3e593122 338 * lcp_close() in passive/silent mode when a connection hasn't
Tuxitheone 0:ecaf3e593122 339 * been established.
Tuxitheone 0:ecaf3e593122 340 */
Tuxitheone 0:ecaf3e593122 341 f->state = LS_CLOSED;
Tuxitheone 0:ecaf3e593122 342 lcp_finished(f);
Tuxitheone 0:ecaf3e593122 343 } else {
Tuxitheone 0:ecaf3e593122 344 fsm_close(f, reason);
Tuxitheone 0:ecaf3e593122 345 }
Tuxitheone 0:ecaf3e593122 346 }
Tuxitheone 0:ecaf3e593122 347
Tuxitheone 0:ecaf3e593122 348
Tuxitheone 0:ecaf3e593122 349 /*
Tuxitheone 0:ecaf3e593122 350 * lcp_lowerup - The lower layer is up.
Tuxitheone 0:ecaf3e593122 351 */
Tuxitheone 0:ecaf3e593122 352 void
Tuxitheone 0:ecaf3e593122 353 lcp_lowerup(int unit)
Tuxitheone 0:ecaf3e593122 354 {
Tuxitheone 0:ecaf3e593122 355 lcp_options *wo = &lcp_wantoptions[unit];
Tuxitheone 0:ecaf3e593122 356
Tuxitheone 0:ecaf3e593122 357 /*
Tuxitheone 0:ecaf3e593122 358 * Don't use A/C or protocol compression on transmission,
Tuxitheone 0:ecaf3e593122 359 * but accept A/C and protocol compressed packets
Tuxitheone 0:ecaf3e593122 360 * if we are going to ask for A/C and protocol compression.
Tuxitheone 0:ecaf3e593122 361 */
Tuxitheone 0:ecaf3e593122 362 ppp_set_xaccm(unit, &xmit_accm[unit]);
Tuxitheone 0:ecaf3e593122 363 ppp_send_config(unit, PPP_MRU, 0xffffffffl, 0, 0);
Tuxitheone 0:ecaf3e593122 364 ppp_recv_config(unit, PPP_MRU, 0x00000000l,
Tuxitheone 0:ecaf3e593122 365 wo->neg_pcompression, wo->neg_accompression);
Tuxitheone 0:ecaf3e593122 366 peer_mru[unit] = PPP_MRU;
Tuxitheone 0:ecaf3e593122 367 lcp_allowoptions[unit].asyncmap = (u_long)xmit_accm[unit][0]
Tuxitheone 0:ecaf3e593122 368 | ((u_long)xmit_accm[unit][1] << 8)
Tuxitheone 0:ecaf3e593122 369 | ((u_long)xmit_accm[unit][2] << 16)
Tuxitheone 0:ecaf3e593122 370 | ((u_long)xmit_accm[unit][3] << 24);
Tuxitheone 0:ecaf3e593122 371 LCPDEBUG(LOG_INFO, ("lcp_lowerup: asyncmap=%X %X %X %X\n",
Tuxitheone 0:ecaf3e593122 372 xmit_accm[unit][3],
Tuxitheone 0:ecaf3e593122 373 xmit_accm[unit][2],
Tuxitheone 0:ecaf3e593122 374 xmit_accm[unit][1],
Tuxitheone 0:ecaf3e593122 375 xmit_accm[unit][0]));
Tuxitheone 0:ecaf3e593122 376
Tuxitheone 0:ecaf3e593122 377 fsm_lowerup(&lcp_fsm[unit]);
Tuxitheone 0:ecaf3e593122 378 }
Tuxitheone 0:ecaf3e593122 379
Tuxitheone 0:ecaf3e593122 380
Tuxitheone 0:ecaf3e593122 381 /*
Tuxitheone 0:ecaf3e593122 382 * lcp_lowerdown - The lower layer is down.
Tuxitheone 0:ecaf3e593122 383 */
Tuxitheone 0:ecaf3e593122 384 void
Tuxitheone 0:ecaf3e593122 385 lcp_lowerdown(int unit)
Tuxitheone 0:ecaf3e593122 386 {
Tuxitheone 0:ecaf3e593122 387 fsm_lowerdown(&lcp_fsm[unit]);
Tuxitheone 0:ecaf3e593122 388 }
Tuxitheone 0:ecaf3e593122 389
Tuxitheone 0:ecaf3e593122 390
Tuxitheone 0:ecaf3e593122 391 /*
Tuxitheone 0:ecaf3e593122 392 * lcp_input - Input LCP packet.
Tuxitheone 0:ecaf3e593122 393 */
Tuxitheone 0:ecaf3e593122 394 static void
Tuxitheone 0:ecaf3e593122 395 lcp_input(int unit, u_char *p, int len)
Tuxitheone 0:ecaf3e593122 396 {
Tuxitheone 0:ecaf3e593122 397 fsm *f = &lcp_fsm[unit];
Tuxitheone 0:ecaf3e593122 398
Tuxitheone 0:ecaf3e593122 399 fsm_input(f, p, len);
Tuxitheone 0:ecaf3e593122 400 }
Tuxitheone 0:ecaf3e593122 401
Tuxitheone 0:ecaf3e593122 402
Tuxitheone 0:ecaf3e593122 403 /*
Tuxitheone 0:ecaf3e593122 404 * lcp_extcode - Handle a LCP-specific code.
Tuxitheone 0:ecaf3e593122 405 */
Tuxitheone 0:ecaf3e593122 406 static int
Tuxitheone 0:ecaf3e593122 407 lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len)
Tuxitheone 0:ecaf3e593122 408 {
Tuxitheone 0:ecaf3e593122 409 u_char *magp;
Tuxitheone 0:ecaf3e593122 410
Tuxitheone 0:ecaf3e593122 411 switch( code ){
Tuxitheone 0:ecaf3e593122 412 case PROTREJ:
Tuxitheone 0:ecaf3e593122 413 lcp_rprotrej(f, inp, len);
Tuxitheone 0:ecaf3e593122 414 break;
Tuxitheone 0:ecaf3e593122 415
Tuxitheone 0:ecaf3e593122 416 case ECHOREQ:
Tuxitheone 0:ecaf3e593122 417 if (f->state != LS_OPENED) {
Tuxitheone 0:ecaf3e593122 418 break;
Tuxitheone 0:ecaf3e593122 419 }
Tuxitheone 0:ecaf3e593122 420 LCPDEBUG(LOG_INFO, ("lcp: Echo-Request, Rcvd id %d\n", id));
Tuxitheone 0:ecaf3e593122 421 magp = inp;
Tuxitheone 0:ecaf3e593122 422 PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp);
Tuxitheone 0:ecaf3e593122 423 fsm_sdata(f, ECHOREP, id, inp, len);
Tuxitheone 0:ecaf3e593122 424 break;
Tuxitheone 0:ecaf3e593122 425
Tuxitheone 0:ecaf3e593122 426 case ECHOREP:
Tuxitheone 0:ecaf3e593122 427 lcp_received_echo_reply(f, id, inp, len);
Tuxitheone 0:ecaf3e593122 428 break;
Tuxitheone 0:ecaf3e593122 429
Tuxitheone 0:ecaf3e593122 430 case DISCREQ:
Tuxitheone 0:ecaf3e593122 431 break;
Tuxitheone 0:ecaf3e593122 432
Tuxitheone 0:ecaf3e593122 433 default:
Tuxitheone 0:ecaf3e593122 434 return 0;
Tuxitheone 0:ecaf3e593122 435 }
Tuxitheone 0:ecaf3e593122 436 return 1;
Tuxitheone 0:ecaf3e593122 437 }
Tuxitheone 0:ecaf3e593122 438
Tuxitheone 0:ecaf3e593122 439
Tuxitheone 0:ecaf3e593122 440 /*
Tuxitheone 0:ecaf3e593122 441 * lcp_rprotrej - Receive an Protocol-Reject.
Tuxitheone 0:ecaf3e593122 442 *
Tuxitheone 0:ecaf3e593122 443 * Figure out which protocol is rejected and inform it.
Tuxitheone 0:ecaf3e593122 444 */
Tuxitheone 0:ecaf3e593122 445 static void
Tuxitheone 0:ecaf3e593122 446 lcp_rprotrej(fsm *f, u_char *inp, int len)
Tuxitheone 0:ecaf3e593122 447 {
Tuxitheone 0:ecaf3e593122 448 int i;
Tuxitheone 0:ecaf3e593122 449 struct protent *protp;
Tuxitheone 0:ecaf3e593122 450 u_short prot;
Tuxitheone 0:ecaf3e593122 451
Tuxitheone 0:ecaf3e593122 452 if (len < (int)sizeof (u_short)) {
Tuxitheone 0:ecaf3e593122 453 LCPDEBUG(LOG_INFO, ("lcp_rprotrej: Rcvd short Protocol-Reject packet!\n"));
Tuxitheone 0:ecaf3e593122 454 return;
Tuxitheone 0:ecaf3e593122 455 }
Tuxitheone 0:ecaf3e593122 456
Tuxitheone 0:ecaf3e593122 457 GETSHORT(prot, inp);
Tuxitheone 0:ecaf3e593122 458
Tuxitheone 0:ecaf3e593122 459 LCPDEBUG(LOG_INFO, ("lcp_rprotrej: Rcvd Protocol-Reject packet for %x!\n", prot));
Tuxitheone 0:ecaf3e593122 460
Tuxitheone 0:ecaf3e593122 461 /*
Tuxitheone 0:ecaf3e593122 462 * Protocol-Reject packets received in any state other than the LCP
Tuxitheone 0:ecaf3e593122 463 * LS_OPENED state SHOULD be silently discarded.
Tuxitheone 0:ecaf3e593122 464 */
Tuxitheone 0:ecaf3e593122 465 if( f->state != LS_OPENED ) {
Tuxitheone 0:ecaf3e593122 466 LCPDEBUG(LOG_INFO, ("Protocol-Reject discarded: LCP in state %d\n", f->state));
Tuxitheone 0:ecaf3e593122 467 return;
Tuxitheone 0:ecaf3e593122 468 }
Tuxitheone 0:ecaf3e593122 469
Tuxitheone 0:ecaf3e593122 470 /*
Tuxitheone 0:ecaf3e593122 471 * Upcall the proper Protocol-Reject routine.
Tuxitheone 0:ecaf3e593122 472 */
Tuxitheone 0:ecaf3e593122 473 for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) {
Tuxitheone 0:ecaf3e593122 474 if (protp->protocol == prot && protp->enabled_flag) {
Tuxitheone 0:ecaf3e593122 475 (*protp->protrej)(f->unit);
Tuxitheone 0:ecaf3e593122 476 return;
Tuxitheone 0:ecaf3e593122 477 }
Tuxitheone 0:ecaf3e593122 478 }
Tuxitheone 0:ecaf3e593122 479
Tuxitheone 0:ecaf3e593122 480 LCPDEBUG(LOG_WARNING, ("Protocol-Reject for unsupported protocol 0x%x\n", prot));
Tuxitheone 0:ecaf3e593122 481 }
Tuxitheone 0:ecaf3e593122 482
Tuxitheone 0:ecaf3e593122 483
Tuxitheone 0:ecaf3e593122 484 /*
Tuxitheone 0:ecaf3e593122 485 * lcp_protrej - A Protocol-Reject was received.
Tuxitheone 0:ecaf3e593122 486 */
Tuxitheone 0:ecaf3e593122 487 static void
Tuxitheone 0:ecaf3e593122 488 lcp_protrej(int unit)
Tuxitheone 0:ecaf3e593122 489 {
Tuxitheone 0:ecaf3e593122 490 LWIP_UNUSED_ARG(unit);
Tuxitheone 0:ecaf3e593122 491 /*
Tuxitheone 0:ecaf3e593122 492 * Can't reject LCP!
Tuxitheone 0:ecaf3e593122 493 */
Tuxitheone 0:ecaf3e593122 494 LCPDEBUG(LOG_WARNING, ("lcp_protrej: Received Protocol-Reject for LCP!\n"));
Tuxitheone 0:ecaf3e593122 495 fsm_protreject(&lcp_fsm[unit]);
Tuxitheone 0:ecaf3e593122 496 }
Tuxitheone 0:ecaf3e593122 497
Tuxitheone 0:ecaf3e593122 498
Tuxitheone 0:ecaf3e593122 499 /*
Tuxitheone 0:ecaf3e593122 500 * lcp_sprotrej - Send a Protocol-Reject for some protocol.
Tuxitheone 0:ecaf3e593122 501 */
Tuxitheone 0:ecaf3e593122 502 void
Tuxitheone 0:ecaf3e593122 503 lcp_sprotrej(int unit, u_char *p, int len)
Tuxitheone 0:ecaf3e593122 504 {
Tuxitheone 0:ecaf3e593122 505 /*
Tuxitheone 0:ecaf3e593122 506 * Send back the protocol and the information field of the
Tuxitheone 0:ecaf3e593122 507 * rejected packet. We only get here if LCP is in the LS_OPENED state.
Tuxitheone 0:ecaf3e593122 508 */
Tuxitheone 0:ecaf3e593122 509
Tuxitheone 0:ecaf3e593122 510 fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id, p, len);
Tuxitheone 0:ecaf3e593122 511 }
Tuxitheone 0:ecaf3e593122 512
Tuxitheone 0:ecaf3e593122 513
Tuxitheone 0:ecaf3e593122 514 /*
Tuxitheone 0:ecaf3e593122 515 * lcp_resetci - Reset our CI.
Tuxitheone 0:ecaf3e593122 516 */
Tuxitheone 0:ecaf3e593122 517 static void
Tuxitheone 0:ecaf3e593122 518 lcp_resetci(fsm *f)
Tuxitheone 0:ecaf3e593122 519 {
Tuxitheone 0:ecaf3e593122 520 lcp_wantoptions[f->unit].magicnumber = magic();
Tuxitheone 0:ecaf3e593122 521 lcp_wantoptions[f->unit].numloops = 0;
Tuxitheone 0:ecaf3e593122 522 lcp_gotoptions[f->unit] = lcp_wantoptions[f->unit];
Tuxitheone 0:ecaf3e593122 523 peer_mru[f->unit] = PPP_MRU;
Tuxitheone 0:ecaf3e593122 524 auth_reset(f->unit);
Tuxitheone 0:ecaf3e593122 525 }
Tuxitheone 0:ecaf3e593122 526
Tuxitheone 0:ecaf3e593122 527
Tuxitheone 0:ecaf3e593122 528 /*
Tuxitheone 0:ecaf3e593122 529 * lcp_cilen - Return length of our CI.
Tuxitheone 0:ecaf3e593122 530 */
Tuxitheone 0:ecaf3e593122 531 static int
Tuxitheone 0:ecaf3e593122 532 lcp_cilen(fsm *f)
Tuxitheone 0:ecaf3e593122 533 {
Tuxitheone 0:ecaf3e593122 534 lcp_options *go = &lcp_gotoptions[f->unit];
Tuxitheone 0:ecaf3e593122 535
Tuxitheone 0:ecaf3e593122 536 #define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0)
Tuxitheone 0:ecaf3e593122 537 #define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0)
Tuxitheone 0:ecaf3e593122 538 #define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0)
Tuxitheone 0:ecaf3e593122 539 #define LENCILONG(neg) ((neg) ? CILEN_LONG : 0)
Tuxitheone 0:ecaf3e593122 540 #define LENCILQR(neg) ((neg) ? CILEN_LQR: 0)
Tuxitheone 0:ecaf3e593122 541 #define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0)
Tuxitheone 0:ecaf3e593122 542 /*
Tuxitheone 0:ecaf3e593122 543 * NB: we only ask for one of CHAP and UPAP, even if we will
Tuxitheone 0:ecaf3e593122 544 * accept either.
Tuxitheone 0:ecaf3e593122 545 */
Tuxitheone 0:ecaf3e593122 546 return (LENCISHORT(go->neg_mru && go->mru != PPP_DEFMRU) +
Tuxitheone 0:ecaf3e593122 547 LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) +
Tuxitheone 0:ecaf3e593122 548 LENCICHAP(go->neg_chap) +
Tuxitheone 0:ecaf3e593122 549 LENCISHORT(!go->neg_chap && go->neg_upap) +
Tuxitheone 0:ecaf3e593122 550 LENCILQR(go->neg_lqr) +
Tuxitheone 0:ecaf3e593122 551 LENCICBCP(go->neg_cbcp) +
Tuxitheone 0:ecaf3e593122 552 LENCILONG(go->neg_magicnumber) +
Tuxitheone 0:ecaf3e593122 553 LENCIVOID(go->neg_pcompression) +
Tuxitheone 0:ecaf3e593122 554 LENCIVOID(go->neg_accompression));
Tuxitheone 0:ecaf3e593122 555 }
Tuxitheone 0:ecaf3e593122 556
Tuxitheone 0:ecaf3e593122 557
Tuxitheone 0:ecaf3e593122 558 /*
Tuxitheone 0:ecaf3e593122 559 * lcp_addci - Add our desired CIs to a packet.
Tuxitheone 0:ecaf3e593122 560 */
Tuxitheone 0:ecaf3e593122 561 static void
Tuxitheone 0:ecaf3e593122 562 lcp_addci(fsm *f, u_char *ucp, int *lenp)
Tuxitheone 0:ecaf3e593122 563 {
Tuxitheone 0:ecaf3e593122 564 lcp_options *go = &lcp_gotoptions[f->unit];
Tuxitheone 0:ecaf3e593122 565 u_char *start_ucp = ucp;
Tuxitheone 0:ecaf3e593122 566
Tuxitheone 0:ecaf3e593122 567 #define ADDCIVOID(opt, neg) \
Tuxitheone 0:ecaf3e593122 568 if (neg) { \
Tuxitheone 0:ecaf3e593122 569 LCPDEBUG(LOG_INFO, ("lcp_addci: opt=%d\n", opt)); \
Tuxitheone 0:ecaf3e593122 570 PUTCHAR(opt, ucp); \
Tuxitheone 0:ecaf3e593122 571 PUTCHAR(CILEN_VOID, ucp); \
Tuxitheone 0:ecaf3e593122 572 }
Tuxitheone 0:ecaf3e593122 573 #define ADDCISHORT(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 574 if (neg) { \
Tuxitheone 0:ecaf3e593122 575 LCPDEBUG(LOG_INFO, ("lcp_addci: INT opt=%d %X\n", opt, val)); \
Tuxitheone 0:ecaf3e593122 576 PUTCHAR(opt, ucp); \
Tuxitheone 0:ecaf3e593122 577 PUTCHAR(CILEN_SHORT, ucp); \
Tuxitheone 0:ecaf3e593122 578 PUTSHORT(val, ucp); \
Tuxitheone 0:ecaf3e593122 579 }
Tuxitheone 0:ecaf3e593122 580 #define ADDCICHAP(opt, neg, val, digest) \
Tuxitheone 0:ecaf3e593122 581 if (neg) { \
Tuxitheone 0:ecaf3e593122 582 LCPDEBUG(LOG_INFO, ("lcp_addci: CHAP opt=%d %X\n", opt, val)); \
Tuxitheone 0:ecaf3e593122 583 PUTCHAR(opt, ucp); \
Tuxitheone 0:ecaf3e593122 584 PUTCHAR(CILEN_CHAP, ucp); \
Tuxitheone 0:ecaf3e593122 585 PUTSHORT(val, ucp); \
Tuxitheone 0:ecaf3e593122 586 PUTCHAR(digest, ucp); \
Tuxitheone 0:ecaf3e593122 587 }
Tuxitheone 0:ecaf3e593122 588 #define ADDCILONG(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 589 if (neg) { \
Tuxitheone 0:ecaf3e593122 590 LCPDEBUG(LOG_INFO, ("lcp_addci: L opt=%d %lX\n", opt, val)); \
Tuxitheone 0:ecaf3e593122 591 PUTCHAR(opt, ucp); \
Tuxitheone 0:ecaf3e593122 592 PUTCHAR(CILEN_LONG, ucp); \
Tuxitheone 0:ecaf3e593122 593 PUTLONG(val, ucp); \
Tuxitheone 0:ecaf3e593122 594 }
Tuxitheone 0:ecaf3e593122 595 #define ADDCILQR(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 596 if (neg) { \
Tuxitheone 0:ecaf3e593122 597 LCPDEBUG(LOG_INFO, ("lcp_addci: LQR opt=%d %lX\n", opt, val)); \
Tuxitheone 0:ecaf3e593122 598 PUTCHAR(opt, ucp); \
Tuxitheone 0:ecaf3e593122 599 PUTCHAR(CILEN_LQR, ucp); \
Tuxitheone 0:ecaf3e593122 600 PUTSHORT(PPP_LQR, ucp); \
Tuxitheone 0:ecaf3e593122 601 PUTLONG(val, ucp); \
Tuxitheone 0:ecaf3e593122 602 }
Tuxitheone 0:ecaf3e593122 603 #define ADDCICHAR(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 604 if (neg) { \
Tuxitheone 0:ecaf3e593122 605 LCPDEBUG(LOG_INFO, ("lcp_addci: CHAR opt=%d %X '%z'\n", opt, val, val)); \
Tuxitheone 0:ecaf3e593122 606 PUTCHAR(opt, ucp); \
Tuxitheone 0:ecaf3e593122 607 PUTCHAR(CILEN_CHAR, ucp); \
Tuxitheone 0:ecaf3e593122 608 PUTCHAR(val, ucp); \
Tuxitheone 0:ecaf3e593122 609 }
Tuxitheone 0:ecaf3e593122 610
Tuxitheone 0:ecaf3e593122 611 ADDCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru);
Tuxitheone 0:ecaf3e593122 612 ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap);
Tuxitheone 0:ecaf3e593122 613 ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
Tuxitheone 0:ecaf3e593122 614 ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
Tuxitheone 0:ecaf3e593122 615 ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
Tuxitheone 0:ecaf3e593122 616 ADDCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT);
Tuxitheone 0:ecaf3e593122 617 ADDCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber);
Tuxitheone 0:ecaf3e593122 618 ADDCIVOID(CI_PCOMPRESSION, go->neg_pcompression);
Tuxitheone 0:ecaf3e593122 619 ADDCIVOID(CI_ACCOMPRESSION, go->neg_accompression);
Tuxitheone 0:ecaf3e593122 620
Tuxitheone 0:ecaf3e593122 621 if (ucp - start_ucp != *lenp) {
Tuxitheone 0:ecaf3e593122 622 /* this should never happen, because peer_mtu should be 1500 */
Tuxitheone 0:ecaf3e593122 623 LCPDEBUG(LOG_ERR, ("Bug in lcp_addci: wrong length\n"));
Tuxitheone 0:ecaf3e593122 624 }
Tuxitheone 0:ecaf3e593122 625 }
Tuxitheone 0:ecaf3e593122 626
Tuxitheone 0:ecaf3e593122 627
Tuxitheone 0:ecaf3e593122 628 /*
Tuxitheone 0:ecaf3e593122 629 * lcp_ackci - Ack our CIs.
Tuxitheone 0:ecaf3e593122 630 * This should not modify any state if the Ack is bad.
Tuxitheone 0:ecaf3e593122 631 *
Tuxitheone 0:ecaf3e593122 632 * Returns:
Tuxitheone 0:ecaf3e593122 633 * 0 - Ack was bad.
Tuxitheone 0:ecaf3e593122 634 * 1 - Ack was good.
Tuxitheone 0:ecaf3e593122 635 */
Tuxitheone 0:ecaf3e593122 636 static int
Tuxitheone 0:ecaf3e593122 637 lcp_ackci(fsm *f, u_char *p, int len)
Tuxitheone 0:ecaf3e593122 638 {
Tuxitheone 0:ecaf3e593122 639 lcp_options *go = &lcp_gotoptions[f->unit];
Tuxitheone 0:ecaf3e593122 640 u_char cilen, citype, cichar;
Tuxitheone 0:ecaf3e593122 641 u_short cishort;
Tuxitheone 0:ecaf3e593122 642 u32_t cilong;
Tuxitheone 0:ecaf3e593122 643
Tuxitheone 0:ecaf3e593122 644 /*
Tuxitheone 0:ecaf3e593122 645 * CIs must be in exactly the same order that we sent.
Tuxitheone 0:ecaf3e593122 646 * Check packet length and CI length at each step.
Tuxitheone 0:ecaf3e593122 647 * If we find any deviations, then this packet is bad.
Tuxitheone 0:ecaf3e593122 648 */
Tuxitheone 0:ecaf3e593122 649 #define ACKCIVOID(opt, neg) \
Tuxitheone 0:ecaf3e593122 650 if (neg) { \
Tuxitheone 0:ecaf3e593122 651 if ((len -= CILEN_VOID) < 0) \
Tuxitheone 0:ecaf3e593122 652 goto bad; \
Tuxitheone 0:ecaf3e593122 653 GETCHAR(citype, p); \
Tuxitheone 0:ecaf3e593122 654 GETCHAR(cilen, p); \
Tuxitheone 0:ecaf3e593122 655 if (cilen != CILEN_VOID || citype != opt) \
Tuxitheone 0:ecaf3e593122 656 goto bad; \
Tuxitheone 0:ecaf3e593122 657 }
Tuxitheone 0:ecaf3e593122 658 #define ACKCISHORT(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 659 if (neg) { \
Tuxitheone 0:ecaf3e593122 660 if ((len -= CILEN_SHORT) < 0) \
Tuxitheone 0:ecaf3e593122 661 goto bad; \
Tuxitheone 0:ecaf3e593122 662 GETCHAR(citype, p); \
Tuxitheone 0:ecaf3e593122 663 GETCHAR(cilen, p); \
Tuxitheone 0:ecaf3e593122 664 if (cilen != CILEN_SHORT || citype != opt) \
Tuxitheone 0:ecaf3e593122 665 goto bad; \
Tuxitheone 0:ecaf3e593122 666 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 667 if (cishort != val) \
Tuxitheone 0:ecaf3e593122 668 goto bad; \
Tuxitheone 0:ecaf3e593122 669 }
Tuxitheone 0:ecaf3e593122 670 #define ACKCICHAR(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 671 if (neg) { \
Tuxitheone 0:ecaf3e593122 672 if ((len -= CILEN_CHAR) < 0) \
Tuxitheone 0:ecaf3e593122 673 goto bad; \
Tuxitheone 0:ecaf3e593122 674 GETCHAR(citype, p); \
Tuxitheone 0:ecaf3e593122 675 GETCHAR(cilen, p); \
Tuxitheone 0:ecaf3e593122 676 if (cilen != CILEN_CHAR || citype != opt) \
Tuxitheone 0:ecaf3e593122 677 goto bad; \
Tuxitheone 0:ecaf3e593122 678 GETCHAR(cichar, p); \
Tuxitheone 0:ecaf3e593122 679 if (cichar != val) \
Tuxitheone 0:ecaf3e593122 680 goto bad; \
Tuxitheone 0:ecaf3e593122 681 }
Tuxitheone 0:ecaf3e593122 682 #define ACKCICHAP(opt, neg, val, digest) \
Tuxitheone 0:ecaf3e593122 683 if (neg) { \
Tuxitheone 0:ecaf3e593122 684 if ((len -= CILEN_CHAP) < 0) \
Tuxitheone 0:ecaf3e593122 685 goto bad; \
Tuxitheone 0:ecaf3e593122 686 GETCHAR(citype, p); \
Tuxitheone 0:ecaf3e593122 687 GETCHAR(cilen, p); \
Tuxitheone 0:ecaf3e593122 688 if (cilen != CILEN_CHAP || citype != opt) \
Tuxitheone 0:ecaf3e593122 689 goto bad; \
Tuxitheone 0:ecaf3e593122 690 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 691 if (cishort != val) \
Tuxitheone 0:ecaf3e593122 692 goto bad; \
Tuxitheone 0:ecaf3e593122 693 GETCHAR(cichar, p); \
Tuxitheone 0:ecaf3e593122 694 if (cichar != digest) \
Tuxitheone 0:ecaf3e593122 695 goto bad; \
Tuxitheone 0:ecaf3e593122 696 }
Tuxitheone 0:ecaf3e593122 697 #define ACKCILONG(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 698 if (neg) { \
Tuxitheone 0:ecaf3e593122 699 if ((len -= CILEN_LONG) < 0) \
Tuxitheone 0:ecaf3e593122 700 goto bad; \
Tuxitheone 0:ecaf3e593122 701 GETCHAR(citype, p); \
Tuxitheone 0:ecaf3e593122 702 GETCHAR(cilen, p); \
Tuxitheone 0:ecaf3e593122 703 if (cilen != CILEN_LONG || citype != opt) \
Tuxitheone 0:ecaf3e593122 704 goto bad; \
Tuxitheone 0:ecaf3e593122 705 GETLONG(cilong, p); \
Tuxitheone 0:ecaf3e593122 706 if (cilong != val) \
Tuxitheone 0:ecaf3e593122 707 goto bad; \
Tuxitheone 0:ecaf3e593122 708 }
Tuxitheone 0:ecaf3e593122 709 #define ACKCILQR(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 710 if (neg) { \
Tuxitheone 0:ecaf3e593122 711 if ((len -= CILEN_LQR) < 0) \
Tuxitheone 0:ecaf3e593122 712 goto bad; \
Tuxitheone 0:ecaf3e593122 713 GETCHAR(citype, p); \
Tuxitheone 0:ecaf3e593122 714 GETCHAR(cilen, p); \
Tuxitheone 0:ecaf3e593122 715 if (cilen != CILEN_LQR || citype != opt) \
Tuxitheone 0:ecaf3e593122 716 goto bad; \
Tuxitheone 0:ecaf3e593122 717 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 718 if (cishort != PPP_LQR) \
Tuxitheone 0:ecaf3e593122 719 goto bad; \
Tuxitheone 0:ecaf3e593122 720 GETLONG(cilong, p); \
Tuxitheone 0:ecaf3e593122 721 if (cilong != val) \
Tuxitheone 0:ecaf3e593122 722 goto bad; \
Tuxitheone 0:ecaf3e593122 723 }
Tuxitheone 0:ecaf3e593122 724
Tuxitheone 0:ecaf3e593122 725 ACKCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru);
Tuxitheone 0:ecaf3e593122 726 ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap);
Tuxitheone 0:ecaf3e593122 727 ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
Tuxitheone 0:ecaf3e593122 728 ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
Tuxitheone 0:ecaf3e593122 729 ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
Tuxitheone 0:ecaf3e593122 730 ACKCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT);
Tuxitheone 0:ecaf3e593122 731 ACKCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber);
Tuxitheone 0:ecaf3e593122 732 ACKCIVOID(CI_PCOMPRESSION, go->neg_pcompression);
Tuxitheone 0:ecaf3e593122 733 ACKCIVOID(CI_ACCOMPRESSION, go->neg_accompression);
Tuxitheone 0:ecaf3e593122 734
Tuxitheone 0:ecaf3e593122 735 /*
Tuxitheone 0:ecaf3e593122 736 * If there are any remaining CIs, then this packet is bad.
Tuxitheone 0:ecaf3e593122 737 */
Tuxitheone 0:ecaf3e593122 738 if (len != 0) {
Tuxitheone 0:ecaf3e593122 739 goto bad;
Tuxitheone 0:ecaf3e593122 740 }
Tuxitheone 0:ecaf3e593122 741 LCPDEBUG(LOG_INFO, ("lcp_acki: Ack\n"));
Tuxitheone 0:ecaf3e593122 742 return (1);
Tuxitheone 0:ecaf3e593122 743 bad:
Tuxitheone 0:ecaf3e593122 744 LCPDEBUG(LOG_WARNING, ("lcp_acki: received bad Ack!\n"));
Tuxitheone 0:ecaf3e593122 745 return (0);
Tuxitheone 0:ecaf3e593122 746 }
Tuxitheone 0:ecaf3e593122 747
Tuxitheone 0:ecaf3e593122 748
Tuxitheone 0:ecaf3e593122 749 /*
Tuxitheone 0:ecaf3e593122 750 * lcp_nakci - Peer has sent a NAK for some of our CIs.
Tuxitheone 0:ecaf3e593122 751 * This should not modify any state if the Nak is bad
Tuxitheone 0:ecaf3e593122 752 * or if LCP is in the LS_OPENED state.
Tuxitheone 0:ecaf3e593122 753 *
Tuxitheone 0:ecaf3e593122 754 * Returns:
Tuxitheone 0:ecaf3e593122 755 * 0 - Nak was bad.
Tuxitheone 0:ecaf3e593122 756 * 1 - Nak was good.
Tuxitheone 0:ecaf3e593122 757 */
Tuxitheone 0:ecaf3e593122 758 static int
Tuxitheone 0:ecaf3e593122 759 lcp_nakci(fsm *f, u_char *p, int len)
Tuxitheone 0:ecaf3e593122 760 {
Tuxitheone 0:ecaf3e593122 761 lcp_options *go = &lcp_gotoptions[f->unit];
Tuxitheone 0:ecaf3e593122 762 lcp_options *wo = &lcp_wantoptions[f->unit];
Tuxitheone 0:ecaf3e593122 763 u_char citype, cichar, *next;
Tuxitheone 0:ecaf3e593122 764 u_short cishort;
Tuxitheone 0:ecaf3e593122 765 u32_t cilong;
Tuxitheone 0:ecaf3e593122 766 lcp_options no; /* options we've seen Naks for */
Tuxitheone 0:ecaf3e593122 767 lcp_options try; /* options to request next time */
Tuxitheone 0:ecaf3e593122 768 int looped_back = 0;
Tuxitheone 0:ecaf3e593122 769 int cilen;
Tuxitheone 0:ecaf3e593122 770
Tuxitheone 0:ecaf3e593122 771 BZERO(&no, sizeof(no));
Tuxitheone 0:ecaf3e593122 772 try = *go;
Tuxitheone 0:ecaf3e593122 773
Tuxitheone 0:ecaf3e593122 774 /*
Tuxitheone 0:ecaf3e593122 775 * Any Nak'd CIs must be in exactly the same order that we sent.
Tuxitheone 0:ecaf3e593122 776 * Check packet length and CI length at each step.
Tuxitheone 0:ecaf3e593122 777 * If we find any deviations, then this packet is bad.
Tuxitheone 0:ecaf3e593122 778 */
Tuxitheone 0:ecaf3e593122 779 #define NAKCIVOID(opt, neg, code) \
Tuxitheone 0:ecaf3e593122 780 if (go->neg && \
Tuxitheone 0:ecaf3e593122 781 len >= CILEN_VOID && \
Tuxitheone 0:ecaf3e593122 782 p[1] == CILEN_VOID && \
Tuxitheone 0:ecaf3e593122 783 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 784 len -= CILEN_VOID; \
Tuxitheone 0:ecaf3e593122 785 INCPTR(CILEN_VOID, p); \
Tuxitheone 0:ecaf3e593122 786 no.neg = 1; \
Tuxitheone 0:ecaf3e593122 787 code \
Tuxitheone 0:ecaf3e593122 788 }
Tuxitheone 0:ecaf3e593122 789 #define NAKCICHAP(opt, neg, code) \
Tuxitheone 0:ecaf3e593122 790 if (go->neg && \
Tuxitheone 0:ecaf3e593122 791 len >= CILEN_CHAP && \
Tuxitheone 0:ecaf3e593122 792 p[1] == CILEN_CHAP && \
Tuxitheone 0:ecaf3e593122 793 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 794 len -= CILEN_CHAP; \
Tuxitheone 0:ecaf3e593122 795 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 796 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 797 GETCHAR(cichar, p); \
Tuxitheone 0:ecaf3e593122 798 no.neg = 1; \
Tuxitheone 0:ecaf3e593122 799 code \
Tuxitheone 0:ecaf3e593122 800 }
Tuxitheone 0:ecaf3e593122 801 #define NAKCICHAR(opt, neg, code) \
Tuxitheone 0:ecaf3e593122 802 if (go->neg && \
Tuxitheone 0:ecaf3e593122 803 len >= CILEN_CHAR && \
Tuxitheone 0:ecaf3e593122 804 p[1] == CILEN_CHAR && \
Tuxitheone 0:ecaf3e593122 805 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 806 len -= CILEN_CHAR; \
Tuxitheone 0:ecaf3e593122 807 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 808 GETCHAR(cichar, p); \
Tuxitheone 0:ecaf3e593122 809 no.neg = 1; \
Tuxitheone 0:ecaf3e593122 810 code \
Tuxitheone 0:ecaf3e593122 811 }
Tuxitheone 0:ecaf3e593122 812 #define NAKCISHORT(opt, neg, code) \
Tuxitheone 0:ecaf3e593122 813 if (go->neg && \
Tuxitheone 0:ecaf3e593122 814 len >= CILEN_SHORT && \
Tuxitheone 0:ecaf3e593122 815 p[1] == CILEN_SHORT && \
Tuxitheone 0:ecaf3e593122 816 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 817 len -= CILEN_SHORT; \
Tuxitheone 0:ecaf3e593122 818 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 819 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 820 no.neg = 1; \
Tuxitheone 0:ecaf3e593122 821 code \
Tuxitheone 0:ecaf3e593122 822 }
Tuxitheone 0:ecaf3e593122 823 #define NAKCILONG(opt, neg, code) \
Tuxitheone 0:ecaf3e593122 824 if (go->neg && \
Tuxitheone 0:ecaf3e593122 825 len >= CILEN_LONG && \
Tuxitheone 0:ecaf3e593122 826 p[1] == CILEN_LONG && \
Tuxitheone 0:ecaf3e593122 827 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 828 len -= CILEN_LONG; \
Tuxitheone 0:ecaf3e593122 829 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 830 GETLONG(cilong, p); \
Tuxitheone 0:ecaf3e593122 831 no.neg = 1; \
Tuxitheone 0:ecaf3e593122 832 code \
Tuxitheone 0:ecaf3e593122 833 }
Tuxitheone 0:ecaf3e593122 834 #define NAKCILQR(opt, neg, code) \
Tuxitheone 0:ecaf3e593122 835 if (go->neg && \
Tuxitheone 0:ecaf3e593122 836 len >= CILEN_LQR && \
Tuxitheone 0:ecaf3e593122 837 p[1] == CILEN_LQR && \
Tuxitheone 0:ecaf3e593122 838 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 839 len -= CILEN_LQR; \
Tuxitheone 0:ecaf3e593122 840 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 841 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 842 GETLONG(cilong, p); \
Tuxitheone 0:ecaf3e593122 843 no.neg = 1; \
Tuxitheone 0:ecaf3e593122 844 code \
Tuxitheone 0:ecaf3e593122 845 }
Tuxitheone 0:ecaf3e593122 846
Tuxitheone 0:ecaf3e593122 847 /*
Tuxitheone 0:ecaf3e593122 848 * We don't care if they want to send us smaller packets than
Tuxitheone 0:ecaf3e593122 849 * we want. Therefore, accept any MRU less than what we asked for,
Tuxitheone 0:ecaf3e593122 850 * but then ignore the new value when setting the MRU in the kernel.
Tuxitheone 0:ecaf3e593122 851 * If they send us a bigger MRU than what we asked, accept it, up to
Tuxitheone 0:ecaf3e593122 852 * the limit of the default MRU we'd get if we didn't negotiate.
Tuxitheone 0:ecaf3e593122 853 */
Tuxitheone 0:ecaf3e593122 854 if (go->neg_mru && go->mru != PPP_DEFMRU) {
Tuxitheone 0:ecaf3e593122 855 NAKCISHORT(CI_MRU, neg_mru,
Tuxitheone 0:ecaf3e593122 856 if (cishort <= wo->mru || cishort < PPP_DEFMRU) {
Tuxitheone 0:ecaf3e593122 857 try.mru = cishort;
Tuxitheone 0:ecaf3e593122 858 }
Tuxitheone 0:ecaf3e593122 859 );
Tuxitheone 0:ecaf3e593122 860 }
Tuxitheone 0:ecaf3e593122 861
Tuxitheone 0:ecaf3e593122 862 /*
Tuxitheone 0:ecaf3e593122 863 * Add any characters they want to our (receive-side) asyncmap.
Tuxitheone 0:ecaf3e593122 864 */
Tuxitheone 0:ecaf3e593122 865 if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) {
Tuxitheone 0:ecaf3e593122 866 NAKCILONG(CI_ASYNCMAP, neg_asyncmap,
Tuxitheone 0:ecaf3e593122 867 try.asyncmap = go->asyncmap | cilong;
Tuxitheone 0:ecaf3e593122 868 );
Tuxitheone 0:ecaf3e593122 869 }
Tuxitheone 0:ecaf3e593122 870
Tuxitheone 0:ecaf3e593122 871 /*
Tuxitheone 0:ecaf3e593122 872 * If they've nak'd our authentication-protocol, check whether
Tuxitheone 0:ecaf3e593122 873 * they are proposing a different protocol, or a different
Tuxitheone 0:ecaf3e593122 874 * hash algorithm for CHAP.
Tuxitheone 0:ecaf3e593122 875 */
Tuxitheone 0:ecaf3e593122 876 if ((go->neg_chap || go->neg_upap)
Tuxitheone 0:ecaf3e593122 877 && len >= CILEN_SHORT
Tuxitheone 0:ecaf3e593122 878 && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) {
Tuxitheone 0:ecaf3e593122 879 cilen = p[1];
Tuxitheone 0:ecaf3e593122 880 len -= cilen;
Tuxitheone 0:ecaf3e593122 881 no.neg_chap = go->neg_chap;
Tuxitheone 0:ecaf3e593122 882 no.neg_upap = go->neg_upap;
Tuxitheone 0:ecaf3e593122 883 INCPTR(2, p);
Tuxitheone 0:ecaf3e593122 884 GETSHORT(cishort, p);
Tuxitheone 0:ecaf3e593122 885 if (cishort == PPP_PAP && cilen == CILEN_SHORT) {
Tuxitheone 0:ecaf3e593122 886 /*
Tuxitheone 0:ecaf3e593122 887 * If we were asking for CHAP, they obviously don't want to do it.
Tuxitheone 0:ecaf3e593122 888 * If we weren't asking for CHAP, then we were asking for PAP,
Tuxitheone 0:ecaf3e593122 889 * in which case this Nak is bad.
Tuxitheone 0:ecaf3e593122 890 */
Tuxitheone 0:ecaf3e593122 891 if (!go->neg_chap) {
Tuxitheone 0:ecaf3e593122 892 goto bad;
Tuxitheone 0:ecaf3e593122 893 }
Tuxitheone 0:ecaf3e593122 894 try.neg_chap = 0;
Tuxitheone 0:ecaf3e593122 895
Tuxitheone 0:ecaf3e593122 896 } else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) {
Tuxitheone 0:ecaf3e593122 897 GETCHAR(cichar, p);
Tuxitheone 0:ecaf3e593122 898 if (go->neg_chap) {
Tuxitheone 0:ecaf3e593122 899 /*
Tuxitheone 0:ecaf3e593122 900 * We were asking for CHAP/MD5; they must want a different
Tuxitheone 0:ecaf3e593122 901 * algorithm. If they can't do MD5, we'll have to stop
Tuxitheone 0:ecaf3e593122 902 * asking for CHAP.
Tuxitheone 0:ecaf3e593122 903 */
Tuxitheone 0:ecaf3e593122 904 if (cichar != go->chap_mdtype) {
Tuxitheone 0:ecaf3e593122 905 try.neg_chap = 0;
Tuxitheone 0:ecaf3e593122 906 }
Tuxitheone 0:ecaf3e593122 907 } else {
Tuxitheone 0:ecaf3e593122 908 /*
Tuxitheone 0:ecaf3e593122 909 * Stop asking for PAP if we were asking for it.
Tuxitheone 0:ecaf3e593122 910 */
Tuxitheone 0:ecaf3e593122 911 try.neg_upap = 0;
Tuxitheone 0:ecaf3e593122 912 }
Tuxitheone 0:ecaf3e593122 913
Tuxitheone 0:ecaf3e593122 914 } else {
Tuxitheone 0:ecaf3e593122 915 /*
Tuxitheone 0:ecaf3e593122 916 * We don't recognize what they're suggesting.
Tuxitheone 0:ecaf3e593122 917 * Stop asking for what we were asking for.
Tuxitheone 0:ecaf3e593122 918 */
Tuxitheone 0:ecaf3e593122 919 if (go->neg_chap) {
Tuxitheone 0:ecaf3e593122 920 try.neg_chap = 0;
Tuxitheone 0:ecaf3e593122 921 } else {
Tuxitheone 0:ecaf3e593122 922 try.neg_upap = 0;
Tuxitheone 0:ecaf3e593122 923 }
Tuxitheone 0:ecaf3e593122 924 p += cilen - CILEN_SHORT;
Tuxitheone 0:ecaf3e593122 925 }
Tuxitheone 0:ecaf3e593122 926 }
Tuxitheone 0:ecaf3e593122 927
Tuxitheone 0:ecaf3e593122 928 /*
Tuxitheone 0:ecaf3e593122 929 * If they can't cope with our link quality protocol, we'll have
Tuxitheone 0:ecaf3e593122 930 * to stop asking for LQR. We haven't got any other protocol.
Tuxitheone 0:ecaf3e593122 931 * If they Nak the reporting period, take their value XXX ?
Tuxitheone 0:ecaf3e593122 932 */
Tuxitheone 0:ecaf3e593122 933 NAKCILQR(CI_QUALITY, neg_lqr,
Tuxitheone 0:ecaf3e593122 934 if (cishort != PPP_LQR) {
Tuxitheone 0:ecaf3e593122 935 try.neg_lqr = 0;
Tuxitheone 0:ecaf3e593122 936 } else {
Tuxitheone 0:ecaf3e593122 937 try.lqr_period = cilong;
Tuxitheone 0:ecaf3e593122 938 }
Tuxitheone 0:ecaf3e593122 939 );
Tuxitheone 0:ecaf3e593122 940
Tuxitheone 0:ecaf3e593122 941 /*
Tuxitheone 0:ecaf3e593122 942 * Only implementing CBCP...not the rest of the callback options
Tuxitheone 0:ecaf3e593122 943 */
Tuxitheone 0:ecaf3e593122 944 NAKCICHAR(CI_CALLBACK, neg_cbcp,
Tuxitheone 0:ecaf3e593122 945 try.neg_cbcp = 0;
Tuxitheone 0:ecaf3e593122 946 );
Tuxitheone 0:ecaf3e593122 947
Tuxitheone 0:ecaf3e593122 948 /*
Tuxitheone 0:ecaf3e593122 949 * Check for a looped-back line.
Tuxitheone 0:ecaf3e593122 950 */
Tuxitheone 0:ecaf3e593122 951 NAKCILONG(CI_MAGICNUMBER, neg_magicnumber,
Tuxitheone 0:ecaf3e593122 952 try.magicnumber = magic();
Tuxitheone 0:ecaf3e593122 953 looped_back = 1;
Tuxitheone 0:ecaf3e593122 954 );
Tuxitheone 0:ecaf3e593122 955
Tuxitheone 0:ecaf3e593122 956 /*
Tuxitheone 0:ecaf3e593122 957 * Peer shouldn't send Nak for protocol compression or
Tuxitheone 0:ecaf3e593122 958 * address/control compression requests; they should send
Tuxitheone 0:ecaf3e593122 959 * a Reject instead. If they send a Nak, treat it as a Reject.
Tuxitheone 0:ecaf3e593122 960 */
Tuxitheone 0:ecaf3e593122 961 NAKCIVOID(CI_PCOMPRESSION, neg_pcompression,
Tuxitheone 0:ecaf3e593122 962 try.neg_pcompression = 0;
Tuxitheone 0:ecaf3e593122 963 );
Tuxitheone 0:ecaf3e593122 964 NAKCIVOID(CI_ACCOMPRESSION, neg_accompression,
Tuxitheone 0:ecaf3e593122 965 try.neg_accompression = 0;
Tuxitheone 0:ecaf3e593122 966 );
Tuxitheone 0:ecaf3e593122 967
Tuxitheone 0:ecaf3e593122 968 /*
Tuxitheone 0:ecaf3e593122 969 * There may be remaining CIs, if the peer is requesting negotiation
Tuxitheone 0:ecaf3e593122 970 * on an option that we didn't include in our request packet.
Tuxitheone 0:ecaf3e593122 971 * If we see an option that we requested, or one we've already seen
Tuxitheone 0:ecaf3e593122 972 * in this packet, then this packet is bad.
Tuxitheone 0:ecaf3e593122 973 * If we wanted to respond by starting to negotiate on the requested
Tuxitheone 0:ecaf3e593122 974 * option(s), we could, but we don't, because except for the
Tuxitheone 0:ecaf3e593122 975 * authentication type and quality protocol, if we are not negotiating
Tuxitheone 0:ecaf3e593122 976 * an option, it is because we were told not to.
Tuxitheone 0:ecaf3e593122 977 * For the authentication type, the Nak from the peer means
Tuxitheone 0:ecaf3e593122 978 * `let me authenticate myself with you' which is a bit pointless.
Tuxitheone 0:ecaf3e593122 979 * For the quality protocol, the Nak means `ask me to send you quality
Tuxitheone 0:ecaf3e593122 980 * reports', but if we didn't ask for them, we don't want them.
Tuxitheone 0:ecaf3e593122 981 * An option we don't recognize represents the peer asking to
Tuxitheone 0:ecaf3e593122 982 * negotiate some option we don't support, so ignore it.
Tuxitheone 0:ecaf3e593122 983 */
Tuxitheone 0:ecaf3e593122 984 while (len > CILEN_VOID) {
Tuxitheone 0:ecaf3e593122 985 GETCHAR(citype, p);
Tuxitheone 0:ecaf3e593122 986 GETCHAR(cilen, p);
Tuxitheone 0:ecaf3e593122 987 if (cilen < CILEN_VOID || (len -= cilen) < 0) {
Tuxitheone 0:ecaf3e593122 988 goto bad;
Tuxitheone 0:ecaf3e593122 989 }
Tuxitheone 0:ecaf3e593122 990 next = p + cilen - 2;
Tuxitheone 0:ecaf3e593122 991
Tuxitheone 0:ecaf3e593122 992 switch (citype) {
Tuxitheone 0:ecaf3e593122 993 case CI_MRU:
Tuxitheone 0:ecaf3e593122 994 if ((go->neg_mru && go->mru != PPP_DEFMRU)
Tuxitheone 0:ecaf3e593122 995 || no.neg_mru || cilen != CILEN_SHORT) {
Tuxitheone 0:ecaf3e593122 996 goto bad;
Tuxitheone 0:ecaf3e593122 997 }
Tuxitheone 0:ecaf3e593122 998 GETSHORT(cishort, p);
Tuxitheone 0:ecaf3e593122 999 if (cishort < PPP_DEFMRU) {
Tuxitheone 0:ecaf3e593122 1000 try.mru = cishort;
Tuxitheone 0:ecaf3e593122 1001 }
Tuxitheone 0:ecaf3e593122 1002 break;
Tuxitheone 0:ecaf3e593122 1003 case CI_ASYNCMAP:
Tuxitheone 0:ecaf3e593122 1004 if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl)
Tuxitheone 0:ecaf3e593122 1005 || no.neg_asyncmap || cilen != CILEN_LONG) {
Tuxitheone 0:ecaf3e593122 1006 goto bad;
Tuxitheone 0:ecaf3e593122 1007 }
Tuxitheone 0:ecaf3e593122 1008 break;
Tuxitheone 0:ecaf3e593122 1009 case CI_AUTHTYPE:
Tuxitheone 0:ecaf3e593122 1010 if (go->neg_chap || no.neg_chap || go->neg_upap || no.neg_upap) {
Tuxitheone 0:ecaf3e593122 1011 goto bad;
Tuxitheone 0:ecaf3e593122 1012 }
Tuxitheone 0:ecaf3e593122 1013 break;
Tuxitheone 0:ecaf3e593122 1014 case CI_MAGICNUMBER:
Tuxitheone 0:ecaf3e593122 1015 if (go->neg_magicnumber || no.neg_magicnumber ||
Tuxitheone 0:ecaf3e593122 1016 cilen != CILEN_LONG) {
Tuxitheone 0:ecaf3e593122 1017 goto bad;
Tuxitheone 0:ecaf3e593122 1018 }
Tuxitheone 0:ecaf3e593122 1019 break;
Tuxitheone 0:ecaf3e593122 1020 case CI_PCOMPRESSION:
Tuxitheone 0:ecaf3e593122 1021 if (go->neg_pcompression || no.neg_pcompression
Tuxitheone 0:ecaf3e593122 1022 || cilen != CILEN_VOID) {
Tuxitheone 0:ecaf3e593122 1023 goto bad;
Tuxitheone 0:ecaf3e593122 1024 }
Tuxitheone 0:ecaf3e593122 1025 break;
Tuxitheone 0:ecaf3e593122 1026 case CI_ACCOMPRESSION:
Tuxitheone 0:ecaf3e593122 1027 if (go->neg_accompression || no.neg_accompression
Tuxitheone 0:ecaf3e593122 1028 || cilen != CILEN_VOID) {
Tuxitheone 0:ecaf3e593122 1029 goto bad;
Tuxitheone 0:ecaf3e593122 1030 }
Tuxitheone 0:ecaf3e593122 1031 break;
Tuxitheone 0:ecaf3e593122 1032 case CI_QUALITY:
Tuxitheone 0:ecaf3e593122 1033 if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) {
Tuxitheone 0:ecaf3e593122 1034 goto bad;
Tuxitheone 0:ecaf3e593122 1035 }
Tuxitheone 0:ecaf3e593122 1036 break;
Tuxitheone 0:ecaf3e593122 1037 }
Tuxitheone 0:ecaf3e593122 1038 p = next;
Tuxitheone 0:ecaf3e593122 1039 }
Tuxitheone 0:ecaf3e593122 1040
Tuxitheone 0:ecaf3e593122 1041 /* If there is still anything left, this packet is bad. */
Tuxitheone 0:ecaf3e593122 1042 if (len != 0) {
Tuxitheone 0:ecaf3e593122 1043 goto bad;
Tuxitheone 0:ecaf3e593122 1044 }
Tuxitheone 0:ecaf3e593122 1045
Tuxitheone 0:ecaf3e593122 1046 /*
Tuxitheone 0:ecaf3e593122 1047 * OK, the Nak is good. Now we can update state.
Tuxitheone 0:ecaf3e593122 1048 */
Tuxitheone 0:ecaf3e593122 1049 if (f->state != LS_OPENED) {
Tuxitheone 0:ecaf3e593122 1050 if (looped_back) {
Tuxitheone 0:ecaf3e593122 1051 if (++try.numloops >= lcp_loopbackfail) {
Tuxitheone 0:ecaf3e593122 1052 LCPDEBUG(LOG_NOTICE, ("Serial line is looped back.\n"));
Tuxitheone 0:ecaf3e593122 1053 lcp_close(f->unit, "Loopback detected");
Tuxitheone 0:ecaf3e593122 1054 }
Tuxitheone 0:ecaf3e593122 1055 } else {
Tuxitheone 0:ecaf3e593122 1056 try.numloops = 0;
Tuxitheone 0:ecaf3e593122 1057 }
Tuxitheone 0:ecaf3e593122 1058 *go = try;
Tuxitheone 0:ecaf3e593122 1059 }
Tuxitheone 0:ecaf3e593122 1060
Tuxitheone 0:ecaf3e593122 1061 return 1;
Tuxitheone 0:ecaf3e593122 1062
Tuxitheone 0:ecaf3e593122 1063 bad:
Tuxitheone 0:ecaf3e593122 1064 LCPDEBUG(LOG_WARNING, ("lcp_nakci: received bad Nak!\n"));
Tuxitheone 0:ecaf3e593122 1065 return 0;
Tuxitheone 0:ecaf3e593122 1066 }
Tuxitheone 0:ecaf3e593122 1067
Tuxitheone 0:ecaf3e593122 1068
Tuxitheone 0:ecaf3e593122 1069 /*
Tuxitheone 0:ecaf3e593122 1070 * lcp_rejci - Peer has Rejected some of our CIs.
Tuxitheone 0:ecaf3e593122 1071 * This should not modify any state if the Reject is bad
Tuxitheone 0:ecaf3e593122 1072 * or if LCP is in the LS_OPENED state.
Tuxitheone 0:ecaf3e593122 1073 *
Tuxitheone 0:ecaf3e593122 1074 * Returns:
Tuxitheone 0:ecaf3e593122 1075 * 0 - Reject was bad.
Tuxitheone 0:ecaf3e593122 1076 * 1 - Reject was good.
Tuxitheone 0:ecaf3e593122 1077 */
Tuxitheone 0:ecaf3e593122 1078 static int
Tuxitheone 0:ecaf3e593122 1079 lcp_rejci(fsm *f, u_char *p, int len)
Tuxitheone 0:ecaf3e593122 1080 {
Tuxitheone 0:ecaf3e593122 1081 lcp_options *go = &lcp_gotoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1082 u_char cichar;
Tuxitheone 0:ecaf3e593122 1083 u_short cishort;
Tuxitheone 0:ecaf3e593122 1084 u32_t cilong;
Tuxitheone 0:ecaf3e593122 1085 lcp_options try; /* options to request next time */
Tuxitheone 0:ecaf3e593122 1086
Tuxitheone 0:ecaf3e593122 1087 try = *go;
Tuxitheone 0:ecaf3e593122 1088
Tuxitheone 0:ecaf3e593122 1089 /*
Tuxitheone 0:ecaf3e593122 1090 * Any Rejected CIs must be in exactly the same order that we sent.
Tuxitheone 0:ecaf3e593122 1091 * Check packet length and CI length at each step.
Tuxitheone 0:ecaf3e593122 1092 * If we find any deviations, then this packet is bad.
Tuxitheone 0:ecaf3e593122 1093 */
Tuxitheone 0:ecaf3e593122 1094 #define REJCIVOID(opt, neg) \
Tuxitheone 0:ecaf3e593122 1095 if (go->neg && \
Tuxitheone 0:ecaf3e593122 1096 len >= CILEN_VOID && \
Tuxitheone 0:ecaf3e593122 1097 p[1] == CILEN_VOID && \
Tuxitheone 0:ecaf3e593122 1098 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 1099 len -= CILEN_VOID; \
Tuxitheone 0:ecaf3e593122 1100 INCPTR(CILEN_VOID, p); \
Tuxitheone 0:ecaf3e593122 1101 try.neg = 0; \
Tuxitheone 0:ecaf3e593122 1102 LCPDEBUG(LOG_INFO, ("lcp_rejci: void opt %d rejected\n", opt)); \
Tuxitheone 0:ecaf3e593122 1103 }
Tuxitheone 0:ecaf3e593122 1104 #define REJCISHORT(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 1105 if (go->neg && \
Tuxitheone 0:ecaf3e593122 1106 len >= CILEN_SHORT && \
Tuxitheone 0:ecaf3e593122 1107 p[1] == CILEN_SHORT && \
Tuxitheone 0:ecaf3e593122 1108 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 1109 len -= CILEN_SHORT; \
Tuxitheone 0:ecaf3e593122 1110 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 1111 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 1112 /* Check rejected value. */ \
Tuxitheone 0:ecaf3e593122 1113 if (cishort != val) { \
Tuxitheone 0:ecaf3e593122 1114 goto bad; \
Tuxitheone 0:ecaf3e593122 1115 } \
Tuxitheone 0:ecaf3e593122 1116 try.neg = 0; \
Tuxitheone 0:ecaf3e593122 1117 LCPDEBUG(LOG_INFO, ("lcp_rejci: short opt %d rejected\n", opt)); \
Tuxitheone 0:ecaf3e593122 1118 }
Tuxitheone 0:ecaf3e593122 1119 #define REJCICHAP(opt, neg, val, digest) \
Tuxitheone 0:ecaf3e593122 1120 if (go->neg && \
Tuxitheone 0:ecaf3e593122 1121 len >= CILEN_CHAP && \
Tuxitheone 0:ecaf3e593122 1122 p[1] == CILEN_CHAP && \
Tuxitheone 0:ecaf3e593122 1123 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 1124 len -= CILEN_CHAP; \
Tuxitheone 0:ecaf3e593122 1125 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 1126 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 1127 GETCHAR(cichar, p); \
Tuxitheone 0:ecaf3e593122 1128 /* Check rejected value. */ \
Tuxitheone 0:ecaf3e593122 1129 if (cishort != val || cichar != digest) { \
Tuxitheone 0:ecaf3e593122 1130 goto bad; \
Tuxitheone 0:ecaf3e593122 1131 } \
Tuxitheone 0:ecaf3e593122 1132 try.neg = 0; \
Tuxitheone 0:ecaf3e593122 1133 try.neg_upap = 0; \
Tuxitheone 0:ecaf3e593122 1134 LCPDEBUG(LOG_INFO, ("lcp_rejci: chap opt %d rejected\n", opt)); \
Tuxitheone 0:ecaf3e593122 1135 }
Tuxitheone 0:ecaf3e593122 1136 #define REJCILONG(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 1137 if (go->neg && \
Tuxitheone 0:ecaf3e593122 1138 len >= CILEN_LONG && \
Tuxitheone 0:ecaf3e593122 1139 p[1] == CILEN_LONG && \
Tuxitheone 0:ecaf3e593122 1140 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 1141 len -= CILEN_LONG; \
Tuxitheone 0:ecaf3e593122 1142 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 1143 GETLONG(cilong, p); \
Tuxitheone 0:ecaf3e593122 1144 /* Check rejected value. */ \
Tuxitheone 0:ecaf3e593122 1145 if (cilong != val) { \
Tuxitheone 0:ecaf3e593122 1146 goto bad; \
Tuxitheone 0:ecaf3e593122 1147 } \
Tuxitheone 0:ecaf3e593122 1148 try.neg = 0; \
Tuxitheone 0:ecaf3e593122 1149 LCPDEBUG(LOG_INFO, ("lcp_rejci: long opt %d rejected\n", opt)); \
Tuxitheone 0:ecaf3e593122 1150 }
Tuxitheone 0:ecaf3e593122 1151 #define REJCILQR(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 1152 if (go->neg && \
Tuxitheone 0:ecaf3e593122 1153 len >= CILEN_LQR && \
Tuxitheone 0:ecaf3e593122 1154 p[1] == CILEN_LQR && \
Tuxitheone 0:ecaf3e593122 1155 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 1156 len -= CILEN_LQR; \
Tuxitheone 0:ecaf3e593122 1157 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 1158 GETSHORT(cishort, p); \
Tuxitheone 0:ecaf3e593122 1159 GETLONG(cilong, p); \
Tuxitheone 0:ecaf3e593122 1160 /* Check rejected value. */ \
Tuxitheone 0:ecaf3e593122 1161 if (cishort != PPP_LQR || cilong != val) { \
Tuxitheone 0:ecaf3e593122 1162 goto bad; \
Tuxitheone 0:ecaf3e593122 1163 } \
Tuxitheone 0:ecaf3e593122 1164 try.neg = 0; \
Tuxitheone 0:ecaf3e593122 1165 LCPDEBUG(LOG_INFO, ("lcp_rejci: LQR opt %d rejected\n", opt)); \
Tuxitheone 0:ecaf3e593122 1166 }
Tuxitheone 0:ecaf3e593122 1167 #define REJCICBCP(opt, neg, val) \
Tuxitheone 0:ecaf3e593122 1168 if (go->neg && \
Tuxitheone 0:ecaf3e593122 1169 len >= CILEN_CBCP && \
Tuxitheone 0:ecaf3e593122 1170 p[1] == CILEN_CBCP && \
Tuxitheone 0:ecaf3e593122 1171 p[0] == opt) { \
Tuxitheone 0:ecaf3e593122 1172 len -= CILEN_CBCP; \
Tuxitheone 0:ecaf3e593122 1173 INCPTR(2, p); \
Tuxitheone 0:ecaf3e593122 1174 GETCHAR(cichar, p); \
Tuxitheone 0:ecaf3e593122 1175 /* Check rejected value. */ \
Tuxitheone 0:ecaf3e593122 1176 if (cichar != val) { \
Tuxitheone 0:ecaf3e593122 1177 goto bad; \
Tuxitheone 0:ecaf3e593122 1178 } \
Tuxitheone 0:ecaf3e593122 1179 try.neg = 0; \
Tuxitheone 0:ecaf3e593122 1180 LCPDEBUG(LOG_INFO, ("lcp_rejci: Callback opt %d rejected\n", opt)); \
Tuxitheone 0:ecaf3e593122 1181 }
Tuxitheone 0:ecaf3e593122 1182
Tuxitheone 0:ecaf3e593122 1183 REJCISHORT(CI_MRU, neg_mru, go->mru);
Tuxitheone 0:ecaf3e593122 1184 REJCILONG(CI_ASYNCMAP, neg_asyncmap, go->asyncmap);
Tuxitheone 0:ecaf3e593122 1185 REJCICHAP(CI_AUTHTYPE, neg_chap, PPP_CHAP, go->chap_mdtype);
Tuxitheone 0:ecaf3e593122 1186 if (!go->neg_chap) {
Tuxitheone 0:ecaf3e593122 1187 REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP);
Tuxitheone 0:ecaf3e593122 1188 }
Tuxitheone 0:ecaf3e593122 1189 REJCILQR(CI_QUALITY, neg_lqr, go->lqr_period);
Tuxitheone 0:ecaf3e593122 1190 REJCICBCP(CI_CALLBACK, neg_cbcp, CBCP_OPT);
Tuxitheone 0:ecaf3e593122 1191 REJCILONG(CI_MAGICNUMBER, neg_magicnumber, go->magicnumber);
Tuxitheone 0:ecaf3e593122 1192 REJCIVOID(CI_PCOMPRESSION, neg_pcompression);
Tuxitheone 0:ecaf3e593122 1193 REJCIVOID(CI_ACCOMPRESSION, neg_accompression);
Tuxitheone 0:ecaf3e593122 1194
Tuxitheone 0:ecaf3e593122 1195 /*
Tuxitheone 0:ecaf3e593122 1196 * If there are any remaining CIs, then this packet is bad.
Tuxitheone 0:ecaf3e593122 1197 */
Tuxitheone 0:ecaf3e593122 1198 if (len != 0) {
Tuxitheone 0:ecaf3e593122 1199 goto bad;
Tuxitheone 0:ecaf3e593122 1200 }
Tuxitheone 0:ecaf3e593122 1201 /*
Tuxitheone 0:ecaf3e593122 1202 * Now we can update state.
Tuxitheone 0:ecaf3e593122 1203 */
Tuxitheone 0:ecaf3e593122 1204 if (f->state != LS_OPENED) {
Tuxitheone 0:ecaf3e593122 1205 *go = try;
Tuxitheone 0:ecaf3e593122 1206 }
Tuxitheone 0:ecaf3e593122 1207 return 1;
Tuxitheone 0:ecaf3e593122 1208
Tuxitheone 0:ecaf3e593122 1209 bad:
Tuxitheone 0:ecaf3e593122 1210 LCPDEBUG(LOG_WARNING, ("lcp_rejci: received bad Reject!\n"));
Tuxitheone 0:ecaf3e593122 1211 return 0;
Tuxitheone 0:ecaf3e593122 1212 }
Tuxitheone 0:ecaf3e593122 1213
Tuxitheone 0:ecaf3e593122 1214
Tuxitheone 0:ecaf3e593122 1215 /*
Tuxitheone 0:ecaf3e593122 1216 * lcp_reqci - Check the peer's requested CIs and send appropriate response.
Tuxitheone 0:ecaf3e593122 1217 *
Tuxitheone 0:ecaf3e593122 1218 * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified
Tuxitheone 0:ecaf3e593122 1219 * appropriately. If reject_if_disagree is non-zero, doesn't return
Tuxitheone 0:ecaf3e593122 1220 * CONFNAK; returns CONFREJ if it can't return CONFACK.
Tuxitheone 0:ecaf3e593122 1221 */
Tuxitheone 0:ecaf3e593122 1222 static int
Tuxitheone 0:ecaf3e593122 1223 lcp_reqci(fsm *f,
Tuxitheone 0:ecaf3e593122 1224 u_char *inp, /* Requested CIs */
Tuxitheone 0:ecaf3e593122 1225 int *lenp, /* Length of requested CIs */
Tuxitheone 0:ecaf3e593122 1226 int reject_if_disagree)
Tuxitheone 0:ecaf3e593122 1227 {
Tuxitheone 0:ecaf3e593122 1228 lcp_options *go = &lcp_gotoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1229 lcp_options *ho = &lcp_hisoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1230 lcp_options *ao = &lcp_allowoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1231 u_char *cip, *next; /* Pointer to current and next CIs */
Tuxitheone 0:ecaf3e593122 1232 int cilen, citype; /* Parsed len, type */
Tuxitheone 0:ecaf3e593122 1233 u_char cichar; /* Parsed char value */
Tuxitheone 0:ecaf3e593122 1234 u_short cishort; /* Parsed short value */
Tuxitheone 0:ecaf3e593122 1235 u32_t cilong; /* Parse long value */
Tuxitheone 0:ecaf3e593122 1236 int rc = CONFACK; /* Final packet return code */
Tuxitheone 0:ecaf3e593122 1237 int orc; /* Individual option return code */
Tuxitheone 0:ecaf3e593122 1238 u_char *p; /* Pointer to next char to parse */
Tuxitheone 0:ecaf3e593122 1239 u_char *rejp; /* Pointer to next char in reject frame */
Tuxitheone 0:ecaf3e593122 1240 u_char *nakp; /* Pointer to next char in Nak frame */
Tuxitheone 0:ecaf3e593122 1241 int l = *lenp; /* Length left */
Tuxitheone 0:ecaf3e593122 1242 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1243 char traceBuf[80];
Tuxitheone 0:ecaf3e593122 1244 size_t traceNdx = 0;
Tuxitheone 0:ecaf3e593122 1245 #endif
Tuxitheone 0:ecaf3e593122 1246
Tuxitheone 0:ecaf3e593122 1247 /*
Tuxitheone 0:ecaf3e593122 1248 * Reset all his options.
Tuxitheone 0:ecaf3e593122 1249 */
Tuxitheone 0:ecaf3e593122 1250 BZERO(ho, sizeof(*ho));
Tuxitheone 0:ecaf3e593122 1251
Tuxitheone 0:ecaf3e593122 1252 /*
Tuxitheone 0:ecaf3e593122 1253 * Process all his options.
Tuxitheone 0:ecaf3e593122 1254 */
Tuxitheone 0:ecaf3e593122 1255 next = inp;
Tuxitheone 0:ecaf3e593122 1256 nakp = nak_buffer;
Tuxitheone 0:ecaf3e593122 1257 rejp = inp;
Tuxitheone 0:ecaf3e593122 1258 while (l) {
Tuxitheone 0:ecaf3e593122 1259 orc = CONFACK; /* Assume success */
Tuxitheone 0:ecaf3e593122 1260 cip = p = next; /* Remember begining of CI */
Tuxitheone 0:ecaf3e593122 1261 if (l < 2 || /* Not enough data for CI header or */
Tuxitheone 0:ecaf3e593122 1262 p[1] < 2 || /* CI length too small or */
Tuxitheone 0:ecaf3e593122 1263 p[1] > l) { /* CI length too big? */
Tuxitheone 0:ecaf3e593122 1264 LCPDEBUG(LOG_WARNING, ("lcp_reqci: bad CI length!\n"));
Tuxitheone 0:ecaf3e593122 1265 orc = CONFREJ; /* Reject bad CI */
Tuxitheone 0:ecaf3e593122 1266 cilen = l; /* Reject till end of packet */
Tuxitheone 0:ecaf3e593122 1267 l = 0; /* Don't loop again */
Tuxitheone 0:ecaf3e593122 1268 citype = 0;
Tuxitheone 0:ecaf3e593122 1269 goto endswitch;
Tuxitheone 0:ecaf3e593122 1270 }
Tuxitheone 0:ecaf3e593122 1271 GETCHAR(citype, p); /* Parse CI type */
Tuxitheone 0:ecaf3e593122 1272 GETCHAR(cilen, p); /* Parse CI length */
Tuxitheone 0:ecaf3e593122 1273 l -= cilen; /* Adjust remaining length */
Tuxitheone 0:ecaf3e593122 1274 next += cilen; /* Step to next CI */
Tuxitheone 0:ecaf3e593122 1275
Tuxitheone 0:ecaf3e593122 1276 switch (citype) { /* Check CI type */
Tuxitheone 0:ecaf3e593122 1277 case CI_MRU:
Tuxitheone 0:ecaf3e593122 1278 if (!ao->neg_mru) { /* Allow option? */
Tuxitheone 0:ecaf3e593122 1279 LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject MRU - not allowed\n"));
Tuxitheone 0:ecaf3e593122 1280 orc = CONFREJ; /* Reject CI */
Tuxitheone 0:ecaf3e593122 1281 break;
Tuxitheone 0:ecaf3e593122 1282 } else if (cilen != CILEN_SHORT) { /* Check CI length */
Tuxitheone 0:ecaf3e593122 1283 LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject MRU - bad length\n"));
Tuxitheone 0:ecaf3e593122 1284 orc = CONFREJ; /* Reject CI */
Tuxitheone 0:ecaf3e593122 1285 break;
Tuxitheone 0:ecaf3e593122 1286 }
Tuxitheone 0:ecaf3e593122 1287 GETSHORT(cishort, p); /* Parse MRU */
Tuxitheone 0:ecaf3e593122 1288
Tuxitheone 0:ecaf3e593122 1289 /*
Tuxitheone 0:ecaf3e593122 1290 * He must be able to receive at least our minimum.
Tuxitheone 0:ecaf3e593122 1291 * No need to check a maximum. If he sends a large number,
Tuxitheone 0:ecaf3e593122 1292 * we'll just ignore it.
Tuxitheone 0:ecaf3e593122 1293 */
Tuxitheone 0:ecaf3e593122 1294 if (cishort < PPP_MINMRU) {
Tuxitheone 0:ecaf3e593122 1295 LCPDEBUG(LOG_INFO, ("lcp_reqci: Nak - MRU too small\n"));
Tuxitheone 0:ecaf3e593122 1296 orc = CONFNAK; /* Nak CI */
Tuxitheone 0:ecaf3e593122 1297 PUTCHAR(CI_MRU, nakp);
Tuxitheone 0:ecaf3e593122 1298 PUTCHAR(CILEN_SHORT, nakp);
Tuxitheone 0:ecaf3e593122 1299 PUTSHORT(PPP_MINMRU, nakp); /* Give him a hint */
Tuxitheone 0:ecaf3e593122 1300 break;
Tuxitheone 0:ecaf3e593122 1301 }
Tuxitheone 0:ecaf3e593122 1302 ho->neg_mru = 1; /* Remember he sent MRU */
Tuxitheone 0:ecaf3e593122 1303 ho->mru = cishort; /* And remember value */
Tuxitheone 0:ecaf3e593122 1304 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1305 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " MRU %d", cishort);
Tuxitheone 0:ecaf3e593122 1306 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1307 #endif
Tuxitheone 0:ecaf3e593122 1308 break;
Tuxitheone 0:ecaf3e593122 1309
Tuxitheone 0:ecaf3e593122 1310 case CI_ASYNCMAP:
Tuxitheone 0:ecaf3e593122 1311 if (!ao->neg_asyncmap) {
Tuxitheone 0:ecaf3e593122 1312 LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject ASYNCMAP not allowed\n"));
Tuxitheone 0:ecaf3e593122 1313 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1314 break;
Tuxitheone 0:ecaf3e593122 1315 } else if (cilen != CILEN_LONG) {
Tuxitheone 0:ecaf3e593122 1316 LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject ASYNCMAP bad length\n"));
Tuxitheone 0:ecaf3e593122 1317 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1318 break;
Tuxitheone 0:ecaf3e593122 1319 }
Tuxitheone 0:ecaf3e593122 1320 GETLONG(cilong, p);
Tuxitheone 0:ecaf3e593122 1321
Tuxitheone 0:ecaf3e593122 1322 /*
Tuxitheone 0:ecaf3e593122 1323 * Asyncmap must have set at least the bits
Tuxitheone 0:ecaf3e593122 1324 * which are set in lcp_allowoptions[unit].asyncmap.
Tuxitheone 0:ecaf3e593122 1325 */
Tuxitheone 0:ecaf3e593122 1326 if ((ao->asyncmap & ~cilong) != 0) {
Tuxitheone 0:ecaf3e593122 1327 LCPDEBUG(LOG_INFO, ("lcp_reqci: Nak ASYNCMAP %lX missing %lX\n",
Tuxitheone 0:ecaf3e593122 1328 cilong, ao->asyncmap));
Tuxitheone 0:ecaf3e593122 1329 orc = CONFNAK;
Tuxitheone 0:ecaf3e593122 1330 PUTCHAR(CI_ASYNCMAP, nakp);
Tuxitheone 0:ecaf3e593122 1331 PUTCHAR(CILEN_LONG, nakp);
Tuxitheone 0:ecaf3e593122 1332 PUTLONG(ao->asyncmap | cilong, nakp);
Tuxitheone 0:ecaf3e593122 1333 break;
Tuxitheone 0:ecaf3e593122 1334 }
Tuxitheone 0:ecaf3e593122 1335 ho->neg_asyncmap = 1;
Tuxitheone 0:ecaf3e593122 1336 ho->asyncmap = cilong;
Tuxitheone 0:ecaf3e593122 1337 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1338 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " ASYNCMAP=%lX", cilong);
Tuxitheone 0:ecaf3e593122 1339 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1340 #endif
Tuxitheone 0:ecaf3e593122 1341 break;
Tuxitheone 0:ecaf3e593122 1342
Tuxitheone 0:ecaf3e593122 1343 case CI_AUTHTYPE:
Tuxitheone 0:ecaf3e593122 1344 if (cilen < CILEN_SHORT) {
Tuxitheone 0:ecaf3e593122 1345 LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject AUTHTYPE missing arg\n"));
Tuxitheone 0:ecaf3e593122 1346 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1347 break;
Tuxitheone 0:ecaf3e593122 1348 } else if (!(ao->neg_upap || ao->neg_chap)) {
Tuxitheone 0:ecaf3e593122 1349 /*
Tuxitheone 0:ecaf3e593122 1350 * Reject the option if we're not willing to authenticate.
Tuxitheone 0:ecaf3e593122 1351 */
Tuxitheone 0:ecaf3e593122 1352 LCPDEBUG(LOG_INFO, ("lcp_reqci: Reject AUTHTYPE not allowed\n"));
Tuxitheone 0:ecaf3e593122 1353 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1354 break;
Tuxitheone 0:ecaf3e593122 1355 }
Tuxitheone 0:ecaf3e593122 1356 GETSHORT(cishort, p);
Tuxitheone 0:ecaf3e593122 1357
Tuxitheone 0:ecaf3e593122 1358 /*
Tuxitheone 0:ecaf3e593122 1359 * Authtype must be UPAP or CHAP.
Tuxitheone 0:ecaf3e593122 1360 *
Tuxitheone 0:ecaf3e593122 1361 * Note: if both ao->neg_upap and ao->neg_chap are set,
Tuxitheone 0:ecaf3e593122 1362 * and the peer sends a Configure-Request with two
Tuxitheone 0:ecaf3e593122 1363 * authenticate-protocol requests, one for CHAP and one
Tuxitheone 0:ecaf3e593122 1364 * for UPAP, then we will reject the second request.
Tuxitheone 0:ecaf3e593122 1365 * Whether we end up doing CHAP or UPAP depends then on
Tuxitheone 0:ecaf3e593122 1366 * the ordering of the CIs in the peer's Configure-Request.
Tuxitheone 0:ecaf3e593122 1367 */
Tuxitheone 0:ecaf3e593122 1368
Tuxitheone 0:ecaf3e593122 1369 if (cishort == PPP_PAP) {
Tuxitheone 0:ecaf3e593122 1370 if (ho->neg_chap) { /* we've already accepted CHAP */
Tuxitheone 0:ecaf3e593122 1371 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE PAP already accepted\n"));
Tuxitheone 0:ecaf3e593122 1372 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1373 break;
Tuxitheone 0:ecaf3e593122 1374 } else if (cilen != CILEN_SHORT) {
Tuxitheone 0:ecaf3e593122 1375 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE PAP bad len\n"));
Tuxitheone 0:ecaf3e593122 1376 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1377 break;
Tuxitheone 0:ecaf3e593122 1378 }
Tuxitheone 0:ecaf3e593122 1379 if (!ao->neg_upap) { /* we don't want to do PAP */
Tuxitheone 0:ecaf3e593122 1380 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE PAP not allowed\n"));
Tuxitheone 0:ecaf3e593122 1381 orc = CONFNAK; /* NAK it and suggest CHAP */
Tuxitheone 0:ecaf3e593122 1382 PUTCHAR(CI_AUTHTYPE, nakp);
Tuxitheone 0:ecaf3e593122 1383 PUTCHAR(CILEN_CHAP, nakp);
Tuxitheone 0:ecaf3e593122 1384 PUTSHORT(PPP_CHAP, nakp);
Tuxitheone 0:ecaf3e593122 1385 PUTCHAR(ao->chap_mdtype, nakp);
Tuxitheone 0:ecaf3e593122 1386 break;
Tuxitheone 0:ecaf3e593122 1387 }
Tuxitheone 0:ecaf3e593122 1388 ho->neg_upap = 1;
Tuxitheone 0:ecaf3e593122 1389 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1390 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " PAP (%X)", cishort);
Tuxitheone 0:ecaf3e593122 1391 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1392 #endif
Tuxitheone 0:ecaf3e593122 1393 break;
Tuxitheone 0:ecaf3e593122 1394 }
Tuxitheone 0:ecaf3e593122 1395 if (cishort == PPP_CHAP) {
Tuxitheone 0:ecaf3e593122 1396 if (ho->neg_upap) { /* we've already accepted PAP */
Tuxitheone 0:ecaf3e593122 1397 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE CHAP accepted PAP\n"));
Tuxitheone 0:ecaf3e593122 1398 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1399 break;
Tuxitheone 0:ecaf3e593122 1400 } else if (cilen != CILEN_CHAP) {
Tuxitheone 0:ecaf3e593122 1401 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE CHAP bad len\n"));
Tuxitheone 0:ecaf3e593122 1402 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1403 break;
Tuxitheone 0:ecaf3e593122 1404 }
Tuxitheone 0:ecaf3e593122 1405 if (!ao->neg_chap) { /* we don't want to do CHAP */
Tuxitheone 0:ecaf3e593122 1406 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE CHAP not allowed\n"));
Tuxitheone 0:ecaf3e593122 1407 orc = CONFNAK; /* NAK it and suggest PAP */
Tuxitheone 0:ecaf3e593122 1408 PUTCHAR(CI_AUTHTYPE, nakp);
Tuxitheone 0:ecaf3e593122 1409 PUTCHAR(CILEN_SHORT, nakp);
Tuxitheone 0:ecaf3e593122 1410 PUTSHORT(PPP_PAP, nakp);
Tuxitheone 0:ecaf3e593122 1411 break;
Tuxitheone 0:ecaf3e593122 1412 }
Tuxitheone 0:ecaf3e593122 1413 GETCHAR(cichar, p); /* get digest type*/
Tuxitheone 0:ecaf3e593122 1414 if (cichar != CHAP_DIGEST_MD5
Tuxitheone 0:ecaf3e593122 1415 #if MSCHAP_SUPPORT
Tuxitheone 0:ecaf3e593122 1416 && cichar != CHAP_MICROSOFT
Tuxitheone 0:ecaf3e593122 1417 #endif
Tuxitheone 0:ecaf3e593122 1418 ) {
Tuxitheone 0:ecaf3e593122 1419 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE CHAP digest=%d\n", (int)cichar));
Tuxitheone 0:ecaf3e593122 1420 orc = CONFNAK;
Tuxitheone 0:ecaf3e593122 1421 PUTCHAR(CI_AUTHTYPE, nakp);
Tuxitheone 0:ecaf3e593122 1422 PUTCHAR(CILEN_CHAP, nakp);
Tuxitheone 0:ecaf3e593122 1423 PUTSHORT(PPP_CHAP, nakp);
Tuxitheone 0:ecaf3e593122 1424 PUTCHAR(ao->chap_mdtype, nakp);
Tuxitheone 0:ecaf3e593122 1425 break;
Tuxitheone 0:ecaf3e593122 1426 }
Tuxitheone 0:ecaf3e593122 1427 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1428 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CHAP %X,%d", cishort, (int)cichar);
Tuxitheone 0:ecaf3e593122 1429 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1430 #endif
Tuxitheone 0:ecaf3e593122 1431 ho->chap_mdtype = cichar; /* save md type */
Tuxitheone 0:ecaf3e593122 1432 ho->neg_chap = 1;
Tuxitheone 0:ecaf3e593122 1433 break;
Tuxitheone 0:ecaf3e593122 1434 }
Tuxitheone 0:ecaf3e593122 1435
Tuxitheone 0:ecaf3e593122 1436 /*
Tuxitheone 0:ecaf3e593122 1437 * We don't recognize the protocol they're asking for.
Tuxitheone 0:ecaf3e593122 1438 * Nak it with something we're willing to do.
Tuxitheone 0:ecaf3e593122 1439 * (At this point we know ao->neg_upap || ao->neg_chap.)
Tuxitheone 0:ecaf3e593122 1440 */
Tuxitheone 0:ecaf3e593122 1441 orc = CONFNAK;
Tuxitheone 0:ecaf3e593122 1442 PUTCHAR(CI_AUTHTYPE, nakp);
Tuxitheone 0:ecaf3e593122 1443 if (ao->neg_chap) {
Tuxitheone 0:ecaf3e593122 1444 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE %d req CHAP\n", cishort));
Tuxitheone 0:ecaf3e593122 1445 PUTCHAR(CILEN_CHAP, nakp);
Tuxitheone 0:ecaf3e593122 1446 PUTSHORT(PPP_CHAP, nakp);
Tuxitheone 0:ecaf3e593122 1447 PUTCHAR(ao->chap_mdtype, nakp);
Tuxitheone 0:ecaf3e593122 1448 } else {
Tuxitheone 0:ecaf3e593122 1449 LCPDEBUG(LOG_WARNING, ("lcp_reqci: Nak AUTHTYPE %d req PAP\n", cishort));
Tuxitheone 0:ecaf3e593122 1450 PUTCHAR(CILEN_SHORT, nakp);
Tuxitheone 0:ecaf3e593122 1451 PUTSHORT(PPP_PAP, nakp);
Tuxitheone 0:ecaf3e593122 1452 }
Tuxitheone 0:ecaf3e593122 1453 break;
Tuxitheone 0:ecaf3e593122 1454
Tuxitheone 0:ecaf3e593122 1455 case CI_QUALITY:
Tuxitheone 0:ecaf3e593122 1456 GETSHORT(cishort, p);
Tuxitheone 0:ecaf3e593122 1457 GETLONG(cilong, p);
Tuxitheone 0:ecaf3e593122 1458 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1459 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " QUALITY (%x %x)", cishort, (unsigned int) cilong);
Tuxitheone 0:ecaf3e593122 1460 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1461 #endif
Tuxitheone 0:ecaf3e593122 1462
Tuxitheone 0:ecaf3e593122 1463 if (!ao->neg_lqr ||
Tuxitheone 0:ecaf3e593122 1464 cilen != CILEN_LQR) {
Tuxitheone 0:ecaf3e593122 1465 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1466 break;
Tuxitheone 0:ecaf3e593122 1467 }
Tuxitheone 0:ecaf3e593122 1468
Tuxitheone 0:ecaf3e593122 1469 /*
Tuxitheone 0:ecaf3e593122 1470 * Check the protocol and the reporting period.
Tuxitheone 0:ecaf3e593122 1471 * XXX When should we Nak this, and what with?
Tuxitheone 0:ecaf3e593122 1472 */
Tuxitheone 0:ecaf3e593122 1473 if (cishort != PPP_LQR) {
Tuxitheone 0:ecaf3e593122 1474 orc = CONFNAK;
Tuxitheone 0:ecaf3e593122 1475 PUTCHAR(CI_QUALITY, nakp);
Tuxitheone 0:ecaf3e593122 1476 PUTCHAR(CILEN_LQR, nakp);
Tuxitheone 0:ecaf3e593122 1477 PUTSHORT(PPP_LQR, nakp);
Tuxitheone 0:ecaf3e593122 1478 PUTLONG(ao->lqr_period, nakp);
Tuxitheone 0:ecaf3e593122 1479 break;
Tuxitheone 0:ecaf3e593122 1480 }
Tuxitheone 0:ecaf3e593122 1481 break;
Tuxitheone 0:ecaf3e593122 1482
Tuxitheone 0:ecaf3e593122 1483 case CI_MAGICNUMBER:
Tuxitheone 0:ecaf3e593122 1484 if (!(ao->neg_magicnumber || go->neg_magicnumber) ||
Tuxitheone 0:ecaf3e593122 1485 cilen != CILEN_LONG) {
Tuxitheone 0:ecaf3e593122 1486 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1487 break;
Tuxitheone 0:ecaf3e593122 1488 }
Tuxitheone 0:ecaf3e593122 1489 GETLONG(cilong, p);
Tuxitheone 0:ecaf3e593122 1490 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1491 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " MAGICNUMBER (%lX)", cilong);
Tuxitheone 0:ecaf3e593122 1492 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1493 #endif
Tuxitheone 0:ecaf3e593122 1494
Tuxitheone 0:ecaf3e593122 1495 /*
Tuxitheone 0:ecaf3e593122 1496 * He must have a different magic number.
Tuxitheone 0:ecaf3e593122 1497 */
Tuxitheone 0:ecaf3e593122 1498 if (go->neg_magicnumber &&
Tuxitheone 0:ecaf3e593122 1499 cilong == go->magicnumber) {
Tuxitheone 0:ecaf3e593122 1500 cilong = magic(); /* Don't put magic() inside macro! */
Tuxitheone 0:ecaf3e593122 1501 orc = CONFNAK;
Tuxitheone 0:ecaf3e593122 1502 PUTCHAR(CI_MAGICNUMBER, nakp);
Tuxitheone 0:ecaf3e593122 1503 PUTCHAR(CILEN_LONG, nakp);
Tuxitheone 0:ecaf3e593122 1504 PUTLONG(cilong, nakp);
Tuxitheone 0:ecaf3e593122 1505 break;
Tuxitheone 0:ecaf3e593122 1506 }
Tuxitheone 0:ecaf3e593122 1507 ho->neg_magicnumber = 1;
Tuxitheone 0:ecaf3e593122 1508 ho->magicnumber = cilong;
Tuxitheone 0:ecaf3e593122 1509 break;
Tuxitheone 0:ecaf3e593122 1510
Tuxitheone 0:ecaf3e593122 1511
Tuxitheone 0:ecaf3e593122 1512 case CI_PCOMPRESSION:
Tuxitheone 0:ecaf3e593122 1513 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1514 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " PCOMPRESSION");
Tuxitheone 0:ecaf3e593122 1515 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1516 #endif
Tuxitheone 0:ecaf3e593122 1517 if (!ao->neg_pcompression ||
Tuxitheone 0:ecaf3e593122 1518 cilen != CILEN_VOID) {
Tuxitheone 0:ecaf3e593122 1519 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1520 break;
Tuxitheone 0:ecaf3e593122 1521 }
Tuxitheone 0:ecaf3e593122 1522 ho->neg_pcompression = 1;
Tuxitheone 0:ecaf3e593122 1523 break;
Tuxitheone 0:ecaf3e593122 1524
Tuxitheone 0:ecaf3e593122 1525 case CI_ACCOMPRESSION:
Tuxitheone 0:ecaf3e593122 1526 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1527 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " ACCOMPRESSION");
Tuxitheone 0:ecaf3e593122 1528 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1529 #endif
Tuxitheone 0:ecaf3e593122 1530 if (!ao->neg_accompression ||
Tuxitheone 0:ecaf3e593122 1531 cilen != CILEN_VOID) {
Tuxitheone 0:ecaf3e593122 1532 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1533 break;
Tuxitheone 0:ecaf3e593122 1534 }
Tuxitheone 0:ecaf3e593122 1535 ho->neg_accompression = 1;
Tuxitheone 0:ecaf3e593122 1536 break;
Tuxitheone 0:ecaf3e593122 1537
Tuxitheone 0:ecaf3e593122 1538 case CI_MRRU:
Tuxitheone 0:ecaf3e593122 1539 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1540 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_MRRU");
Tuxitheone 0:ecaf3e593122 1541 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1542 #endif
Tuxitheone 0:ecaf3e593122 1543 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1544 break;
Tuxitheone 0:ecaf3e593122 1545
Tuxitheone 0:ecaf3e593122 1546 case CI_SSNHF:
Tuxitheone 0:ecaf3e593122 1547 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1548 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_SSNHF");
Tuxitheone 0:ecaf3e593122 1549 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1550 #endif
Tuxitheone 0:ecaf3e593122 1551 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1552 break;
Tuxitheone 0:ecaf3e593122 1553
Tuxitheone 0:ecaf3e593122 1554 case CI_EPDISC:
Tuxitheone 0:ecaf3e593122 1555 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1556 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_EPDISC");
Tuxitheone 0:ecaf3e593122 1557 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1558 #endif
Tuxitheone 0:ecaf3e593122 1559 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1560 break;
Tuxitheone 0:ecaf3e593122 1561
Tuxitheone 0:ecaf3e593122 1562 default:
Tuxitheone 0:ecaf3e593122 1563 #if TRACELCP
Tuxitheone 0:ecaf3e593122 1564 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " unknown %d", citype);
Tuxitheone 0:ecaf3e593122 1565 traceNdx = strlen(traceBuf);
Tuxitheone 0:ecaf3e593122 1566 #endif
Tuxitheone 0:ecaf3e593122 1567 orc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1568 break;
Tuxitheone 0:ecaf3e593122 1569 }
Tuxitheone 0:ecaf3e593122 1570
Tuxitheone 0:ecaf3e593122 1571 endswitch:
Tuxitheone 0:ecaf3e593122 1572 #if TRACELCP
Tuxitheone 0:ecaf3e593122 1573 if (traceNdx >= 80 - 32) {
Tuxitheone 0:ecaf3e593122 1574 LCPDEBUG(LOG_INFO, ("lcp_reqci: rcvd%s\n", traceBuf));
Tuxitheone 0:ecaf3e593122 1575 traceNdx = 0;
Tuxitheone 0:ecaf3e593122 1576 }
Tuxitheone 0:ecaf3e593122 1577 #endif
Tuxitheone 0:ecaf3e593122 1578 if (orc == CONFACK && /* Good CI */
Tuxitheone 0:ecaf3e593122 1579 rc != CONFACK) { /* but prior CI wasnt? */
Tuxitheone 0:ecaf3e593122 1580 continue; /* Don't send this one */
Tuxitheone 0:ecaf3e593122 1581 }
Tuxitheone 0:ecaf3e593122 1582
Tuxitheone 0:ecaf3e593122 1583 if (orc == CONFNAK) { /* Nak this CI? */
Tuxitheone 0:ecaf3e593122 1584 if (reject_if_disagree /* Getting fed up with sending NAKs? */
Tuxitheone 0:ecaf3e593122 1585 && citype != CI_MAGICNUMBER) {
Tuxitheone 0:ecaf3e593122 1586 orc = CONFREJ; /* Get tough if so */
Tuxitheone 0:ecaf3e593122 1587 } else {
Tuxitheone 0:ecaf3e593122 1588 if (rc == CONFREJ) { /* Rejecting prior CI? */
Tuxitheone 0:ecaf3e593122 1589 continue; /* Don't send this one */
Tuxitheone 0:ecaf3e593122 1590 }
Tuxitheone 0:ecaf3e593122 1591 rc = CONFNAK;
Tuxitheone 0:ecaf3e593122 1592 }
Tuxitheone 0:ecaf3e593122 1593 }
Tuxitheone 0:ecaf3e593122 1594 if (orc == CONFREJ) { /* Reject this CI */
Tuxitheone 0:ecaf3e593122 1595 rc = CONFREJ;
Tuxitheone 0:ecaf3e593122 1596 if (cip != rejp) { /* Need to move rejected CI? */
Tuxitheone 0:ecaf3e593122 1597 BCOPY(cip, rejp, cilen); /* Move it */
Tuxitheone 0:ecaf3e593122 1598 }
Tuxitheone 0:ecaf3e593122 1599 INCPTR(cilen, rejp); /* Update output pointer */
Tuxitheone 0:ecaf3e593122 1600 }
Tuxitheone 0:ecaf3e593122 1601 }
Tuxitheone 0:ecaf3e593122 1602
Tuxitheone 0:ecaf3e593122 1603 /*
Tuxitheone 0:ecaf3e593122 1604 * If we wanted to send additional NAKs (for unsent CIs), the
Tuxitheone 0:ecaf3e593122 1605 * code would go here. The extra NAKs would go at *nakp.
Tuxitheone 0:ecaf3e593122 1606 * At present there are no cases where we want to ask the
Tuxitheone 0:ecaf3e593122 1607 * peer to negotiate an option.
Tuxitheone 0:ecaf3e593122 1608 */
Tuxitheone 0:ecaf3e593122 1609
Tuxitheone 0:ecaf3e593122 1610 switch (rc) {
Tuxitheone 0:ecaf3e593122 1611 case CONFACK:
Tuxitheone 0:ecaf3e593122 1612 *lenp = (int)(next - inp);
Tuxitheone 0:ecaf3e593122 1613 break;
Tuxitheone 0:ecaf3e593122 1614 case CONFNAK:
Tuxitheone 0:ecaf3e593122 1615 /*
Tuxitheone 0:ecaf3e593122 1616 * Copy the Nak'd options from the nak_buffer to the caller's buffer.
Tuxitheone 0:ecaf3e593122 1617 */
Tuxitheone 0:ecaf3e593122 1618 *lenp = (int)(nakp - nak_buffer);
Tuxitheone 0:ecaf3e593122 1619 BCOPY(nak_buffer, inp, *lenp);
Tuxitheone 0:ecaf3e593122 1620 break;
Tuxitheone 0:ecaf3e593122 1621 case CONFREJ:
Tuxitheone 0:ecaf3e593122 1622 *lenp = (int)(rejp - inp);
Tuxitheone 0:ecaf3e593122 1623 break;
Tuxitheone 0:ecaf3e593122 1624 }
Tuxitheone 0:ecaf3e593122 1625
Tuxitheone 0:ecaf3e593122 1626 #if TRACELCP > 0
Tuxitheone 0:ecaf3e593122 1627 if (traceNdx > 0) {
Tuxitheone 0:ecaf3e593122 1628 LCPDEBUG(LOG_INFO, ("lcp_reqci: %s\n", traceBuf));
Tuxitheone 0:ecaf3e593122 1629 }
Tuxitheone 0:ecaf3e593122 1630 #endif
Tuxitheone 0:ecaf3e593122 1631 LCPDEBUG(LOG_INFO, ("lcp_reqci: returning CONF%s.\n", CODENAME(rc)));
Tuxitheone 0:ecaf3e593122 1632 return (rc); /* Return final code */
Tuxitheone 0:ecaf3e593122 1633 }
Tuxitheone 0:ecaf3e593122 1634
Tuxitheone 0:ecaf3e593122 1635
Tuxitheone 0:ecaf3e593122 1636 /*
Tuxitheone 0:ecaf3e593122 1637 * lcp_up - LCP has come UP.
Tuxitheone 0:ecaf3e593122 1638 */
Tuxitheone 0:ecaf3e593122 1639 static void
Tuxitheone 0:ecaf3e593122 1640 lcp_up(fsm *f)
Tuxitheone 0:ecaf3e593122 1641 {
Tuxitheone 0:ecaf3e593122 1642 lcp_options *wo = &lcp_wantoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1643 lcp_options *ho = &lcp_hisoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1644 lcp_options *go = &lcp_gotoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1645 lcp_options *ao = &lcp_allowoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1646
Tuxitheone 0:ecaf3e593122 1647 if (!go->neg_magicnumber) {
Tuxitheone 0:ecaf3e593122 1648 go->magicnumber = 0;
Tuxitheone 0:ecaf3e593122 1649 }
Tuxitheone 0:ecaf3e593122 1650 if (!ho->neg_magicnumber) {
Tuxitheone 0:ecaf3e593122 1651 ho->magicnumber = 0;
Tuxitheone 0:ecaf3e593122 1652 }
Tuxitheone 0:ecaf3e593122 1653
Tuxitheone 0:ecaf3e593122 1654 /*
Tuxitheone 0:ecaf3e593122 1655 * Set our MTU to the smaller of the MTU we wanted and
Tuxitheone 0:ecaf3e593122 1656 * the MRU our peer wanted. If we negotiated an MRU,
Tuxitheone 0:ecaf3e593122 1657 * set our MRU to the larger of value we wanted and
Tuxitheone 0:ecaf3e593122 1658 * the value we got in the negotiation.
Tuxitheone 0:ecaf3e593122 1659 */
Tuxitheone 0:ecaf3e593122 1660 ppp_send_config(f->unit, LWIP_MIN(ao->mru, (ho->neg_mru? ho->mru: PPP_MRU)),
Tuxitheone 0:ecaf3e593122 1661 (ho->neg_asyncmap? ho->asyncmap: 0xffffffffl),
Tuxitheone 0:ecaf3e593122 1662 ho->neg_pcompression, ho->neg_accompression);
Tuxitheone 0:ecaf3e593122 1663 /*
Tuxitheone 0:ecaf3e593122 1664 * If the asyncmap hasn't been negotiated, we really should
Tuxitheone 0:ecaf3e593122 1665 * set the receive asyncmap to ffffffff, but we set it to 0
Tuxitheone 0:ecaf3e593122 1666 * for backwards contemptibility.
Tuxitheone 0:ecaf3e593122 1667 */
Tuxitheone 0:ecaf3e593122 1668 ppp_recv_config(f->unit, (go->neg_mru? LWIP_MAX(wo->mru, go->mru): PPP_MRU),
Tuxitheone 0:ecaf3e593122 1669 (go->neg_asyncmap? go->asyncmap: 0x00000000),
Tuxitheone 0:ecaf3e593122 1670 go->neg_pcompression, go->neg_accompression);
Tuxitheone 0:ecaf3e593122 1671
Tuxitheone 0:ecaf3e593122 1672 if (ho->neg_mru) {
Tuxitheone 0:ecaf3e593122 1673 peer_mru[f->unit] = ho->mru;
Tuxitheone 0:ecaf3e593122 1674 }
Tuxitheone 0:ecaf3e593122 1675
Tuxitheone 0:ecaf3e593122 1676 lcp_echo_lowerup(f->unit); /* Enable echo messages */
Tuxitheone 0:ecaf3e593122 1677
Tuxitheone 0:ecaf3e593122 1678 link_established(f->unit); /* The link is up; authenticate now */
Tuxitheone 0:ecaf3e593122 1679 }
Tuxitheone 0:ecaf3e593122 1680
Tuxitheone 0:ecaf3e593122 1681
Tuxitheone 0:ecaf3e593122 1682 /*
Tuxitheone 0:ecaf3e593122 1683 * lcp_down - LCP has gone DOWN.
Tuxitheone 0:ecaf3e593122 1684 *
Tuxitheone 0:ecaf3e593122 1685 * Alert other protocols.
Tuxitheone 0:ecaf3e593122 1686 */
Tuxitheone 0:ecaf3e593122 1687 static void
Tuxitheone 0:ecaf3e593122 1688 lcp_down(fsm *f)
Tuxitheone 0:ecaf3e593122 1689 {
Tuxitheone 0:ecaf3e593122 1690 lcp_options *go = &lcp_gotoptions[f->unit];
Tuxitheone 0:ecaf3e593122 1691
Tuxitheone 0:ecaf3e593122 1692 lcp_echo_lowerdown(f->unit);
Tuxitheone 0:ecaf3e593122 1693
Tuxitheone 0:ecaf3e593122 1694 link_down(f->unit);
Tuxitheone 0:ecaf3e593122 1695
Tuxitheone 0:ecaf3e593122 1696 ppp_send_config(f->unit, PPP_MRU, 0xffffffffl, 0, 0);
Tuxitheone 0:ecaf3e593122 1697 ppp_recv_config(f->unit, PPP_MRU,
Tuxitheone 0:ecaf3e593122 1698 (go->neg_asyncmap? go->asyncmap: 0x00000000),
Tuxitheone 0:ecaf3e593122 1699 go->neg_pcompression, go->neg_accompression);
Tuxitheone 0:ecaf3e593122 1700 peer_mru[f->unit] = PPP_MRU;
Tuxitheone 0:ecaf3e593122 1701 }
Tuxitheone 0:ecaf3e593122 1702
Tuxitheone 0:ecaf3e593122 1703
Tuxitheone 0:ecaf3e593122 1704 /*
Tuxitheone 0:ecaf3e593122 1705 * lcp_starting - LCP needs the lower layer up.
Tuxitheone 0:ecaf3e593122 1706 */
Tuxitheone 0:ecaf3e593122 1707 static void
Tuxitheone 0:ecaf3e593122 1708 lcp_starting(fsm *f)
Tuxitheone 0:ecaf3e593122 1709 {
Tuxitheone 0:ecaf3e593122 1710 link_required(f->unit); /* lwip: currently does nothing */
Tuxitheone 0:ecaf3e593122 1711 }
Tuxitheone 0:ecaf3e593122 1712
Tuxitheone 0:ecaf3e593122 1713
Tuxitheone 0:ecaf3e593122 1714 /*
Tuxitheone 0:ecaf3e593122 1715 * lcp_finished - LCP has finished with the lower layer.
Tuxitheone 0:ecaf3e593122 1716 */
Tuxitheone 0:ecaf3e593122 1717 static void
Tuxitheone 0:ecaf3e593122 1718 lcp_finished(fsm *f)
Tuxitheone 0:ecaf3e593122 1719 {
Tuxitheone 0:ecaf3e593122 1720 link_terminated(f->unit); /* we are finished with the link */
Tuxitheone 0:ecaf3e593122 1721 }
Tuxitheone 0:ecaf3e593122 1722
Tuxitheone 0:ecaf3e593122 1723
Tuxitheone 0:ecaf3e593122 1724 #if PPP_ADDITIONAL_CALLBACKS
Tuxitheone 0:ecaf3e593122 1725 /*
Tuxitheone 0:ecaf3e593122 1726 * print_string - print a readable representation of a string using
Tuxitheone 0:ecaf3e593122 1727 * printer.
Tuxitheone 0:ecaf3e593122 1728 */
Tuxitheone 0:ecaf3e593122 1729 static void
Tuxitheone 0:ecaf3e593122 1730 print_string( char *p, int len, void (*printer) (void *, char *, ...), void *arg)
Tuxitheone 0:ecaf3e593122 1731 {
Tuxitheone 0:ecaf3e593122 1732 int c;
Tuxitheone 0:ecaf3e593122 1733
Tuxitheone 0:ecaf3e593122 1734 printer(arg, "\"");
Tuxitheone 0:ecaf3e593122 1735 for (; len > 0; --len) {
Tuxitheone 0:ecaf3e593122 1736 c = *p++;
Tuxitheone 0:ecaf3e593122 1737 if (' ' <= c && c <= '~') {
Tuxitheone 0:ecaf3e593122 1738 if (c == '\\' || c == '"') {
Tuxitheone 0:ecaf3e593122 1739 printer(arg, "\\");
Tuxitheone 0:ecaf3e593122 1740 }
Tuxitheone 0:ecaf3e593122 1741 printer(arg, "%c", c);
Tuxitheone 0:ecaf3e593122 1742 } else {
Tuxitheone 0:ecaf3e593122 1743 switch (c) {
Tuxitheone 0:ecaf3e593122 1744 case '\n':
Tuxitheone 0:ecaf3e593122 1745 printer(arg, "\\n");
Tuxitheone 0:ecaf3e593122 1746 break;
Tuxitheone 0:ecaf3e593122 1747 case '\r':
Tuxitheone 0:ecaf3e593122 1748 printer(arg, "\\r");
Tuxitheone 0:ecaf3e593122 1749 break;
Tuxitheone 0:ecaf3e593122 1750 case '\t':
Tuxitheone 0:ecaf3e593122 1751 printer(arg, "\\t");
Tuxitheone 0:ecaf3e593122 1752 break;
Tuxitheone 0:ecaf3e593122 1753 default:
Tuxitheone 0:ecaf3e593122 1754 printer(arg, "\\%.3o", c);
Tuxitheone 0:ecaf3e593122 1755 }
Tuxitheone 0:ecaf3e593122 1756 }
Tuxitheone 0:ecaf3e593122 1757 }
Tuxitheone 0:ecaf3e593122 1758 printer(arg, "\"");
Tuxitheone 0:ecaf3e593122 1759 }
Tuxitheone 0:ecaf3e593122 1760
Tuxitheone 0:ecaf3e593122 1761
Tuxitheone 0:ecaf3e593122 1762 /*
Tuxitheone 0:ecaf3e593122 1763 * lcp_printpkt - print the contents of an LCP packet.
Tuxitheone 0:ecaf3e593122 1764 */
Tuxitheone 0:ecaf3e593122 1765 static char *lcp_codenames[] = {
Tuxitheone 0:ecaf3e593122 1766 "ConfReq", "ConfAck", "ConfNak", "ConfRej",
Tuxitheone 0:ecaf3e593122 1767 "TermReq", "TermAck", "CodeRej", "ProtRej",
Tuxitheone 0:ecaf3e593122 1768 "EchoReq", "EchoRep", "DiscReq"
Tuxitheone 0:ecaf3e593122 1769 };
Tuxitheone 0:ecaf3e593122 1770
Tuxitheone 0:ecaf3e593122 1771 static int
Tuxitheone 0:ecaf3e593122 1772 lcp_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg)
Tuxitheone 0:ecaf3e593122 1773 {
Tuxitheone 0:ecaf3e593122 1774 int code, id, len, olen;
Tuxitheone 0:ecaf3e593122 1775 u_char *pstart, *optend;
Tuxitheone 0:ecaf3e593122 1776 u_short cishort;
Tuxitheone 0:ecaf3e593122 1777 u32_t cilong;
Tuxitheone 0:ecaf3e593122 1778
Tuxitheone 0:ecaf3e593122 1779 if (plen < HEADERLEN) {
Tuxitheone 0:ecaf3e593122 1780 return 0;
Tuxitheone 0:ecaf3e593122 1781 }
Tuxitheone 0:ecaf3e593122 1782 pstart = p;
Tuxitheone 0:ecaf3e593122 1783 GETCHAR(code, p);
Tuxitheone 0:ecaf3e593122 1784 GETCHAR(id, p);
Tuxitheone 0:ecaf3e593122 1785 GETSHORT(len, p);
Tuxitheone 0:ecaf3e593122 1786 if (len < HEADERLEN || len > plen) {
Tuxitheone 0:ecaf3e593122 1787 return 0;
Tuxitheone 0:ecaf3e593122 1788 }
Tuxitheone 0:ecaf3e593122 1789
Tuxitheone 0:ecaf3e593122 1790 if (code >= 1 && code <= sizeof(lcp_codenames) / sizeof(char *)) {
Tuxitheone 0:ecaf3e593122 1791 printer(arg, " %s", lcp_codenames[code-1]);
Tuxitheone 0:ecaf3e593122 1792 } else {
Tuxitheone 0:ecaf3e593122 1793 printer(arg, " code=0x%x", code);
Tuxitheone 0:ecaf3e593122 1794 }
Tuxitheone 0:ecaf3e593122 1795 printer(arg, " id=0x%x", id);
Tuxitheone 0:ecaf3e593122 1796 len -= HEADERLEN;
Tuxitheone 0:ecaf3e593122 1797 switch (code) {
Tuxitheone 0:ecaf3e593122 1798 case CONFREQ:
Tuxitheone 0:ecaf3e593122 1799 case CONFACK:
Tuxitheone 0:ecaf3e593122 1800 case CONFNAK:
Tuxitheone 0:ecaf3e593122 1801 case CONFREJ:
Tuxitheone 0:ecaf3e593122 1802 /* print option list */
Tuxitheone 0:ecaf3e593122 1803 while (len >= 2) {
Tuxitheone 0:ecaf3e593122 1804 GETCHAR(code, p);
Tuxitheone 0:ecaf3e593122 1805 GETCHAR(olen, p);
Tuxitheone 0:ecaf3e593122 1806 p -= 2;
Tuxitheone 0:ecaf3e593122 1807 if (olen < 2 || olen > len) {
Tuxitheone 0:ecaf3e593122 1808 break;
Tuxitheone 0:ecaf3e593122 1809 }
Tuxitheone 0:ecaf3e593122 1810 printer(arg, " <");
Tuxitheone 0:ecaf3e593122 1811 len -= olen;
Tuxitheone 0:ecaf3e593122 1812 optend = p + olen;
Tuxitheone 0:ecaf3e593122 1813 switch (code) {
Tuxitheone 0:ecaf3e593122 1814 case CI_MRU:
Tuxitheone 0:ecaf3e593122 1815 if (olen == CILEN_SHORT) {
Tuxitheone 0:ecaf3e593122 1816 p += 2;
Tuxitheone 0:ecaf3e593122 1817 GETSHORT(cishort, p);
Tuxitheone 0:ecaf3e593122 1818 printer(arg, "mru %d", cishort);
Tuxitheone 0:ecaf3e593122 1819 }
Tuxitheone 0:ecaf3e593122 1820 break;
Tuxitheone 0:ecaf3e593122 1821 case CI_ASYNCMAP:
Tuxitheone 0:ecaf3e593122 1822 if (olen == CILEN_LONG) {
Tuxitheone 0:ecaf3e593122 1823 p += 2;
Tuxitheone 0:ecaf3e593122 1824 GETLONG(cilong, p);
Tuxitheone 0:ecaf3e593122 1825 printer(arg, "asyncmap 0x%lx", cilong);
Tuxitheone 0:ecaf3e593122 1826 }
Tuxitheone 0:ecaf3e593122 1827 break;
Tuxitheone 0:ecaf3e593122 1828 case CI_AUTHTYPE:
Tuxitheone 0:ecaf3e593122 1829 if (olen >= CILEN_SHORT) {
Tuxitheone 0:ecaf3e593122 1830 p += 2;
Tuxitheone 0:ecaf3e593122 1831 printer(arg, "auth ");
Tuxitheone 0:ecaf3e593122 1832 GETSHORT(cishort, p);
Tuxitheone 0:ecaf3e593122 1833 switch (cishort) {
Tuxitheone 0:ecaf3e593122 1834 case PPP_PAP:
Tuxitheone 0:ecaf3e593122 1835 printer(arg, "pap");
Tuxitheone 0:ecaf3e593122 1836 break;
Tuxitheone 0:ecaf3e593122 1837 case PPP_CHAP:
Tuxitheone 0:ecaf3e593122 1838 printer(arg, "chap");
Tuxitheone 0:ecaf3e593122 1839 break;
Tuxitheone 0:ecaf3e593122 1840 default:
Tuxitheone 0:ecaf3e593122 1841 printer(arg, "0x%x", cishort);
Tuxitheone 0:ecaf3e593122 1842 }
Tuxitheone 0:ecaf3e593122 1843 }
Tuxitheone 0:ecaf3e593122 1844 break;
Tuxitheone 0:ecaf3e593122 1845 case CI_QUALITY:
Tuxitheone 0:ecaf3e593122 1846 if (olen >= CILEN_SHORT) {
Tuxitheone 0:ecaf3e593122 1847 p += 2;
Tuxitheone 0:ecaf3e593122 1848 printer(arg, "quality ");
Tuxitheone 0:ecaf3e593122 1849 GETSHORT(cishort, p);
Tuxitheone 0:ecaf3e593122 1850 switch (cishort) {
Tuxitheone 0:ecaf3e593122 1851 case PPP_LQR:
Tuxitheone 0:ecaf3e593122 1852 printer(arg, "lqr");
Tuxitheone 0:ecaf3e593122 1853 break;
Tuxitheone 0:ecaf3e593122 1854 default:
Tuxitheone 0:ecaf3e593122 1855 printer(arg, "0x%x", cishort);
Tuxitheone 0:ecaf3e593122 1856 }
Tuxitheone 0:ecaf3e593122 1857 }
Tuxitheone 0:ecaf3e593122 1858 break;
Tuxitheone 0:ecaf3e593122 1859 case CI_CALLBACK:
Tuxitheone 0:ecaf3e593122 1860 if (olen >= CILEN_CHAR) {
Tuxitheone 0:ecaf3e593122 1861 p += 2;
Tuxitheone 0:ecaf3e593122 1862 printer(arg, "callback ");
Tuxitheone 0:ecaf3e593122 1863 GETSHORT(cishort, p);
Tuxitheone 0:ecaf3e593122 1864 switch (cishort) {
Tuxitheone 0:ecaf3e593122 1865 case CBCP_OPT:
Tuxitheone 0:ecaf3e593122 1866 printer(arg, "CBCP");
Tuxitheone 0:ecaf3e593122 1867 break;
Tuxitheone 0:ecaf3e593122 1868 default:
Tuxitheone 0:ecaf3e593122 1869 printer(arg, "0x%x", cishort);
Tuxitheone 0:ecaf3e593122 1870 }
Tuxitheone 0:ecaf3e593122 1871 }
Tuxitheone 0:ecaf3e593122 1872 break;
Tuxitheone 0:ecaf3e593122 1873 case CI_MAGICNUMBER:
Tuxitheone 0:ecaf3e593122 1874 if (olen == CILEN_LONG) {
Tuxitheone 0:ecaf3e593122 1875 p += 2;
Tuxitheone 0:ecaf3e593122 1876 GETLONG(cilong, p);
Tuxitheone 0:ecaf3e593122 1877 printer(arg, "magic 0x%x", cilong);
Tuxitheone 0:ecaf3e593122 1878 }
Tuxitheone 0:ecaf3e593122 1879 break;
Tuxitheone 0:ecaf3e593122 1880 case CI_PCOMPRESSION:
Tuxitheone 0:ecaf3e593122 1881 if (olen == CILEN_VOID) {
Tuxitheone 0:ecaf3e593122 1882 p += 2;
Tuxitheone 0:ecaf3e593122 1883 printer(arg, "pcomp");
Tuxitheone 0:ecaf3e593122 1884 }
Tuxitheone 0:ecaf3e593122 1885 break;
Tuxitheone 0:ecaf3e593122 1886 case CI_ACCOMPRESSION:
Tuxitheone 0:ecaf3e593122 1887 if (olen == CILEN_VOID) {
Tuxitheone 0:ecaf3e593122 1888 p += 2;
Tuxitheone 0:ecaf3e593122 1889 printer(arg, "accomp");
Tuxitheone 0:ecaf3e593122 1890 }
Tuxitheone 0:ecaf3e593122 1891 break;
Tuxitheone 0:ecaf3e593122 1892 }
Tuxitheone 0:ecaf3e593122 1893 while (p < optend) {
Tuxitheone 0:ecaf3e593122 1894 GETCHAR(code, p);
Tuxitheone 0:ecaf3e593122 1895 printer(arg, " %.2x", code);
Tuxitheone 0:ecaf3e593122 1896 }
Tuxitheone 0:ecaf3e593122 1897 printer(arg, ">");
Tuxitheone 0:ecaf3e593122 1898 }
Tuxitheone 0:ecaf3e593122 1899 break;
Tuxitheone 0:ecaf3e593122 1900
Tuxitheone 0:ecaf3e593122 1901 case TERMACK:
Tuxitheone 0:ecaf3e593122 1902 case TERMREQ:
Tuxitheone 0:ecaf3e593122 1903 if (len > 0 && *p >= ' ' && *p < 0x7f) {
Tuxitheone 0:ecaf3e593122 1904 printer(arg, " ");
Tuxitheone 0:ecaf3e593122 1905 print_string((char*)p, len, printer, arg);
Tuxitheone 0:ecaf3e593122 1906 p += len;
Tuxitheone 0:ecaf3e593122 1907 len = 0;
Tuxitheone 0:ecaf3e593122 1908 }
Tuxitheone 0:ecaf3e593122 1909 break;
Tuxitheone 0:ecaf3e593122 1910
Tuxitheone 0:ecaf3e593122 1911 case ECHOREQ:
Tuxitheone 0:ecaf3e593122 1912 case ECHOREP:
Tuxitheone 0:ecaf3e593122 1913 case DISCREQ:
Tuxitheone 0:ecaf3e593122 1914 if (len >= 4) {
Tuxitheone 0:ecaf3e593122 1915 GETLONG(cilong, p);
Tuxitheone 0:ecaf3e593122 1916 printer(arg, " magic=0x%x", cilong);
Tuxitheone 0:ecaf3e593122 1917 p += 4;
Tuxitheone 0:ecaf3e593122 1918 len -= 4;
Tuxitheone 0:ecaf3e593122 1919 }
Tuxitheone 0:ecaf3e593122 1920 break;
Tuxitheone 0:ecaf3e593122 1921 }
Tuxitheone 0:ecaf3e593122 1922
Tuxitheone 0:ecaf3e593122 1923 /* print the rest of the bytes in the packet */
Tuxitheone 0:ecaf3e593122 1924 for (; len > 0; --len) {
Tuxitheone 0:ecaf3e593122 1925 GETCHAR(code, p);
Tuxitheone 0:ecaf3e593122 1926 printer(arg, " %.2x", code);
Tuxitheone 0:ecaf3e593122 1927 }
Tuxitheone 0:ecaf3e593122 1928
Tuxitheone 0:ecaf3e593122 1929 return (int)(p - pstart);
Tuxitheone 0:ecaf3e593122 1930 }
Tuxitheone 0:ecaf3e593122 1931 #endif /* PPP_ADDITIONAL_CALLBACKS */
Tuxitheone 0:ecaf3e593122 1932
Tuxitheone 0:ecaf3e593122 1933 /*
Tuxitheone 0:ecaf3e593122 1934 * Time to shut down the link because there is nothing out there.
Tuxitheone 0:ecaf3e593122 1935 */
Tuxitheone 0:ecaf3e593122 1936 static void
Tuxitheone 0:ecaf3e593122 1937 LcpLinkFailure (fsm *f)
Tuxitheone 0:ecaf3e593122 1938 {
Tuxitheone 0:ecaf3e593122 1939 if (f->state == LS_OPENED) {
Tuxitheone 0:ecaf3e593122 1940 LCPDEBUG(LOG_INFO, ("No response to %d echo-requests\n", lcp_echos_pending));
Tuxitheone 0:ecaf3e593122 1941 LCPDEBUG(LOG_NOTICE, ("Serial link appears to be disconnected.\n"));
Tuxitheone 0:ecaf3e593122 1942 lcp_close(f->unit, "Peer not responding");
Tuxitheone 0:ecaf3e593122 1943 }
Tuxitheone 0:ecaf3e593122 1944 }
Tuxitheone 0:ecaf3e593122 1945
Tuxitheone 0:ecaf3e593122 1946 /*
Tuxitheone 0:ecaf3e593122 1947 * Timer expired for the LCP echo requests from this process.
Tuxitheone 0:ecaf3e593122 1948 */
Tuxitheone 0:ecaf3e593122 1949 static void
Tuxitheone 0:ecaf3e593122 1950 LcpEchoCheck (fsm *f)
Tuxitheone 0:ecaf3e593122 1951 {
Tuxitheone 0:ecaf3e593122 1952 LcpSendEchoRequest (f);
Tuxitheone 0:ecaf3e593122 1953
Tuxitheone 0:ecaf3e593122 1954 /*
Tuxitheone 0:ecaf3e593122 1955 * Start the timer for the next interval.
Tuxitheone 0:ecaf3e593122 1956 */
Tuxitheone 0:ecaf3e593122 1957 LWIP_ASSERT("lcp_echo_timer_running == 0", lcp_echo_timer_running == 0);
Tuxitheone 0:ecaf3e593122 1958
Tuxitheone 0:ecaf3e593122 1959 TIMEOUT (LcpEchoTimeout, f, lcp_echo_interval);
Tuxitheone 0:ecaf3e593122 1960 lcp_echo_timer_running = 1;
Tuxitheone 0:ecaf3e593122 1961 }
Tuxitheone 0:ecaf3e593122 1962
Tuxitheone 0:ecaf3e593122 1963 /*
Tuxitheone 0:ecaf3e593122 1964 * LcpEchoTimeout - Timer expired on the LCP echo
Tuxitheone 0:ecaf3e593122 1965 */
Tuxitheone 0:ecaf3e593122 1966 static void
Tuxitheone 0:ecaf3e593122 1967 LcpEchoTimeout (void *arg)
Tuxitheone 0:ecaf3e593122 1968 {
Tuxitheone 0:ecaf3e593122 1969 if (lcp_echo_timer_running != 0) {
Tuxitheone 0:ecaf3e593122 1970 lcp_echo_timer_running = 0;
Tuxitheone 0:ecaf3e593122 1971 LcpEchoCheck ((fsm *) arg);
Tuxitheone 0:ecaf3e593122 1972 }
Tuxitheone 0:ecaf3e593122 1973 }
Tuxitheone 0:ecaf3e593122 1974
Tuxitheone 0:ecaf3e593122 1975 /*
Tuxitheone 0:ecaf3e593122 1976 * LcpEchoReply - LCP has received a reply to the echo
Tuxitheone 0:ecaf3e593122 1977 */
Tuxitheone 0:ecaf3e593122 1978 static void
Tuxitheone 0:ecaf3e593122 1979 lcp_received_echo_reply (fsm *f, int id, u_char *inp, int len)
Tuxitheone 0:ecaf3e593122 1980 {
Tuxitheone 0:ecaf3e593122 1981 u32_t magic;
Tuxitheone 0:ecaf3e593122 1982
Tuxitheone 0:ecaf3e593122 1983 LWIP_UNUSED_ARG(id);
Tuxitheone 0:ecaf3e593122 1984
Tuxitheone 0:ecaf3e593122 1985 /* Check the magic number - don't count replies from ourselves. */
Tuxitheone 0:ecaf3e593122 1986 if (len < 4) {
Tuxitheone 0:ecaf3e593122 1987 LCPDEBUG(LOG_WARNING, ("lcp: received short Echo-Reply, length %d\n", len));
Tuxitheone 0:ecaf3e593122 1988 return;
Tuxitheone 0:ecaf3e593122 1989 }
Tuxitheone 0:ecaf3e593122 1990 GETLONG(magic, inp);
Tuxitheone 0:ecaf3e593122 1991 if (lcp_gotoptions[f->unit].neg_magicnumber && magic == lcp_gotoptions[f->unit].magicnumber) {
Tuxitheone 0:ecaf3e593122 1992 LCPDEBUG(LOG_WARNING, ("appear to have received our own echo-reply!\n"));
Tuxitheone 0:ecaf3e593122 1993 return;
Tuxitheone 0:ecaf3e593122 1994 }
Tuxitheone 0:ecaf3e593122 1995
Tuxitheone 0:ecaf3e593122 1996 /* Reset the number of outstanding echo frames */
Tuxitheone 0:ecaf3e593122 1997 lcp_echos_pending = 0;
Tuxitheone 0:ecaf3e593122 1998 }
Tuxitheone 0:ecaf3e593122 1999
Tuxitheone 0:ecaf3e593122 2000 /*
Tuxitheone 0:ecaf3e593122 2001 * LcpSendEchoRequest - Send an echo request frame to the peer
Tuxitheone 0:ecaf3e593122 2002 */
Tuxitheone 0:ecaf3e593122 2003 static void
Tuxitheone 0:ecaf3e593122 2004 LcpSendEchoRequest (fsm *f)
Tuxitheone 0:ecaf3e593122 2005 {
Tuxitheone 0:ecaf3e593122 2006 u32_t lcp_magic;
Tuxitheone 0:ecaf3e593122 2007 u_char pkt[4], *pktp;
Tuxitheone 0:ecaf3e593122 2008
Tuxitheone 0:ecaf3e593122 2009 /*
Tuxitheone 0:ecaf3e593122 2010 * Detect the failure of the peer at this point.
Tuxitheone 0:ecaf3e593122 2011 */
Tuxitheone 0:ecaf3e593122 2012 if (lcp_echo_fails != 0) {
Tuxitheone 0:ecaf3e593122 2013 if (lcp_echos_pending >= lcp_echo_fails) {
Tuxitheone 0:ecaf3e593122 2014 LcpLinkFailure(f);
Tuxitheone 0:ecaf3e593122 2015 lcp_echos_pending = 0;
Tuxitheone 0:ecaf3e593122 2016 }
Tuxitheone 0:ecaf3e593122 2017 }
Tuxitheone 0:ecaf3e593122 2018
Tuxitheone 0:ecaf3e593122 2019 /*
Tuxitheone 0:ecaf3e593122 2020 * Make and send the echo request frame.
Tuxitheone 0:ecaf3e593122 2021 */
Tuxitheone 0:ecaf3e593122 2022 if (f->state == LS_OPENED) {
Tuxitheone 0:ecaf3e593122 2023 lcp_magic = lcp_gotoptions[f->unit].magicnumber;
Tuxitheone 0:ecaf3e593122 2024 pktp = pkt;
Tuxitheone 0:ecaf3e593122 2025 PUTLONG(lcp_magic, pktp);
Tuxitheone 0:ecaf3e593122 2026 fsm_sdata(f, ECHOREQ, (u_char)(lcp_echo_number++ & 0xFF), pkt, (int)(pktp - pkt));
Tuxitheone 0:ecaf3e593122 2027 ++lcp_echos_pending;
Tuxitheone 0:ecaf3e593122 2028 }
Tuxitheone 0:ecaf3e593122 2029 }
Tuxitheone 0:ecaf3e593122 2030
Tuxitheone 0:ecaf3e593122 2031 /*
Tuxitheone 0:ecaf3e593122 2032 * lcp_echo_lowerup - Start the timer for the LCP frame
Tuxitheone 0:ecaf3e593122 2033 */
Tuxitheone 0:ecaf3e593122 2034
Tuxitheone 0:ecaf3e593122 2035 static void
Tuxitheone 0:ecaf3e593122 2036 lcp_echo_lowerup (int unit)
Tuxitheone 0:ecaf3e593122 2037 {
Tuxitheone 0:ecaf3e593122 2038 fsm *f = &lcp_fsm[unit];
Tuxitheone 0:ecaf3e593122 2039
Tuxitheone 0:ecaf3e593122 2040 /* Clear the parameters for generating echo frames */
Tuxitheone 0:ecaf3e593122 2041 lcp_echos_pending = 0;
Tuxitheone 0:ecaf3e593122 2042 lcp_echo_number = 0;
Tuxitheone 0:ecaf3e593122 2043 lcp_echo_timer_running = 0;
Tuxitheone 0:ecaf3e593122 2044
Tuxitheone 0:ecaf3e593122 2045 /* If a timeout interval is specified then start the timer */
Tuxitheone 0:ecaf3e593122 2046 if (lcp_echo_interval != 0) {
Tuxitheone 0:ecaf3e593122 2047 LcpEchoCheck (f);
Tuxitheone 0:ecaf3e593122 2048 }
Tuxitheone 0:ecaf3e593122 2049 }
Tuxitheone 0:ecaf3e593122 2050
Tuxitheone 0:ecaf3e593122 2051 /*
Tuxitheone 0:ecaf3e593122 2052 * lcp_echo_lowerdown - Stop the timer for the LCP frame
Tuxitheone 0:ecaf3e593122 2053 */
Tuxitheone 0:ecaf3e593122 2054
Tuxitheone 0:ecaf3e593122 2055 static void
Tuxitheone 0:ecaf3e593122 2056 lcp_echo_lowerdown (int unit)
Tuxitheone 0:ecaf3e593122 2057 {
Tuxitheone 0:ecaf3e593122 2058 fsm *f = &lcp_fsm[unit];
Tuxitheone 0:ecaf3e593122 2059
Tuxitheone 0:ecaf3e593122 2060 if (lcp_echo_timer_running != 0) {
Tuxitheone 0:ecaf3e593122 2061 UNTIMEOUT (LcpEchoTimeout, f);
Tuxitheone 0:ecaf3e593122 2062 lcp_echo_timer_running = 0;
Tuxitheone 0:ecaf3e593122 2063 }
Tuxitheone 0:ecaf3e593122 2064 }
Tuxitheone 0:ecaf3e593122 2065
Tuxitheone 0:ecaf3e593122 2066 #endif /* PPP_SUPPORT */