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

📄 ospreauthreq.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 3 页
字号:
/**########################################################################*########################################################################*########################################################################*                                                               *   COPYRIGHT (c) 1998, 1999 by TransNexus, LLC                          *                                                                    *   This software contains proprietary and confidential information  *   of TransNexus, LLC. Except as may be set forth in the license    *   agreement under which this software is supplied, use, disclosure, *   or reproduction is prohibited without the prior, express, written*   consent of TransNexus, LLC.                                      *                                     *******#########################################################################*#########################################################################*#########################################################################*//* * ospreauthreq.c - OSP authorisation request functions */#include "assert.h"#include "osp.h"#include "osperrno.h"#include "ospbfr.h"#include "osplist.h"#include "ospxmlattr.h"#include "ospxmlelem.h"#include "ospmsgattr.h"#include "ospmsgelem.h"#include "ospcallid.h"#include "osptoken.h"#include "ospdest.h"#include "ospusage.h"#include "ospreauthreq.h"#include "ospcallid.h"#include "osputils.h"#ifdef OSPC_DEBUG/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasTimestamp() - Does authorisation request have a valid timestamp? *-----------------------------------------------------------------------*/unsigned                                   /* returns non-zero if time */OSPPReauthReqHasTimestamp(    OSPTREAUTHREQ *ospvReauthReq               /* authorisation request in question */){    unsigned ospvHasTime = OSPC_FALSE;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvHasTime = (ospvReauthReq->ospmReauthReqTimestamp != OSPC_TIMEMIN);    }    return(ospvHasTime);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqSetTimestamp() - sets the timestamp for an authorisation request *-----------------------------------------------------------------------*/void                                       /* nothing returned */OSPPReauthReqSetTimestamp(    OSPTREAUTHREQ *ospvReauthReq,    OSPTTIME  ospvTime){    if (ospvReauthReq != OSPC_OSNULL)    {        ospvReauthReq->ospmReauthReqTimestamp = ospvTime;    }}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetTimestamp() - returns timestamp for an authorisation request *-----------------------------------------------------------------------*/OSPTTIME                                   /* returns the time value */    OSPPReauthReqGetTimestamp(    OSPTREAUTHREQ *ospvReauthReq               /* authorisation request */    ){    OSPTTIME ospvTime = 0;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvTime = ospvReauthReq->ospmReauthReqTimestamp;    }    return(ospvTime);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasCallId() - does an authorisation request have a Call ID? *-----------------------------------------------------------------------*/unsigned                                   /* returns non-zero if exists */OSPPReauthReqHasCallId(    OSPTREAUTHREQ *ospvReauthReq                  /* authorisation request */){    unsigned ospvHasId = OSPC_FALSE;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvHasId = (ospvReauthReq->ospmReauthReqCallId != OSPC_OSNULL);    }    return(ospvHasId);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetCallId() - gets the call ID for an authorisation request *-----------------------------------------------------------------------*/OSPTCALLID *                               /* returns call ID pointer */    OSPPReauthReqGetCallId(    OSPTREAUTHREQ *ospvReauthReq               /* authorisation request */    ){    OSPTCALLID *ospvCallId = OSPC_OSNULL;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvCallId = ospvReauthReq->ospmReauthReqCallId;    }    return(ospvCallId);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqSetSourceNumber() - set the source number for an * authorisation request *-----------------------------------------------------------------------*/void                                       /* nothing returned */OSPPReauthReqSetSourceNumber(    OSPTREAUTHREQ         *ospvReauthReq,      /* authorisation request  to set */    const unsigned char *ospvNum           /* source number (as string) */){    if (ospvReauthReq != OSPC_OSNULL)    {        if (ospvNum  != OSPC_OSNULL)        {            if (OSPM_STRLEN((const char *)ospvNum) < OSPC_E164NUMSIZE)            {                OSPM_STRNCPY((char *) (ospvReauthReq->ospmReauthReqSourceNumber),                     (const char *)ospvNum, OSPC_E164NUMSIZE-1);            }        }    }}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetSourceNumber() - returns the source number for an  * authorisation request *-----------------------------------------------------------------------*/const unsigned char *                      /* returns number as string */OSPPReauthReqGetSourceNumber(    OSPTREAUTHREQ *ospvReauthReq               /* authorisation request */){    const unsigned char *ospvNum = OSPC_OSNULL;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvNum = ospvReauthReq->ospmReauthReqSourceNumber;    }    return(ospvNum);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqSetDestNumber() - set the destination number for an * authorisation request *-----------------------------------------------------------------------*/void                                       /* nothing returned */OSPPReauthReqSetDestNumber(    OSPTREAUTHREQ         *ospvReauthReq,      /* authorisation request to set */    const unsigned char *ospvNum           /* destination number (as string) */){    if (ospvReauthReq != OSPC_OSNULL)    {        if (ospvNum  != OSPC_OSNULL)        {            if (OSPM_STRLEN((const char *)ospvNum) < OSPC_E164NUMSIZE)            {                OSPM_STRNCPY((char *) (ospvReauthReq->ospmReauthReqDestNumber),                     (const char *)ospvNum, OSPC_E164NUMSIZE-1);            }        }    }}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetDestNumber() - returns the destination number for an * authorisation request *-----------------------------------------------------------------------*/const unsigned char *                      /* returns number as string */OSPPReauthReqGetDestNumber(    OSPTREAUTHREQ *ospvReauthReq               /* authorisation request */){    const unsigned char *ospvNum = OSPC_OSNULL;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvNum = ospvReauthReq->ospmReauthReqDestNumber;    }    return(ospvNum);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasTrxId() - does an authorisation request have a Transaction ID? *-----------------------------------------------------------------------*/unsigned                                   /* returns non-zero if exists */OSPPReauthReqHasTrxId(    OSPTREAUTHREQ *ospvReauthReq                  /* authorisation request */){    unsigned ospvHasId = OSPC_FALSE;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvHasId = (ospvReauthReq->ospmReauthReqTrxId != 0);    }    return(ospvHasId);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqSetTrxId() - sets the transaction ID for an authorisation *-----------------------------------------------------------------------*/void                                       /* nothing returned */OSPPReauthReqSetTrxId(    OSPTREAUTHREQ   *ospvReauthReq,            /* authorisation request */    OSPTTRXID ospvTrxId                 /* transaction ID to set */){    if (ospvReauthReq   != OSPC_OSNULL)    {        ospvReauthReq->ospmReauthReqTrxId = ospvTrxId;    }}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetTrxId() - gets the transaction ID for an authorisation request *-----------------------------------------------------------------------*/OSPTTRXID                                /* returns transaction ID pointer */    OSPPReauthReqGetTrxId(    OSPTREAUTHREQ *ospvReauthReq               /* authorisation request */    ){    OSPTTRXID ospvTrxId = 0;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvTrxId = ospvReauthReq->ospmReauthReqTrxId;    }    return(ospvTrxId);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasDuration() - is the duration set ? *-----------------------------------------------------------------------*/unsigned                            /* returns non-zero if number exists */OSPPReauthReqHasDuration(    OSPTREAUTHREQ *ospvReauthReq              /* Usage Indication effected */){    unsigned ospvHasDuration = OSPC_FALSE;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvHasDuration = (ospvReauthReq->ospmReauthReqDuration >= 0);    }    return ospvHasDuration;}/**//*-----------------------------------------------------------------------* * OSPPReauthReqSetDuration() - set the duration *-----------------------------------------------------------------------*/void                                /* nothing returned */OSPPReauthReqSetDuration(    OSPTREAUTHREQ *ospvReauthReq,     /* usage indication to set */    int ospvDuration /* duration to set to */){    if (ospvReauthReq != OSPC_OSNULL)    {        if (ospvDuration  >= 0)        {            ospvReauthReq->ospmReauthReqDuration = ospvDuration;        }    }    return;}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetDuration() - returns the duration for a usage ind *-----------------------------------------------------------------------*/intOSPPReauthReqGetDuration(    OSPTREAUTHREQ *ospvReauthReq                     /* usage ind */){    int ospvDuration = 0;    if (ospvReauthReq != OSPC_OSNULL)    {        ospvDuration = ospvReauthReq->ospmReauthReqDuration;    }    return ospvDuration;}/**//*-----------------------------------------------------------------------* * OSPPReauthReqAddToken() - adds a token to an authorisation indication *-----------------------------------------------------------------------*/void                                       /* nothing returned */OSPPReauthReqAddToken(    OSPTREAUTHREQ  *ospvReauthReq,             /* authorisation indication */    OSPTTOKEN *ospvToken                   /* token to add */){    if (ospvReauthReq != OSPC_OSNULL)    {        OSPPListAppend(&(ospvReauthReq->ospmReauthReqTokens), ospvToken);    }}/**//*-----------------------------------------------------------------------* * OSPPReauthReqFirstToken() - gets first token for authorisation indication *-----------------------------------------------------------------------*/OSPTTOKEN *                                /* returns null if none */    OSPPReauthReqFirstToken(    OSPTREAUTHREQ *ospvReauthReq    ){    OSPTTOKEN *ospvToken = OSPC_OSNULL;    if(ospvReauthReq != OSPC_OSNULL)    {        ospvToken = (OSPTTOKEN *)OSPPListFirst(&(ospvReauthReq->ospmReauthReqTokens));    }    return(ospvToken);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqNextToken() - gets next token (in list) for authorisation indication *-----------------------------------------------------------------------*/OSPTTOKEN *                                /* returns NULL if no more */    OSPPReauthReqNextToken(    OSPTREAUTHREQ  *ospvReauthReq,             /* authorisation indication */    OSPTTOKEN *ospvToken                   /* current token */    ){    OSPTTOKEN *ospvNextToken = OSPC_OSNULL;    if (ospvReauthReq  != OSPC_OSNULL)    {        if (ospvToken != OSPC_OSNULL)        {            ospvNextToken = (OSPTTOKEN *)OSPPListNext(&(ospvReauthReq->ospmReauthReqTokens), ospvToken);        }    }    return(ospvNextToken);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqHasComponentId() - is the component id set ? *-----------------------------------------------------------------------*/unsigned                    /* returns non-zero if component id is set */OSPPReauthReqHasComponentId(    OSPTREAUTHREQ *ospvReauthReq){  return (ospvReauthReq->ospmReauthReqComponentId != OSPC_OSNULL);}/**//*-----------------------------------------------------------------------* * OSPPReauthReqGetComponentId() - returns a new copy of the component id. *-----------------------------------------------------------------------*/unsigned char  *OSPPReauthReqGetComponentId(    OSPTREAUTHREQ *ospvReauthReq){    unsigned char   *componentstring   = OSPC_OSNULL;    int             len                = 0;    if (OSPPReauthReqHasComponentId(ospvReauthReq))    {

⌨️ 快捷键说明

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