]> git.ozlabs.org Git - ppp.git/blob - pppd/chap-new.c
Use autoconf/automake to configure and make ppp
[ppp.git] / pppd / chap-new.c
1 /*
2  * chap-new.c - New CHAP implementation.
3  *
4  * Copyright (c) 2003 Paul Mackerras. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. The name(s) of the authors of this software must not be used to
14  *    endorse or promote products derived from this software without
15  *    prior written permission.
16  *
17  * 3. Redistributions of any form whatsoever must retain the following
18  *    acknowledgment:
19  *    "This product includes software developed by Paul Mackerras
20  *     <paulus@samba.org>".
21  *
22  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
23  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
27  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
28  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29  */
30
31 #define RCSID   "$Id: chap-new.c,v 1.9 2007/06/19 02:08:35 carlsonj Exp $"
32
33 #ifdef HAVE_CONFIG_H
34 #include "config.h"
35 #endif
36
37 #include <stdlib.h>
38 #include <string.h>
39 #include "pppd.h"
40 #include "session.h"
41 #include "chap-new.h"
42 #include "chap-md5.h"
43
44 #ifdef CHAPMS
45 #include "chap_ms.h"
46 #define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
47 #else
48 #define MDTYPE_ALL (MDTYPE_MD5)
49 #endif
50
51 int chap_mdtype_all = MDTYPE_ALL;
52
53 /* Hook for a plugin to validate CHAP challenge */
54 int (*chap_verify_hook)(char *name, char *ourname, int id,
55                         struct chap_digest_type *digest,
56                         unsigned char *challenge, unsigned char *response,
57                         char *message, int message_space) = NULL;
58
59 /*
60  * Option variables.
61  */
62 int chap_server_timeout_time = 3;
63 int chap_max_transmits = 10;
64 int chap_rechallenge_time = 0;
65 int chap_client_timeout_time = 60;
66 int chapms_strip_domain = 0;
67
68 /*
69  * Command-line options.
70  */
71 static option_t chap_option_list[] = {
72         { "chap-restart", o_int, &chap_server_timeout_time,
73           "Set timeout for CHAP (as server)", OPT_PRIO },
74         { "chap-max-challenge", o_int, &chap_max_transmits,
75           "Set max #xmits for challenge", OPT_PRIO },
76         { "chap-interval", o_int, &chap_rechallenge_time,
77           "Set interval for rechallenge", OPT_PRIO },
78         { "chap-timeout", o_int, &chap_client_timeout_time,
79           "Set timeout for CHAP (as client)", OPT_PRIO },
80         { "chapms-strip-domain", o_bool, &chapms_strip_domain,
81           "Strip the domain prefix before the Username", 1 },
82         { NULL }
83 };
84
85 /*
86  * Internal state.
87  */
88 static struct chap_client_state {
89         int flags;
90         char *name;
91         struct chap_digest_type *digest;
92         unsigned char priv[64];         /* private area for digest's use */
93 } client;
94
95 /*
96  * These limits apply to challenge and response packets we send.
97  * The +4 is the +1 that we actually need rounded up.
98  */
99 #define CHAL_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_CHALLENGE_LEN + MAXNAMELEN)
100 #define RESP_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_RESPONSE_LEN + MAXNAMELEN)
101
102 static struct chap_server_state {
103         int flags;
104         int id;
105         char *name;
106         struct chap_digest_type *digest;
107         int challenge_xmits;
108         int challenge_pktlen;
109         unsigned char challenge[CHAL_MAX_PKTLEN];
110         char message[256];
111 } server;
112
113 /* Values for flags in chap_client_state and chap_server_state */
114 #define LOWERUP                 1
115 #define AUTH_STARTED            2
116 #define AUTH_DONE               4
117 #define AUTH_FAILED             8
118 #define TIMEOUT_PENDING         0x10
119 #define CHALLENGE_VALID         0x20
120
121 /*
122  * Prototypes.
123  */
124 static void chap_init(int unit);
125 static void chap_lowerup(int unit);
126 static void chap_lowerdown(int unit);
127 static void chap_server_timeout(void *arg);
128 static void chap_client_timeout(void *arg);
129 static void chap_generate_challenge(struct chap_server_state *ss);
130 static void chap_handle_response(struct chap_server_state *ss, int code,
131                 unsigned char *pkt, int len);
132 static int chap_verify_response(char *name, char *ourname, int id,
133                 struct chap_digest_type *digest,
134                 unsigned char *challenge, unsigned char *response,
135                 char *message, int message_space);
136 static void chap_respond(struct chap_client_state *cs, int id,
137                 unsigned char *pkt, int len);
138 static void chap_handle_status(struct chap_client_state *cs, int code, int id,
139                 unsigned char *pkt, int len);
140 static void chap_protrej(int unit);
141 static void chap_input(int unit, unsigned char *pkt, int pktlen);
142 static int chap_print_pkt(unsigned char *p, int plen,
143                 void (*printer)(void *, char *, ...), void *arg);
144
145 /* List of digest types that we know about */
146 static struct chap_digest_type *chap_digests;
147
148 /*
149  * chap_init - reset to initial state.
150  */
151 static void
152 chap_init(int unit)
153 {
154         memset(&client, 0, sizeof(client));
155         memset(&server, 0, sizeof(server));
156
157         chap_md5_init();
158 #ifdef CHAPMS
159         chapms_init();
160 #endif
161 }
162
163 /*
164  * Add a new digest type to the list.
165  */
166 void
167 chap_register_digest(struct chap_digest_type *dp)
168 {
169         dp->next = chap_digests;
170         chap_digests = dp;
171 }
172
173 /*
174  * Lookup a digest type by code
175  */
176 struct chap_digest_type *
177 chap_find_digest(int digest_code) {
178         struct chap_digest_type *dp = NULL;
179         for (dp = chap_digests; dp != NULL; dp = dp->next)
180                 if (dp->code == digest_code)
181                         break;
182         return dp;
183 }
184
185 /*
186  * chap_lowerup - we can start doing stuff now.
187  */
188 static void
189 chap_lowerup(int unit)
190 {
191         struct chap_client_state *cs = &client;
192         struct chap_server_state *ss = &server;
193
194         cs->flags |= LOWERUP;
195         ss->flags |= LOWERUP;
196         if (ss->flags & AUTH_STARTED)
197                 chap_server_timeout(ss);
198 }
199
200 static void
201 chap_lowerdown(int unit)
202 {
203         struct chap_client_state *cs = &client;
204         struct chap_server_state *ss = &server;
205
206         if (cs->flags & TIMEOUT_PENDING)
207                 UNTIMEOUT(chap_client_timeout, cs);
208         cs->flags = 0;
209         if (ss->flags & TIMEOUT_PENDING)
210                 UNTIMEOUT(chap_server_timeout, ss);
211         ss->flags = 0;
212 }
213
214 /*
215  * chap_auth_peer - Start authenticating the peer.
216  * If the lower layer is already up, we start sending challenges,
217  * otherwise we wait for the lower layer to come up.
218  */
219 void
220 chap_auth_peer(int unit, char *our_name, int digest_code)
221 {
222         struct chap_server_state *ss = &server;
223         struct chap_digest_type *dp;
224
225         if (ss->flags & AUTH_STARTED) {
226                 error("CHAP: peer authentication already started!");
227                 return;
228         }
229
230         dp = chap_find_digest(digest_code);
231         if (dp == NULL)
232                 fatal("CHAP digest 0x%x requested but not available",
233                       digest_code);
234
235         ss->digest = dp;
236         ss->name = our_name;
237         /* Start with a random ID value */
238         ss->id = (unsigned char)(drand48() * 256);
239         ss->flags |= AUTH_STARTED;
240         if (ss->flags & LOWERUP)
241                 chap_server_timeout(ss);
242 }
243
244 /*
245  * chap_auth_with_peer - Prepare to authenticate ourselves to the peer.
246  * There isn't much to do until we receive a challenge.
247  */
248 void
249 chap_auth_with_peer(int unit, char *our_name, int digest_code)
250 {
251         struct chap_client_state *cs = &client;
252         struct chap_digest_type *dp;
253
254         if (cs->flags & AUTH_STARTED) {
255                 error("CHAP: authentication with peer already started!");
256                 return;
257         }
258         for (dp = chap_digests; dp != NULL; dp = dp->next)
259                 if (dp->code == digest_code)
260                         break;
261         if (dp == NULL)
262                 fatal("CHAP digest 0x%x requested but not available",
263                       digest_code);
264
265         cs->digest = dp;
266         cs->name = our_name;
267         cs->flags |= AUTH_STARTED | TIMEOUT_PENDING;
268         TIMEOUT(chap_client_timeout, cs, chap_client_timeout_time);
269 }
270
271 /*
272  * chap_server_timeout - It's time to send another challenge to the peer.
273  * This could be either a retransmission of a previous challenge,
274  * or a new challenge to start re-authentication.
275  */
276 static void
277 chap_server_timeout(void *arg)
278 {
279         struct chap_server_state *ss = arg;
280
281         ss->flags &= ~TIMEOUT_PENDING;
282         if ((ss->flags & CHALLENGE_VALID) == 0) {
283                 ss->challenge_xmits = 0;
284                 chap_generate_challenge(ss);
285                 ss->flags |= CHALLENGE_VALID;
286         } else if (ss->challenge_xmits >= chap_max_transmits) {
287                 ss->flags &= ~CHALLENGE_VALID;
288                 ss->flags |= AUTH_DONE | AUTH_FAILED;
289                 auth_peer_fail(0, PPP_CHAP);
290                 return;
291         }
292
293         output(0, ss->challenge, ss->challenge_pktlen);
294         ++ss->challenge_xmits;
295         ss->flags |= TIMEOUT_PENDING;
296         TIMEOUT(chap_server_timeout, arg, chap_server_timeout_time);
297 }
298
299 /* chap_client_timeout - Authentication with peer timed out. */
300 static void
301 chap_client_timeout(void *arg)
302 {
303         struct chap_client_state *cs = arg;
304
305         cs->flags &= ~TIMEOUT_PENDING;
306         cs->flags |= AUTH_DONE | AUTH_FAILED;
307         error("CHAP authentication timed out");
308         auth_withpeer_fail(0, PPP_CHAP);
309 }
310
311 /*
312  * chap_generate_challenge - generate a challenge string and format
313  * the challenge packet in ss->challenge_pkt.
314  */
315 static void
316 chap_generate_challenge(struct chap_server_state *ss)
317 {
318         int clen = 1, nlen, len;
319         unsigned char *p;
320
321         p = ss->challenge;
322         MAKEHEADER(p, PPP_CHAP);
323         p += CHAP_HDRLEN;
324         ss->digest->generate_challenge(p);
325         clen = *p;
326         nlen = strlen(ss->name);
327         memcpy(p + 1 + clen, ss->name, nlen);
328
329         len = CHAP_HDRLEN + 1 + clen + nlen;
330         ss->challenge_pktlen = PPP_HDRLEN + len;
331
332         p = ss->challenge + PPP_HDRLEN;
333         p[0] = CHAP_CHALLENGE;
334         p[1] = ++ss->id;
335         p[2] = len >> 8;
336         p[3] = len;
337 }
338
339 /*
340  * chap_handle_response - check the response to our challenge.
341  */
342 static void
343 chap_handle_response(struct chap_server_state *ss, int id,
344                      unsigned char *pkt, int len)
345 {
346         int response_len, ok, mlen;
347         unsigned char *response, *p;
348         char *name = NULL;      /* initialized to shut gcc up */
349         int (*verifier)(char *, char *, int, struct chap_digest_type *,
350                 unsigned char *, unsigned char *, char *, int);
351         char rname[MAXNAMELEN+1];
352
353         if ((ss->flags & LOWERUP) == 0)
354                 return;
355         if (id != ss->challenge[PPP_HDRLEN+1] || len < 2)
356                 return;
357         if (ss->flags & CHALLENGE_VALID) {
358                 response = pkt;
359                 GETCHAR(response_len, pkt);
360                 len -= response_len + 1;        /* length of name */
361                 name = (char *)pkt + response_len;
362                 if (len < 0)
363                         return;
364
365                 if (ss->flags & TIMEOUT_PENDING) {
366                         ss->flags &= ~TIMEOUT_PENDING;
367                         UNTIMEOUT(chap_server_timeout, ss);
368                 }
369
370                 if (explicit_remote) {
371                         name = remote_name;
372                 } else {
373                         /* Null terminate and clean remote name. */
374                         slprintf(rname, sizeof(rname), "%.*v", len, name);
375                         name = rname;
376
377                         /* strip the MS domain name */
378                         if (chapms_strip_domain && strrchr(rname, '\\')) {
379                                 char tmp[MAXNAMELEN+1];
380
381                                 strcpy(tmp, strrchr(rname, '\\') + 1);
382                                 strcpy(rname, tmp);
383                         }
384                 }
385
386                 if (chap_verify_hook)
387                         verifier = chap_verify_hook;
388                 else
389                         verifier = chap_verify_response;
390                 ok = (*verifier)(name, ss->name, id, ss->digest,
391                                  ss->challenge + PPP_HDRLEN + CHAP_HDRLEN,
392                                  response, ss->message, sizeof(ss->message));
393                 if (!ok || !auth_number()) {
394                         ss->flags |= AUTH_FAILED;
395                         warn("Peer %q failed CHAP authentication", name);
396                 }
397         } else if ((ss->flags & AUTH_DONE) == 0)
398                 return;
399
400         /* send the response */
401         p = outpacket_buf;
402         MAKEHEADER(p, PPP_CHAP);
403         mlen = strlen(ss->message);
404         len = CHAP_HDRLEN + mlen;
405         p[0] = (ss->flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS;
406         p[1] = id;
407         p[2] = len >> 8;
408         p[3] = len;
409         if (mlen > 0)
410                 memcpy(p + CHAP_HDRLEN, ss->message, mlen);
411         output(0, outpacket_buf, PPP_HDRLEN + len);
412
413         if (ss->flags & CHALLENGE_VALID) {
414                 ss->flags &= ~CHALLENGE_VALID;
415                 if (!(ss->flags & AUTH_DONE) && !(ss->flags & AUTH_FAILED)) {
416                     /*
417                      * Auth is OK, so now we need to check session restrictions
418                      * to ensure everything is OK, but only if we used a
419                      * plugin, and only if we're configured to check.  This
420                      * allows us to do PAM checks on PPP servers that
421                      * authenticate against ActiveDirectory, and use AD for
422                      * account info (like when using Winbind integrated with
423                      * PAM).
424                      */
425                     if (session_mgmt &&
426                         session_check(name, NULL, devnam, NULL) == 0) {
427                         ss->flags |= AUTH_FAILED;
428                         warn("Peer %q failed CHAP Session verification", name);
429                     }
430                 }
431                 if (ss->flags & AUTH_FAILED) {
432                         auth_peer_fail(0, PPP_CHAP);
433                 } else {
434                         if ((ss->flags & AUTH_DONE) == 0)
435                                 auth_peer_success(0, PPP_CHAP,
436                                                   ss->digest->code,
437                                                   name, strlen(name));
438                         if (chap_rechallenge_time) {
439                                 ss->flags |= TIMEOUT_PENDING;
440                                 TIMEOUT(chap_server_timeout, ss,
441                                         chap_rechallenge_time);
442                         }
443                 }
444                 ss->flags |= AUTH_DONE;
445         }
446 }
447
448 /*
449  * chap_verify_response - check whether the peer's response matches
450  * what we think it should be.  Returns 1 if it does (authentication
451  * succeeded), or 0 if it doesn't.
452  */
453 static int
454 chap_verify_response(char *name, char *ourname, int id,
455                      struct chap_digest_type *digest,
456                      unsigned char *challenge, unsigned char *response,
457                      char *message, int message_space)
458 {
459         int ok;
460         unsigned char secret[MAXSECRETLEN];
461         int secret_len;
462
463         /* Get the secret that the peer is supposed to know */
464         if (!get_secret(0, name, ourname, (char *)secret, &secret_len, 1)) {
465                 error("No CHAP secret found for authenticating %q", name);
466                 return 0;
467         }
468
469         ok = digest->verify_response(id, name, secret, secret_len, challenge,
470                                      response, message, message_space);
471         memset(secret, 0, sizeof(secret));
472
473         return ok;
474 }
475
476 /*
477  * chap_respond - Generate and send a response to a challenge.
478  */
479 static void
480 chap_respond(struct chap_client_state *cs, int id,
481              unsigned char *pkt, int len)
482 {
483         int clen, nlen;
484         int secret_len;
485         unsigned char *p;
486         unsigned char response[RESP_MAX_PKTLEN];
487         char rname[MAXNAMELEN+1];
488         char secret[MAXSECRETLEN+1];
489
490         if ((cs->flags & (LOWERUP | AUTH_STARTED)) != (LOWERUP | AUTH_STARTED))
491                 return;         /* not ready */
492         if (len < 2 || len < pkt[0] + 1)
493                 return;         /* too short */
494         clen = pkt[0];
495         nlen = len - (clen + 1);
496
497         /* Null terminate and clean remote name. */
498         slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1);
499
500         /* Microsoft doesn't send their name back in the PPP packet */
501         if (explicit_remote || (remote_name[0] != 0 && rname[0] == 0))
502                 strlcpy(rname, remote_name, sizeof(rname));
503
504         /* get secret for authenticating ourselves with the specified host */
505         if (!get_secret(0, cs->name, rname, secret, &secret_len, 0)) {
506                 secret_len = 0; /* assume null secret if can't find one */
507                 warn("No CHAP secret found for authenticating us to %q", rname);
508         }
509
510         p = response;
511         MAKEHEADER(p, PPP_CHAP);
512         p += CHAP_HDRLEN;
513
514         cs->digest->make_response(p, id, cs->name, pkt,
515                                   secret, secret_len, cs->priv);
516         memset(secret, 0, secret_len);
517
518         clen = *p;
519         nlen = strlen(cs->name);
520         memcpy(p + clen + 1, cs->name, nlen);
521
522         p = response + PPP_HDRLEN;
523         len = CHAP_HDRLEN + clen + 1 + nlen;
524         p[0] = CHAP_RESPONSE;
525         p[1] = id;
526         p[2] = len >> 8;
527         p[3] = len;
528
529         output(0, response, PPP_HDRLEN + len);
530 }
531
532 static void
533 chap_handle_status(struct chap_client_state *cs, int code, int id,
534                    unsigned char *pkt, int len)
535 {
536         const char *msg = NULL;
537
538         if ((cs->flags & (AUTH_DONE|AUTH_STARTED|LOWERUP))
539             != (AUTH_STARTED|LOWERUP))
540                 return;
541         cs->flags |= AUTH_DONE;
542
543         UNTIMEOUT(chap_client_timeout, cs);
544         cs->flags &= ~TIMEOUT_PENDING;
545
546         if (code == CHAP_SUCCESS) {
547                 /* used for MS-CHAP v2 mutual auth, yuck */
548                 if (cs->digest->check_success != NULL) {
549                         if (!(*cs->digest->check_success)(id, pkt, len))
550                                 code = CHAP_FAILURE;
551                 } else
552                         msg = "CHAP authentication succeeded";
553         } else {
554                 if (cs->digest->handle_failure != NULL)
555                         (*cs->digest->handle_failure)(pkt, len);
556                 else
557                         msg = "CHAP authentication failed";
558         }
559         if (msg) {
560                 if (len > 0)
561                         info("%s: %.*v", msg, len, pkt);
562                 else
563                         info("%s", msg);
564         }
565         if (code == CHAP_SUCCESS)
566                 auth_withpeer_success(0, PPP_CHAP, cs->digest->code);
567         else {
568                 cs->flags |= AUTH_FAILED;
569                 error("CHAP authentication failed");
570                 auth_withpeer_fail(0, PPP_CHAP);
571         }
572 }
573
574 static void
575 chap_input(int unit, unsigned char *pkt, int pktlen)
576 {
577         struct chap_client_state *cs = &client;
578         struct chap_server_state *ss = &server;
579         unsigned char code, id;
580         int len;
581
582         if (pktlen < CHAP_HDRLEN)
583                 return;
584         GETCHAR(code, pkt);
585         GETCHAR(id, pkt);
586         GETSHORT(len, pkt);
587         if (len < CHAP_HDRLEN || len > pktlen)
588                 return;
589         len -= CHAP_HDRLEN;
590
591         switch (code) {
592         case CHAP_CHALLENGE:
593                 chap_respond(cs, id, pkt, len);
594                 break;
595         case CHAP_RESPONSE:
596                 chap_handle_response(ss, id, pkt, len);
597                 break;
598         case CHAP_FAILURE:
599         case CHAP_SUCCESS:
600                 chap_handle_status(cs, code, id, pkt, len);
601                 break;
602         }
603 }
604
605 static void
606 chap_protrej(int unit)
607 {
608         struct chap_client_state *cs = &client;
609         struct chap_server_state *ss = &server;
610
611         if (ss->flags & TIMEOUT_PENDING) {
612                 ss->flags &= ~TIMEOUT_PENDING;
613                 UNTIMEOUT(chap_server_timeout, ss);
614         }
615         if (ss->flags & AUTH_STARTED) {
616                 ss->flags = 0;
617                 auth_peer_fail(0, PPP_CHAP);
618         }
619         if ((cs->flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) {
620                 cs->flags &= ~AUTH_STARTED;
621                 error("CHAP authentication failed due to protocol-reject");
622                 auth_withpeer_fail(0, PPP_CHAP);
623         }
624 }
625
626 /*
627  * chap_print_pkt - print the contents of a CHAP packet.
628  */
629 static char *chap_code_names[] = {
630         "Challenge", "Response", "Success", "Failure"
631 };
632
633 static int
634 chap_print_pkt(unsigned char *p, int plen,
635                void (*printer)(void *, char *, ...), void *arg)
636 {
637         int code, id, len;
638         int clen, nlen;
639         unsigned char x;
640
641         if (plen < CHAP_HDRLEN)
642                 return 0;
643         GETCHAR(code, p);
644         GETCHAR(id, p);
645         GETSHORT(len, p);
646         if (len < CHAP_HDRLEN || len > plen)
647                 return 0;
648
649         if (code >= 1 && code <= sizeof(chap_code_names) / sizeof(char *))
650                 printer(arg, " %s", chap_code_names[code-1]);
651         else
652                 printer(arg, " code=0x%x", code);
653         printer(arg, " id=0x%x", id);
654         len -= CHAP_HDRLEN;
655         switch (code) {
656         case CHAP_CHALLENGE:
657         case CHAP_RESPONSE:
658                 if (len < 1)
659                         break;
660                 clen = p[0];
661                 if (len < clen + 1)
662                         break;
663                 ++p;
664                 nlen = len - clen - 1;
665                 printer(arg, " <");
666                 for (; clen > 0; --clen) {
667                         GETCHAR(x, p);
668                         printer(arg, "%.2x", x);
669                 }
670                 printer(arg, ">, name = ");
671                 print_string((char *)p, nlen, printer, arg);
672                 break;
673         case CHAP_FAILURE:
674         case CHAP_SUCCESS:
675                 printer(arg, " ");
676                 print_string((char *)p, len, printer, arg);
677                 break;
678         default:
679                 for (clen = len; clen > 0; --clen) {
680                         GETCHAR(x, p);
681                         printer(arg, " %.2x", x);
682                 }
683         }
684
685         return len + CHAP_HDRLEN;
686 }
687
688 struct protent chap_protent = {
689         PPP_CHAP,
690         chap_init,
691         chap_input,
692         chap_protrej,
693         chap_lowerup,
694         chap_lowerdown,
695         NULL,           /* open */
696         NULL,           /* close */
697         chap_print_pkt,
698         NULL,           /* datainput */
699         1,              /* enabled_flag */
700         "CHAP",         /* name */
701         NULL,           /* data_name */
702         chap_option_list,
703         NULL,           /* check_options */
704 };