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

📄 ma_acc1.c

📁 gsm map协议源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
   switch(*spId)
   {
      case MA_ACC_SAP_0:

         *spId = MA_ACC_SAP_1;
         break;

      case MA_ACC_SAP_1:

         *spId = MA_ACC_SAP_0;
         break;

      case MA_ACC_SAP_2:

         *spId = MA_ACC_SAP_3;
         break;

      case MA_ACC_SAP_3:

         *spId = MA_ACC_SAP_2;
         break;

      case MA_ACC_SAP_4:

         *spId = MA_ACC_SAP_5;
         break;

      case MA_ACC_SAP_5:

         *spId = MA_ACC_SAP_4;
         break;

      case MA_ACC_SAP_6:

         *spId = MA_ACC_SAP_7;
         break;

      case MA_ACC_SAP_7:

         *spId = MA_ACC_SAP_6;
         break;

      default:

         RETVALUE(RFAILED);
   }

   RETVALUE(ROK);
} /* End of maAccSwapSpId */



/*
*
*       Fun:   maAccPopCmpQ
*
*       Desc:  Remove a component event form the component queue
*
*       Ret:   ROK     - operation was successful
*              RFAILED - queue is empty
*
*       Notes: This function is used by the layer 4 to remove a component
*              request primitive from the queue.
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC  S16 maAccPopCmpQ
(
MaAccCmpQElm  **cmpElm,       /* queued component to be returned */
U16             idx           /* Index in the dialogue Cp list */
)
#else
PUBLIC  S16 maAccPopCmpQ(cmpElm, idx)
MaAccCmpQElm  **cmpElm;       /* queued component to be returned */
U16             idx;          /* Index in the dialogue Cp list */
#endif
{

   TRC2(maAccPopCmpQ)

   /* Check If queue is EMPTY */
   if (maAccCb.dlgCp[idx].cmpQ.rdPtr == maAccCb.dlgCp[idx].cmpQ.wrPtr)
   {
      *cmpElm = NULLP;
      RETVALUE(RFAILED);
   }
   
   *cmpElm = &maAccCb.dlgCp[idx].cmpQ.q[maAccCb.dlgCp[idx].cmpQ.rdPtr];

   /* Increment the read pointer to the next location */
   maAccCb.dlgCp[idx].cmpQ.rdPtr++;

   if (maAccCb.dlgCp[idx].cmpQ.rdPtr == (U16)MA_ACC_CMP_QSIZE)
   {
      maAccCb.dlgCp[idx].cmpQ.rdPtr = 0;
   }

   RETVALUE(ROK);
} /* maAccPopCmpQ */




/*
*
*       Fun:   maAccPushCmpQ
*
*       Desc:  Inserts a component event at the back of the component queue
*
*       Ret:   ROK     - operation was successful
*              RFAILED - queue is full
*
*       Notes: None
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC S16 maAccPushCmpQ
(
StComps       *compEv,        /* Component event */
Buffer        *cpBuf,         /* parameters buffer */
U16            idx            /* Index in the dialogue cp list */
)
#else
PUBLIC S16 maAccPushCmpQ(compEv, cpBuf, idx)
StComps       *compEv;        /* Component event */
Buffer        *cpBuf;         /* parameters buffer */
U16            idx;           /* Index in the dialogue cp list */
#endif
{
   U16            oldPtr;     /* saved pointer value */ 

   TRC2(maAccPushCmpQ)

   /* save the old pointer */
   oldPtr = maAccCb.dlgCp[idx].cmpQ.wrPtr;

   /* increment the write pointer */
   maAccCb.dlgCp[idx].cmpQ.wrPtr++;

   if (maAccCb.dlgCp[idx].cmpQ.wrPtr == (U16)MA_ACC_MSG_QSIZE)
   {
      maAccCb.dlgCp[idx].cmpQ.wrPtr = 0;
   }

   /* Check if the queue if FULL */
   if (maAccCb.dlgCp[idx].cmpQ.wrPtr == maAccCb.dlgCp[idx].cmpQ.rdPtr)
   {
      maAccCb.dlgCp[idx].cmpQ.wrPtr = oldPtr;

      AULOGERROR(ERRCLS_DEBUG, EAU100, (ErrVal)maAccCb.curTst.id,
                 "maAccPushCmpQ(): Queue is full");

      RETVALUE(RFAILED);
   }

   /* queue the passed element */
   cmCpy(compEv, &maAccCb.dlgCp[idx].cmpQ.q[oldPtr].compEv, sizeof(StComps));
   maAccCb.dlgCp[idx].cmpQ.q[oldPtr].cpBuf=cpBuf;
   
   RETVALUE(ROK);
} /* maAccPushCmpQ */



/*
*
*       Fun:   maAccExamCmpQ
*
*       Desc:  Examine the Component at the front of the Queue
*
*       Ret:   ROK     - operation was successful
*              RFAILED - queue is empty
*
*       Notes: None
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC  S16 maAccExamCmpQ
(
MaAccCmpQElm  **cmpElm,       /* queue message to be returned */
U16             idx           /* Index in the dialogue cp list */
)
#else
PUBLIC  S16 maAccExamCmpQ(cmpElm, idx)
MaAccCmpQElm  **cmpElm;       /* queue message to be returned */
U16             idx;          /* Index in the dialogue cp list */
#endif
{

   TRC2(maAccExamCmpQ)

   /* Check If queue is EMPTY */
   if (maAccCb.dlgCp[idx].cmpQ.rdPtr == maAccCb.dlgCp[idx].cmpQ.wrPtr)
   {
      *cmpElm = NULLP;
      RETVALUE(RFAILED);
   }
   
   *cmpElm = &maAccCb.dlgCp[idx].cmpQ.q[maAccCb.dlgCp[idx].cmpQ.rdPtr];

   RETVALUE(ROK);
} /* maAccExamCmpQ */



/*
*
*       Fun:   maAccFndDlgCp
*
*       Desc:  Find the dialogue cp from the list of dialogue cp
*
*       Ret:   ROK     - operation was successful
*              RFAILED - queue is empty
*
*       Notes: None
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC  S16 maAccFndDlgCp
(
SpId            spId,         /* Sap Id */
StDlgId         maDlgId,      /* MAP Dialogue id */
StDlgId         stDlgId,      /* TCAP Dialogue id */
U16            *idx           /* To return the index */
)
#else
PUBLIC  S16 maAccFndDlgCp(spId, maDlgId, stDlgId, idx)
SpId            spId;         /* Sap Id */
StDlgId         maDlgId;      /* MAP Dialogue id */
StDlgId         stDlgId;      /* TCAP Dialogue id */
U16            *idx;          /* To return the index */
#endif
{
   U16   i;

   TRC2(maAccFndDlgCp)

   UNUSED(stDlgId);

   for (i = 0; i < (U16)(MA_ACC_MAX_DLGS * 2); i++)
   {
       if (maAccCb.dlgCp[i].spId == spId)
       {
         if (( stDlgId ==0) && (maDlgId !=0) &&
             (maAccCb.dlgCp[i].smaDlgId == maDlgId))
          {
             *idx = i;

             RETVALUE(ROK);
          }
          if((stDlgId !=0)  && (maDlgId == 0) &&
             (maAccCb.dlgCp[i].sstDlgId == stDlgId))
          {
             *idx = i;

             RETVALUE(ROK);
            
          }
       }
   }

   RETVALUE(RFAILED);

} /* maAccFndDlgCp */



/*
*
*       Fun:   maAccGetCmpQSize
*
*       Desc:  Get the number of entrmas present in the queue
*
*       Ret:   ROK     - operation was successful
*
*       Notes: None
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC S16 maAccGetCmpQSize
(
U16    idx,             /* Index of dialogue cp in the list */
U16   *qSize            /* To return size of the queue */
)
#else
PUBLIC S16 maAccGetCmpQSize(idx, qSize)
U16    idx;             /* Index of dialogue cp in the list */
U16   *qSize;           /* To return size of the queue */
#endif
{
   TRC2(maAccGetCmpQSize)

   *qSize = 0;

   if (maAccCb.dlgCp[idx].cmpQ.wrPtr < maAccCb.dlgCp[idx].cmpQ.rdPtr)
   {
      *qSize = MA_ACC_MSG_QSIZE +
               maAccCb.dlgCp[idx].cmpQ.wrPtr - maAccCb.dlgCp[idx].cmpQ.rdPtr;
   }
   else
   {
      *qSize = maAccCb.dlgCp[idx].cmpQ.wrPtr - maAccCb.dlgCp[idx].cmpQ.rdPtr;
   }

   RETVALUE(ROK);
} /* maAccGetCmpQSize */



/*
*
*       Fun:   maAccFlushCmpQ
*
*       Desc:  Flush the Queue
*
*       Ret:   ROK     - operation was successful
*
*       Notes: None
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC S16 maAccFlushCmpQ
(
U16    idx              /* Index of dialogue cp in the list */
)
#else
PUBLIC S16 maAccFlushCmpQ(idx)
U16    idx;             /* Index of dialogue cp in the list */
#endif
{
   TRC2(maAccFlushCmpQ);

   while (maAccCb.dlgCp[idx].cmpQ.rdPtr != maAccCb.dlgCp[idx].cmpQ.wrPtr)
   {
     if (maAccCb.dlgCp[idx].cmpQ.q[maAccCb.dlgCp[idx].cmpQ.rdPtr].cpBuf)
       SPutMsg (maAccCb.dlgCp[idx].cmpQ.q[maAccCb.dlgCp[idx].cmpQ.rdPtr].cpBuf);
     maAccCb.dlgCp[idx].cmpQ.rdPtr++;
     if (maAccCb.dlgCp[idx].cmpQ.rdPtr == (U16)MA_ACC_CMP_QSIZE)
       maAccCb.dlgCp[idx].cmpQ.rdPtr = 0;
   }    

   maAccCb.dlgCp[idx].cmpQ.wrPtr = 0;
   maAccCb.dlgCp[idx].cmpQ.rdPtr = 0;

   RETVALUE(ROK);
} /* maAccFlushCmpQ */



/*
*
*       Fun:   maAccPrntCmpQElm
*
*       Desc:  Print the component element of the component queue
*
*       Ret:   ROK     - operation was successful
*              RFAILED - queue is empty
*
*       Notes: None
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC S16 maAccPrntCmpQElm
(
MaAccCmpQElm  *cmpElm
)
#else
PUBLIC S16 maAccPrntCmpQElm(cmpElm)
MaAccCmpQElm  *cmpElm;
#endif
{
   Txt   prntBuf[MA_PRNTBUF_SIZE];

   TRC2(maAccPrntCmpQElm)

   switch(cmpElm->compEv.stCompType)
   {
      case STU_INVOKE:
         MAACCPRINT((prntBuf, "INVOKE Comp"));
         break;

      case STU_RET_RES_L:
         MAACCPRINT((prntBuf, "RETURN_RESULT_LAST Comp"));
         break;

      case STU_RET_ERR:
         MAACCPRINT((prntBuf, "RETURN_ERROR Comp"));
         break;

      case STU_REJECT:
         MAACCPRINT((prntBuf, "REJECT Comp"));
         break;

      case STU_RET_RES_NL:
         MAACCPRINT((prntBuf, "RETURN_RESULT_NOT_LAST Comp"));
         break;

#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS96)
      case STU_INVOKE_L:
         MAACCPRINT((prntBuf, "INVOKE_LAST Comp"));
         break;

      case STU_INVOKE_NL:
         MAACCPRINT((prntBuf, "INVOKE_NOT_LAST Comp"));
         break;
#endif

      default:
         MAACCPRINT((prntBuf, "UNKNOWN Comp"));
         break;
   }

   if (maAccCb.curTst.prntFlag)
   {
      MAACCPRINT((prntBuf, "\ncomponent parameters:\n"));
      (Void) SPrntMsg(cmpElm->cpBuf, 0, 0);
   }

   RETVALUE(ROK);
} /* maAccPrntCmpQElm */



/*
*
*       Fun:   maAccPopMsgQ
*
*       Desc:  Remove a message form the queue
*
*       Ret:   ROK     - operation was successful
*              RFAILED - queue is empty
*
*       Notes: None
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC  S16 maAccPopMsgQ
(
MaAccMsgQElm  **msg           /* queue message to be returned */
)
#else
PUBLIC  S16 maAccPopMsgQ(msg)
MaAccMsgQElm  **msg;          /* queue message to be returned */
#endif
{

   TRC2(maAccPopMsgQ)

   /* Check If queue is EMPTY */
   if (maAccCb.msgQ.rdPtr == maAccCb.msgQ.wrPtr)
   {
      *msg = NULLP;
      RETVALUE(RFAILED);
   }
   
   *msg = &maAccCb.msgQ.q[maAccCb.msgQ.rdPtr];

   /* Increment the read pointer to the next location */
   maAccCb.msgQ.rdPtr++;

   if (maAccCb.msgQ.rdPtr == (U16)MA_ACC_MSG_QSIZE)
   {
      maAccCb.msgQ.rdPtr = 0;
   }

   RETVALUE(ROK);
} /* maAccPopMsgQ */



/*
*
*       Fun:   maAccPushMsgQ
*
*       Desc:  Inserts a message at the back of the message queue
*
*       Ret:   ROK     - operation was successful
*              RFAILED - queue is full
*
*       Notes: None
*
*       File:  ma_acc1.c
*
*/
#ifdef ANSI
PUBLIC S16 maAccPushMsgQ
(
MaAccMsgQElm  *msg            /* Message to be inserted in the queue */
)
#else
PUBLIC S16 maAccPushMsgQ(msg)
MaAccMsgQElm  *msg;           /* Message to be inserted in the queue */
#endif

⌨️ 快捷键说明

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