2 * lcp.c - PPP Link Control Protocol.
4 * Copyright (c) 1989 Carnegie Mellon University.
7 * Redistribution and use in source and binary forms are permitted
8 * provided that the above copyright notice and this paragraph are
9 * duplicated in all such forms and that any documentation,
10 * advertising materials, and other materials related to such
11 * distribution and use acknowledge that the software was developed
12 * by Carnegie Mellon University. The name of the
13 * University may not be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 static char rcsid[] = "$Id: lcp.c,v 1.40 1999/05/13 00:33:26 paulus Exp $";
39 * LCP-related command-line options.
41 int lcp_echo_interval = 0; /* Interval between LCP echo-requests */
42 int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */
43 bool lax_recv = 0; /* accept control chars in asyncmap */
45 static int setescape __P((char **));
47 static option_t lcp_option_list[] = {
49 { "noaccomp", o_bool, &lcp_wantoptions[0].neg_accompression,
50 "Disable address/control compression",
51 OPT_A2COPY, &lcp_allowoptions[0].neg_accompression },
52 { "-ac", o_bool, &lcp_wantoptions[0].neg_accompression,
53 "Disable address/control compression",
54 OPT_A2COPY, &lcp_allowoptions[0].neg_accompression },
55 { "default-asyncmap", o_bool, &lcp_wantoptions[0].neg_asyncmap,
56 "Disable asyncmap negotiation",
57 OPT_A2COPY, &lcp_allowoptions[0].neg_asyncmap },
58 { "-am", o_bool, &lcp_wantoptions[0].neg_asyncmap,
59 "Disable asyncmap negotiation",
60 OPT_A2COPY, &lcp_allowoptions[0].neg_asyncmap },
61 { "asyncmap", o_uint32, &lcp_wantoptions[0].asyncmap,
62 "Set asyncmap (for received packets)",
63 OPT_OR, &lcp_wantoptions[0].neg_asyncmap },
64 { "-as", o_uint32, &lcp_wantoptions[0].asyncmap,
65 "Set asyncmap (for received packets)",
66 OPT_OR, &lcp_wantoptions[0].neg_asyncmap },
67 { "nomagicnumber", o_bool, &lcp_wantoptions[0].neg_magicnumber,
68 "Disable magic number negotiation (looped-back line detection)",
69 OPT_A2COPY, &lcp_allowoptions[0].neg_magicnumber },
70 { "-mn", o_bool, &lcp_wantoptions[0].neg_magicnumber,
71 "Disable magic number negotiation (looped-back line detection)",
72 OPT_A2COPY, &lcp_allowoptions[0].neg_magicnumber },
73 { "default-mru", o_bool, &lcp_wantoptions[0].neg_mru,
74 "Disable MRU negotiation (use default 1500)",
75 OPT_A2COPY, &lcp_allowoptions[0].neg_mru },
76 { "-mru", o_bool, &lcp_wantoptions[0].neg_mru,
77 "Disable MRU negotiation (use default 1500)",
78 OPT_A2COPY, &lcp_allowoptions[0].neg_mru },
79 { "mru", o_int, &lcp_wantoptions[0].mru,
80 "Set MRU (maximum received packet size) for negotiation",
81 0, &lcp_wantoptions[0].neg_mru },
82 { "nopcomp", o_bool, &lcp_wantoptions[0].neg_pcompression,
83 "Disable protocol field compression",
84 OPT_A2COPY, &lcp_allowoptions[0].neg_pcompression },
85 { "-pc", o_bool, &lcp_wantoptions[0].neg_pcompression,
86 "Disable protocol field compression",
87 OPT_A2COPY, &lcp_allowoptions[0].neg_pcompression },
88 { "-p", o_bool, &lcp_wantoptions[0].passive,
89 "Set passive mode", 1 },
90 { "passive", o_bool, &lcp_wantoptions[0].passive,
91 "Set passive mode", 1 },
92 { "silent", o_bool, &lcp_wantoptions[0].silent,
93 "Set silent mode", 1 },
94 { "escape", o_special, setescape,
95 "List of character codes to escape on transmission" },
96 { "lcp-echo-failure", o_int, &lcp_echo_fails,
97 "Set number of consecutive echo failures to indicate link failure" },
98 { "lcp-echo-interval", o_int, &lcp_echo_interval,
99 "Set time in seconds between LCP echo requests" },
100 { "lcp-restart", o_int, &lcp_fsm[0].timeouttime,
101 "Set time in seconds between LCP retransmissions" },
102 { "lcp-max-terminate", o_int, &lcp_fsm[0].maxtermtransmits,
103 "Set maximum number of LCP terminate-request transmissions" },
104 { "lcp-max-configure", o_int, &lcp_fsm[0].maxconfreqtransmits,
105 "Set maximum number of LCP configure-request transmissions" },
106 { "lcp-max-failure", o_int, &lcp_fsm[0].maxnakloops,
107 "Set limit on number of LCP configure-naks" },
108 { "receive-all", o_bool, &lax_recv,
109 "Accept all received control characters", 1 },
114 fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/
115 lcp_options lcp_wantoptions[NUM_PPP]; /* Options that we want to request */
116 lcp_options lcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */
117 lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
118 lcp_options lcp_hisoptions[NUM_PPP]; /* Options that we ack'd */
119 u_int32_t xmit_accm[NUM_PPP][8]; /* extended transmit ACCM */
121 static u_int32_t lcp_echos_pending = 0; /* Number of outstanding echo msgs */
122 static u_int32_t lcp_echo_number = 0; /* ID number of next echo frame */
123 static u_int32_t lcp_echo_timer_running = 0; /* set if a timer is running */
125 static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */
128 * Callbacks for fsm code. (CI = Configuration Information)
130 static void lcp_resetci __P((fsm *)); /* Reset our CI */
131 static int lcp_cilen __P((fsm *)); /* Return length of our CI */
132 static void lcp_addci __P((fsm *, u_char *, int *)); /* Add our CI to pkt */
133 static int lcp_ackci __P((fsm *, u_char *, int)); /* Peer ack'd our CI */
134 static int lcp_nakci __P((fsm *, u_char *, int)); /* Peer nak'd our CI */
135 static int lcp_rejci __P((fsm *, u_char *, int)); /* Peer rej'd our CI */
136 static int lcp_reqci __P((fsm *, u_char *, int *, int)); /* Rcv peer CI */
137 static void lcp_up __P((fsm *)); /* We're UP */
138 static void lcp_down __P((fsm *)); /* We're DOWN */
139 static void lcp_starting __P((fsm *)); /* We need lower layer up */
140 static void lcp_finished __P((fsm *)); /* We need lower layer down */
141 static int lcp_extcode __P((fsm *, int, int, u_char *, int));
142 static void lcp_rprotrej __P((fsm *, u_char *, int));
145 * routines to send LCP echos to peer
148 static void lcp_echo_lowerup __P((int));
149 static void lcp_echo_lowerdown __P((int));
150 static void LcpEchoTimeout __P((void *));
151 static void lcp_received_echo_reply __P((fsm *, int, u_char *, int));
152 static void LcpSendEchoRequest __P((fsm *));
153 static void LcpLinkFailure __P((fsm *));
154 static void LcpEchoCheck __P((fsm *));
156 static fsm_callbacks lcp_callbacks = { /* LCP callback routines */
157 lcp_resetci, /* Reset our Configuration Information */
158 lcp_cilen, /* Length of our Configuration Information */
159 lcp_addci, /* Add our Configuration Information */
160 lcp_ackci, /* ACK our Configuration Information */
161 lcp_nakci, /* NAK our Configuration Information */
162 lcp_rejci, /* Reject our Configuration Information */
163 lcp_reqci, /* Request peer's Configuration Information */
164 lcp_up, /* Called when fsm reaches OPENED state */
165 lcp_down, /* Called when fsm leaves OPENED state */
166 lcp_starting, /* Called when we want the lower layer up */
167 lcp_finished, /* Called when we want the lower layer down */
168 NULL, /* Called when Protocol-Reject received */
169 NULL, /* Retransmission is necessary */
170 lcp_extcode, /* Called to handle LCP-specific codes */
171 "LCP" /* String name of protocol */
175 * Protocol entry points.
176 * Some of these are called directly.
179 static void lcp_init __P((int));
180 static void lcp_input __P((int, u_char *, int));
181 static void lcp_protrej __P((int));
182 static int lcp_printpkt __P((u_char *, int,
183 void (*) __P((void *, char *, ...)), void *));
185 struct protent lcp_protent = {
205 int lcp_loopbackfail = DEFLOOPBACKFAIL;
208 * Length of each type of configuration option (in octets)
212 #define CILEN_SHORT 4 /* CILEN_VOID + sizeof(short) */
213 #define CILEN_CHAP 5 /* CILEN_VOID + sizeof(short) + 1 */
214 #define CILEN_LONG 6 /* CILEN_VOID + sizeof(long) */
215 #define CILEN_LQR 8 /* CILEN_VOID + sizeof(short) + sizeof(long) */
218 #define CODENAME(x) ((x) == CONFACK ? "ACK" : \
219 (x) == CONFNAK ? "NAK" : "REJ")
223 * setescape - add chars to the set we escape on transmission.
235 n = strtol(p, &endp, 16);
237 option_error("escape parameter contains invalid hex number '%s'",
242 if (n < 0 || n == 0x5E || n > 0xFF) {
243 option_error("can't escape character 0x%x", n);
246 xmit_accm[0][n >> 5] |= 1 << (n & 0x1F);
247 while (*p == ',' || *p == ' ')
254 * lcp_init - Initialize LCP.
260 fsm *f = &lcp_fsm[unit];
261 lcp_options *wo = &lcp_wantoptions[unit];
262 lcp_options *ao = &lcp_allowoptions[unit];
265 f->protocol = PPP_LCP;
266 f->callbacks = &lcp_callbacks;
272 wo->restart = 0; /* Set to 1 in kernels or multi-line
276 wo->neg_asyncmap = 1;
278 wo->neg_chap = 0; /* Set to 1 on server */
279 wo->neg_upap = 0; /* Set to 1 on server */
280 wo->chap_mdtype = CHAP_DIGEST_MD5;
281 wo->neg_magicnumber = 1;
282 wo->neg_pcompression = 1;
283 wo->neg_accompression = 1;
284 wo->neg_lqr = 0; /* no LQR implementation yet */
289 ao->neg_asyncmap = 1;
292 ao->chap_mdtype = CHAP_DIGEST_MD5;
294 ao->neg_magicnumber = 1;
295 ao->neg_pcompression = 1;
296 ao->neg_accompression = 1;
297 ao->neg_lqr = 0; /* no LQR implementation yet */
304 memset(xmit_accm[unit], 0, sizeof(xmit_accm[0]));
305 xmit_accm[unit][3] = 0x60000000;
310 * lcp_open - LCP is allowed to come up.
316 fsm *f = &lcp_fsm[unit];
317 lcp_options *wo = &lcp_wantoptions[unit];
321 f->flags |= OPT_PASSIVE;
323 f->flags |= OPT_SILENT;
329 * lcp_close - Take LCP down.
332 lcp_close(unit, reason)
336 fsm *f = &lcp_fsm[unit];
338 if (phase != PHASE_DEAD)
339 phase = PHASE_TERMINATE;
340 if (f->state == STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) {
342 * This action is not strictly according to the FSM in RFC1548,
343 * but it does mean that the program terminates if you do a
344 * lcp_close() in passive/silent mode when a connection hasn't
351 fsm_close(&lcp_fsm[unit], reason);
356 * lcp_lowerup - The lower layer is up.
362 lcp_options *wo = &lcp_wantoptions[unit];
365 * Don't use A/C or protocol compression on transmission,
366 * but accept A/C and protocol compressed packets
367 * if we are going to ask for A/C and protocol compression.
369 ppp_set_xaccm(unit, xmit_accm[unit]);
370 ppp_send_config(unit, PPP_MRU, 0xffffffff, 0, 0);
371 ppp_recv_config(unit, PPP_MRU, (lax_recv? 0: 0xffffffff),
372 wo->neg_pcompression, wo->neg_accompression);
373 peer_mru[unit] = PPP_MRU;
374 lcp_allowoptions[unit].asyncmap = xmit_accm[unit][0];
376 fsm_lowerup(&lcp_fsm[unit]);
381 * lcp_lowerdown - The lower layer is down.
387 fsm_lowerdown(&lcp_fsm[unit]);
392 * lcp_input - Input LCP packet.
395 lcp_input(unit, p, len)
400 fsm *f = &lcp_fsm[unit];
402 fsm_input(f, p, len);
407 * lcp_extcode - Handle a LCP-specific code.
410 lcp_extcode(f, code, id, inp, len)
420 lcp_rprotrej(f, inp, len);
424 if (f->state != OPENED)
427 PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp);
428 fsm_sdata(f, ECHOREP, id, inp, len);
432 lcp_received_echo_reply(f, id, inp, len);
446 * lcp_rprotrej - Receive an Protocol-Reject.
448 * Figure out which protocol is rejected and inform it.
451 lcp_rprotrej(f, inp, len)
457 struct protent *protp;
460 if (len < sizeof (u_short)) {
461 LCPDEBUG(("lcp_rprotrej: Rcvd short Protocol-Reject packet!"));
468 * Protocol-Reject packets received in any state other than the LCP
469 * OPENED state SHOULD be silently discarded.
471 if( f->state != OPENED ){
472 LCPDEBUG(("Protocol-Reject discarded: LCP in state %d", f->state));
477 * Upcall the proper Protocol-Reject routine.
479 for (i = 0; (protp = protocols[i]) != NULL; ++i)
480 if (protp->protocol == prot && protp->enabled_flag) {
481 (*protp->protrej)(f->unit);
485 warn("Protocol-Reject for unsupported protocol 0x%x", prot);
490 * lcp_protrej - A Protocol-Reject was received.
500 error("Received Protocol-Reject for LCP!");
501 fsm_protreject(&lcp_fsm[unit]);
506 * lcp_sprotrej - Send a Protocol-Reject for some protocol.
509 lcp_sprotrej(unit, p, len)
515 * Send back the protocol and the information field of the
516 * rejected packet. We only get here if LCP is in the OPENED state.
521 fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id,
527 * lcp_resetci - Reset our CI.
533 lcp_wantoptions[f->unit].magicnumber = magic();
534 lcp_wantoptions[f->unit].numloops = 0;
535 lcp_gotoptions[f->unit] = lcp_wantoptions[f->unit];
536 peer_mru[f->unit] = PPP_MRU;
542 * lcp_cilen - Return length of our CI.
548 lcp_options *go = &lcp_gotoptions[f->unit];
550 #define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0)
551 #define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0)
552 #define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0)
553 #define LENCILONG(neg) ((neg) ? CILEN_LONG : 0)
554 #define LENCILQR(neg) ((neg) ? CILEN_LQR: 0)
555 #define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0)
557 * NB: we only ask for one of CHAP and UPAP, even if we will
560 return (LENCISHORT(go->neg_mru && go->mru != DEFMRU) +
561 LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) +
562 LENCICHAP(go->neg_chap) +
563 LENCISHORT(!go->neg_chap && go->neg_upap) +
564 LENCILQR(go->neg_lqr) +
565 LENCICBCP(go->neg_cbcp) +
566 LENCILONG(go->neg_magicnumber) +
567 LENCIVOID(go->neg_pcompression) +
568 LENCIVOID(go->neg_accompression));
573 * lcp_addci - Add our desired CIs to a packet.
576 lcp_addci(f, ucp, lenp)
581 lcp_options *go = &lcp_gotoptions[f->unit];
582 u_char *start_ucp = ucp;
584 #define ADDCIVOID(opt, neg) \
587 PUTCHAR(CILEN_VOID, ucp); \
589 #define ADDCISHORT(opt, neg, val) \
592 PUTCHAR(CILEN_SHORT, ucp); \
593 PUTSHORT(val, ucp); \
595 #define ADDCICHAP(opt, neg, val, digest) \
598 PUTCHAR(CILEN_CHAP, ucp); \
599 PUTSHORT(val, ucp); \
600 PUTCHAR(digest, ucp); \
602 #define ADDCILONG(opt, neg, val) \
605 PUTCHAR(CILEN_LONG, ucp); \
608 #define ADDCILQR(opt, neg, val) \
611 PUTCHAR(CILEN_LQR, ucp); \
612 PUTSHORT(PPP_LQR, ucp); \
615 #define ADDCICHAR(opt, neg, val) \
618 PUTCHAR(CILEN_CHAR, ucp); \
622 ADDCISHORT(CI_MRU, go->neg_mru && go->mru != DEFMRU, go->mru);
623 ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF,
625 ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
626 ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
627 ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
628 ADDCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT);
629 ADDCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber);
630 ADDCIVOID(CI_PCOMPRESSION, go->neg_pcompression);
631 ADDCIVOID(CI_ACCOMPRESSION, go->neg_accompression);
633 if (ucp - start_ucp != *lenp) {
634 /* this should never happen, because peer_mtu should be 1500 */
635 error("Bug in lcp_addci: wrong length");
641 * lcp_ackci - Ack our CIs.
642 * This should not modify any state if the Ack is bad.
654 lcp_options *go = &lcp_gotoptions[f->unit];
655 u_char cilen, citype, cichar;
660 * CIs must be in exactly the same order that we sent.
661 * Check packet length and CI length at each step.
662 * If we find any deviations, then this packet is bad.
664 #define ACKCIVOID(opt, neg) \
666 if ((len -= CILEN_VOID) < 0) \
668 GETCHAR(citype, p); \
670 if (cilen != CILEN_VOID || \
674 #define ACKCISHORT(opt, neg, val) \
676 if ((len -= CILEN_SHORT) < 0) \
678 GETCHAR(citype, p); \
680 if (cilen != CILEN_SHORT || \
683 GETSHORT(cishort, p); \
684 if (cishort != val) \
687 #define ACKCICHAR(opt, neg, val) \
689 if ((len -= CILEN_CHAR) < 0) \
691 GETCHAR(citype, p); \
693 if (cilen != CILEN_CHAR || \
696 GETCHAR(cichar, p); \
700 #define ACKCICHAP(opt, neg, val, digest) \
702 if ((len -= CILEN_CHAP) < 0) \
704 GETCHAR(citype, p); \
706 if (cilen != CILEN_CHAP || \
709 GETSHORT(cishort, p); \
710 if (cishort != val) \
712 GETCHAR(cichar, p); \
713 if (cichar != digest) \
716 #define ACKCILONG(opt, neg, val) \
718 if ((len -= CILEN_LONG) < 0) \
720 GETCHAR(citype, p); \
722 if (cilen != CILEN_LONG || \
725 GETLONG(cilong, p); \
729 #define ACKCILQR(opt, neg, val) \
731 if ((len -= CILEN_LQR) < 0) \
733 GETCHAR(citype, p); \
735 if (cilen != CILEN_LQR || \
738 GETSHORT(cishort, p); \
739 if (cishort != PPP_LQR) \
741 GETLONG(cilong, p); \
746 ACKCISHORT(CI_MRU, go->neg_mru && go->mru != DEFMRU, go->mru);
747 ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF,
749 ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
750 ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
751 ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
752 ACKCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT);
753 ACKCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber);
754 ACKCIVOID(CI_PCOMPRESSION, go->neg_pcompression);
755 ACKCIVOID(CI_ACCOMPRESSION, go->neg_accompression);
758 * If there are any remaining CIs, then this packet is bad.
764 LCPDEBUG(("lcp_acki: received bad Ack!"));
770 * lcp_nakci - Peer has sent a NAK for some of our CIs.
771 * This should not modify any state if the Nak is bad
772 * or if LCP is in the OPENED state.
784 lcp_options *go = &lcp_gotoptions[f->unit];
785 lcp_options *wo = &lcp_wantoptions[f->unit];
786 u_char citype, cichar, *next;
789 lcp_options no; /* options we've seen Naks for */
790 lcp_options try; /* options to request next time */
794 BZERO(&no, sizeof(no));
798 * Any Nak'd CIs must be in exactly the same order that we sent.
799 * Check packet length and CI length at each step.
800 * If we find any deviations, then this packet is bad.
802 #define NAKCIVOID(opt, neg, code) \
804 len >= CILEN_VOID && \
805 p[1] == CILEN_VOID && \
808 INCPTR(CILEN_VOID, p); \
812 #define NAKCICHAP(opt, neg, code) \
814 len >= CILEN_CHAP && \
815 p[1] == CILEN_CHAP && \
819 GETSHORT(cishort, p); \
820 GETCHAR(cichar, p); \
824 #define NAKCICHAR(opt, neg, code) \
826 len >= CILEN_CHAR && \
827 p[1] == CILEN_CHAR && \
831 GETCHAR(cichar, p); \
835 #define NAKCISHORT(opt, neg, code) \
837 len >= CILEN_SHORT && \
838 p[1] == CILEN_SHORT && \
840 len -= CILEN_SHORT; \
842 GETSHORT(cishort, p); \
846 #define NAKCILONG(opt, neg, code) \
848 len >= CILEN_LONG && \
849 p[1] == CILEN_LONG && \
853 GETLONG(cilong, p); \
857 #define NAKCILQR(opt, neg, code) \
859 len >= CILEN_LQR && \
860 p[1] == CILEN_LQR && \
864 GETSHORT(cishort, p); \
865 GETLONG(cilong, p); \
871 * We don't care if they want to send us smaller packets than
872 * we want. Therefore, accept any MRU less than what we asked for,
873 * but then ignore the new value when setting the MRU in the kernel.
874 * If they send us a bigger MRU than what we asked, accept it, up to
875 * the limit of the default MRU we'd get if we didn't negotiate.
877 if (go->neg_mru && go->mru != DEFMRU) {
878 NAKCISHORT(CI_MRU, neg_mru,
879 if (cishort <= wo->mru || cishort <= DEFMRU)
885 * Add any characters they want to our (receive-side) asyncmap.
887 if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) {
888 NAKCILONG(CI_ASYNCMAP, neg_asyncmap,
889 try.asyncmap = go->asyncmap | cilong;
894 * If they've nak'd our authentication-protocol, check whether
895 * they are proposing a different protocol, or a different
896 * hash algorithm for CHAP.
898 if ((go->neg_chap || go->neg_upap)
899 && len >= CILEN_SHORT
900 && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) {
903 no.neg_chap = go->neg_chap;
904 no.neg_upap = go->neg_upap;
906 GETSHORT(cishort, p);
907 if (cishort == PPP_PAP && cilen == CILEN_SHORT) {
909 * If we were asking for CHAP, they obviously don't want to do it.
910 * If we weren't asking for CHAP, then we were asking for PAP,
911 * in which case this Nak is bad.
917 } else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) {
921 * We were asking for CHAP/MD5; they must want a different
922 * algorithm. If they can't do MD5, we'll have to stop
925 if (cichar != go->chap_mdtype)
929 * Stop asking for PAP if we were asking for it.
936 * We don't recognize what they're suggesting.
937 * Stop asking for what we were asking for.
943 p += cilen - CILEN_SHORT;
948 * If they can't cope with our link quality protocol, we'll have
949 * to stop asking for LQR. We haven't got any other protocol.
950 * If they Nak the reporting period, take their value XXX ?
952 NAKCILQR(CI_QUALITY, neg_lqr,
953 if (cishort != PPP_LQR)
956 try.lqr_period = cilong;
960 * Only implementing CBCP...not the rest of the callback options
962 NAKCICHAR(CI_CALLBACK, neg_cbcp,
967 * Check for a looped-back line.
969 NAKCILONG(CI_MAGICNUMBER, neg_magicnumber,
970 try.magicnumber = magic();
975 * Peer shouldn't send Nak for protocol compression or
976 * address/control compression requests; they should send
977 * a Reject instead. If they send a Nak, treat it as a Reject.
979 NAKCIVOID(CI_PCOMPRESSION, neg_pcompression,
980 try.neg_pcompression = 0;
982 NAKCIVOID(CI_ACCOMPRESSION, neg_accompression,
983 try.neg_accompression = 0;
987 * There may be remaining CIs, if the peer is requesting negotiation
988 * on an option that we didn't include in our request packet.
989 * If we see an option that we requested, or one we've already seen
990 * in this packet, then this packet is bad.
991 * If we wanted to respond by starting to negotiate on the requested
992 * option(s), we could, but we don't, because except for the
993 * authentication type and quality protocol, if we are not negotiating
994 * an option, it is because we were told not to.
995 * For the authentication type, the Nak from the peer means
996 * `let me authenticate myself with you' which is a bit pointless.
997 * For the quality protocol, the Nak means `ask me to send you quality
998 * reports', but if we didn't ask for them, we don't want them.
999 * An option we don't recognize represents the peer asking to
1000 * negotiate some option we don't support, so ignore it.
1002 while (len > CILEN_VOID) {
1005 if (cilen < CILEN_VOID || (len -= cilen) < 0)
1007 next = p + cilen - 2;
1011 if ((go->neg_mru && go->mru != DEFMRU)
1012 || no.neg_mru || cilen != CILEN_SHORT)
1014 GETSHORT(cishort, p);
1015 if (cishort < DEFMRU)
1019 if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF)
1020 || no.neg_asyncmap || cilen != CILEN_LONG)
1024 if (go->neg_chap || no.neg_chap || go->neg_upap || no.neg_upap)
1027 case CI_MAGICNUMBER:
1028 if (go->neg_magicnumber || no.neg_magicnumber ||
1029 cilen != CILEN_LONG)
1032 case CI_PCOMPRESSION:
1033 if (go->neg_pcompression || no.neg_pcompression
1034 || cilen != CILEN_VOID)
1037 case CI_ACCOMPRESSION:
1038 if (go->neg_accompression || no.neg_accompression
1039 || cilen != CILEN_VOID)
1043 if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR)
1051 * OK, the Nak is good. Now we can update state.
1052 * If there are any options left we ignore them.
1054 if (f->state != OPENED) {
1056 if (++try.numloops >= lcp_loopbackfail) {
1057 notice("Serial line is looped back.");
1058 lcp_close(f->unit, "Loopback detected");
1059 status = EXIT_LOOPBACK;
1069 LCPDEBUG(("lcp_nakci: received bad Nak!"));
1075 * lcp_rejci - Peer has Rejected some of our CIs.
1076 * This should not modify any state if the Reject is bad
1077 * or if LCP is in the OPENED state.
1080 * 0 - Reject was bad.
1081 * 1 - Reject was good.
1084 lcp_rejci(f, p, len)
1089 lcp_options *go = &lcp_gotoptions[f->unit];
1093 lcp_options try; /* options to request next time */
1098 * Any Rejected CIs must be in exactly the same order that we sent.
1099 * Check packet length and CI length at each step.
1100 * If we find any deviations, then this packet is bad.
1102 #define REJCIVOID(opt, neg) \
1104 len >= CILEN_VOID && \
1105 p[1] == CILEN_VOID && \
1107 len -= CILEN_VOID; \
1108 INCPTR(CILEN_VOID, p); \
1111 #define REJCISHORT(opt, neg, val) \
1113 len >= CILEN_SHORT && \
1114 p[1] == CILEN_SHORT && \
1116 len -= CILEN_SHORT; \
1118 GETSHORT(cishort, p); \
1119 /* Check rejected value. */ \
1120 if (cishort != val) \
1124 #define REJCICHAP(opt, neg, val, digest) \
1126 len >= CILEN_CHAP && \
1127 p[1] == CILEN_CHAP && \
1129 len -= CILEN_CHAP; \
1131 GETSHORT(cishort, p); \
1132 GETCHAR(cichar, p); \
1133 /* Check rejected value. */ \
1134 if (cishort != val || cichar != digest) \
1139 #define REJCILONG(opt, neg, val) \
1141 len >= CILEN_LONG && \
1142 p[1] == CILEN_LONG && \
1144 len -= CILEN_LONG; \
1146 GETLONG(cilong, p); \
1147 /* Check rejected value. */ \
1148 if (cilong != val) \
1152 #define REJCILQR(opt, neg, val) \
1154 len >= CILEN_LQR && \
1155 p[1] == CILEN_LQR && \
1159 GETSHORT(cishort, p); \
1160 GETLONG(cilong, p); \
1161 /* Check rejected value. */ \
1162 if (cishort != PPP_LQR || cilong != val) \
1166 #define REJCICBCP(opt, neg, val) \
1168 len >= CILEN_CBCP && \
1169 p[1] == CILEN_CBCP && \
1171 len -= CILEN_CBCP; \
1173 GETCHAR(cichar, p); \
1174 /* Check rejected value. */ \
1175 if (cichar != val) \
1180 REJCISHORT(CI_MRU, neg_mru, go->mru);
1181 REJCILONG(CI_ASYNCMAP, neg_asyncmap, go->asyncmap);
1182 REJCICHAP(CI_AUTHTYPE, neg_chap, PPP_CHAP, go->chap_mdtype);
1183 if (!go->neg_chap) {
1184 REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP);
1186 REJCILQR(CI_QUALITY, neg_lqr, go->lqr_period);
1187 REJCICBCP(CI_CALLBACK, neg_cbcp, CBCP_OPT);
1188 REJCILONG(CI_MAGICNUMBER, neg_magicnumber, go->magicnumber);
1189 REJCIVOID(CI_PCOMPRESSION, neg_pcompression);
1190 REJCIVOID(CI_ACCOMPRESSION, neg_accompression);
1193 * If there are any remaining CIs, then this packet is bad.
1198 * Now we can update state.
1200 if (f->state != OPENED)
1205 LCPDEBUG(("lcp_rejci: received bad Reject!"));
1211 * lcp_reqci - Check the peer's requested CIs and send appropriate response.
1213 * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified
1214 * appropriately. If reject_if_disagree is non-zero, doesn't return
1215 * CONFNAK; returns CONFREJ if it can't return CONFACK.
1218 lcp_reqci(f, inp, lenp, reject_if_disagree)
1220 u_char *inp; /* Requested CIs */
1221 int *lenp; /* Length of requested CIs */
1222 int reject_if_disagree;
1224 lcp_options *go = &lcp_gotoptions[f->unit];
1225 lcp_options *ho = &lcp_hisoptions[f->unit];
1226 lcp_options *ao = &lcp_allowoptions[f->unit];
1227 u_char *cip, *next; /* Pointer to current and next CIs */
1228 int cilen, citype, cichar; /* Parsed len, type, char value */
1229 u_short cishort; /* Parsed short value */
1230 u_int32_t cilong; /* Parse long value */
1231 int rc = CONFACK; /* Final packet return code */
1232 int orc; /* Individual option return code */
1233 u_char *p; /* Pointer to next char to parse */
1234 u_char *rejp; /* Pointer to next char in reject frame */
1235 u_char *nakp; /* Pointer to next char in Nak frame */
1236 int l = *lenp; /* Length left */
1239 * Reset all his options.
1241 BZERO(ho, sizeof(*ho));
1244 * Process all his options.
1250 orc = CONFACK; /* Assume success */
1251 cip = p = next; /* Remember begining of CI */
1252 if (l < 2 || /* Not enough data for CI header or */
1253 p[1] < 2 || /* CI length too small or */
1254 p[1] > l) { /* CI length too big? */
1255 LCPDEBUG(("lcp_reqci: bad CI length!"));
1256 orc = CONFREJ; /* Reject bad CI */
1257 cilen = l; /* Reject till end of packet */
1258 l = 0; /* Don't loop again */
1262 GETCHAR(citype, p); /* Parse CI type */
1263 GETCHAR(cilen, p); /* Parse CI length */
1264 l -= cilen; /* Adjust remaining length */
1265 next += cilen; /* Step to next CI */
1267 switch (citype) { /* Check CI type */
1269 if (!ao->neg_mru || /* Allow option? */
1270 cilen != CILEN_SHORT) { /* Check CI length */
1271 orc = CONFREJ; /* Reject CI */
1274 GETSHORT(cishort, p); /* Parse MRU */
1277 * He must be able to receive at least our minimum.
1278 * No need to check a maximum. If he sends a large number,
1279 * we'll just ignore it.
1281 if (cishort < MINMRU) {
1282 orc = CONFNAK; /* Nak CI */
1283 PUTCHAR(CI_MRU, nakp);
1284 PUTCHAR(CILEN_SHORT, nakp);
1285 PUTSHORT(MINMRU, nakp); /* Give him a hint */
1288 ho->neg_mru = 1; /* Remember he sent MRU */
1289 ho->mru = cishort; /* And remember value */
1293 if (!ao->neg_asyncmap ||
1294 cilen != CILEN_LONG) {
1301 * Asyncmap must have set at least the bits
1302 * which are set in lcp_allowoptions[unit].asyncmap.
1304 if ((ao->asyncmap & ~cilong) != 0) {
1306 PUTCHAR(CI_ASYNCMAP, nakp);
1307 PUTCHAR(CILEN_LONG, nakp);
1308 PUTLONG(ao->asyncmap | cilong, nakp);
1311 ho->neg_asyncmap = 1;
1312 ho->asyncmap = cilong;
1316 if (cilen < CILEN_SHORT ||
1317 !(ao->neg_upap || ao->neg_chap)) {
1319 * Reject the option if we're not willing to authenticate.
1324 GETSHORT(cishort, p);
1327 * Authtype must be UPAP or CHAP.
1329 * Note: if both ao->neg_upap and ao->neg_chap are set,
1330 * and the peer sends a Configure-Request with two
1331 * authenticate-protocol requests, one for CHAP and one
1332 * for UPAP, then we will reject the second request.
1333 * Whether we end up doing CHAP or UPAP depends then on
1334 * the ordering of the CIs in the peer's Configure-Request.
1337 if (cishort == PPP_PAP) {
1338 if (ho->neg_chap || /* we've already accepted CHAP */
1339 cilen != CILEN_SHORT) {
1340 LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE PAP, rejecting..."));
1344 if (!ao->neg_upap) { /* we don't want to do PAP */
1345 orc = CONFNAK; /* NAK it and suggest CHAP */
1346 PUTCHAR(CI_AUTHTYPE, nakp);
1347 PUTCHAR(CILEN_CHAP, nakp);
1348 PUTSHORT(PPP_CHAP, nakp);
1349 PUTCHAR(ao->chap_mdtype, nakp);
1355 if (cishort == PPP_CHAP) {
1356 if (ho->neg_upap || /* we've already accepted PAP */
1357 cilen != CILEN_CHAP) {
1358 LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE CHAP, rejecting..."));
1362 if (!ao->neg_chap) { /* we don't want to do CHAP */
1363 orc = CONFNAK; /* NAK it and suggest PAP */
1364 PUTCHAR(CI_AUTHTYPE, nakp);
1365 PUTCHAR(CILEN_SHORT, nakp);
1366 PUTSHORT(PPP_PAP, nakp);
1369 GETCHAR(cichar, p); /* get digest type*/
1370 if (cichar != CHAP_DIGEST_MD5
1372 && cichar != CHAP_MICROSOFT
1376 PUTCHAR(CI_AUTHTYPE, nakp);
1377 PUTCHAR(CILEN_CHAP, nakp);
1378 PUTSHORT(PPP_CHAP, nakp);
1379 PUTCHAR(ao->chap_mdtype, nakp);
1382 ho->chap_mdtype = cichar; /* save md type */
1388 * We don't recognize the protocol they're asking for.
1389 * Nak it with something we're willing to do.
1390 * (At this point we know ao->neg_upap || ao->neg_chap.)
1393 PUTCHAR(CI_AUTHTYPE, nakp);
1395 PUTCHAR(CILEN_CHAP, nakp);
1396 PUTSHORT(PPP_CHAP, nakp);
1397 PUTCHAR(ao->chap_mdtype, nakp);
1399 PUTCHAR(CILEN_SHORT, nakp);
1400 PUTSHORT(PPP_PAP, nakp);
1406 cilen != CILEN_LQR) {
1411 GETSHORT(cishort, p);
1415 * Check the protocol and the reporting period.
1416 * XXX When should we Nak this, and what with?
1418 if (cishort != PPP_LQR) {
1420 PUTCHAR(CI_QUALITY, nakp);
1421 PUTCHAR(CILEN_LQR, nakp);
1422 PUTSHORT(PPP_LQR, nakp);
1423 PUTLONG(ao->lqr_period, nakp);
1428 case CI_MAGICNUMBER:
1429 if (!(ao->neg_magicnumber || go->neg_magicnumber) ||
1430 cilen != CILEN_LONG) {
1437 * He must have a different magic number.
1439 if (go->neg_magicnumber &&
1440 cilong == go->magicnumber) {
1441 cilong = magic(); /* Don't put magic() inside macro! */
1443 PUTCHAR(CI_MAGICNUMBER, nakp);
1444 PUTCHAR(CILEN_LONG, nakp);
1445 PUTLONG(cilong, nakp);
1448 ho->neg_magicnumber = 1;
1449 ho->magicnumber = cilong;
1453 case CI_PCOMPRESSION:
1454 if (!ao->neg_pcompression ||
1455 cilen != CILEN_VOID) {
1459 ho->neg_pcompression = 1;
1462 case CI_ACCOMPRESSION:
1463 if (!ao->neg_accompression ||
1464 cilen != CILEN_VOID) {
1468 ho->neg_accompression = 1;
1472 LCPDEBUG(("lcp_reqci: rcvd unknown option %d", citype));
1478 if (orc == CONFACK && /* Good CI */
1479 rc != CONFACK) /* but prior CI wasnt? */
1480 continue; /* Don't send this one */
1482 if (orc == CONFNAK) { /* Nak this CI? */
1483 if (reject_if_disagree /* Getting fed up with sending NAKs? */
1484 && citype != CI_MAGICNUMBER) {
1485 orc = CONFREJ; /* Get tough if so */
1487 if (rc == CONFREJ) /* Rejecting prior CI? */
1488 continue; /* Don't send this one */
1492 if (orc == CONFREJ) { /* Reject this CI */
1494 if (cip != rejp) /* Need to move rejected CI? */
1495 BCOPY(cip, rejp, cilen); /* Move it */
1496 INCPTR(cilen, rejp); /* Update output pointer */
1501 * If we wanted to send additional NAKs (for unsent CIs), the
1502 * code would go here. The extra NAKs would go at *nakp.
1503 * At present there are no cases where we want to ask the
1504 * peer to negotiate an option.
1513 * Copy the Nak'd options from the nak_buffer to the caller's buffer.
1515 *lenp = nakp - nak_buffer;
1516 BCOPY(nak_buffer, inp, *lenp);
1523 LCPDEBUG(("lcp_reqci: returning CONF%s.", CODENAME(rc)));
1524 return (rc); /* Return final code */
1529 * lcp_up - LCP has come UP.
1535 lcp_options *wo = &lcp_wantoptions[f->unit];
1536 lcp_options *ho = &lcp_hisoptions[f->unit];
1537 lcp_options *go = &lcp_gotoptions[f->unit];
1538 lcp_options *ao = &lcp_allowoptions[f->unit];
1540 if (!go->neg_magicnumber)
1541 go->magicnumber = 0;
1542 if (!ho->neg_magicnumber)
1543 ho->magicnumber = 0;
1546 * Set our MTU to the smaller of the MTU we wanted and
1547 * the MRU our peer wanted. If we negotiated an MRU,
1548 * set our MRU to the larger of value we wanted and
1549 * the value we got in the negotiation.
1551 ppp_send_config(f->unit, MIN(ao->mru, (ho->neg_mru? ho->mru: PPP_MRU)),
1552 (ho->neg_asyncmap? ho->asyncmap: 0xffffffff),
1553 ho->neg_pcompression, ho->neg_accompression);
1554 ppp_recv_config(f->unit, (go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU),
1555 (lax_recv? 0: go->neg_asyncmap? go->asyncmap: 0xffffffff),
1556 go->neg_pcompression, go->neg_accompression);
1559 peer_mru[f->unit] = ho->mru;
1561 lcp_echo_lowerup(f->unit); /* Enable echo messages */
1563 link_established(f->unit);
1568 * lcp_down - LCP has gone DOWN.
1570 * Alert other protocols.
1576 lcp_options *go = &lcp_gotoptions[f->unit];
1578 lcp_echo_lowerdown(f->unit);
1582 ppp_send_config(f->unit, PPP_MRU, 0xffffffff, 0, 0);
1583 ppp_recv_config(f->unit, PPP_MRU,
1584 (go->neg_asyncmap? go->asyncmap: 0xffffffff),
1585 go->neg_pcompression, go->neg_accompression);
1586 peer_mru[f->unit] = PPP_MRU;
1591 * lcp_starting - LCP needs the lower layer up.
1597 link_required(f->unit);
1602 * lcp_finished - LCP has finished with the lower layer.
1608 link_terminated(f->unit);
1613 * lcp_printpkt - print the contents of an LCP packet.
1615 static char *lcp_codenames[] = {
1616 "ConfReq", "ConfAck", "ConfNak", "ConfRej",
1617 "TermReq", "TermAck", "CodeRej", "ProtRej",
1618 "EchoReq", "EchoRep", "DiscReq"
1622 lcp_printpkt(p, plen, printer, arg)
1625 void (*printer) __P((void *, char *, ...));
1628 int code, id, len, olen;
1629 u_char *pstart, *optend;
1633 if (plen < HEADERLEN)
1639 if (len < HEADERLEN || len > plen)
1642 if (code >= 1 && code <= sizeof(lcp_codenames) / sizeof(char *))
1643 printer(arg, " %s", lcp_codenames[code-1]);
1645 printer(arg, " code=0x%x", code);
1646 printer(arg, " id=0x%x", id);
1653 /* print option list */
1658 if (olen < 2 || olen > len) {
1666 if (olen == CILEN_SHORT) {
1668 GETSHORT(cishort, p);
1669 printer(arg, "mru %d", cishort);
1673 if (olen == CILEN_LONG) {
1676 printer(arg, "asyncmap 0x%x", cilong);
1680 if (olen >= CILEN_SHORT) {
1682 printer(arg, "auth ");
1683 GETSHORT(cishort, p);
1686 printer(arg, "pap");
1689 printer(arg, "chap");
1692 case CHAP_DIGEST_MD5:
1693 printer(arg, " MD5");
1697 case CHAP_MICROSOFT:
1698 printer(arg, " m$oft");
1706 printer(arg, "0x%x", cishort);
1711 if (olen >= CILEN_SHORT) {
1713 printer(arg, "quality ");
1714 GETSHORT(cishort, p);
1717 printer(arg, "lqr");
1720 printer(arg, "0x%x", cishort);
1725 if (olen >= CILEN_CHAR) {
1727 printer(arg, "callback ");
1728 GETCHAR(cishort, p);
1731 printer(arg, "CBCP");
1734 printer(arg, "0x%x", cishort);
1738 case CI_MAGICNUMBER:
1739 if (olen == CILEN_LONG) {
1742 printer(arg, "magic 0x%x", cilong);
1745 case CI_PCOMPRESSION:
1746 if (olen == CILEN_VOID) {
1748 printer(arg, "pcomp");
1751 case CI_ACCOMPRESSION:
1752 if (olen == CILEN_VOID) {
1754 printer(arg, "accomp");
1758 while (p < optend) {
1760 printer(arg, " %.2x", code);
1768 if (len > 0 && *p >= ' ' && *p < 0x7f) {
1770 print_string(p, len, printer, arg);
1781 printer(arg, " magic=0x%x", cilong);
1788 /* print the rest of the bytes in the packet */
1789 for (; len > 0; --len) {
1791 printer(arg, " %.2x", code);
1798 * Time to shut down the link because there is nothing out there.
1802 void LcpLinkFailure (f)
1805 if (f->state == OPENED) {
1806 info("No response to %d echo-requests", lcp_echos_pending);
1807 notice("Serial link appears to be disconnected.");
1808 lcp_close(f->unit, "Peer not responding");
1809 status = EXIT_PEER_DEAD;
1814 * Timer expired for the LCP echo requests from this process.
1821 LcpSendEchoRequest (f);
1824 * Start the timer for the next interval.
1826 if (lcp_echo_timer_running)
1827 warn("assertion lcp_echo_timer_running==0 failed");
1828 TIMEOUT (LcpEchoTimeout, f, lcp_echo_interval);
1829 lcp_echo_timer_running = 1;
1833 * LcpEchoTimeout - Timer expired on the LCP echo
1837 LcpEchoTimeout (arg)
1840 if (lcp_echo_timer_running != 0) {
1841 lcp_echo_timer_running = 0;
1842 LcpEchoCheck ((fsm *) arg);
1847 * LcpEchoReply - LCP has received a reply to the echo
1851 lcp_received_echo_reply (f, id, inp, len)
1853 int id; u_char *inp; int len;
1857 /* Check the magic number - don't count replies from ourselves. */
1859 dbglog("lcp: received short Echo-Reply, length %d", len);
1862 GETLONG(magic, inp);
1863 if (lcp_gotoptions[f->unit].neg_magicnumber
1864 && magic == lcp_gotoptions[f->unit].magicnumber) {
1865 warn("appear to have received our own echo-reply!");
1869 /* Reset the number of outstanding echo frames */
1870 lcp_echos_pending = 0;
1874 * LcpSendEchoRequest - Send an echo request frame to the peer
1878 LcpSendEchoRequest (f)
1881 u_int32_t lcp_magic;
1882 u_char pkt[4], *pktp;
1885 * Detect the failure of the peer at this point.
1887 if (lcp_echo_fails != 0) {
1888 if (lcp_echos_pending >= lcp_echo_fails) {
1890 lcp_echos_pending = 0;
1895 * Make and send the echo request frame.
1897 if (f->state == OPENED) {
1898 lcp_magic = lcp_gotoptions[f->unit].magicnumber;
1900 PUTLONG(lcp_magic, pktp);
1901 fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt);
1902 ++lcp_echos_pending;
1907 * lcp_echo_lowerup - Start the timer for the LCP frame
1911 lcp_echo_lowerup (unit)
1914 fsm *f = &lcp_fsm[unit];
1916 /* Clear the parameters for generating echo frames */
1917 lcp_echos_pending = 0;
1918 lcp_echo_number = 0;
1919 lcp_echo_timer_running = 0;
1921 /* If a timeout interval is specified then start the timer */
1922 if (lcp_echo_interval != 0)
1927 * lcp_echo_lowerdown - Stop the timer for the LCP frame
1931 lcp_echo_lowerdown (unit)
1934 fsm *f = &lcp_fsm[unit];
1936 if (lcp_echo_timer_running != 0) {
1937 UNTIMEOUT (LcpEchoTimeout, f);
1938 lcp_echo_timer_running = 0;