--- embedaddon/mpd/src/lcp.c 2016/11/01 09:56:12 1.1.1.2 +++ embedaddon/mpd/src/lcp.c 2021/03/17 00:39:23 1.1.1.3 @@ -100,7 +100,7 @@ { "MULTILINKHEADERFMT", TY_MULTILINKHEADERFMT, 0, 0, FALSE }, { "INTERNAT", TY_INTERNAT, 0, 0, FALSE }, { "SDATALINKSONET", TY_SDATALINKSONET, 0, 0, FALSE }, - { NULL } + { NULL, 0, 0, 0, 0 } }; static struct fsmtype gLcpFsmType = { @@ -126,6 +126,7 @@ NULL, NULL, LcpRecvIdent, + NULL, NULL, NULL }; /* List of possible Authentication Protocols */ @@ -224,6 +225,7 @@ LcpConfigure(Fsm fp) lcp->fsm.conf.check_magic = Enabled(&l->conf.options, LINK_CONF_CHECK_MAGIC); lcp->peer_reject = 0; + lcp->need_reset = 0; /* Initialize normal LCP stuff */ lcp->peer_mru = PhysGetMtu(l, 1); @@ -526,12 +528,16 @@ LcpAuthResult(Link l, int success) */ int -LcpStat(Context ctx, int ac, char *av[], void *arg) +LcpStat(Context ctx, int ac, const char *const av[], const void *arg) { Link const l = ctx->lnk; LcpState const lcp = &l->lcp; char buf[64]; + (void)ac; + (void)av; + (void)arg; + Printf("%s [%s]\r\n", lcp->fsm.type->name, FsmStateName(lcp->fsm.state)); Printf("Self:\r\n"); @@ -681,7 +687,11 @@ static void LcpLayerDown(Fsm fp) { Link l = (Link)fp->arg; + LcpState const lcp = &l->lcp; + LcpStopActivity(l); + if (lcp->phase == PHASE_AUTHENTICATE || lcp->phase == PHASE_NETWORK) + lcp->need_reset = 1; } void LcpOpen(Link l) @@ -711,10 +721,12 @@ void LcpDown(Link l) static int LcpRecvProtoRej(Fsm fp, int proto, Mbuf bp) { - Link l = (Link)fp->arg; + Link l = (Link)fp->arg; int fatal = FALSE; Fsm rej = NULL; + (void)bp; + /* Which protocol? */ switch (proto) { case PROTO_CCP: @@ -749,7 +761,7 @@ static void LcpRecvIdent(Fsm fp, Mbuf bp) { Link l = (Link)fp->arg; - int len, clen; + unsigned len, clen; if (bp == NULL) return; @@ -793,6 +805,9 @@ LcpDecodeConfig(Fsm fp, FsmOption list, int num, int m /* If we have got request, forget the previous values */ if (mode == MODE_REQ) { + if (lcp->need_reset) /* perform complete reset when going back */ + LcpConfigure(fp); /* from PHASE_AUTHENTICATE or PHASE_NETWORK */ + else { lcp->peer_mru = PhysGetMtu(l, 1); lcp->peer_accmap = 0xffffffff; lcp->peer_acfcomp = FALSE; @@ -802,6 +817,7 @@ LcpDecodeConfig(Fsm fp, FsmOption list, int num, int m lcp->peer_alg = 0; lcp->peer_mrru = 0; lcp->peer_shortseq = FALSE; + } } /* Decode each config option */ @@ -1245,29 +1261,29 @@ LcpInput(Link l, Mbuf bp) static const struct fsmoption * LcpAuthProtoNak(ushort proto, u_char alg) { - static const u_char chapmd5cf[] = + static u_char chapmd5cf[] = { PROTO_CHAP >> 8, PROTO_CHAP & 0xff, CHAP_ALG_MD5 }; static const struct fsmoption chapmd5Nak = { TY_AUTHPROTO, 2 + sizeof(chapmd5cf), (u_char *) chapmd5cf }; - static const u_char chapmsv1cf[] = + static u_char chapmsv1cf[] = { PROTO_CHAP >> 8, PROTO_CHAP & 0xff, CHAP_ALG_MSOFT }; static const struct fsmoption chapmsv1Nak = { TY_AUTHPROTO, 2 + sizeof(chapmsv1cf), (u_char *) chapmsv1cf }; - static const u_char chapmsv2cf[] = + static u_char chapmsv2cf[] = { PROTO_CHAP >> 8, PROTO_CHAP & 0xff, CHAP_ALG_MSOFTv2 }; - static const struct fsmoption chapmsv2Nak = + static struct fsmoption chapmsv2Nak = { TY_AUTHPROTO, 2 + sizeof(chapmsv2cf), (u_char *) chapmsv2cf }; - static const u_char papcf[] = + static u_char papcf[] = { PROTO_PAP >> 8, PROTO_PAP & 0xff }; - static const struct fsmoption papNak = + static struct fsmoption papNak = { TY_AUTHPROTO, 2 + sizeof(papcf), (u_char *) papcf }; - static const u_char eapcf[] = + static u_char eapcf[] = { PROTO_EAP >> 8, PROTO_EAP & 0xff }; - static const struct fsmoption eapNak = + static struct fsmoption eapNak = { TY_AUTHPROTO, 2 + sizeof(eapcf), (u_char *) eapcf }; if (proto == PROTO_PAP) {