📄 inet_msg_sip.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* inet_msg_sip.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* This file contains INET message for SIP.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef _INET_MSG_SIP_C
#define _INET_MSG_SIP_C
#ifdef INET_MSG_LIB_SUPPORT
/*****************************************************************************
* Include
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h> /* atoi */
#include <ctype.h> /* toupper */
#include "kal_release.h"
#include "inet_msg_cfg.h"
#include "inet_msg_def.h"
#include "inet_msg_struct.h"
#include "inet_msg_mem.h"
#include "inet_msg_api.h"
#include "inet_msg_res.h"
#include "inet_msg_unpack.h"
#include "inet_msg_pack.h"
#include "inet_msg_util.h"
#include "inet_msg_sip.h"
/*****************************************************************************
* Compact
*****************************************************************************/
const inet_compact_header_table_struct inet_compact_header_name_table[] =
{
/* 1 */ {INET_HDR_CALL_ID, 'i'},
/* Call-ID */
{INET_HDR_CONTACT, 'm'}, /* Contact */
{INET_HDR_CONTENT_ENCODING, 'e'}, /* Content-Encoding */
{INET_HDR_CONTENT_LENGTH, 'l'}, /* Content-Length */
/* 5 */ {INET_HDR_CONTENT_TYPE, 'c'},
/* Content-Type */
{INET_HDR_FROM, 'f'}, /* From */
{INET_HDR_SESSION_EXPIRES, 'x'}, /* Session-Expires */
{INET_HDR_SUBJECT, 's'}, /* Subject */
{INET_HDR_SUPPORTED, 'k'}, /* Supported */
/* 10 */ {INET_HDR_TO, 't'},
/* To */
{INET_HDR_VIA, 'v'}, /* Via */
{INET_HDR_REFER_TO, 'r'}, /* Refer-To */
{INET_HDR_ACCEPT_CONTACT, 'a'}, /* Accept-Contact */
{INET_HDR_EVENT, 'o'}, /* Event */
{999999, 0} /* End of item */
};
/*****************************************************************************
* FUNCTION
* inet_msg_get_compact_header_type
* DESCRIPTION
*
* PARAMETERS
* h [IN]
* header_type [?]
* RETURNS
*
*****************************************************************************/
kal_bool inet_msg_get_compact_header_type(kal_char h, kal_uint32 *header_type)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint16 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; inet_compact_header_name_table[i].compact; i++)
{
if (toupper(inet_compact_header_name_table[i].compact) == toupper(h))
{
*header_type = inet_compact_header_name_table[i].type;
return KAL_TRUE;
}
}
return KAL_FALSE;
}
/*****************************************************************************
* Unpack functions
*****************************************************************************/
/*****************************************************************************
* FUNCTION
* inet_msg_unpack_session_expires
* DESCRIPTION
* This function unpacks the Session-Expires.
* GRAMMER
* Session-Expires = ("Session-Expires" / "x") HCOLON delta-seconds
* *(SEMI se-params)
* se-params = refresher-param / generic-param
* refresher-param = "refresher" EQUAL ("uas" / "uac")
*
* example:
*
* Session-Expires: 4800;refresher=uas
* Session-Expires: 4800
* PARAMETERS
* mem_func [IN] Memory function
* text [IN] String of field value
* RETURNS
* inet_session_expires_struct pointer
*****************************************************************************/
kal_uint32 inet_msg_unpack_session_expires(inet_mem_func_struct *mem_func, kal_char *text)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_char *param;
inet_session_expires_struct *se = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
param = strchr(text, ';');
if (param)
{
*param++ = '\0';
}
se = inet_malloc(mem_func, sizeof(inet_session_expires_struct));
if (!se)
{
goto se_error;
}
se->expires = atoi(text);
if (param)
{
se->param_list = (inet_param_list_struct*) inet_msg_unpack_param(mem_func, param);
if (!se->param_list)
{
goto se_error;
}
}
return (kal_uint32) se;
se_error:
if (se)
{
inet_session_expires_struct_free_fn(mem_func, se);
}
return 0;
} /* end of inet_msg_unpack_session_expires */
/*****************************************************************************
* FUNCTION
* inet_msg_unpack_event
* DESCRIPTION
* This function unpacks the Event.
* GRAMMER
*
* example:
*
* Event: presence
* Event: conference;id=aaaaa
* PARAMETERS
* mem_func [IN] Memory function
* text [IN] String of field value
* RETURNS
* inet_event_struct pointer
*****************************************************************************/
kal_uint32 inet_msg_unpack_event(inet_mem_func_struct *mem_func, kal_char *text)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_char *param;
inet_event_struct *evt = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
param = strchr(text, ';');
if (param)
{
*param++ = '\0';
}
evt = inet_malloc(mem_func, sizeof(inet_event_struct));
if (!evt)
{
goto evt_error;
}
evt->event = inet_msg_strdup(mem_func, text);
if (!evt->event)
{
goto evt_error;
}
if (param)
{
evt->param_list = (inet_param_list_struct*) inet_msg_unpack_param(mem_func, param);
if (!evt->param_list)
{
goto evt_error;
}
}
return (kal_uint32) evt;
evt_error:
inet_event_struct_free_fn(mem_func, evt);
return 0;
} /* end of inet_msg_unpack_event */
/*****************************************************************************
* FUNCTION
* inet_msg_unpack_subscription_state
* DESCRIPTION
* This function unpacks the Event.
* GRAMMER
*
* Subscription-State = "Subscription-State" HCOLON substate-value
* *( SEMI subexp-params )
* substate-value = "active" / "pending" / "terminated"
* / extension-substate
* extension-substate = token
* subexp-params = ("reason" EQUAL event-reason-value)
* / ("expires" EQUAL delta-seconds)
* / ("retry-after" EQUAL delta-seconds)
* / generic-param
* event-reason-value = "deactivated"
* / "probation"
* / "rejected"
* / "timeout"
* / "giveup"
* / "noresource"
* / event-reason-extension
* event-reason-extension = token
*
* example:
*
* Subscription-State: terminated; reason="timeout"
* PARAMETERS
* mem_func [IN] Memory function
* text [IN] String of field value
* RETURNS
* inet_subscription_state_struct pointer
*****************************************************************************/
kal_uint32 inet_msg_unpack_subscription_state(inet_mem_func_struct *mem_func, kal_char *text)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_char *param;
inet_subscription_state_struct *ss = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
param = strchr(text, ';');
if (param)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -