Diff for /embedaddon/mpd/src/lcp.c between versions 1.1 and 1.1.1.3.2.1

version 1.1, 2012/02/21 23:32:47 version 1.1.1.3.2.1, 2023/09/27 11:08:00
Line 26 Line 26
   
   #define LCP_ECHO_INTERVAL     5       /* Enable keep alive by default */    #define LCP_ECHO_INTERVAL     5       /* Enable keep alive by default */
   #define LCP_ECHO_TIMEOUT      40    #define LCP_ECHO_TIMEOUT      40
     #define LCP_MAX_RESETS        3
   
   #define LCP_KNOWN_CODES       (   (1 << CODE_CONFIGREQ)       \    #define LCP_KNOWN_CODES       (   (1 << CODE_CONFIGREQ)       \
                                   | (1 << CODE_CONFIGACK)       \                                    | (1 << CODE_CONFIGACK)       \
Line 100 Line 101
     { "MULTILINKHEADERFMT", TY_MULTILINKHEADERFMT, 0, 0, FALSE },      { "MULTILINKHEADERFMT", TY_MULTILINKHEADERFMT, 0, 0, FALSE },
     { "INTERNAT", TY_INTERNAT, 0, 0, FALSE },      { "INTERNAT", TY_INTERNAT, 0, 0, FALSE },
     { "SDATALINKSONET", TY_SDATALINKSONET, 0, 0, FALSE },      { "SDATALINKSONET", TY_SDATALINKSONET, 0, 0, FALSE },
    { NULL }    { NULL, 0, 0, 0, 0 }
   };    };
   
   static struct fsmtype gLcpFsmType = {    static struct fsmtype gLcpFsmType = {
Line 126 Line 127
     NULL,      NULL,
     NULL,      NULL,
     LcpRecvIdent,      LcpRecvIdent,
       NULL, NULL, NULL
   };    };
   
   /* List of possible Authentication Protocols */    /* List of possible Authentication Protocols */
Line 179  LcpInit(Link l) Line 181  LcpInit(Link l)
   FsmInit(&lcp->fsm, &gLcpFsmType, l);    FsmInit(&lcp->fsm, &gLcpFsmType, l);
   lcp->fsm.conf.echo_int = LCP_ECHO_INTERVAL;    lcp->fsm.conf.echo_int = LCP_ECHO_INTERVAL;
   lcp->fsm.conf.echo_max = LCP_ECHO_TIMEOUT;    lcp->fsm.conf.echo_max = LCP_ECHO_TIMEOUT;
     lcp->resets = LCP_MAX_RESETS;
   lcp->phase = PHASE_DEAD;    lcp->phase = PHASE_DEAD;
       
   AuthInit(l);    AuthInit(l);
Line 224  LcpConfigure(Fsm fp) Line 227  LcpConfigure(Fsm fp)
     lcp->fsm.conf.check_magic =      lcp->fsm.conf.check_magic =
         Enabled(&l->conf.options, LINK_CONF_CHECK_MAGIC);          Enabled(&l->conf.options, LINK_CONF_CHECK_MAGIC);
     lcp->peer_reject = 0;      lcp->peer_reject = 0;
       lcp->need_reset = 0;
   
     /* Initialize normal LCP stuff */      /* Initialize normal LCP stuff */
    lcp->peer_mru = l->conf.mtu;    lcp->peer_mru = PhysGetMtu(l, 1);
    lcp->want_mru = l->conf.mru;    lcp->want_mru = PhysGetMru(l, 1);
    if (l->type && (lcp->want_mru > l->type->mru))    if (l->type && (lcp->want_mru > PhysGetMru(l, 0)))
        lcp->want_mru = l->type->mru;        lcp->want_mru = PhysGetMru(l, 0);
     lcp->peer_accmap = 0xffffffff;      lcp->peer_accmap = 0xffffffff;
     lcp->want_accmap = l->conf.accmap;      lcp->want_accmap = l->conf.accmap;
     lcp->peer_acfcomp = FALSE;      lcp->peer_acfcomp = FALSE;
Line 526  LcpAuthResult(Link l, int success) Line 530  LcpAuthResult(Link l, int success)
  */   */
   
 int  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;      Link        const l = ctx->lnk;
     LcpState    const lcp = &l->lcp;      LcpState    const lcp = &l->lcp;
     char        buf[64];      char        buf[64];
   
       (void)ac;
       (void)av;
       (void)arg;
   
     Printf("%s [%s]\r\n", lcp->fsm.type->name, FsmStateName(lcp->fsm.state));      Printf("%s [%s]\r\n", lcp->fsm.type->name, FsmStateName(lcp->fsm.state));
   
     Printf("Self:\r\n");      Printf("Self:\r\n");
Line 681  static void Line 689  static void
 LcpLayerDown(Fsm fp)  LcpLayerDown(Fsm fp)
 {  {
     Link        l = (Link)fp->arg;      Link        l = (Link)fp->arg;
       LcpState    const lcp = &l->lcp;
   
     LcpStopActivity(l);      LcpStopActivity(l);
       if (lcp->phase == PHASE_AUTHENTICATE || lcp->phase == PHASE_NETWORK) {
         lcp->need_reset = 1;
         if (lcp->resets > 0) {
           Log(LG_LCP2, ("[%s] LCP: Reset (%u left)", l->name, (int)lcp->resets));
           lcp->resets--;
         } else {
           Log(LG_LCP2, ("[%s] LCP: Too many resets", l->name));
           FsmFailure(&lcp->fsm, FAIL_NEGOT_FAILURE);
           lcp->resets = LCP_MAX_RESETS;
         }
       }
 }  }
   
 void LcpOpen(Link l)  void LcpOpen(Link l)
Line 711  void LcpDown(Link l) Line 732  void LcpDown(Link l)
 static int  static int
 LcpRecvProtoRej(Fsm fp, int proto, Mbuf bp)  LcpRecvProtoRej(Fsm fp, int proto, Mbuf bp)
 {  {
    Link        l = (Link)fp->arg;  Link  l = (Link)fp->arg;
   int   fatal = FALSE;    int   fatal = FALSE;
   Fsm   rej = NULL;    Fsm   rej = NULL;
   
     (void)bp;
   
   /* Which protocol? */    /* Which protocol? */
   switch (proto) {    switch (proto) {
     case PROTO_CCP:      case PROTO_CCP:
Line 749  static void Line 772  static void
 LcpRecvIdent(Fsm fp, Mbuf bp)  LcpRecvIdent(Fsm fp, Mbuf bp)
 {  {
     Link        l = (Link)fp->arg;      Link        l = (Link)fp->arg;
    int         len, clen;    unsigned        len, clen;
   
     if (bp == NULL)      if (bp == NULL)
         return;          return;
Line 793  LcpDecodeConfig(Fsm fp, FsmOption list, int num, int m Line 816  LcpDecodeConfig(Fsm fp, FsmOption list, int num, int m
   
     /* If we have got request, forget the previous values */      /* If we have got request, forget the previous values */
     if (mode == MODE_REQ) {      if (mode == MODE_REQ) {
        lcp->peer_mru = l->conf.mtu;      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_accmap = 0xffffffff;
         lcp->peer_acfcomp = FALSE;          lcp->peer_acfcomp = FALSE;
         lcp->peer_protocomp = FALSE;          lcp->peer_protocomp = FALSE;
Line 802  LcpDecodeConfig(Fsm fp, FsmOption list, int num, int m Line 828  LcpDecodeConfig(Fsm fp, FsmOption list, int num, int m
         lcp->peer_alg = 0;          lcp->peer_alg = 0;
         lcp->peer_mrru = 0;          lcp->peer_mrru = 0;
         lcp->peer_shortseq = FALSE;          lcp->peer_shortseq = FALSE;
         }
     }      }
   
   /* Decode each config option */    /* Decode each config option */
Line 1127  LcpDecodeConfig(Fsm fp, FsmOption list, int num, int m Line 1154  LcpDecodeConfig(Fsm fp, FsmOption list, int num, int m
   
           memcpy(&magic, opt->data, 4);            memcpy(&magic, opt->data, 4);
           magic = ntohl(magic);            magic = ntohl(magic);
          Log(LG_LCP, ("[%s]   %s %08x", l->name, oi->name, magic));          Log(LG_LCP, ("[%s]   %s 0x%08x", l->name, oi->name, magic));
           switch (mode) {            switch (mode) {
             case MODE_REQ:              case MODE_REQ:
               if (lcp->want_magic) {                if (lcp->want_magic) {
Line 1245  LcpInput(Link l, Mbuf bp) Line 1272  LcpInput(Link l, Mbuf bp)
 static const struct fsmoption *  static const struct fsmoption *
 LcpAuthProtoNak(ushort proto, u_char alg)  LcpAuthProtoNak(ushort proto, u_char alg)
 {  {
  static const u_char chapmd5cf[] =  static u_char  chapmd5cf[] =
     { PROTO_CHAP >> 8, PROTO_CHAP & 0xff, CHAP_ALG_MD5 };      { PROTO_CHAP >> 8, PROTO_CHAP & 0xff, CHAP_ALG_MD5 };
   static const struct   fsmoption chapmd5Nak =    static const struct   fsmoption chapmd5Nak =
     { TY_AUTHPROTO, 2 + sizeof(chapmd5cf), (u_char *) chapmd5cf };      { 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 };      { PROTO_CHAP >> 8, PROTO_CHAP & 0xff, CHAP_ALG_MSOFT };
   static const struct   fsmoption chapmsv1Nak =    static const struct   fsmoption chapmsv1Nak =
     { TY_AUTHPROTO, 2 + sizeof(chapmsv1cf), (u_char *) chapmsv1cf };      { 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 };      { 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 };      { TY_AUTHPROTO, 2 + sizeof(chapmsv2cf), (u_char *) chapmsv2cf };
   
  static const u_char papcf[] =  static u_char  papcf[] =
     { PROTO_PAP >> 8, PROTO_PAP & 0xff };      { PROTO_PAP >> 8, PROTO_PAP & 0xff };
  static const struct fsmoption papNak =  static struct  fsmoption papNak =
     { TY_AUTHPROTO, 2 + sizeof(papcf), (u_char *) papcf };      { TY_AUTHPROTO, 2 + sizeof(papcf), (u_char *) papcf };
   
  static const u_char eapcf[] =  static u_char  eapcf[] =
     { PROTO_EAP >> 8, PROTO_EAP & 0xff };      { PROTO_EAP >> 8, PROTO_EAP & 0xff };
  static const struct fsmoption eapNak =  static struct  fsmoption eapNak =
     { TY_AUTHPROTO, 2 + sizeof(eapcf), (u_char *) eapcf };      { TY_AUTHPROTO, 2 + sizeof(eapcf), (u_char *) eapcf };
   
   if (proto == PROTO_PAP) {    if (proto == PROTO_PAP) {

Removed from v.1.1  
changed lines
  Added in v.1.1.1.3.2.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>