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));
......
......@@ -32,11 +32,13 @@ int clean_suite1(void) {
void test_simple_header_contact(void) {
belle_sip_header_contact_t* L_tmp;
belle_sip_header_contact_t* L_contact = belle_sip_header_contact_parse("Contact:sip:titi.com");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_contact));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_contact));
L_contact = belle_sip_header_contact_parse(l_raw_header);
L_tmp = belle_sip_header_contact_parse(l_raw_header);
L_contact = BELLE_SIP_HEADER_CONTACT(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
belle_sip_uri_t* L_uri = belle_sip_header_address_get_uri((belle_sip_header_address_t*)L_contact);
......@@ -48,9 +50,11 @@ void test_simple_header_contact(void) {
}
void test_complex_header_contact(void) {
belle_sip_header_contact_t* L_contact;
belle_sip_header_contact_t* L_tmp = belle_sip_header_contact_parse("Contact: \"jremis\" <sip:sip.linphone.org>;expires=3600;q=0.7, sip:titi.com");
belle_sip_header_contact_t* L_contact = belle_sip_header_contact_parse("Contact: \"jremis\" <sip:sip.linphone.org>;expires=3600;q=0.7, sip:titi.com");
L_contact = BELLE_SIP_HEADER_CONTACT(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_uri_t* L_uri = belle_sip_header_address_get_uri((belle_sip_header_address_t*)L_contact);
......@@ -82,11 +86,13 @@ void test_complex_header_contact(void) {
}
void test_simple_header_from(void) {
belle_sip_header_from_t* L_tmp;
belle_sip_header_from_t* L_from = belle_sip_header_from_parse("From:<sip:titi.com;transport=tcp>;tag=dlfjklcn6545614XX");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_from));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_from));
L_from = belle_sip_header_from_parse(l_raw_header);
L_tmp = belle_sip_header_from_parse(l_raw_header);
L_from = BELLE_SIP_HEADER_FROM(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
belle_sip_uri_t* L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_from));
......@@ -113,11 +119,13 @@ void test_simple_header_to(void) {
belle_sip_object_unref(BELLE_SIP_OBJECT(L_to));
}
void test_header_via(void) {
belle_sip_header_via_t* L_tmp;
belle_sip_header_via_t* L_via = belle_sip_header_via_parse("Via: SIP/2.0/UDP 192.168.0.19:5062;rport;received=192.169.0.4;branch=z9hG4bK368560724");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_via));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_via));
L_via = belle_sip_header_via_parse(l_raw_header);
L_tmp = belle_sip_header_via_parse(l_raw_header);
L_via = BELLE_SIP_HEADER_VIA(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_protocol(L_via), "SIP/2.0");
......@@ -140,22 +148,26 @@ void test_header_via(void) {
}
void test_header_call_id(void) {
belle_sip_header_call_id_t* L_tmp;
belle_sip_header_call_id_t* L_call_id = belle_sip_header_call_id_parse("Call-ID: 1665237789@titi.com");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_call_id));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_call_id));
L_call_id = belle_sip_header_call_id_parse(l_raw_header);
L_tmp= belle_sip_header_call_id_parse(l_raw_header);
L_call_id = BELLE_SIP_HEADER_CALL_ID(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_STRING_EQUAL(belle_sip_header_call_id_get_call_id(L_call_id), "1665237789@titi.com");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_call_id));
}
void test_header_cseq(void) {
belle_sip_header_cseq_t* L_tmp;
belle_sip_header_cseq_t* L_cseq = belle_sip_header_cseq_parse("CSeq: 21 INVITE");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_cseq));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_cseq));
L_cseq = belle_sip_header_cseq_parse(l_raw_header);
L_tmp = belle_sip_header_cseq_parse(l_raw_header);
L_cseq = BELLE_SIP_HEADER_CSEQ(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_EQUAL(belle_sip_header_cseq_get_seq_number(L_cseq),21);
......@@ -163,11 +175,13 @@ void test_header_cseq(void) {
belle_sip_object_unref(BELLE_SIP_OBJECT(L_cseq));
}
void test_header_content_type(void) {
belle_sip_header_content_type_t* L_tmp;
belle_sip_header_content_type_t* L_content_type = belle_sip_header_content_type_parse("Content-Type: text/html; charset=ISO-8859-4");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_content_type));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_content_type));
L_content_type = belle_sip_header_content_type_parse(l_raw_header);
L_tmp = belle_sip_header_content_type_parse(l_raw_header);
L_content_type = BELLE_SIP_HEADER_CONTENT_TYPE(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_STRING_EQUAL(belle_sip_header_content_type_get_type(L_content_type),"text");
......@@ -233,20 +247,25 @@ void test_header_route(void) {
belle_sip_object_unref(BELLE_SIP_OBJECT(L_route));
}
void test_header_content_length(void) {
belle_sip_header_content_length_t* L_tmp;
belle_sip_header_content_length_t* L_content_length = belle_sip_header_content_length_parse("Content-Length: 3495");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_content_length));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_content_length));
L_content_length = belle_sip_header_content_length_parse(l_raw_header);
L_tmp = belle_sip_header_content_length_parse(l_raw_header);
L_content_length = BELLE_SIP_HEADER_CONTENT_LENGTH(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_EQUAL(belle_sip_header_content_length_get_content_length(L_content_length), 3495);
belle_sip_object_unref(BELLE_SIP_OBJECT(L_content_length));
}
void test_header_extention(void) {
belle_sip_header_extension_t* L_tmp;
belle_sip_header_extension_t* L_extension = belle_sip_header_extension_parse("toto: titi");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_extension));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_extension));
L_extension = belle_sip_header_extension_parse(l_raw_header);
L_tmp = belle_sip_header_extension_parse(l_raw_header);
L_extension = BELLE_SIP_HEADER_EXTENSION(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_STRING_EQUAL(belle_sip_header_extension_get_value(L_extension), "titi");
......@@ -257,10 +276,13 @@ void test_header_authorization(void) {
"realm=\"sip.ovh.net\", nonce=\"1bcdcb194b30df5f43973d4c69bdf54f\", uri=\"sip:sip.ovh.net\", response=\"eb36c8d5c8642c1c5f44ec3404613c81\","\
"algorithm=MD5, opaque=\"1bc7f9097684320\","
"\r\n qop=auth, nc=00000001,cnonce=\"0a4f113b\", blabla=\"toto\"";
belle_sip_header_authorization_t* L_tmp;
belle_sip_header_authorization_t* L_authorization = belle_sip_header_authorization_parse(l_header);
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_authorization));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_authorization));
L_authorization = belle_sip_header_authorization_parse(l_raw_header);
L_tmp = belle_sip_header_authorization_parse(l_raw_header);
L_authorization = BELLE_SIP_HEADER_AUTHORIZATION(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_PTR_NOT_NULL(L_authorization);
......@@ -298,10 +320,13 @@ void test_header_www_authenticate(void) {
const char* l_header = "WWW-Authenticate: Digest "
"algorithm=MD5, realm=\"atlanta.com\", opaque=\"1bc7f9097684320\","
" qop=\"auth\", nonce=\"c60f3082ee1212b402a21831ae\", stale=true, domain=\"sip:boxesbybob.com\"";
belle_sip_header_www_authenticate_t* L_tmp;
belle_sip_header_www_authenticate_t* L_authorization = belle_sip_header_www_authenticate_parse(l_header);
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_authorization));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_authorization));
L_authorization = belle_sip_header_www_authenticate_parse(l_raw_header);
L_tmp = belle_sip_header_www_authenticate_parse(l_raw_header);
L_authorization = BELLE_SIP_HEADER_WWW_AUTHENTICATE(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_PTR_NOT_NULL(L_authorization);
CU_ASSERT_STRING_EQUAL(belle_sip_header_www_authenticate_get_realm(L_authorization), "atlanta.com");
......@@ -317,11 +342,15 @@ void test_header_www_authenticate(void) {
}
void test_header_max_forwards(void) {
const char* l_header = "Max-Forwards: 6";
belle_sip_header_max_forwards_t* L_tmp;
belle_sip_header_max_forwards_t* L_max_forwards = belle_sip_header_max_forwards_parse(l_header);
belle_sip_header_max_forwards_decrement_max_forwards(L_max_forwards);
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_max_forwards));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_max_forwards));
L_max_forwards = belle_sip_header_max_forwards_parse(l_raw_header);
L_tmp = belle_sip_header_max_forwards_parse(l_raw_header);
L_max_forwards = BELLE_SIP_HEADER_MAX_FORWARDS(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_PTR_NOT_NULL(L_max_forwards);
CU_ASSERT_EQUAL(belle_sip_header_max_forwards_get_max_forwards(L_max_forwards), 5);
......@@ -331,10 +360,14 @@ void test_header_max_forwards(void) {
}
void test_header_user_agent(void) {
const char* l_header = "User-Agent: Linphone/3.4.99.1 (eXosip2/3.3.0)";
belle_sip_header_user_agent_t* L_tmp;
belle_sip_header_user_agent_t* L_user_agent = belle_sip_header_user_agent_parse(l_header);
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_user_agent));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_user_agent));
L_user_agent = belle_sip_header_user_agent_parse(l_raw_header);
L_tmp = belle_sip_header_user_agent_parse(l_raw_header);
L_user_agent = BELLE_SIP_HEADER_USER_AGENT(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
const char* values[] ={"Linphone/3.4.99.1"
......@@ -352,20 +385,25 @@ void test_header_user_agent(void) {
}
void test_header_expires(void) {
belle_sip_header_expires_t* L_tmp;
belle_sip_header_expires_t* L_expires = belle_sip_header_expires_parse("Expires: 3600");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_expires));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_expires));
L_expires = belle_sip_header_expires_parse(l_raw_header);
L_tmp= belle_sip_header_expires_parse(l_raw_header);
L_expires = BELLE_SIP_HEADER_EXPIRES(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_EQUAL(belle_sip_header_expires_get_expires(L_expires), 3600);
belle_sip_object_unref(BELLE_SIP_OBJECT(L_expires));
}
void test_header_allow(void) {
belle_sip_header_allow_t* L_tmp;
belle_sip_header_allow_t* L_allow = belle_sip_header_allow_parse("Allow:INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_allow));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_allow));
L_allow = belle_sip_header_allow_parse(l_raw_header);
L_tmp = belle_sip_header_allow_parse(l_raw_header);
L_allow = BELLE_SIP_HEADER_ALLOW(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
CU_ASSERT_STRING_EQUAL(belle_sip_header_allow_get_method(L_allow), "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
......
......@@ -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