- Begin adding support for presence publication as per RFC 3903.
- Add support for dummy headers (arbitrary/user-defined headers). - Add support for UA capabilities indication as per RFC 3840.
This commit is contained in:
parent
99fdeea784
commit
70d57ea547
|
@ -38,6 +38,7 @@
|
|||
# pragma comment(lib, "Fwpuclnt.lib")
|
||||
#endif
|
||||
|
||||
#include <ws2tcpip.h>
|
||||
#include <Fwpmu.h>
|
||||
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ tsk_param_t *tsk_params_parse_param(const char* line, size_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tsk_params_has_param(const tsk_params_L_t *self, const char* name)
|
||||
int tsk_params_have_param(const tsk_params_L_t *self, const char* name)
|
||||
{
|
||||
if(self)
|
||||
{
|
||||
|
@ -90,8 +90,7 @@ int tsk_params_add_param(tsk_params_L_t **self, const char* name, const char* va
|
|||
|
||||
if(!name) return -1;
|
||||
|
||||
if(!*self)
|
||||
{
|
||||
if(!*self){
|
||||
*self = TSK_LIST_CREATE();
|
||||
}
|
||||
|
||||
|
@ -223,8 +222,7 @@ static void* tsk_param_create(void * self, va_list * app)
|
|||
if(name)
|
||||
{
|
||||
param->name = tsk_strdup(name);
|
||||
if(value)
|
||||
{
|
||||
if(value && !tsk_strempty(value)) {
|
||||
param->value = tsk_strdup(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef tsk_list_t tsk_params_L_t; /**< List of @ref tsk_param_t elements. */
|
|||
|
||||
TINYSAK_API tsk_param_t *tsk_params_parse_param(const char* line, size_t size);
|
||||
|
||||
TINYSAK_API int tsk_params_has_param(const tsk_params_L_t *self, const char* name);
|
||||
TINYSAK_API int tsk_params_have_param(const tsk_params_L_t *self, const char* name);
|
||||
TINYSAK_API int tsk_params_add_param(tsk_params_L_t **self, const char* name, const char* value);
|
||||
TINYSAK_API int tsk_params_remove_param(tsk_params_L_t *self, const char* name);
|
||||
TINYSAK_API const tsk_param_t *tsk_params_get_param_by_name(const tsk_params_L_t *self, const char* name);
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file tsip_dialog_publish.h
|
||||
* @brief SIP dialog PUBLISH as per RFC 3903.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TINYSIP_DIALOG_PUBLISH_H
|
||||
#define TINYSIP_DIALOG_PUBLISH_H
|
||||
|
||||
#include "tinysip_config.h"
|
||||
#include "tinysip/dialogs/tsip_dialog.h"
|
||||
|
||||
#include "tsk_fsm.h"
|
||||
|
||||
TSIP_BEGIN_DECLS
|
||||
|
||||
#define TSIP_DIALOG_PUBLISH_CREATE(stack, operation) tsk_object_new(tsip_dialog_publish_def_t, (tsip_stack_handle_t *)stack, (tsip_operation_handle_t*) operation)
|
||||
|
||||
#define TSIP_DIALOG_PUBLISH(self) ((tsip_dialog_publish_t*)(self))
|
||||
|
||||
typedef struct tsip_dialog_publish
|
||||
{
|
||||
TSIP_DECLARE_DIALOG;
|
||||
|
||||
tsk_fsm_t *fsm;
|
||||
|
||||
tsip_timer_t timerrefresh;
|
||||
|
||||
unsigned unpublishing:1;
|
||||
|
||||
char* package;
|
||||
}
|
||||
tsip_dialog_publish_t;
|
||||
|
||||
int tsip_dialog_publish_start(tsip_dialog_publish_t *self);
|
||||
|
||||
TINYSIP_GEXTERN const void *tsip_dialog_publish_def_t;
|
||||
|
||||
|
||||
TSIP_END_DECLS
|
||||
|
||||
|
||||
#endif /* TINYSIP_DIALOG_PUBLISH_H */
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
/**@file tsip_dialog_subscribe.h
|
||||
* @brief SIP dialog SUBSCRIBE.
|
||||
* @brief SIP dialog SUBSCRIBE as per RFC 3265.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef enum tsip_header_type_e
|
|||
tsip_htype_Content_Type,
|
||||
tsip_htype_CSeq,
|
||||
tsip_htype_Date,
|
||||
tsip_htype_Dummy,
|
||||
tsip_htype_Error_Info,
|
||||
tsip_htype_Event,
|
||||
tsip_htype_Expires,
|
||||
|
@ -171,7 +172,7 @@ TINYSIP_API const char *tsip_header_get_name(tsip_header_type_t type);
|
|||
TINYSIP_API char tsip_header_get_param_separator(const tsip_header_t *self);
|
||||
TINYSIP_API int tsip_header_tostring(const tsip_header_t *self, tsk_buffer_t *output);
|
||||
|
||||
#define TSIP_HEADER_HAS_PARAM(self, name) tsk_params_has_param(self ? TSIP_HEADER(self)->params : 0, name)
|
||||
#define TSIP_HEADER_HAVE_PARAM(self, name) tsk_params_have_param(self ? TSIP_HEADER(self)->params : 0, name)
|
||||
#define TSIP_HEADER_ADD_PARAM(self, name, value) tsk_params_add_param(self ? &TSIP_HEADER(self)->params : 0, name, value)
|
||||
#define TSIP_HEADER_REMOVE_PARAM(self, name) tsk_params_remove_param(self ? TSIP_HEADER(self)->params : 0, name)
|
||||
#define TSIP_HEADER_GET_PARAM_BY_NAME(self, name) tsk_params_get_param_by_name(self ? TSIP_HEADER(self)->params : 0, name)
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file tsip_header_Dummy.h
|
||||
* @brief SIP dummy header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef _TSIP_HEADER_DUMMY_H_
|
||||
#define _TSIP_HEADER_DUMMY_H_
|
||||
|
||||
#include "tinysip_config.h"
|
||||
#include "tinysip/headers/tsip_header.h"
|
||||
|
||||
TSIP_BEGIN_DECLS
|
||||
|
||||
/**@def TSIP_HEADER_DUMMY_CREATE
|
||||
* Creates new sip Dummy header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
|
||||
* @sa TSK_OBJECT_SAFE_FREE.
|
||||
*/
|
||||
#define TSIP_HEADER_DUMMY_VA_ARGS(name, value) tsip_header_Dummy_def_t, (const char*)name, (const char*)value
|
||||
#define TSIP_HEADER_DUMMY_CREATE(name, value) tsk_object_new(TSIP_HEADER_DUMMY_VA_ARGS(name, value))
|
||||
#define TSIP_HEADER_DUMMY_CREATE_NULL() TSIP_HEADER_DUMMY_CREATE(TSIP_NULL, TSIP_NULL)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @struct
|
||||
///
|
||||
/// @brief SIP Dummy header.
|
||||
/// @author Mamadou
|
||||
/// @date 12/3/2009
|
||||
///
|
||||
/// @par ABNF : token SP* HCOLON SP*<: any*
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct tsip_header_Dummy_s
|
||||
{
|
||||
TSIP_DECLARE_HEADER;
|
||||
|
||||
char *name;
|
||||
char *value;
|
||||
}
|
||||
tsip_header_Dummy_t;
|
||||
|
||||
tsip_header_Dummy_t *tsip_header_Dummy_parse(const char *data, size_t size);
|
||||
|
||||
TINYSIP_GEXTERN const void *tsip_header_Dummy_def_t;
|
||||
|
||||
TSIP_END_DECLS
|
||||
|
||||
#endif /* _TSIP_HEADER_DUMMY_H_ */
|
||||
|
|
@ -49,20 +49,27 @@ typedef uint64_t tsip_operation_id_t;
|
|||
|
||||
typedef enum tsip_operation_param_type_e
|
||||
{
|
||||
oppname_nvp,
|
||||
|
||||
oppname_null
|
||||
optype_param,
|
||||
optype_header,
|
||||
optype_caps,
|
||||
optype_null
|
||||
}
|
||||
tsip_operation_param_type_t;
|
||||
|
||||
#define TSIP_OPERATION_SET_PARAM(NAME_STR, VALUE_STR) oppname_nvp, (const char*)NAME_STR, (const char*)VALUE_STR
|
||||
#define TSIP_OPERATION_SET_NULL() oppname_null
|
||||
#define TSIP_OPERATION_SET_PARAM(NAME_STR, VALUE_STR) optype_param, (const char*)NAME_STR, (const char*)VALUE_STR
|
||||
#define TSIP_OPERATION_SET_HEADER(NAME_STR, VALUE_STR) optype_header, (const char*)NAME_STR, (const char*)VALUE_STR
|
||||
#define TSIP_OPERATION_SET_CAPS(NAME_STR, VALUE_STR) optype_caps, (const char*)NAME_STR, (const char*)VALUE_STR /* RFC 3840 */
|
||||
#define TSIP_OPERATION_SET_NULL() optype_null
|
||||
|
||||
typedef void tsip_operation_handle_t;
|
||||
|
||||
tsip_operation_handle_t *tsip_operation_createex(const struct tsip_message_s* message);
|
||||
TINYSIP_API int tsip_operation_set(tsip_operation_handle_t *self, ...);
|
||||
TINYSIP_API tsip_operation_id_t tsip_operation_get_id(const tsip_operation_handle_t *self);
|
||||
const tsk_param_t* tsip_operation_get_param(const tsip_operation_handle_t *self, const char* pname);
|
||||
const tsk_params_L_t* tsip_operation_get_headers(const tsip_operation_handle_t *self);
|
||||
const tsk_params_L_t* tsip_operation_get_params(const tsip_operation_handle_t *self);
|
||||
const tsk_params_L_t* tsip_operation_get_caps(const tsip_operation_handle_t *self);
|
||||
|
||||
typedef tsk_list_t tsip_operations_L_t; /**< List of @ref tsip_operation_handle_t elements. */
|
||||
TINYSIP_GEXTERN const void *tsip_operation_def_t;
|
||||
|
|
|
@ -38,6 +38,9 @@ ragel.exe $OPTIONS -o ../src/headers/tsip_header_Contact.c tsip_parser_header_Co
|
|||
# ==CSeq
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_CSeq.c tsip_parser_header_CSeq.rl
|
||||
|
||||
# ==Dummy
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Dummy.c tsip_parser_header_Dummy.rl
|
||||
|
||||
# ==Event
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Event.c tsip_parser_header_Event.rl
|
||||
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file tsip_header_Dummy.c
|
||||
* @brief SIP DUmmy header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinysip/headers/tsip_header_Dummy.h"
|
||||
|
||||
#include "tinysip/parsers/tsip_parser_uri.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup tsip_header_Dummy_group SIP Dummy header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine tsip_machine_parser_header_Dummy;
|
||||
|
||||
# Includes
|
||||
include tsip_machine_utils "./tsip_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
action parse_name
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Dummy->name);
|
||||
}
|
||||
|
||||
action parse_value
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Dummy->value);
|
||||
}
|
||||
|
||||
action eob
|
||||
{
|
||||
}
|
||||
|
||||
Dummy = token>tag %parse_name SP* HCOLON SP*<: any*>tag %parse_value;
|
||||
|
||||
# Entry point
|
||||
main := Dummy :>CRLF @eob;
|
||||
|
||||
}%%
|
||||
|
||||
int tsip_header_Dummy_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const tsip_header_Dummy_t *Dummy = header;
|
||||
if(Dummy->value)
|
||||
{
|
||||
tsk_buffer_append(output, Dummy->value, strlen(Dummy->value));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsip_header_Dummy_t *tsip_header_Dummy_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
tsip_header_Dummy_t *hdr_Dummy = TSIP_HEADER_DUMMY_CREATE_NULL();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_Dummy);
|
||||
}
|
||||
|
||||
return hdr_Dummy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Dummy header object definition
|
||||
//
|
||||
|
||||
/**@ingroup tsip_header_Dummy_group
|
||||
*/
|
||||
static void* tsip_header_Dummy_create(void *self, va_list * app)
|
||||
{
|
||||
tsip_header_Dummy_t *Dummy = self;
|
||||
if(Dummy)
|
||||
{
|
||||
TSIP_HEADER(Dummy)->type = tsip_htype_Dummy;
|
||||
TSIP_HEADER(Dummy)->tostring = tsip_header_Dummy_tostring;
|
||||
|
||||
Dummy->name = tsk_strdup(va_arg(*app, const char*));
|
||||
Dummy->value = tsk_strdup(va_arg(*app, const char*));
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Dummy header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup tsip_header_Dummy_group
|
||||
*/
|
||||
static void* tsip_header_Dummy_destroy(void *self)
|
||||
{
|
||||
tsip_header_Dummy_t *Dummy = self;
|
||||
if(Dummy)
|
||||
{
|
||||
TSK_FREE(Dummy->name);
|
||||
TSK_FREE(Dummy->value);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Dummy));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Dummy header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tsip_header_Dummy_def_s =
|
||||
{
|
||||
sizeof(tsip_header_Dummy_t),
|
||||
tsip_header_Dummy_create,
|
||||
tsip_header_Dummy_destroy,
|
||||
0
|
||||
};
|
||||
const void *tsip_header_Dummy_def_t = &tsip_header_Dummy_def_s;
|
|
@ -90,7 +90,7 @@ tsip_header_User_Agent_t *tsip_header_User_Agent_parse(const char *data, size_t
|
|||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
tsip_header_User_Agent_t *hdr_user_agent = TSIP_HEADER_USER_AGENT_CREATE(0);
|
||||
tsip_header_User_Agent_t *hdr_user_agent = TSIP_HEADER_USER_AGENT_CREATE(TSIP_NULL);
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "tinysip/headers/tsip_header_Authorization.h"
|
||||
#include "tinysip/headers/tsip_header_Contact.h"
|
||||
#include "tinysip/headers/tsip_header_Dummy.h"
|
||||
#include "tinysip/headers/tsip_header_Expires.h"
|
||||
#include "tinysip/headers/tsip_header_P_Preferred_Identity.h"
|
||||
#include "tinysip/headers/tsip_header_Proxy_Authenticate.h"
|
||||
|
@ -57,6 +58,9 @@ tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* m
|
|||
tsip_uri_t *to_uri, *from_uri, *request_uri;
|
||||
const char *call_id;
|
||||
int copy_routes_start = -1; /* NONE */
|
||||
const tsk_list_item_t* item;
|
||||
const tsk_params_L_t* params;
|
||||
const tsk_param_t* param;
|
||||
|
||||
/*
|
||||
RFC 3261 - 12.2.1.1 Generating the Request
|
||||
|
@ -137,7 +141,7 @@ tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* m
|
|||
else
|
||||
{
|
||||
tsip_uri_t *first_route = self->routes->head->data;
|
||||
if(tsk_params_has_param(first_route->params, "lr"))
|
||||
if(tsk_params_have_param(first_route->params, "lr"))
|
||||
{
|
||||
request_uri = tsk_object_ref(self->uri_remote_target);
|
||||
copy_routes_start = 0; /* Copy all */
|
||||
|
@ -173,12 +177,21 @@ tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* m
|
|||
tsip_header_Contacts_L_t *hdr_contacts;
|
||||
tsk_sprintf(&contact, "m: <%s:%s@%s:%d>;expires=%d;doubs\r\n", /*self->issecure*/0?"sips":"sip", from_uri->user_name, "127.0.0.1", 5060, self->expires);
|
||||
hdr_contacts = tsip_header_Contact_parse(contact, strlen(contact));
|
||||
if(!TSK_LIST_IS_EMPTY(hdr_contacts))
|
||||
{
|
||||
if(!TSK_LIST_IS_EMPTY(hdr_contacts)){
|
||||
request->Contact = tsk_object_ref(hdr_contacts->head->data);
|
||||
}
|
||||
TSK_OBJECT_SAFE_FREE(hdr_contacts);
|
||||
TSK_FREE(contact);
|
||||
|
||||
/* Add capabilities as per RFC 3840. */
|
||||
params = tsip_operation_get_caps(self->operation);
|
||||
if(request->Contact){
|
||||
tsk_list_foreach(item, params)
|
||||
{
|
||||
param = (const tsk_param_t*)item->data;
|
||||
tsk_params_add_param(&TSIP_HEADER(request->Contact)->params, param->name, param->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Update authorizations */
|
||||
|
@ -209,7 +222,6 @@ tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* m
|
|||
}
|
||||
else if(!TSK_LIST_IS_EMPTY(self->challenges))
|
||||
{
|
||||
tsk_list_item_t *item;
|
||||
tsip_challenge_t *challenge;
|
||||
tsip_header_t* auth_hdr;
|
||||
tsk_list_foreach(item, self->challenges)
|
||||
|
@ -231,11 +243,24 @@ tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* m
|
|||
/* Route generation
|
||||
* ==> http://betelco.blogspot.com/2008/11/proxy-and-service-route-discovery-in.html
|
||||
* The dialog Routes have been copied above.
|
||||
|
||||
3GPP TS 24.229 - 5.1.2A.1 UE-originating case
|
||||
|
||||
The UE shall build a proper preloaded Route header field value for all new dialogs and standalone transactions. The UE
|
||||
shall build a list of Route header field values made out of the following, in this order:
|
||||
a) the P-CSCF URI containing the IP address or the FQDN learnt through the P-CSCF discovery procedures; and
|
||||
b) the P-CSCF port based on the security mechanism in use:
|
||||
|
||||
- if IMS AKA or SIP digest with TLS is in use as a security mechanism, the protected server port learnt during
|
||||
the registration procedure;
|
||||
- if SIP digest without TLS, NASS-IMS bundled authentciation or GPRS-IMS-Bundled authentication is in
|
||||
use as a security mechanism, the unprotected server port used during the registration procedure;
|
||||
c) and the values received in the Service-Route header field saved from the 200 (OK) response to the last
|
||||
registration or re-registration of the public user identity with associated contact address.
|
||||
*/
|
||||
if(request->type != tsip_REGISTER)
|
||||
if(request->request_type != tsip_REGISTER)
|
||||
{ // According to the above link ==> Initial/Re/De registration do not have routes.
|
||||
tsk_list_item_t* item;
|
||||
if(copy_routes_start !=-1)
|
||||
if(copy_routes_start != -1)
|
||||
{ /* The dialog already have routes ==> copy them. */
|
||||
if(self->state == tsip_early || self->state == tsip_established)
|
||||
{
|
||||
|
@ -269,9 +294,18 @@ tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* m
|
|||
}
|
||||
}
|
||||
|
||||
/* Add headers associated to the dialog's operation. */
|
||||
params = tsip_operation_get_headers(self->operation);
|
||||
tsk_list_foreach(item, params)
|
||||
{
|
||||
param = (const tsk_param_t*)item->data;
|
||||
TSIP_MESSAGE_ADD_HEADER(request, TSIP_HEADER_DUMMY_VA_ARGS(param->name, param->value));
|
||||
}
|
||||
|
||||
/* Add common headers */
|
||||
tsip_dialog_add_common_headers(self, request);
|
||||
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(request_uri);
|
||||
TSK_OBJECT_SAFE_FREE(from_uri);
|
||||
TSK_OBJECT_SAFE_FREE(to_uri);
|
||||
|
|
|
@ -385,7 +385,11 @@ int tsip_dialog_register_Trying_2_Connected_X_2xx(va_list *app)
|
|||
tsk_list_push_back_data(TSIP_DIALOG_GET_STACK(self)->associated_uris, (void**)&uri);
|
||||
}
|
||||
|
||||
/* Service-Route */
|
||||
/* Service-Route (3GPP TS 24.229)
|
||||
store the list of service route values contained in the Service-Route header field and bind the list to the contact
|
||||
address used in registration, in order to build a proper preloaded Route header field value for new dialogs and
|
||||
standalone transactions when using the respective contact address.
|
||||
*/
|
||||
for(index = 0; (hdr_Service_Route = (const tsip_header_Service_Route_t*)tsip_message_get_headerAt(message, tsip_htype_Service_Route, index)); index++){
|
||||
if(!TSIP_DIALOG_GET_STACK(self)->service_routes){
|
||||
TSIP_DIALOG_GET_STACK(self)->service_routes = TSK_LIST_CREATE();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
/**@file tsip_dialog_subscribe.client.c
|
||||
* @brief SIP dialog subscribe (Client side).
|
||||
* @brief SIP dialog SUBSCRIBE (Client side) as per RFC 3265.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
*/
|
||||
#include "tinysip/headers/tsip_header.h"
|
||||
|
||||
#include "tinysip/headers/tsip_header_Dummy.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn const char *tsip_header_get_name(tsip_header_type_t type)
|
||||
///
|
||||
|
@ -175,39 +177,34 @@ int tsip_header_tostring(const tsip_header_t *self, tsk_buffer_t *output)
|
|||
{
|
||||
tsk_list_item_t *item;
|
||||
|
||||
hname = tsip_header_get_name(self->type);
|
||||
if(self->type == tsip_htype_Dummy){
|
||||
hname = ((tsip_header_Dummy_t*)self)->name;
|
||||
}
|
||||
else{
|
||||
hname = tsip_header_get_name(self->type);
|
||||
}
|
||||
ret = 0; // for empty lists
|
||||
|
||||
/*
|
||||
* Header name
|
||||
*/
|
||||
/* Header name */
|
||||
tsk_buffer_appendEx(output, "%s: ", hname);
|
||||
|
||||
/*
|
||||
* Header value.
|
||||
*/
|
||||
if((ret=TSIP_HEADER(self)->tostring(self, output)))
|
||||
{
|
||||
/* Header value.*/
|
||||
if((ret = TSIP_HEADER(self)->tostring(self, output))){
|
||||
// CHECK all headers return value!
|
||||
//return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parameters
|
||||
*/
|
||||
/* Parameters */
|
||||
tsk_list_foreach(item, self->params)
|
||||
{
|
||||
tsk_param_t* param = item->data;
|
||||
separator = tsip_header_get_param_separator(self);
|
||||
if(ret=tsk_buffer_appendEx(output, param->value?"%c%s=%s":"%c%s", separator, param->name, param->value))
|
||||
{
|
||||
if(ret = tsk_buffer_appendEx(output, param->value?"%c%s=%s":"%c%s", separator, param->name, param->value)){
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CRLF
|
||||
*/
|
||||
/* CRLF */
|
||||
tsk_buffer_append(output, "\r\n", 2);
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -0,0 +1,325 @@
|
|||
|
||||
/* #line 1 "tsip_parser_header_Dummy.rl" */
|
||||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file tsip_header_Dummy.c
|
||||
* @brief SIP DUmmy header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinysip/headers/tsip_header_Dummy.h"
|
||||
|
||||
#include "tinysip/parsers/tsip_parser_uri.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup tsip_header_Dummy_group SIP Dummy header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
|
||||
/* #line 75 "tsip_parser_header_Dummy.rl" */
|
||||
|
||||
|
||||
int tsip_header_Dummy_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const tsip_header_Dummy_t *Dummy = header;
|
||||
if(Dummy->value)
|
||||
{
|
||||
tsk_buffer_append(output, Dummy->value, strlen(Dummy->value));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsip_header_Dummy_t *tsip_header_Dummy_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
tsip_header_Dummy_t *hdr_Dummy = TSIP_HEADER_DUMMY_CREATE_NULL();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
|
||||
/* #line 78 "../src/headers/tsip_header_Dummy.c" */
|
||||
static const char _tsip_machine_parser_header_Dummy_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2, 1,
|
||||
3, 2, 0, 2
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Dummy_key_offsets[] = {
|
||||
0, 0, 14, 31, 34, 37, 38, 39,
|
||||
40, 42, 45
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Dummy_trans_keys[] = {
|
||||
33, 37, 39, 126, 42, 43, 45, 46,
|
||||
48, 57, 65, 90, 95, 122, 9, 32,
|
||||
33, 37, 39, 58, 126, 42, 43, 45,
|
||||
46, 48, 57, 65, 90, 95, 122, 9,
|
||||
32, 58, 9, 13, 32, 13, 10, 10,
|
||||
9, 32, 9, 13, 32, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Dummy_single_lengths[] = {
|
||||
0, 4, 7, 3, 3, 1, 1, 1,
|
||||
2, 3, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Dummy_range_lengths[] = {
|
||||
0, 5, 5, 0, 0, 0, 0, 0,
|
||||
0, 0, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Dummy_index_offsets[] = {
|
||||
0, 0, 10, 23, 27, 31, 33, 35,
|
||||
37, 40, 44
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Dummy_indicies[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 2, 2, 3, 3, 3, 4,
|
||||
3, 3, 3, 3, 3, 3, 1, 5,
|
||||
5, 6, 1, 6, 8, 6, 7, 10,
|
||||
9, 11, 1, 12, 1, 13, 13, 1,
|
||||
13, 14, 13, 7, 1, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Dummy_trans_targs[] = {
|
||||
2, 0, 3, 2, 4, 3, 4, 5,
|
||||
7, 5, 6, 10, 8, 9, 6
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Dummy_trans_actions[] = {
|
||||
1, 0, 3, 0, 3, 0, 0, 1,
|
||||
0, 0, 5, 7, 0, 0, 9
|
||||
};
|
||||
|
||||
static const int tsip_machine_parser_header_Dummy_start = 1;
|
||||
static const int tsip_machine_parser_header_Dummy_first_final = 10;
|
||||
static const int tsip_machine_parser_header_Dummy_error = 0;
|
||||
|
||||
static const int tsip_machine_parser_header_Dummy_en_main = 1;
|
||||
|
||||
|
||||
/* #line 103 "tsip_parser_header_Dummy.rl" */
|
||||
|
||||
/* #line 141 "../src/headers/tsip_header_Dummy.c" */
|
||||
{
|
||||
cs = tsip_machine_parser_header_Dummy_start;
|
||||
}
|
||||
|
||||
/* #line 104 "tsip_parser_header_Dummy.rl" */
|
||||
|
||||
/* #line 148 "../src/headers/tsip_header_Dummy.c" */
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
const char *_keys;
|
||||
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
_resume:
|
||||
_keys = _tsip_machine_parser_header_Dummy_trans_keys + _tsip_machine_parser_header_Dummy_key_offsets[cs];
|
||||
_trans = _tsip_machine_parser_header_Dummy_index_offsets[cs];
|
||||
|
||||
_klen = _tsip_machine_parser_header_Dummy_single_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + _klen - 1;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + ((_upper-_lower) >> 1);
|
||||
if ( (*p) < *_mid )
|
||||
_upper = _mid - 1;
|
||||
else if ( (*p) > *_mid )
|
||||
_lower = _mid + 1;
|
||||
else {
|
||||
_trans += (_mid - _keys);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_keys += _klen;
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_klen = _tsip_machine_parser_header_Dummy_range_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + (_klen<<1) - 2;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
||||
if ( (*p) < _mid[0] )
|
||||
_upper = _mid - 2;
|
||||
else if ( (*p) > _mid[1] )
|
||||
_lower = _mid + 2;
|
||||
else {
|
||||
_trans += ((_mid - _keys)>>1);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_match:
|
||||
_trans = _tsip_machine_parser_header_Dummy_indicies[_trans];
|
||||
cs = _tsip_machine_parser_header_Dummy_trans_targs[_trans];
|
||||
|
||||
if ( _tsip_machine_parser_header_Dummy_trans_actions[_trans] == 0 )
|
||||
goto _again;
|
||||
|
||||
_acts = _tsip_machine_parser_header_Dummy_actions + _tsip_machine_parser_header_Dummy_trans_actions[_trans];
|
||||
_nacts = (unsigned int) *_acts++;
|
||||
while ( _nacts-- > 0 )
|
||||
{
|
||||
switch ( *_acts++ )
|
||||
{
|
||||
case 0:
|
||||
/* #line 52 "tsip_parser_header_Dummy.rl" */
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* #line 57 "tsip_parser_header_Dummy.rl" */
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Dummy->name);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
/* #line 62 "tsip_parser_header_Dummy.rl" */
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Dummy->value);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* #line 67 "tsip_parser_header_Dummy.rl" */
|
||||
{
|
||||
}
|
||||
break;
|
||||
/* #line 245 "../src/headers/tsip_header_Dummy.c" */
|
||||
}
|
||||
}
|
||||
|
||||
_again:
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
if ( ++p != pe )
|
||||
goto _resume;
|
||||
_test_eof: {}
|
||||
_out: {}
|
||||
}
|
||||
|
||||
/* #line 105 "tsip_parser_header_Dummy.rl" */
|
||||
|
||||
if( cs <
|
||||
/* #line 261 "../src/headers/tsip_header_Dummy.c" */
|
||||
10
|
||||
/* #line 106 "tsip_parser_header_Dummy.rl" */
|
||||
)
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_Dummy);
|
||||
}
|
||||
|
||||
return hdr_Dummy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Dummy header object definition
|
||||
//
|
||||
|
||||
/**@ingroup tsip_header_Dummy_group
|
||||
*/
|
||||
static void* tsip_header_Dummy_create(void *self, va_list * app)
|
||||
{
|
||||
tsip_header_Dummy_t *Dummy = self;
|
||||
if(Dummy)
|
||||
{
|
||||
TSIP_HEADER(Dummy)->type = tsip_htype_Dummy;
|
||||
TSIP_HEADER(Dummy)->tostring = tsip_header_Dummy_tostring;
|
||||
|
||||
Dummy->name = tsk_strdup(va_arg(*app, const char*));
|
||||
Dummy->value = tsk_strdup(va_arg(*app, const char*));
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Dummy header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup tsip_header_Dummy_group
|
||||
*/
|
||||
static void* tsip_header_Dummy_destroy(void *self)
|
||||
{
|
||||
tsip_header_Dummy_t *Dummy = self;
|
||||
if(Dummy)
|
||||
{
|
||||
TSK_FREE(Dummy->name);
|
||||
TSK_FREE(Dummy->value);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Dummy));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Dummy header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tsip_header_Dummy_def_s =
|
||||
{
|
||||
sizeof(tsip_header_Dummy_t),
|
||||
tsip_header_Dummy_create,
|
||||
tsip_header_Dummy_destroy,
|
||||
0
|
||||
};
|
||||
const void *tsip_header_Dummy_def_t = &tsip_header_Dummy_def_s;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -69,7 +69,7 @@ tsip_header_User_Agent_t *tsip_header_User_Agent_parse(const char *data, size_t
|
|||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
tsip_header_User_Agent_t *hdr_user_agent = TSIP_HEADER_USER_AGENT_CREATE(0);
|
||||
tsip_header_User_Agent_t *hdr_user_agent = TSIP_HEADER_USER_AGENT_CREATE(TSIP_NULL);
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
|
|
|
@ -94,26 +94,31 @@ int tsip_transport_msg_update(const tsip_transport_t* self, tsip_message_t *msg)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* VERY IMPORTANT: Only request/response with a contact header containing "doubs" parameter will be updated.
|
||||
* The update will concern the contact header(sigcomp uuid, host, port, ...), ipsec headers (Security-Client, Security-Verify, ...), ...
|
||||
*/
|
||||
|
||||
/* Update the contact header.*/
|
||||
if(msg->Contact){
|
||||
if(msg->Contact->uri && TSIP_HEADER_HAS_PARAM(msg->Contact, "doubs")){
|
||||
if(msg->Contact && TSIP_HEADER_HAVE_PARAM(msg->Contact, "doubs")){
|
||||
/* Host and port */
|
||||
if(msg->Contact->uri){
|
||||
tsk_strupdate(&(msg->Contact->uri->scheme), self->scheme);
|
||||
tsk_strupdate(&(msg->Contact->uri->host), ip);
|
||||
msg->Contact->uri->port = port;
|
||||
msg->Contact->uri->host_type = TNET_SOCKET_TYPE_IS_IPV6(self->type) ? host_ipv6 : host_ipv4;
|
||||
tsk_params_add_param(&msg->Contact->uri->params, "transport", self->protocol);
|
||||
|
||||
TSIP_HEADER_REMOVE_PARAM(msg->Contact, "doubs");
|
||||
}
|
||||
}
|
||||
|
||||
/* IPSec. */
|
||||
if(TNET_SOCKET_TYPE_IS_IPSEC(self->type)){
|
||||
ret = tsip_transport_ipsec_updateMSG(TSIP_TRANSPORT_IPSEC(self), msg);
|
||||
}
|
||||
|
||||
/* IPSec headers */
|
||||
if(TNET_SOCKET_TYPE_IS_IPSEC(self->type)){
|
||||
ret = tsip_transport_ipsec_updateMSG(TSIP_TRANSPORT_IPSEC(self), msg);
|
||||
}
|
||||
|
||||
/* SigComp. */
|
||||
/* SigComp */
|
||||
|
||||
/* Remove the parameter */
|
||||
TSIP_HEADER_REMOVE_PARAM(msg->Contact, "doubs");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -317,13 +317,11 @@ uint32_t tsip_message_getContent_length(const tsip_message_t *self)
|
|||
|
||||
int tsip_message_tostring(const tsip_message_t *self, tsk_buffer_t *output)
|
||||
{
|
||||
if(!self)
|
||||
{
|
||||
if(!self){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(TSIP_MESSAGE_IS_REQUEST(self))
|
||||
{
|
||||
if(TSIP_MESSAGE_IS_REQUEST(self)){
|
||||
/*Method SP Request_URI SP SIP_Version CRLF*/
|
||||
/* Method */
|
||||
tsk_buffer_appendEx(output, "%s ", self->method);
|
||||
|
@ -332,8 +330,7 @@ int tsip_message_tostring(const tsip_message_t *self, tsk_buffer_t *output)
|
|||
/* SIP VERSION */
|
||||
tsk_buffer_appendEx(output, " %s\r\n", TSIP_MESSAGE_VERSION_DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
/*SIP_Version SP Status_Code SP Reason_Phrase CRLF*/
|
||||
tsk_buffer_appendEx(output, "%s %hi %s\r\n", TSIP_MESSAGE_VERSION_DEFAULT, TSIP_RESPONSE_CODE(self), TSIP_RESPONSE_PHRASE(self));
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef struct tsip_operation_s
|
|||
tsip_operation_id_t id;
|
||||
const tsip_stack_handle_t* stack;
|
||||
tsk_params_L_t *params;
|
||||
tsk_params_L_t *capabilities;
|
||||
tsk_params_L_t *caps;
|
||||
tsk_params_L_t *headers;
|
||||
}
|
||||
tsip_operation_t;
|
||||
|
@ -73,10 +73,72 @@ tsip_operation_handle_t *tsip_operation_createex(const struct tsip_message_s* me
|
|||
return operation;
|
||||
}
|
||||
|
||||
int __tsip_operation_set(tsip_operation_t *self, va_list values)
|
||||
{
|
||||
tsip_operation_param_type_t curr;
|
||||
|
||||
if(!self){
|
||||
return -1;
|
||||
}
|
||||
|
||||
while((curr=va_arg(values, tsip_operation_param_type_t)) != optype_null)
|
||||
{
|
||||
switch(curr)
|
||||
{
|
||||
case optype_param:
|
||||
case optype_header:
|
||||
case optype_caps:
|
||||
{
|
||||
const char* name = va_arg(values, const char *);
|
||||
const char* value = va_arg(values, const char *);
|
||||
|
||||
tsk_param_t *param = TSK_PARAM_CREATE(name, value);
|
||||
if(curr == optype_param){
|
||||
tsk_list_push_back_data(self->params, ((void**) ¶m));
|
||||
} else if(curr == optype_header){
|
||||
tsk_list_push_back_data(self->headers, ((void**) ¶m));
|
||||
}else if(curr == optype_caps){
|
||||
tsk_list_push_back_data(self->caps, ((void**) ¶m));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
TSK_DEBUG_ERROR("NOT SUPPORTED.");
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bail:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tsip_operation_set(tsip_operation_handle_t *self, ...)
|
||||
{
|
||||
if(self){
|
||||
int ret;
|
||||
va_list params;
|
||||
|
||||
tsip_operation_t *operation = self;
|
||||
|
||||
if(operation->id == TSIP_OPERATION_INVALID_ID){
|
||||
return -2;
|
||||
}
|
||||
|
||||
va_start(params, self);
|
||||
ret = __tsip_operation_set(operation, params);
|
||||
va_end(params);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsip_operation_id_t tsip_operation_get_id(const tsip_operation_handle_t *self)
|
||||
{
|
||||
if(self)
|
||||
{
|
||||
if(self){
|
||||
const tsip_operation_t *operation = self;
|
||||
return operation->id;
|
||||
}
|
||||
|
@ -85,15 +147,36 @@ tsip_operation_id_t tsip_operation_get_id(const tsip_operation_handle_t *self)
|
|||
|
||||
const tsk_param_t* tsip_operation_get_param(const tsip_operation_handle_t *self, const char* pname)
|
||||
{
|
||||
if(self)
|
||||
{
|
||||
if(self){
|
||||
const tsip_operation_t *operation = self;
|
||||
return tsk_params_get_param_by_name(operation->params, pname);
|
||||
}
|
||||
return TSIP_NULL;
|
||||
}
|
||||
|
||||
|
||||
const tsk_params_L_t* tsip_operation_get_headers(const tsip_operation_handle_t *self)
|
||||
{
|
||||
if(self){
|
||||
return ((const tsip_operation_t *)self)->headers;
|
||||
}
|
||||
return TSIP_NULL;
|
||||
}
|
||||
|
||||
const tsk_params_L_t* tsip_operation_get_params(const tsip_operation_handle_t *self)
|
||||
{
|
||||
if(self){
|
||||
return ((const tsip_operation_t *)self)->params;
|
||||
}
|
||||
return TSIP_NULL;
|
||||
}
|
||||
|
||||
const tsk_params_L_t* tsip_operation_get_caps(const tsip_operation_handle_t *self)
|
||||
{
|
||||
if(self){
|
||||
return ((const tsip_operation_t *)self)->caps;
|
||||
}
|
||||
return TSIP_NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -109,39 +192,19 @@ static void* tsip_operation_create(void * self, va_list * app)
|
|||
static tsip_operation_id_t unique_id = 0;
|
||||
if(operation)
|
||||
{
|
||||
tsip_operation_param_type_t curr;
|
||||
|
||||
operation->stack = va_arg(*app, const tsip_stack_handle_t*);
|
||||
operation->params = TSK_LIST_CREATE();
|
||||
operation->capabilities = TSK_LIST_CREATE();
|
||||
operation->caps = TSK_LIST_CREATE();
|
||||
operation->headers = TSK_LIST_CREATE();
|
||||
|
||||
while((curr=va_arg(*app, tsip_operation_param_type_t)) != oppname_null)
|
||||
{
|
||||
switch(curr)
|
||||
{
|
||||
case oppname_nvp:
|
||||
{
|
||||
const char* name = va_arg(*app, const char *);
|
||||
const char* value = va_arg(*app, const char *);
|
||||
|
||||
tsk_param_t *param = TSK_PARAM_CREATE(name, value);
|
||||
tsk_list_push_back_data(operation->params, ((void**) ¶m));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
TSK_DEBUG_ERROR("NOT SUPPORTED.");
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
if(__tsip_operation_set(self, *app)){
|
||||
operation->id = TSIP_OPERATION_INVALID_ID;
|
||||
}
|
||||
else{
|
||||
operation->id = ++unique_id;
|
||||
}
|
||||
|
||||
operation->id = ++unique_id;
|
||||
}
|
||||
|
||||
bail:
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -151,7 +214,7 @@ static void* tsip_operation_destroy(void * self)
|
|||
if(operation)
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(operation->params);
|
||||
TSK_OBJECT_SAFE_FREE(operation->capabilities);
|
||||
TSK_OBJECT_SAFE_FREE(operation->caps);
|
||||
TSK_OBJECT_SAFE_FREE(operation->headers);
|
||||
}
|
||||
return self;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#ifndef _TEST_SIPMESSAGES_H
|
||||
#define _TEST_SIPMESSAGES_H
|
||||
|
||||
#include "tinysip/headers/tsip_header_Dummy.h"
|
||||
|
||||
#define SIP_REQUEST \
|
||||
"REGISTER sip:open-ims.test SIP/2.0\r\n" \
|
||||
"Test-Header: 0\r\n" \
|
||||
|
@ -141,6 +143,10 @@ void test_parser()
|
|||
|
||||
expires = tsip_message_getExpires(message);
|
||||
clength = TSIP_MESSAGE_CONTENT_LENGTH(message);
|
||||
|
||||
/* Add new headers */
|
||||
TSIP_MESSAGE_ADD_HEADER(message, TSIP_HEADER_DUMMY_VA_ARGS("MyHeader1", "Value1; test=123;m"));
|
||||
TSIP_MESSAGE_ADD_HEADER(message, TSIP_HEADER_DUMMY_VA_ARGS("MyHeader2", "Value2"));
|
||||
|
||||
tsip_message_tostring(message, buffer);
|
||||
TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer));
|
||||
|
|
|
@ -140,7 +140,7 @@ void test_stack()
|
|||
TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"),
|
||||
TSIP_STACK_SET_PRIVACY("header;id"),
|
||||
*/
|
||||
/*
|
||||
|
||||
tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback,
|
||||
TSIP_STACK_SET_DISPLAY_NAME("Mamadou"),
|
||||
TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@ericsson.com"),
|
||||
|
@ -152,12 +152,13 @@ void test_stack()
|
|||
TSIP_STACK_SET_PROXY_CSCF("192.168.0.11", "udp", 0),
|
||||
//TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0),
|
||||
TSIP_STACK_SET_PROXY_CSCF_PORT(5081),
|
||||
TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"),
|
||||
TSIP_STACK_SET_MOBILITY("fixed"),
|
||||
TSIP_STACK_SET_DEVICE_ID("DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC"),
|
||||
TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"),
|
||||
TSIP_STACK_SET_PRIVACY("header;id"),
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback,
|
||||
TSIP_STACK_SET_DISPLAY_NAME("Mamadou"),
|
||||
TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@ims.inexbee.com"),
|
||||
|
@ -174,11 +175,14 @@ void test_stack()
|
|||
TSIP_STACK_SET_DEVICE_ID("DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC"),
|
||||
TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"),
|
||||
TSIP_STACK_SET_PRIVACY("header;id"),
|
||||
|
||||
*/
|
||||
TSIP_STACK_SET_NULL());
|
||||
|
||||
tsip_operation_handle_t *op = TSIP_OPERATION_CREATE(stack,
|
||||
TSIP_OPERATION_SET_PARAM("expires", "300"),
|
||||
TSIP_OPERATION_SET_PARAM("expires", "30"),
|
||||
|
||||
TSIP_OPERATION_SET_CAPS("language", "\"en,fr\""),
|
||||
TSIP_OPERATION_SET_CAPS("+audio", ""),
|
||||
|
||||
TSIP_OPERATION_SET_NULL());
|
||||
|
||||
|
@ -193,22 +197,24 @@ void test_stack()
|
|||
|
||||
tsip_register(stack, op);
|
||||
|
||||
/*tsk_thread_sleep(2000);
|
||||
tsk_thread_sleep(2000);
|
||||
|
||||
{
|
||||
tsip_operation_handle_t *op2 = TSIP_OPERATION_CREATE(stack,
|
||||
TSIP_OPERATION_SET_PARAM("to", "sip:mamadou@ericsson.com"),
|
||||
TSIP_OPERATION_SET_PARAM("expires", "30"),
|
||||
TSIP_OPERATION_SET_PARAM("package", "reg"),
|
||||
TSIP_OPERATION_SET_PARAM("accept", "application/reginfo+xml"),
|
||||
TSIP_OPERATION_SET_PARAM("to", "sip:mamadou@ericsson.com"),
|
||||
TSIP_OPERATION_SET_HEADER("Accept", "application/reginfo+xml"),
|
||||
TSIP_OPERATION_SET_HEADER("Allow-Events", "refer, presence, presence.winfo, xcap-diff"),
|
||||
TSIP_OPERATION_SET_HEADER("Allow", "INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER"),
|
||||
|
||||
TSIP_OPERATION_SET_NULL());
|
||||
tsip_subscribe(stack, op2);
|
||||
}*/
|
||||
}
|
||||
|
||||
//{
|
||||
// tsip_operation_handle_t *op3 = TSIP_OPERATION_CREATE(stack,
|
||||
// TSIP_OPERATION_SET_PARAM("to", "sip:laurent@ims.inexbee.com"),
|
||||
// TSIP_OPERATION_SET_PARAM("to", "sip:alice@ericsson.com"),
|
||||
// TSIP_OPERATION_SET_PARAM("content", "test"),
|
||||
// TSIP_OPERATION_SET_PARAM("content-type", "text/plain"),
|
||||
//
|
||||
|
|
|
@ -457,6 +457,10 @@
|
|||
RelativePath=".\src\headers\tsip_header_Date.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\headers\tsip_header_Dummy.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\headers\tsip_header_Error_Info.c"
|
||||
>
|
||||
|
@ -829,6 +833,10 @@
|
|||
RelativePath=".\src\dialogs\tsip_dialog_message.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\dialogs\tsip_dialog_publish.client.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\dialogs\tsip_dialog_register.client.c"
|
||||
>
|
||||
|
@ -1007,6 +1015,10 @@
|
|||
RelativePath=".\include\tinysip\headers\tsip_header_Date.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinysip\headers\tsip_header_Dummy.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinysip\headers\tsip_header_Error_Info.h"
|
||||
>
|
||||
|
@ -1379,6 +1391,10 @@
|
|||
RelativePath=".\include\tinysip\dialogs\tsip_dialog_message.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinysip\dialogs\tsip_dialog_publish.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinysip\dialogs\tsip_dialog_register.h"
|
||||
>
|
||||
|
@ -1524,6 +1540,10 @@
|
|||
RelativePath=".\ragel\tsip_parser_header_Date.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\tsip_parser_header_Dummy.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\tsip_parser_header_Error_Info.rl"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue