Commit e4aed285 authored by jehan's avatar jehan

finilize clone implementation for SIP headers

parent db486d24
......@@ -67,9 +67,6 @@
</tool>
</toolChain>
</folderInfo>
<fileInfo id="cdt.managedbuild.config.gnu.macosx.exe.debug.341835025.821599532" name="basic_test.c" rcbsApplicability="disable" resourcePath="tester/basic_test.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.939505843">
<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.939505843" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201"/>
</fileInfo>
<fileInfo id="cdt.managedbuild.config.gnu.macosx.exe.debug.341835025.2100612038" name="belle_sdp_tester.c" rcbsApplicability="disable" resourcePath="tester/belle_sdp_tester.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.1004313556">
<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.1004313556" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201">
<option id="gnu.c.compiler.option.include.paths.1078534444" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
......@@ -122,9 +119,9 @@
</tool>
</fileInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include"/>
<entry excluding="basic_test.c|cast_test.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="tester"/>
<entry excluding="sender_task.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
......@@ -1183,9 +1180,9 @@
</tool>
</fileInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="tester"/>
<entry excluding="sender_task.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
......
......@@ -45,7 +45,7 @@ int belle_sdp_bandwidth_get_value(const belle_sdp_bandwidth_t* attribute);
const char* belle_sdp_bandwidth_get_type(const belle_sdp_bandwidth_t* attribute);
void belle_sdp_bandwidth_set_value(belle_sdp_bandwidth_t* attribute, int value);
void belle_sdp_bandwidth_set_type(belle_sdp_bandwidth_t* attribute, const char* type);
#define BELLE_SDP_BANDWITH(t) BELLE_SDP_CAST(t,belle_sdp_bandwidth_t);
#define BELLE_SDP_BANDWIDTH(t) BELLE_SDP_CAST(t,belle_sdp_bandwidth_t);
/***************************************************************************************
* Connection
*
......
......@@ -30,9 +30,13 @@ struct _belle_sdp_attribute {
const char* value;
};
void belle_sdp_attribute_destroy(belle_sdp_attribute_t* attribute) {
if (attribute->name) belle_sip_free((void*)attribute->name);
if (attribute->value) belle_sip_free((void*)attribute->value);
}
void belle_sdp_attribute_clone(belle_sdp_attribute_t *attribute, const belle_sdp_attribute_t *orig){
CLONE_STRING(belle_sdp_attribute,name,attribute,orig)
CLONE_STRING(belle_sdp_attribute,value,attribute,orig)
}
int belle_sdp_attribute_marshal(belle_sdp_attribute_t* attribute, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......@@ -65,9 +69,12 @@ struct _belle_sdp_bandwidth {
int value;
};
void belle_sdp_bandwidth_destroy(belle_sdp_bandwidth_t* bandwidth) {
if (bandwidth->type) belle_sip_free((void*)bandwidth->type);
}
void belle_sdp_bandwidth_clone(belle_sdp_bandwidth_t *bandwidth, const belle_sdp_bandwidth_t *orig){
CLONE_STRING(belle_sdp_bandwidth,type,bandwidth,orig)
bandwidth->value=orig->value;
}
int belle_sdp_bandwidth_marshal(belle_sdp_bandwidth_t* bandwidth, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......
......@@ -37,7 +37,7 @@ void belle_sip_header_init(belle_sip_header_t *header) {
}
static void belle_sip_header_clone(belle_sip_header_t *header, const belle_sip_header_t *orig){
CLONE_STRING(belle_sip_header,name,header,orig)
if (belle_sip_header_get_next(orig)) {
belle_sip_header_set_next(header,BELLE_SIP_HEADER(belle_sip_object_clone(BELLE_SIP_OBJECT(belle_sip_header_get_next(orig))))) ;
}
......@@ -64,7 +64,7 @@ int belle_sip_header_marshal(belle_sip_header_t* header, char* buff,unsigned int
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(belle_sip_header_t);
BELLE_SIP_INSTANCIATE_VPTR(belle_sip_header_t,belle_sip_object_t,belle_sip_header_destroy,NULL,belle_sip_header_marshal);
BELLE_SIP_INSTANCIATE_VPTR(belle_sip_header_t,belle_sip_object_t,belle_sip_header_destroy,belle_sip_header_clone,belle_sip_header_marshal);
/************************
......@@ -168,6 +168,7 @@ void belle_sip_header_contact_destroy(belle_sip_header_contact_t* contact) {
}
void belle_sip_header_contact_clone(belle_sip_header_contact_t *contact, const belle_sip_header_contact_t *orig){
contact->wildcard=orig->wildcard;
}
int belle_sip_header_contact_marshal(belle_sip_header_contact_t* contact, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......@@ -284,6 +285,10 @@ static void belle_sip_header_user_agent_destroy(belle_sip_header_user_agent_t* u
}
static void belle_sip_header_user_agent_clone(belle_sip_header_user_agent_t* user_agent, const belle_sip_header_user_agent_t* orig){
belle_sip_list_t* list=orig->products;
for(;list!=NULL;list=list->next){
belle_sip_header_user_agent_add_product(user_agent,(const char *)list->data);
}
}
int belle_sip_header_user_agent_marshal(belle_sip_header_user_agent_t* user_agent, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......@@ -298,7 +303,7 @@ int belle_sip_header_user_agent_marshal(belle_sip_header_user_agent_t* user_agen
return current_offset-offset;
}
BELLE_SIP_NEW_HEADER(header_user_agent,header_address,"User-Agent")
BELLE_SIP_NEW_HEADER(header_user_agent,header,"User-Agent")
BELLE_SIP_PARSE(header_user_agent)
belle_sip_list_t* belle_sip_header_user_agent_get_products(const belle_sip_header_user_agent_t* user_agent) {
return user_agent->products;
......@@ -331,11 +336,16 @@ struct _belle_sip_header_via {
};
static void belle_sip_header_via_destroy(belle_sip_header_via_t* via) {
if (via->host) belle_sip_free(via->host);
if (via->protocol) belle_sip_free(via->protocol);
if (via->transport) belle_sip_free(via->transport);
if (via->host) belle_sip_free(via->host);
}
static void belle_sip_header_via_clone(belle_sip_header_via_t* via, const belle_sip_header_via_t*orig){
CLONE_STRING(belle_sip_header_via,protocol,via,orig)
CLONE_STRING(belle_sip_header_via,transport,via,orig)
CLONE_STRING(belle_sip_header_via,host,via,orig)
via->port=orig->port;
}
int belle_sip_header_via_marshal(belle_sip_header_via_t* via, char* buff,unsigned int offset,unsigned int buff_size) {
......@@ -360,7 +370,7 @@ belle_sip_header_via_t* belle_sip_header_via_create(const char *host, int port,
return via;
}
BELLE_SIP_NEW_HEADER(header_via,header_address,"Via")
BELLE_SIP_NEW_HEADER(header_via,parameters,"Via")
BELLE_SIP_PARSE(header_via)
GET_SET_STRING(belle_sip_header_via,protocol);
GET_SET_STRING(belle_sip_header_via,transport);
......@@ -423,6 +433,7 @@ static void belle_sip_header_call_id_destroy(belle_sip_header_call_id_t* call_id
}
static void belle_sip_header_call_id_clone(belle_sip_header_call_id_t* call_id,const belle_sip_header_call_id_t *orig){
CLONE_STRING(belle_sip_header_call_id,call_id,call_id,orig);
}
int belle_sip_header_call_id_marshal(belle_sip_header_call_id_t* call_id, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......@@ -449,8 +460,8 @@ static void belle_sip_header_cseq_destroy(belle_sip_header_cseq_t* cseq) {
}
static void belle_sip_header_cseq_clone(belle_sip_header_cseq_t* cseq, const belle_sip_header_cseq_t *orig) {
if (cseq->method) belle_sip_free(cseq->method);
cseq->method=belle_sip_strdup(orig->method);
CLONE_STRING(belle_sip_header_cseq,method,cseq,orig)
cseq->seq_number=orig->seq_number;
}
int belle_sip_header_cseq_marshal(belle_sip_header_cseq_t* cseq, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......@@ -484,6 +495,8 @@ static void belle_sip_header_content_type_destroy(belle_sip_header_content_type_
}
static void belle_sip_header_content_type_clone(belle_sip_header_content_type_t* content_type, const belle_sip_header_content_type_t* orig){
CLONE_STRING(belle_sip_header_content_type,type,content_type,orig);
CLONE_STRING(belle_sip_header_content_type,subtype,content_type,orig);
}
int belle_sip_header_content_type_marshal(belle_sip_header_content_type_t* content_type, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......@@ -547,6 +560,7 @@ static void belle_sip_header_content_length_destroy(belle_sip_header_content_len
static void belle_sip_header_content_length_clone(belle_sip_header_content_length_t* content_length,
const belle_sip_header_content_length_t *orig ) {
content_length->content_length=orig->content_length;
}
int belle_sip_header_content_length_marshal(belle_sip_header_content_length_t* content_length, char* buff,unsigned int offset,unsigned int buff_size) {
......@@ -572,6 +586,7 @@ static void belle_sip_header_expires_destroy(belle_sip_header_expires_t* expires
static void belle_sip_header_expires_clone(belle_sip_header_expires_t* expires,
const belle_sip_header_expires_t *orig ) {
expires->expires=orig->expires;
}
int belle_sip_header_expires_marshal(belle_sip_header_expires_t* expires, char* buff,unsigned int offset,unsigned int buff_size) {
......@@ -598,6 +613,7 @@ static void belle_sip_header_extension_destroy(belle_sip_header_extension_t* ext
}
static void belle_sip_header_extension_clone(belle_sip_header_extension_t* extension, const belle_sip_header_extension_t* orig){
CLONE_STRING(belle_sip_header_extension,value,extension,orig)
}
int belle_sip_header_extension_marshal(belle_sip_header_extension_t* extension, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......@@ -654,6 +670,13 @@ GET_SET_STRING(belle_sip_header_extension,value);
if (obj->qop) belle_sip_free((void*)obj->qop);\
/*if (obj->params_list) FIXME free list*/
#define AUTH_BASE_CLONE(object_type,dest,src) \
CLONE_STRING(object_type,scheme,dest,src)\
CLONE_STRING(object_type,realm,dest,src)\
CLONE_STRING(object_type,nonce,dest,src)\
CLONE_STRING(object_type,algorithm,dest,src)\
CLONE_STRING(object_type,opaque,dest,src)\
CLONE_STRING(object_type,qop,dest,src)
#define AUTH_BASE_MARSHAL(header) \
unsigned int current_offset=offset;\
......@@ -712,6 +735,14 @@ static void belle_sip_header_authorization_destroy(belle_sip_header_authorizatio
static void belle_sip_header_authorization_clone(belle_sip_header_authorization_t* authorization,
const belle_sip_header_authorization_t *orig ) {
AUTH_BASE_CLONE(belle_sip_header_authorization,authorization,orig)
CLONE_STRING(belle_sip_header_authorization,username,authorization,orig)
if (belle_sip_header_authorization_get_uri(orig)) {
belle_sip_header_authorization_set_uri(authorization,BELLE_SIP_URI(belle_sip_object_clone(BELLE_SIP_OBJECT(belle_sip_header_authorization_get_uri(orig)))));
}
CLONE_STRING(belle_sip_header_authorization,response,authorization,orig)
CLONE_STRING(belle_sip_header_authorization,cnonce,authorization,orig)
authorization->nonce_count=orig->nonce_count;
}
static void belle_sip_header_authorization_init(belle_sip_header_authorization_t* authorization) {
}
......@@ -812,6 +843,9 @@ void belle_sip_header_www_authenticate_init(belle_sip_header_www_authenticate_t*
}
static void belle_sip_header_www_authenticate_clone(belle_sip_header_www_authenticate_t* www_authenticate,
const belle_sip_header_www_authenticate_t *orig ) {
AUTH_BASE_CLONE(belle_sip_header_www_authenticate,www_authenticate,orig)
CLONE_STRING(belle_sip_header_www_authenticate,domain,www_authenticate,orig)
www_authenticate->stale=orig->stale;
}
int belle_sip_header_www_authenticate_marshal(belle_sip_header_www_authenticate_t* www_authenticate, char* buff,unsigned int offset,unsigned int buff_size) {
AUTH_BASE_MARSHAL(www_authenticate)
......@@ -852,6 +886,7 @@ static void belle_sip_header_max_forwards_destroy(belle_sip_header_max_forwards_
static void belle_sip_header_max_forwards_clone(belle_sip_header_max_forwards_t* max_forwards,
const belle_sip_header_max_forwards_t *orig ) {
max_forwards->max_forwards=orig->max_forwards;
}
int belle_sip_header_max_forwards_marshal(belle_sip_header_max_forwards_t* max_forwards, char* buff,unsigned int offset,unsigned int buff_size) {
......
......@@ -52,7 +52,7 @@ belle_sip_object_t * belle_sip_object_ref(void *obj){
void belle_sip_object_unref(void *ptr){
belle_sip_object_t *obj=BELLE_SIP_OBJECT(ptr);
if (obj->ref==0){
belle_sip_warning("Destroying unowed object");
/*might hide a double unref belle_sip_warning("Destroying unowed object");*/
belle_sip_object_delete(obj);
return;
}
......
......@@ -29,7 +29,11 @@ static void belle_sip_parameters_destroy(belle_sip_parameters_t* params) {
}
static void belle_sip_parameters_clone(belle_sip_parameters_t *params, const belle_sip_parameters_t *orig){
belle_sip_fatal("not implemented");
belle_sip_list_t* list=orig->param_list;
for(;list!=NULL;list=list->next){
belle_sip_param_pair_t* container = (belle_sip_param_pair_t* )(list->data);
belle_sip_parameters_set_parameter( params,container->name,container->value);
}
}
int belle_sip_parameters_marshal(belle_sip_parameters_t* params, char* buff,unsigned int offset,unsigned int buff_size) {
belle_sip_list_t* list=params->param_list;
......
......@@ -50,18 +50,18 @@ struct _belle_sip_uri {
belle_sip_parameters_t * header_list;
};
void belle_sip_uri_destroy(belle_sip_uri_t* uri) {
static void belle_sip_uri_destroy(belle_sip_uri_t* uri) {
if (uri->user) belle_sip_free (uri->user);
if (uri->host) belle_sip_free (uri->host);
belle_sip_object_unref(BELLE_SIP_OBJECT(uri->header_list));
}
void belle_sip_uri_clone(belle_sip_uri_t* uri, const belle_sip_uri_t *orig){
static void belle_sip_uri_clone(belle_sip_uri_t* uri, const belle_sip_uri_t *orig){
uri->secure=orig->secure;
uri->user=belle_sip_strdup(orig->user);
uri->host=belle_sip_strdup(orig->host);
uri->user=orig->user?belle_sip_strdup(orig->user):NULL;
uri->host=orig->host?belle_sip_strdup(orig->host):NULL;
uri->port=orig->port;
uri->header_list=(belle_sip_parameters_t*)belle_sip_object_clone(BELLE_SIP_OBJECT(orig->header_list));
uri->header_list=orig->header_list?(belle_sip_parameters_t*)belle_sip_object_clone(BELLE_SIP_OBJECT(orig->header_list)):NULL;
}
int belle_sip_uri_marshal(belle_sip_uri_t* uri, char* buff,unsigned int offset,unsigned int buff_size) {
......
......@@ -47,20 +47,26 @@ static int clean_suite_sdp(void) {
//a=fmtp:98 CIF=1;QCIF=1
static void test_attribute(void) {
belle_sdp_attribute_t* lTmp;
belle_sdp_attribute_t* lAttribute = belle_sdp_attribute_parse("a=rtpmap:101 telephone-event/8000");
char* l_raw_attribute = belle_sip_object_to_string(BELLE_SIP_OBJECT(lAttribute));
belle_sip_object_unref(BELLE_SIP_OBJECT(lAttribute));
lAttribute = belle_sdp_attribute_parse(l_raw_attribute);
lTmp = belle_sdp_attribute_parse(l_raw_attribute);
lAttribute = BELLE_SDP_ATTRIBUTE(belle_sip_object_clone(BELLE_SIP_OBJECT(lTmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(lTmp));
CU_ASSERT_STRING_EQUAL(belle_sdp_attribute_get_name(lAttribute), "rtpmap");
CU_ASSERT_STRING_EQUAL(belle_sdp_attribute_get_value(lAttribute), "101 telephone-event/8000");
CU_ASSERT_TRUE(belle_sdp_attribute_as_value(lAttribute));
belle_sip_object_unref(BELLE_SIP_OBJECT(lAttribute));
}
static void test_bandwidth(void) {
belle_sdp_bandwidth_t* lTmp;
belle_sdp_bandwidth_t* l_bandwidth = belle_sdp_bandwidth_parse("b=AS:380");
char* l_raw_bandwidth = belle_sip_object_to_string(BELLE_SIP_OBJECT(l_bandwidth));
belle_sip_object_unref(BELLE_SIP_OBJECT(l_bandwidth));
l_bandwidth = belle_sdp_bandwidth_parse(l_raw_bandwidth);
lTmp = belle_sdp_bandwidth_parse(l_raw_bandwidth);
l_bandwidth = BELLE_SDP_BANDWIDTH(belle_sip_object_clone(BELLE_SIP_OBJECT(lTmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(lTmp));
CU_ASSERT_STRING_EQUAL(belle_sdp_bandwidth_get_type(l_bandwidth), "AS");
CU_ASSERT_EQUAL(belle_sdp_bandwidth_get_value(l_bandwidth),380);
belle_sip_object_unref(BELLE_SIP_OBJECT(l_bandwidth));
......
This diff is collapsed.
......@@ -30,11 +30,15 @@ static int clean_suite_uri(void) {
static void testSIMPLEURI(void) {
belle_sip_uri_t* L_tmp;
belle_sip_uri_t* L_uri = belle_sip_uri_parse("sip:titi.com");
char* l_raw_uri = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_uri));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
L_uri = belle_sip_uri_parse(l_raw_uri);
L_tmp = belle_sip_uri_parse(l_raw_uri);
L_uri = BELLE_SIP_URI(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_uri);
CU_ASSERT_PTR_NULL(belle_sip_uri_get_user(L_uri));
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "titi.com");
CU_ASSERT_PTR_NULL(belle_sip_uri_get_transport_param(L_uri));
......@@ -42,10 +46,13 @@ static void testSIMPLEURI(void) {
}
static void testCOMPLEXURI(void) {
belle_sip_uri_t* L_tmp;
belle_sip_uri_t * L_uri = belle_sip_uri_parse("sip:toto@titi.com:5060;transport=tcp");
char* l_raw_uri = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_uri));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
L_uri = belle_sip_uri_parse(l_raw_uri);
L_tmp = belle_sip_uri_parse(l_raw_uri);
L_uri = BELLE_SIP_URI(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_uri);
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_user(L_uri), "toto");
CU_ASSERT_EQUAL(belle_sip_uri_get_port(L_uri), 5060);
......@@ -54,6 +61,7 @@ static void testCOMPLEXURI(void) {
belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
}
static void testSIPSURI(void) {
belle_sip_uri_t * L_uri = belle_sip_uri_parse("sips:linphone.org");
char* l_raw_uri = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_uri));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
......@@ -96,13 +104,18 @@ static void test_maddr(void) {
}
static void test_uri_parameters () {
belle_sip_uri_t* L_tmp;
belle_sip_uri_t * L_uri = belle_sip_uri_parse("sip:192.168.0.1;ttl=12");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
L_uri = belle_sip_uri_parse("sip:maddr=@192.168.0.1;lr;maddr=192.168.0.1;user=ip;ttl=140;transport=sctp;method=INVITE;rport=5060");
char* l_raw_uri = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_uri));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
L_uri = belle_sip_uri_parse(l_raw_uri);
L_tmp = belle_sip_uri_parse(l_raw_uri);
L_uri = BELLE_SIP_URI(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_uri);
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_maddr_param(L_uri), "192.168.0.1");
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_user_param(L_uri), "ip");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment