⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 message.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 5 页
字号:
  return (ncci);}static void ncci_free_receive_buffers (PLCI   *plci, word ncci){  DIVA_CAPI_ADAPTER   *a;  APPL   *appl;  word i, ncci_code;  dword Id;  a = plci->adapter;  Id = (((dword) ncci) << 16) | (((word)(plci->Id)) << 8) | a->Id;  if (ncci)  {    if (a->ncci_plci[ncci] == plci->Id)    {      if (!plci->appl)      {        ncci_mapping_bug++;        dbug(1,dprintf("NCCI mapping appl expected %ld %08lx",          ncci_mapping_bug, Id));      }      else      {        appl = plci->appl;        ncci_code = ncci | (((word) a->Id) << 8);        for (i = 0; i < appl->MaxBuffer; i++)        {          if ((appl->DataNCCI[i] == ncci_code)           && (((byte)(appl->DataFlags[i] >> 8)) == plci->Id))          {            appl->DataNCCI[i] = 0;          }        }      }    }  }  else  {    for (ncci = 1; ncci < MAX_NCCI+1; ncci++)    {      if (a->ncci_plci[ncci] == plci->Id)      {        if (!plci->appl)        {          ncci_mapping_bug++;          dbug(1,dprintf("NCCI mapping no appl %ld %08lx",            ncci_mapping_bug, Id));        }        else        {          appl = plci->appl;          ncci_code = ncci | (((word) a->Id) << 8);          for (i = 0; i < appl->MaxBuffer; i++)          {            if ((appl->DataNCCI[i] == ncci_code)             && (((byte)(appl->DataFlags[i] >> 8)) == plci->Id))            {              appl->DataNCCI[i] = 0;            }          }        }      }    }  }}static void cleanup_ncci_data (PLCI   *plci, word ncci){  NCCI   *ncci_ptr;  if (ncci && (plci->adapter->ncci_plci[ncci] == plci->Id))  {    ncci_ptr = &(plci->adapter->ncci[ncci]);    if (plci->appl)    {      while (ncci_ptr->data_pending != 0)      {        if (!plci->data_sent || (ncci_ptr->DBuffer[ncci_ptr->data_out].P != plci->data_sent_ptr))          TransmitBufferFree (plci->appl, ncci_ptr->DBuffer[ncci_ptr->data_out].P);        (ncci_ptr->data_out)++;        if (ncci_ptr->data_out == MAX_DATA_B3)          ncci_ptr->data_out = 0;        (ncci_ptr->data_pending)--;      }    }    ncci_ptr->data_out = 0;    ncci_ptr->data_pending = 0;    ncci_ptr->data_ack_out = 0;    ncci_ptr->data_ack_pending = 0;  }}static void ncci_remove (PLCI   *plci, word ncci, byte preserve_ncci){  DIVA_CAPI_ADAPTER   *a;  dword Id;  word i;  a = plci->adapter;  Id = (((dword) ncci) << 16) | (((word)(plci->Id)) << 8) | a->Id;  if (!preserve_ncci)    ncci_free_receive_buffers (plci, ncci);  if (ncci)  {    if (a->ncci_plci[ncci] != plci->Id)    {      ncci_mapping_bug++;      dbug(1,dprintf("NCCI mapping doesn't exist %ld %08lx %02x",        ncci_mapping_bug, Id, preserve_ncci));    }    else    {      cleanup_ncci_data (plci, ncci);      dbug(1,dprintf("NCCI mapping released %ld %08lx %02x %02x-%02x",        ncci_mapping_bug, Id, preserve_ncci, a->ncci_ch[ncci], ncci));      a->ch_ncci[a->ncci_ch[ncci]] = 0;      if (!preserve_ncci)      {        a->ncci_ch[ncci] = 0;        a->ncci_plci[ncci] = 0;        a->ncci_state[ncci] = IDLE;        i = plci->ncci_ring_list;        while ((i != 0) && (a->ncci_next[i] != plci->ncci_ring_list) && (a->ncci_next[i] != ncci))          i = a->ncci_next[i];        if ((i != 0) && (a->ncci_next[i] == ncci))        {          if (i == ncci)            plci->ncci_ring_list = 0;          else if (plci->ncci_ring_list == ncci)            plci->ncci_ring_list = i;          a->ncci_next[i] = a->ncci_next[ncci];        }        a->ncci_next[ncci] = 0;      }    }  }  else  {    for (ncci = 1; ncci < MAX_NCCI+1; ncci++)    {      if (a->ncci_plci[ncci] == plci->Id)      {        cleanup_ncci_data (plci, ncci);        dbug(1,dprintf("NCCI mapping released %ld %08lx %02x %02x-%02x",          ncci_mapping_bug, Id, preserve_ncci, a->ncci_ch[ncci], ncci));        a->ch_ncci[a->ncci_ch[ncci]] = 0;        if (!preserve_ncci)        {          a->ncci_ch[ncci] = 0;          a->ncci_plci[ncci] = 0;          a->ncci_state[ncci] = IDLE;          a->ncci_next[ncci] = 0;        }      }    }    if (!preserve_ncci)      plci->ncci_ring_list = 0;  }}/*------------------------------------------------------------------*//* PLCI remove function                                             *//*------------------------------------------------------------------*/static void plci_free_msg_in_queue (PLCI   *plci){  word i;  if (plci->appl)  {    i = plci->msg_in_read_pos;    while (i != plci->msg_in_write_pos)    {      if (i == plci->msg_in_wrap_pos)        i = 0;      if (((CAPI_MSG   *)(&((byte   *)(plci->msg_in_queue))[i]))->header.command == _DATA_B3_R)      {        TransmitBufferFree (plci->appl,          (byte   *)(((CAPI_MSG   *)(&((byte   *)(plci->msg_in_queue))[i]))->info.data_b3_req.Data));      }      i += (((CAPI_MSG   *)(&((byte   *)(plci->msg_in_queue))[i]))->header.length +        MSG_IN_OVERHEAD + 3) & 0xfffc;    }  }  plci->msg_in_write_pos = MSG_IN_QUEUE_SIZE;  plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE;  plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE;}static void plci_remove(PLCI   * plci){  if(!plci) {    dbug(1,dprintf("plci_remove(no plci)"));    return;  }  init_internal_command_queue (plci);  dbug(1,dprintf("plci_remove(%x,tel=%x)",plci->Id,plci->tel));  if(plci_remove_check(plci))  {    return;  }  if (plci->Sig.Id == 0xff)  {    dbug(1,dprintf("D-channel X.25 plci->NL.Id:%0x", plci->NL.Id));    if (plci->NL.Id && !plci->nl_remove_id)    {      nl_req_ncci(plci,REMOVE,0);      send_req(plci);    }  }  else  {    if (!plci->sig_remove_id     && (plci->Sig.Id      || (plci->req_in!=plci->req_out)      || (plci->nl_req || plci->sig_req)))    {      sig_req(plci,HANGUP,0);      send_req(plci);    }  }  ncci_remove (plci, 0, FALSE);  plci_free_msg_in_queue (plci);  plci->channels = 0;  plci->appl = NULL;  if ((plci->State == INC_CON_PENDING) || (plci->State == INC_CON_ALERT))    plci->State = OUTG_DIS_PENDING;}/*------------------------------------------------------------------*//* Application Group function helpers                               *//*------------------------------------------------------------------*/static void set_group_ind_mask (PLCI   *plci){  word i;  for (i = 0; i < C_IND_MASK_DWORDS; i++)    plci->group_optimization_mask_table[i] = 0xffffffffL;}static void clear_group_ind_mask_bit (PLCI   *plci, word b){  plci->group_optimization_mask_table[b >> 5] &= ~(1L << (b & 0x1f));}static byte test_group_ind_mask_bit (PLCI   *plci, word b){  return ((plci->group_optimization_mask_table[b >> 5] & (1L << (b & 0x1f))) != 0);}/*------------------------------------------------------------------*//* c_ind_mask operations for arbitrary MAX_APPL                     *//*------------------------------------------------------------------*/static void clear_c_ind_mask (PLCI   *plci){  word i;  for (i = 0; i < C_IND_MASK_DWORDS; i++)    plci->c_ind_mask_table[i] = 0;}static byte c_ind_mask_empty (PLCI   *plci){  word i;  i = 0;  while ((i < C_IND_MASK_DWORDS) && (plci->c_ind_mask_table[i] == 0))    i++;  return (i == C_IND_MASK_DWORDS);}static void set_c_ind_mask_bit (PLCI   *plci, word b){  plci->c_ind_mask_table[b >> 5] |= (1L << (b & 0x1f));}static void clear_c_ind_mask_bit (PLCI   *plci, word b){  plci->c_ind_mask_table[b >> 5] &= ~(1L << (b & 0x1f));}static byte test_c_ind_mask_bit (PLCI   *plci, word b){  return ((plci->c_ind_mask_table[b >> 5] & (1L << (b & 0x1f))) != 0);}static void dump_c_ind_mask (PLCI   *plci){static char hex_digit_table[0x10] =  {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};  word i, j, k;  dword d;    char *p;    char buf[40];  for (i = 0; i < C_IND_MASK_DWORDS; i += 4)  {    p = buf + 36;    *p = '\0';    for (j = 0; j < 4; j++)    {      if (i+j < C_IND_MASK_DWORDS)      {        d = plci->c_ind_mask_table[i+j];        for (k = 0; k < 8; k++)        {          *(--p) = hex_digit_table[d & 0xf];          d >>= 4;        }      }      else if (i != 0)      {        for (k = 0; k < 8; k++)          *(--p) = ' ';      }      *(--p) = ' ';    }    dbug(1,dprintf ("c_ind_mask =%s", (char   *) p));  }}#define dump_plcis(a)/*------------------------------------------------------------------*//* translation function for each message                            *//*------------------------------------------------------------------*/byte connect_req(dword Id, word Number, DIVA_CAPI_ADAPTER   * a, PLCI   * plci, APPL   * appl, API_PARSE * parms){  word ch;  word i;  word Info;  word CIP;  byte LinkLayer;  API_PARSE * ai;  API_PARSE * bp;    API_PARSE ai_parms[5];  word channel = 0;  dword ch_mask;  byte m;  static byte esc_chi[35] = {0x02,0x18,0x01};  static byte lli[2] = {0x01,0x00};  byte noCh = 0;  word dir = 0;  byte   *p_chi = "";  for(i=0;i<5;i++) ai_parms[i].length = 0;  dbug(1,dprintf("connect_req(%d)",parms->length));  Info = _WRONG_IDENTIFIER;  if(a)  {    if(a->adapter_disabled)    {      dbug(1,dprintf("adapter disabled"));      Id = ((word)1<<8)|a->Id;      sendf(appl,_CONNECT_R|CONFIRM,Id,Number,"w",0);      sendf(appl, _DISCONNECT_I, Id, 0, "w", _L1_ERROR);      return FALSE;    }    Info = _OUT_OF_PLCI;    if((i=get_plci(a)))    {      Info = 0;      plci = &a->plci[i-1];      plci->appl = appl;      plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE;      /* check 'external controller' bit for codec support */      if(Id & EXT_CONTROLLER)      {        if(AdvCodecSupport(a, plci, appl, 0) )        {          plci->Id = 0;          sendf(appl, _CONNECT_R|CONFIRM, Id, Number, "w", _WRONG_IDENTIFIER);          return 2;        }      }      ai = &parms[9];      bp = &parms[5];      ch = 0;      if(bp->length)LinkLayer = bp->info[3];      else LinkLayer = 0;      if(ai->length)      {        ch=0xffff;        if(!api_parse(&ai->info[1],(word)ai->length,"ssss",ai_parms))        {          ch = 0;          if(ai_parms[0].length)          {            ch = GET_WORD(ai_parms[0].info+1);            if(ch>4) ch=0; /* safety -> ignore ChannelID */            if(ch==4) /* explizit CHI in message */            {              /* check length of B-CH struct */              if((ai_parms[0].info)[3]>=1)              {                if((ai_parms[0].info)[4]==CHI)                {                  p_chi = &((ai_parms[0].info)[5]);                }                else                {                  p_chi = &((ai_parms[0].info)[3]);                }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -