ospauthreq.c

来自「mgcp协议源代码。支持多种编码:g711」· C语言 代码 · 共 994 行 · 第 1/3 页

C
994
字号
/**########################################################################*########################################################################*########################################################################*                                                               *   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.                                      *                                     *******#########################################################################*#########################################################################*#########################################################################*//* *  ospauthreq.c - OSP authorisation request functions */#include "osp.h"#include "osperrno.h"#include "ospbfr.h"#include "ospxmlattr.h"#include "ospxmlelem.h"#include "ospmsgattr.h"#include "ospmsgelem.h"#include "ospcallid.h"#include "ospauthreq.h"#include "osputils.h"#ifdef OSPC_DEBUG/**//*-----------------------------------------------------------------------* * OSPPAuthReqHasTimestamp() - Does authorisation request have a valid timestamp? *-----------------------------------------------------------------------*/unsigned                                   /* returns non-zero if time */OSPPAuthReqHasTimestamp(    OSPTAUTHREQ *ospvAuthReq               /* authorisation request in question */){    unsigned ospvHasTimestamp = OSPC_FALSE;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvHasTimestamp = ((ospvAuthReq)->ospmAuthReqTimestamp != OSPC_TIMEMIN);    }    return(ospvHasTimestamp);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqSetTimestamp() - sets the timestamp for an authorisation request *-----------------------------------------------------------------------*/void                                       /* nothing returned */OSPPAuthReqSetTimestamp(    OSPTAUTHREQ *ospvAuthReq,    OSPTTIME  ospvTime){    if (ospvAuthReq != OSPC_OSNULL)    {        (ospvAuthReq)->ospmAuthReqTimestamp = (ospvTime);    }}/**//*-----------------------------------------------------------------------* * OSPPAuthReqGetTimestamp() - returns timestamp for an authorisation request *-----------------------------------------------------------------------*/OSPTTIME                                   /* returns the time value */    OSPPAuthReqGetTimestamp(    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */    ){    OSPTTIME ospvTimestamp = 0;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvTimestamp = (ospvAuthReq)->ospmAuthReqTimestamp;    }    return(ospvTimestamp);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqHasCallId() - does an authorisation request have a Call ID? *-----------------------------------------------------------------------*/unsigned                                   /* returns non-zero if exists */OSPPAuthReqHasCallId(    OSPTAUTHREQ *ospvAuthReq                  /* authorisation request */){    unsigned ospvHasCallId = OSPC_FALSE;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvHasCallId = (OSPPAuthReqFirstCallId(ospvAuthReq) != OSPC_OSNULL);    }    return(ospvHasCallId);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqFirstCallId() - gets the First call ID for an authorisation request *-----------------------------------------------------------------------*/OSPTCALLID *                               /* returns call ID pointer */    OSPPAuthReqFirstCallId(    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */    ){    OSPTCALLID *ospvCallId = OSPC_OSNULL;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvCallId = (OSPTCALLID *)OSPPListFirst(&(ospvAuthReq->ospmAuthReqCallId));    }    return(ospvCallId);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqNextCallId() - gets the next call ID for an authorisation request *-----------------------------------------------------------------------*/OSPTCALLID *                               /* returns call ID pointer */    OSPPAuthReqNextCallId(    OSPTAUTHREQ *ospvAuthReq,               /* authorisation request */    OSPTCALLID  *ospvCallId                 /* current callid */    ){    OSPTCALLID *nextcallid = OSPC_OSNULL;    if (ospvAuthReq != OSPC_OSNULL)    {        nextcallid = (OSPTCALLID *)OSPPListNext(&(ospvAuthReq->ospmAuthReqCallId), ospvCallId);    }    return(nextcallid);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqHasSourceNumber() - does the authorisation request have * a source number? *-----------------------------------------------------------------------*/unsigned                            /* returns non-zero if number exists */OSPPAuthReqHasSourceNumber(    OSPTAUTHREQ *ospvAuthReq        /* authorisation request effected */){    unsigned ospvHasNumber = OSPC_FALSE;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvHasNumber = ((ospvAuthReq)->ospmAuthReqSourceNumber[0] != '\0');    }    return(ospvHasNumber);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqSetSourceNumber() - set the source number for an * authorisation request *-----------------------------------------------------------------------*/void                                       /* nothing returned */OSPPAuthReqSetSourceNumber(    OSPTAUTHREQ         *ospvAuthReq,      /* authorisation request  to set */    const unsigned char *ospvNum           /* source number (as string) */){    if (ospvAuthReq != OSPC_OSNULL)    {        if (ospvNum  != OSPC_OSNULL)        {            OSPM_STRNCPY((char *)(ospvAuthReq)->ospmAuthReqSourceNumber,                 (const char *)(ospvNum),                 osp_min(OSPM_STRLEN((const char *)ospvNum)+1,OSPC_E164NUMSIZE-1));        }    }}/**//*-----------------------------------------------------------------------* * OSPPAuthReqGetSourceNumber() - returns the source number for an  * authorisation request *-----------------------------------------------------------------------*/unsigned char *                      /* returns number as string */OSPPAuthReqGetSourceNumber(    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */){    unsigned char *ospvNum = OSPC_OSNULL;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvNum = (ospvAuthReq->ospmAuthReqSourceNumber);    }    return(ospvNum);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqHasSourceAlt() - does an authorisation request have a  * Source Alternate? *-----------------------------------------------------------------------*/unsigned                                   /* returns non-zero if exists */OSPPAuthReqHasSourceAlt(    OSPTAUTHREQ *ospvAuthReq                  /* authorisation request */){    unsigned ospvHasSourceAlt = OSPC_FALSE;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvHasSourceAlt = (OSPPAuthReqFirstSourceAlt(ospvAuthReq) != OSPC_OSNULL);    }    return(ospvHasSourceAlt);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqFirstSourceAlt() - gets the First Source alternate for an  * authorisation request *-----------------------------------------------------------------------*/OSPTALTINFO *                              /* returns alt info pointer */    OSPPAuthReqFirstSourceAlt(    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */    ){    OSPTALTINFO *ospvAltInfo = OSPC_OSNULL;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvAltInfo =             (OSPTALTINFO *)OSPPListFirst(&((ospvAuthReq)->ospmAuthReqSourceAlternate));    }    return(ospvAltInfo);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqNextSourceAlt() - gets the next source alternate for an  * authorisation request *-----------------------------------------------------------------------*/OSPTALTINFO *                               /* returns alt info pointer */    OSPPAuthReqNextSourceAlt(    OSPTAUTHREQ *ospvAuthReq,               /* authorisation request */    OSPTALTINFO  *ospvAltInfo    ){    OSPTALTINFO *altinfo = OSPC_OSNULL;    if (ospvAuthReq != OSPC_OSNULL)    {        altinfo =             (OSPTALTINFO *)OSPPListNext(&((ospvAuthReq)->ospmAuthReqSourceAlternate),             ospvAltInfo);    }    return(altinfo);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqHasDestinationAlt() - does an authorisation request have a  * Destination Alternate? *-----------------------------------------------------------------------*/unsigned                                   /* returns non-zero if exists */OSPPAuthReqHasDestinationAlt(    OSPTAUTHREQ *ospvAuthReq                  /* authorisation request */){    unsigned ospvHasDestinationAlt = OSPC_FALSE;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvHasDestinationAlt = (OSPPAuthReqFirstDestinationAlt(ospvAuthReq) != OSPC_OSNULL);    }    return(ospvHasDestinationAlt);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqFirstDestinationAlt() - gets the First Destination alternate for an  * authorisation request *-----------------------------------------------------------------------*/OSPTALTINFO *                              /* returns alt info pointer */    OSPPAuthReqFirstDestinationAlt(    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */    ){    OSPTALTINFO *ospvAltInfo = OSPC_OSNULL;    if (ospvAuthReq != OSPC_OSNULL)    {        ospvAltInfo =             (OSPTALTINFO *)OSPPListFirst(&((ospvAuthReq)->ospmAuthReqDestinationAlternate));    }    return(ospvAltInfo);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqNextDestinationAlt() - gets the next Destination alternate for an  * authorisation request *-----------------------------------------------------------------------*/OSPTALTINFO *                               /* returns alt info pointer */    OSPPAuthReqNextDestinationAlt(    OSPTAUTHREQ *ospvAuthReq,               /* authorisation request */    OSPTALTINFO  *ospvAltInfo    ){    OSPTALTINFO *altinfo = OSPC_OSNULL;    if (ospvAuthReq != OSPC_OSNULL)    {        altinfo =             (OSPTALTINFO *)OSPPListNext(&((ospvAuthReq)->ospmAuthReqDestinationAlternate),             ospvAltInfo);    }    return(altinfo);}/**//*-----------------------------------------------------------------------*

⌨️ 快捷键说明

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