Deleted Added
full compact
lcp.c (85991) lcp.c (93418)
1/*-
2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
4 * Internet Initiative Japan, Inc (IIJ)
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
4 * Internet Initiative Japan, Inc (IIJ)
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/usr.sbin/ppp/lcp.c 85991 2001-11-03 21:45:32Z brian $
28 * $FreeBSD: head/usr.sbin/ppp/lcp.c 93418 2002-03-30 12:30:09Z brian $
29 */
30
31#include <sys/param.h>
32#include <netinet/in.h>
33#include <netinet/in_systm.h>
34#include <netinet/ip.h>
35#include <sys/socket.h>
36#include <sys/un.h>

--- 168 unchanged lines hidden (view full) ---

205 lcp->cfg.fsm.maxreq, lcp->cfg.fsm.maxreq == 1 ? "" : "s",
206 lcp->cfg.fsm.maxtrm, lcp->cfg.fsm.maxtrm == 1 ? "" : "s");
207 prompt_Printf(arg->prompt, " Ident: %s\n", lcp->cfg.ident);
208 prompt_Printf(arg->prompt, "\n Negotiation:\n");
209 prompt_Printf(arg->prompt, " ACFCOMP = %s\n",
210 command_ShowNegval(lcp->cfg.acfcomp));
211 prompt_Printf(arg->prompt, " CHAP = %s\n",
212 command_ShowNegval(lcp->cfg.chap05));
29 */
30
31#include <sys/param.h>
32#include <netinet/in.h>
33#include <netinet/in_systm.h>
34#include <netinet/ip.h>
35#include <sys/socket.h>
36#include <sys/un.h>

--- 168 unchanged lines hidden (view full) ---

205 lcp->cfg.fsm.maxreq, lcp->cfg.fsm.maxreq == 1 ? "" : "s",
206 lcp->cfg.fsm.maxtrm, lcp->cfg.fsm.maxtrm == 1 ? "" : "s");
207 prompt_Printf(arg->prompt, " Ident: %s\n", lcp->cfg.ident);
208 prompt_Printf(arg->prompt, "\n Negotiation:\n");
209 prompt_Printf(arg->prompt, " ACFCOMP = %s\n",
210 command_ShowNegval(lcp->cfg.acfcomp));
211 prompt_Printf(arg->prompt, " CHAP = %s\n",
212 command_ShowNegval(lcp->cfg.chap05));
213#ifdef HAVE_DES
213#ifndef NODES
214 prompt_Printf(arg->prompt, " CHAP80 = %s\n",
215 command_ShowNegval(lcp->cfg.chap80nt));
216 prompt_Printf(arg->prompt, " LANMan = %s\n",
217 command_ShowNegval(lcp->cfg.chap80lm));
218 prompt_Printf(arg->prompt, " CHAP81 = %s\n",
219 command_ShowNegval(lcp->cfg.chap81));
220#endif
221 prompt_Printf(arg->prompt, " LQR = %s\n",

--- 41 unchanged lines hidden (view full) ---

263 lcp->cfg.openmode = 1;
264 lcp->cfg.lqrperiod = DEF_LQRPERIOD;
265 lcp->cfg.fsm.timeout = DEF_FSMRETRY;
266 lcp->cfg.fsm.maxreq = DEF_FSMTRIES;
267 lcp->cfg.fsm.maxtrm = DEF_FSMTRIES;
268
269 lcp->cfg.acfcomp = NEG_ENABLED|NEG_ACCEPTED;
270 lcp->cfg.chap05 = NEG_ACCEPTED;
214 prompt_Printf(arg->prompt, " CHAP80 = %s\n",
215 command_ShowNegval(lcp->cfg.chap80nt));
216 prompt_Printf(arg->prompt, " LANMan = %s\n",
217 command_ShowNegval(lcp->cfg.chap80lm));
218 prompt_Printf(arg->prompt, " CHAP81 = %s\n",
219 command_ShowNegval(lcp->cfg.chap81));
220#endif
221 prompt_Printf(arg->prompt, " LQR = %s\n",

--- 41 unchanged lines hidden (view full) ---

263 lcp->cfg.openmode = 1;
264 lcp->cfg.lqrperiod = DEF_LQRPERIOD;
265 lcp->cfg.fsm.timeout = DEF_FSMRETRY;
266 lcp->cfg.fsm.maxreq = DEF_FSMTRIES;
267 lcp->cfg.fsm.maxtrm = DEF_FSMTRIES;
268
269 lcp->cfg.acfcomp = NEG_ENABLED|NEG_ACCEPTED;
270 lcp->cfg.chap05 = NEG_ACCEPTED;
271#ifdef HAVE_DES
271#ifndef NODES
272 lcp->cfg.chap80nt = NEG_ACCEPTED;
273 lcp->cfg.chap80lm = 0;
274 lcp->cfg.chap81 = NEG_ACCEPTED;
275#endif
276 lcp->cfg.lqr = NEG_ACCEPTED;
277 lcp->cfg.pap = NEG_ACCEPTED;
278 lcp->cfg.protocomp = NEG_ENABLED|NEG_ACCEPTED;
279 *lcp->cfg.ident = '\0';

--- 30 unchanged lines hidden (view full) ---

310 lcp->want_accmap = lcp->cfg.accmap;
311 lcp->his_protocomp = 0;
312 lcp->want_protocomp = IsEnabled(lcp->cfg.protocomp) ? 1 : 0;
313 lcp->want_magic = GenerateMagic();
314
315 if (IsEnabled(lcp->cfg.chap05)) {
316 lcp->want_auth = PROTO_CHAP;
317 lcp->want_authtype = 0x05;
272 lcp->cfg.chap80nt = NEG_ACCEPTED;
273 lcp->cfg.chap80lm = 0;
274 lcp->cfg.chap81 = NEG_ACCEPTED;
275#endif
276 lcp->cfg.lqr = NEG_ACCEPTED;
277 lcp->cfg.pap = NEG_ACCEPTED;
278 lcp->cfg.protocomp = NEG_ENABLED|NEG_ACCEPTED;
279 *lcp->cfg.ident = '\0';

--- 30 unchanged lines hidden (view full) ---

310 lcp->want_accmap = lcp->cfg.accmap;
311 lcp->his_protocomp = 0;
312 lcp->want_protocomp = IsEnabled(lcp->cfg.protocomp) ? 1 : 0;
313 lcp->want_magic = GenerateMagic();
314
315 if (IsEnabled(lcp->cfg.chap05)) {
316 lcp->want_auth = PROTO_CHAP;
317 lcp->want_authtype = 0x05;
318#ifdef HAVE_DES
318#ifndef NODES
319 } else if (IsEnabled(lcp->cfg.chap80nt) ||
320 IsEnabled(lcp->cfg.chap80lm)) {
321 lcp->want_auth = PROTO_CHAP;
322 lcp->want_authtype = 0x80;
323 } else if (IsEnabled(lcp->cfg.chap81)) {
324 lcp->want_auth = PROTO_CHAP;
325 lcp->want_authtype = 0x81;
326#endif

--- 241 unchanged lines hidden (view full) ---

568static int
569LcpLayerUp(struct fsm *fp)
570{
571 /* We're now up */
572 struct physical *p = link2physical(fp->link);
573 struct lcp *lcp = fsm2lcp(fp);
574
575 log_Printf(LogLCP, "%s: LayerUp\n", fp->link->name);
319 } else if (IsEnabled(lcp->cfg.chap80nt) ||
320 IsEnabled(lcp->cfg.chap80lm)) {
321 lcp->want_auth = PROTO_CHAP;
322 lcp->want_authtype = 0x80;
323 } else if (IsEnabled(lcp->cfg.chap81)) {
324 lcp->want_auth = PROTO_CHAP;
325 lcp->want_authtype = 0x81;
326#endif

--- 241 unchanged lines hidden (view full) ---

568static int
569LcpLayerUp(struct fsm *fp)
570{
571 /* We're now up */
572 struct physical *p = link2physical(fp->link);
573 struct lcp *lcp = fsm2lcp(fp);
574
575 log_Printf(LogLCP, "%s: LayerUp\n", fp->link->name);
576 async_SetLinkParams(&p->async, lcp);
576 physical_SetAsyncParams(p, lcp->want_accmap, lcp->his_accmap);
577 lqr_Start(lcp);
578 hdlc_StartTimer(&p->hdlc);
579 fp->more.reqs = fp->more.naks = fp->more.rejs = lcp->cfg.fsm.maxreq * 3;
580
581 lcp_SendIdentification(lcp);
582
583 return 1;
584}

--- 205 unchanged lines hidden (view full) ---

790 memcpy(dec->ackend, cp, length);
791 dec->ackend += length;
792 } else if (IsAccepted(lcp->cfg.chap05)) {
793 *dec->nakend++ = *cp;
794 *dec->nakend++ = 5;
795 *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8);
796 *dec->nakend++ = (unsigned char) PROTO_CHAP;
797 *dec->nakend++ = 0x05;
577 lqr_Start(lcp);
578 hdlc_StartTimer(&p->hdlc);
579 fp->more.reqs = fp->more.naks = fp->more.rejs = lcp->cfg.fsm.maxreq * 3;
580
581 lcp_SendIdentification(lcp);
582
583 return 1;
584}

--- 205 unchanged lines hidden (view full) ---

790 memcpy(dec->ackend, cp, length);
791 dec->ackend += length;
792 } else if (IsAccepted(lcp->cfg.chap05)) {
793 *dec->nakend++ = *cp;
794 *dec->nakend++ = 5;
795 *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8);
796 *dec->nakend++ = (unsigned char) PROTO_CHAP;
797 *dec->nakend++ = 0x05;
798#ifdef HAVE_DES
798#ifndef NODES
799 } else if (IsAccepted(lcp->cfg.chap80nt) ||
800 IsAccepted(lcp->cfg.chap80lm)) {
801 *dec->nakend++ = *cp;
802 *dec->nakend++ = 5;
803 *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8);
804 *dec->nakend++ = (unsigned char) PROTO_CHAP;
805 *dec->nakend++ = 0x80;
806 } else if (IsAccepted(lcp->cfg.chap81)) {

--- 8 unchanged lines hidden (view full) ---

815 break;
816
817 case PROTO_CHAP:
818 if (length != 5) {
819 log_Printf(LogLCP, " Bad length!\n");
820 goto reqreject;
821 }
822 if ((cp[4] == 0x05 && IsAccepted(lcp->cfg.chap05))
799 } else if (IsAccepted(lcp->cfg.chap80nt) ||
800 IsAccepted(lcp->cfg.chap80lm)) {
801 *dec->nakend++ = *cp;
802 *dec->nakend++ = 5;
803 *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8);
804 *dec->nakend++ = (unsigned char) PROTO_CHAP;
805 *dec->nakend++ = 0x80;
806 } else if (IsAccepted(lcp->cfg.chap81)) {

--- 8 unchanged lines hidden (view full) ---

815 break;
816
817 case PROTO_CHAP:
818 if (length != 5) {
819 log_Printf(LogLCP, " Bad length!\n");
820 goto reqreject;
821 }
822 if ((cp[4] == 0x05 && IsAccepted(lcp->cfg.chap05))
823#ifdef HAVE_DES
823#ifndef NODES
824 || (cp[4] == 0x80 && (IsAccepted(lcp->cfg.chap80nt) ||
825 (IsAccepted(lcp->cfg.chap80lm))))
826 || (cp[4] == 0x81 && IsAccepted(lcp->cfg.chap81))
827#endif
828 ) {
829 lcp->his_auth = proto;
830 lcp->his_authtype = cp[4];
831 memcpy(dec->ackend, cp, length);

--- 11 unchanged lines hidden (view full) ---

843 Auth2Nam(PROTO_CHAP, cp[4]));
844
845 if (IsAccepted(lcp->cfg.chap05)) {
846 *dec->nakend++ = *cp;
847 *dec->nakend++ = 5;
848 *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8);
849 *dec->nakend++ = (unsigned char) PROTO_CHAP;
850 *dec->nakend++ = 0x05;
824 || (cp[4] == 0x80 && (IsAccepted(lcp->cfg.chap80nt) ||
825 (IsAccepted(lcp->cfg.chap80lm))))
826 || (cp[4] == 0x81 && IsAccepted(lcp->cfg.chap81))
827#endif
828 ) {
829 lcp->his_auth = proto;
830 lcp->his_authtype = cp[4];
831 memcpy(dec->ackend, cp, length);

--- 11 unchanged lines hidden (view full) ---

843 Auth2Nam(PROTO_CHAP, cp[4]));
844
845 if (IsAccepted(lcp->cfg.chap05)) {
846 *dec->nakend++ = *cp;
847 *dec->nakend++ = 5;
848 *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8);
849 *dec->nakend++ = (unsigned char) PROTO_CHAP;
850 *dec->nakend++ = 0x05;
851#ifdef HAVE_DES
851#ifndef NODES
852 } else if (IsAccepted(lcp->cfg.chap80nt) ||
853 IsAccepted(lcp->cfg.chap80lm)) {
854 *dec->nakend++ = *cp;
855 *dec->nakend++ = 5;
856 *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8);
857 *dec->nakend++ = (unsigned char) PROTO_CHAP;
858 *dec->nakend++ = 0x80;
859 } else if (IsAccepted(lcp->cfg.chap81)) {

--- 31 unchanged lines hidden (view full) ---

891 log_Printf(LogLCP, "Peer will only send PAP (not enabled)\n");
892 lcp->his_reject |= (1 << type);
893 }
894 break;
895 case PROTO_CHAP:
896 if (cp[4] == 0x05 && IsEnabled(lcp->cfg.chap05)) {
897 lcp->want_auth = PROTO_CHAP;
898 lcp->want_authtype = 0x05;
852 } else if (IsAccepted(lcp->cfg.chap80nt) ||
853 IsAccepted(lcp->cfg.chap80lm)) {
854 *dec->nakend++ = *cp;
855 *dec->nakend++ = 5;
856 *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8);
857 *dec->nakend++ = (unsigned char) PROTO_CHAP;
858 *dec->nakend++ = 0x80;
859 } else if (IsAccepted(lcp->cfg.chap81)) {

--- 31 unchanged lines hidden (view full) ---

891 log_Printf(LogLCP, "Peer will only send PAP (not enabled)\n");
892 lcp->his_reject |= (1 << type);
893 }
894 break;
895 case PROTO_CHAP:
896 if (cp[4] == 0x05 && IsEnabled(lcp->cfg.chap05)) {
897 lcp->want_auth = PROTO_CHAP;
898 lcp->want_authtype = 0x05;
899#ifdef HAVE_DES
899#ifndef NODES
900 } else if (cp[4] == 0x80 && (IsEnabled(lcp->cfg.chap80nt) ||
901 IsEnabled(lcp->cfg.chap80lm))) {
902 lcp->want_auth = PROTO_CHAP;
903 lcp->want_authtype = 0x80;
904 } else if (cp[4] == 0x81 && IsEnabled(lcp->cfg.chap81)) {
905 lcp->want_auth = PROTO_CHAP;
906 lcp->want_authtype = 0x81;
907#endif

--- 4 unchanged lines hidden (view full) ---

912 " without DES)\n");
913 } else if (cp[4] == 0x81) {
914 log_Printf(LogLCP, "Peer will only send MSCHAPV2 (not available"
915 " without DES)\n");
916 } else
917#endif
918 log_Printf(LogLCP, "Peer will only send %s (not %s)\n",
919 Auth2Nam(PROTO_CHAP, cp[4]),
900 } else if (cp[4] == 0x80 && (IsEnabled(lcp->cfg.chap80nt) ||
901 IsEnabled(lcp->cfg.chap80lm))) {
902 lcp->want_auth = PROTO_CHAP;
903 lcp->want_authtype = 0x80;
904 } else if (cp[4] == 0x81 && IsEnabled(lcp->cfg.chap81)) {
905 lcp->want_auth = PROTO_CHAP;
906 lcp->want_authtype = 0x81;
907#endif

--- 4 unchanged lines hidden (view full) ---

912 " without DES)\n");
913 } else if (cp[4] == 0x81) {
914 log_Printf(LogLCP, "Peer will only send MSCHAPV2 (not available"
915 " without DES)\n");
916 } else
917#endif
918 log_Printf(LogLCP, "Peer will only send %s (not %s)\n",
919 Auth2Nam(PROTO_CHAP, cp[4]),
920#ifdef HAVE_DES
920#ifndef NODES
921 (cp[4] == 0x80 || cp[4] == 0x81) ? "configured" :
922#endif
923 "supported");
924 lcp->his_reject |= (1 << type);
925 }
926 break;
927 default:
928 /* We've been NAK'd with something we don't understand :-( */

--- 385 unchanged lines hidden ---
921 (cp[4] == 0x80 || cp[4] == 0x81) ? "configured" :
922#endif
923 "supported");
924 lcp->his_reject |= (1 << type);
925 }
926 break;
927 default:
928 /* We've been NAK'd with something we don't understand :-( */

--- 385 unchanged lines hidden ---