Exemple #1
0
void
physical_SetupStack(struct physical *p, const char *who, int how)
{
  link_EmptyStack(&p->link);
  if (how == PHYSICAL_FORCE_SYNC || how == PHYSICAL_FORCE_SYNCNOACF ||
      (how == PHYSICAL_NOFORCE && physical_IsSync(p)))
    link_Stack(&p->link, &synclayer);
  else {
    link_Stack(&p->link, &asynclayer);
    link_Stack(&p->link, &hdlclayer);
  }
  if (how != PHYSICAL_FORCE_SYNCNOACF)
    link_Stack(&p->link, &acflayer);
  link_Stack(&p->link, &protolayer);
  link_Stack(&p->link, &lqrlayer);
  link_Stack(&p->link, &ccplayer);
  link_Stack(&p->link, &vjlayer);
  link_Stack(&p->link, &tcpmsslayer);
#ifndef NONAT
  link_Stack(&p->link, &natlayer);
#endif
  if (how == PHYSICAL_FORCE_ASYNC && physical_IsSync(p)) {
    log_Printf(LogWARN, "Sync device setting ignored for ``%s'' device\n", who);
    p->cfg.speed = MODEM_SPEED;
  } else if (how == PHYSICAL_FORCE_SYNC && !physical_IsSync(p)) {
    log_Printf(LogWARN, "Async device setting ignored for ``%s'' device\n",
               who);
    physical_SetSync(p);
  }
}
VOS_VOID link_Init(struct link *l)
{
    l->phase = PHASE_DEAD;
    l->type = PHYSICAL_LINK;
    l->name = VOS_NULL;
    l->len = sizeof(*l);

    /* The sample period is fixed - see physical2iov() & iov2physical() */
    throughput_init(&l->stats.total, SAMPLE_PERIOD);

    #if 0/*fanzhibin f49086 delete it*/
    p->link.stats.parent = dl->bundle->ncp.mp.active ?
    &dl->bundle->ncp.mp.link.stats.total : VOS_NULL_PTR;
    #endif

    l->stats.gather = 1;
    l->DropedPacketFromGgsn = 0;

    PS_MEM_SET(l->Queue, '\0', sizeof l->Queue);
    PS_MEM_SET(l->proto_in, '\0', sizeof l->proto_in);
    PS_MEM_SET(l->proto_out, '\0', sizeof l->proto_out);
    link_EmptyStack(l);

    /*依次压入PPP协议的各个处理层*/
    #if (PPP_FEATURE == PPP_FEATURE_PPP)
    link_Stack(l, &asynclayer);
    link_Stack(l, &hdlclayer);
    link_Stack(l, &acflayer);
    #endif

    link_Stack(l, &protolayer);

    async_Init(&(l->async));
    hdlc_Init(&(l->hdlc),&(l->lcp));

    /*参数const struct fsm_parent * parent不能为空*/
    lcp_Init(&(l->lcp), l, &parent);
    ipcp_Init(&(l->ipcp), l, &parent);
    pap_Init(&(l->pap));
    chap_Init(&(l->chap));
}