Commit db6dd274 authored by jehan's avatar jehan

fix cseq generation for dialogs

parent 5f07fd35
......@@ -155,7 +155,8 @@ belle_sdp_media_description_t* belle_sdp_media_description_create(const char* me
,const char* protocol
,belle_sip_list_t* static_media_formats);
void belle_sdp_media_description_add_dynamic_payloads(belle_sdp_media_description_t* media_description, belle_sip_list_t* payloadNames, belle_sip_list_t* payloadValues);
const char* belle_sdp_media_description_get_attribute(const belle_sdp_media_description_t* media_description, const char* name);
const char* belle_sdp_media_description_get_attribute_value(const belle_sdp_media_description_t* media_description, const char* name);
const belle_sdp_attribute_t* belle_sdp_media_description_get_attribute(const belle_sdp_media_description_t* media_description, const char* name);
belle_sip_list_t* belle_sdp_media_description_get_attributes(const belle_sdp_media_description_t* media_description);
int belle_sdp_media_description_get_bandwidth(const belle_sdp_media_description_t* media_description, const char* name);
belle_sip_list_t* belle_sdp_media_description_get_bandwidths(const belle_sdp_media_description_t* media_description);
......@@ -167,7 +168,7 @@ belle_sip_list_t* belle_sdp_media_description_build_mime_parameters(const belle_
/*belle_sip_list_t* belle_sdp_media_description_get_mime_types(const belle_sdp_media_description_t* media_description);*/
void belle_sdp_media_description_remove_attribute(belle_sdp_media_description_t* media_description,const char* attribute);
void belle_sdp_media_description_remove_bandwidth(belle_sdp_media_description_t* media_description,const char* bandwidth);
void belle_sdp_media_description_set_attribute(belle_sdp_media_description_t* media_description, const char* name, const char* value);
void belle_sdp_media_description_set_attribute_value(belle_sdp_media_description_t* media_description, const char* name, const char* value);
void belle_sdp_media_description_add_attribute(belle_sdp_media_description_t* media_description, const belle_sdp_attribute_t* attr);
void belle_sdp_media_description_set_attributes(belle_sdp_media_description_t* media_description, belle_sip_list_t* Attributes);
void belle_sdp_media_description_set_bandwidth(belle_sdp_media_description_t* media_description, const char* name, int value);
......@@ -298,7 +299,7 @@ belle_sdp_session_description_t* belle_sdp_session_description_parse (const char
* @returns belle_sdp_session_description_t or NULL if no sdp present
* */
belle_sdp_session_description_t* belle_sdp_session_description_create(belle_sip_message_t* message);
const char* belle_sdp_session_description_get_attribute(const belle_sdp_session_description_t* session_description, const char* name);
const char* belle_sdp_session_description_get_attribute_value(const belle_sdp_session_description_t* session_description, const char* name);
int belle_sdp_session_description_get_bandwidth(const belle_sdp_session_description_t* session_description, const char* name);
belle_sip_list_t* belle_sdp_session_description_get_bandwidths(const belle_sdp_session_description_t* session_description);
belle_sdp_connection_t* belle_sdp_session_description_get_connection(const belle_sdp_session_description_t* session_description);
......@@ -315,7 +316,7 @@ belle_sdp_version_t* belle_sdp_session_description_get_version(const belle_sdp_s
belle_sdp_uri_t* belle_sdp_session_description_get_zone_adjustments(const belle_sdp_session_description_t* session_description);
void belle_sdp_session_description_remove_attribute(belle_sdp_session_description_t* session_description, const char* name);
void belle_sdp_session_description_remove_bandwidth(belle_sdp_session_description_t* session_description, const char* name);
void belle_sdp_session_description_set_attribute(belle_sdp_session_description_t* session_description, const char* name, const char* value);
void belle_sdp_session_description_set_attribute_value(belle_sdp_session_description_t* session_description, const char* name, const char* value);
void belle_sdp_session_description_add_attribute(belle_sdp_session_description_t* session_description, const belle_sdp_attribute_t* attribute);
void belle_sdp_session_description_set_attributes(belle_sdp_session_description_t* session_description, belle_sip_list_t* Attributes);
void belle_sdp_session_description_set_bandwidth(belle_sdp_session_description_t* session_description, const char* name, int value);
......
......@@ -339,15 +339,23 @@ BELLE_SIP_INSTANCIATE_VPTR(belle_sdp_base_description_t
static int belle_sdp_base_description_attribute_comp_func(const belle_sdp_attribute_t* a, const char*b) {
return strcmp(a->name,b);
}
const char* belle_sdp_base_description_get_attribute(const belle_sdp_base_description_t* base_description, const char* name) {
const belle_sdp_attribute_t* belle_sdp_base_description_get_attribute(const belle_sdp_base_description_t* base_description, const char* name) {
belle_sip_list_t* attribute;
attribute = belle_sip_list_find_custom(base_description->attributes, (belle_sip_compare_func)belle_sdp_base_description_attribute_comp_func, name);
if (attribute) {
return ((belle_sdp_attribute_t*)attribute->data)->value;
return ((belle_sdp_attribute_t*)attribute->data);
} else {
return NULL;
}
}
const char* belle_sdp_base_description_get_attribute_value(const belle_sdp_base_description_t* base_description, const char* name) {
const belle_sdp_attribute_t* attribute = belle_sdp_base_description_get_attribute(base_description,name);
if (attribute)
return belle_sdp_attribute_get_value(attribute);
else
return NULL;
}
belle_sip_list_t* belle_sdp_base_description_get_attributes(const belle_sdp_base_description_t* base_description) {
return base_description->attributes;
}
......@@ -381,7 +389,7 @@ void belle_sdp_base_description_remove_bandwidth(belle_sdp_base_description_t* b
base_description->bandwidths = belle_sip_list_remove_link(base_description->bandwidths,bandwidth);
}
}
void belle_sdp_base_description_set_attribute(belle_sdp_base_description_t* base_description, const char* name, const char* value) {
void belle_sdp_base_description_set_attribute_value(belle_sdp_base_description_t* base_description, const char* name, const char* value) {
belle_sdp_attribute_t* attribute = belle_sdp_attribute_new();
belle_sdp_attribute_set_name(attribute,name);
belle_sdp_attribute_set_value(attribute,value);
......@@ -453,9 +461,12 @@ BELLE_SDP_PARSE(media_description)
void belle_sdp_media_description_add_dynamic_payloads(belle_sdp_media_description_t* media_description, belle_sip_list_t* payloadNames, belle_sip_list_t* payloadValues) {
}
const char* belle_sdp_media_description_get_attribute(const belle_sdp_media_description_t* media_description, const char* name) {
const belle_sdp_attribute_t* belle_sdp_media_description_get_attribute(const belle_sdp_media_description_t* media_description, const char* name) {
return belle_sdp_base_description_get_attribute(BELLE_SIP_CAST(media_description,belle_sdp_base_description_t),name);
}
const char* belle_sdp_media_description_get_attribute_value(const belle_sdp_media_description_t* media_description, const char* name) {
return belle_sdp_base_description_get_attribute_value(BELLE_SIP_CAST(media_description,belle_sdp_base_description_t),name);
}
belle_sip_list_t* belle_sdp_media_description_get_attributes(const belle_sdp_media_description_t* media_description) {
return BELLE_SIP_CAST(media_description,belle_sdp_base_description_t)->attributes;
}
......@@ -570,9 +581,9 @@ belle_sip_list_t* belle_sdp_media_description_build_mime_parameters(const belle_
belle_sip_error("belle_sdp_media_description_build_mime_parameters: no media");
return NULL;
}
ptime = belle_sdp_media_description_get_attribute(media_description,"ptime");
ptime = belle_sdp_media_description_get_attribute_value(media_description,"ptime");
ptime?ptime_as_int=atoi(ptime):-1;
max_ptime = belle_sdp_media_description_get_attribute(media_description,"maxptime");
max_ptime = belle_sdp_media_description_get_attribute_value(media_description,"maxptime");
max_ptime?max_ptime_as_int=atoi(max_ptime):-1;
for (media_formats = belle_sdp_media_get_media_formats(media);media_formats!=NULL;media_formats=media_formats->next) {
......@@ -622,12 +633,12 @@ void belle_sdp_media_description_append_values_from_mime_parameter(belle_sdp_med
,belle_sdp_mime_parameter_get_type(mime_parameter)
,belle_sdp_mime_parameter_get_rate(mime_parameter));
}
belle_sdp_media_description_set_attribute(media_description,"rtpmap",atribute_value);
belle_sdp_media_description_set_attribute_value(media_description,"rtpmap",atribute_value);
if (belle_sdp_mime_parameter_get_parameters(mime_parameter)) {
snprintf(atribute_value,MAX_FMTP_LENGH,"%i %s"
,belle_sdp_mime_parameter_get_media_format(mime_parameter)
,belle_sdp_mime_parameter_get_parameters(mime_parameter));
belle_sdp_media_description_set_attribute(media_description,"fmtp",atribute_value);
belle_sdp_media_description_set_attribute_value(media_description,"fmtp",atribute_value);
}
}
......@@ -644,8 +655,8 @@ void belle_sdp_media_description_remove_attribute(belle_sdp_media_description_t*
void belle_sdp_media_description_remove_bandwidth(belle_sdp_media_description_t* media_description,const char* name) {
belle_sdp_base_description_remove_bandwidth(BELLE_SIP_CAST(media_description,belle_sdp_base_description_t),name);
}
void belle_sdp_media_description_set_attribute(belle_sdp_media_description_t* media_description, const char* name, const char* value) {
belle_sdp_base_description_set_attribute(BELLE_SIP_CAST(media_description,belle_sdp_base_description_t),name,value);
void belle_sdp_media_description_set_attribute_value(belle_sdp_media_description_t* media_description, const char* name, const char* value) {
belle_sdp_base_description_set_attribute_value(BELLE_SIP_CAST(media_description,belle_sdp_base_description_t),name,value);
}
void belle_sdp_media_description_set_attributes(belle_sdp_media_description_t* media_description, belle_sip_list_t* value) {
belle_sdp_base_description_set_attributes(BELLE_SIP_CAST(media_description,belle_sdp_base_description_t),value);
......@@ -881,8 +892,8 @@ belle_sdp_session_description_t* belle_sdp_session_description_create(belle_sip_
}
return session_desc;
}
const char* belle_sdp_session_description_get_attribute(const belle_sdp_session_description_t* session_description, const char* name) {
return belle_sdp_base_description_get_attribute(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),name);
const char* belle_sdp_session_description_get_attribute_value(const belle_sdp_session_description_t* session_description, const char* name) {
return belle_sdp_base_description_get_attribute_value(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),name);
}
int belle_sdp_session_description_get_bandwidth(const belle_sdp_session_description_t* session_description, const char* name) {
return belle_sdp_base_description_get_bandwidth(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),name);
......@@ -930,8 +941,8 @@ void belle_sdp_session_description_remove_attribute(belle_sdp_session_descriptio
void belle_sdp_session_description_remove_bandwidth(belle_sdp_session_description_t* session_description, const char* name) {
belle_sdp_base_description_remove_bandwidth(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),name);
}
void belle_sdp_session_description_set_attribute(belle_sdp_session_description_t* session_description, const char* name, const char* value) {
belle_sdp_base_description_set_attribute(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),name,value);
void belle_sdp_session_description_set_attribute_value(belle_sdp_session_description_t* session_description, const char* name, const char* value) {
belle_sdp_base_description_set_attribute_value(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),name,value);
}
void belle_sdp_session_description_set_attributes(belle_sdp_session_description_t* session_description, belle_sip_list_t* attributes) {
belle_sdp_base_description_set_attributes(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),attributes);
......
......@@ -345,6 +345,7 @@ belle_sip_request_t *belle_sip_dialog_create_ack(belle_sip_dialog_t *obj, unsign
belle_sip_request_t *belle_sip_dialog_create_request(belle_sip_dialog_t *obj, const char *method){
if (obj->local_cseq==0) obj->local_cseq=110;
if (strcmp(method,"ACK")!=0) obj->local_cseq++;
belle_sip_request_t *req=belle_sip_request_create(belle_sip_header_address_get_uri(obj->remote_target),
method,
obj->call_id,
......@@ -357,7 +358,6 @@ belle_sip_request_t *belle_sip_dialog_create_request(belle_sip_dialog_t *obj, co
belle_sip_list_for_each(obj->route_set,(void (*)(void *) )belle_sip_object_ref);/*don't forget to inc ref count*/
belle_sip_message_add_headers((belle_sip_message_t*)req,obj->route_set);
}
if (strcmp(method,"ACK")!=0) obj->local_cseq++;
return req;
}
......
......@@ -305,7 +305,7 @@ static void test_mime_parameter(void) {
for (;mime_parameter_list_iterator!=NULL;mime_parameter_list_iterator=mime_parameter_list_iterator->next) {
belle_sdp_media_description_append_values_from_mime_parameter(l_media_description,(belle_sdp_mime_parameter_t*)mime_parameter_list_iterator->data);
}
belle_sdp_media_description_set_attribute(l_media_description,"ptime","40");
belle_sdp_media_description_set_attribute_value(l_media_description,"ptime","40");
belle_sip_list_free_with_data(mime_parameter_list, (void (*)(void*))belle_sip_object_unref);
mime_parameter_list = belle_sdp_media_description_build_mime_parameters(l_media_description);
......
......@@ -311,7 +311,7 @@ static void simple_call(void) {
belle_sip_client_transaction_send_request(client_transaction);
//int i=0;
//for(i=0;i<10 &&!call_endeed;i++)
belle_sip_stack_sleep(stack,30000);
belle_sip_stack_sleep(stack,30000);
CU_ASSERT_EQUAL(call_endeed,1);
......
......@@ -145,7 +145,7 @@ void unregister_user(belle_sip_stack_t * stack
using_transaction=0;
req=(belle_sip_request_t*)belle_sip_object_clone((belle_sip_object_t*)initial_request);
belle_sip_header_cseq_t* cseq=(belle_sip_header_cseq_t*)belle_sip_message_get_header((belle_sip_message_t*)req,BELLE_SIP_CSEQ);
belle_sip_header_cseq_set_seq_number(cseq,belle_sip_header_cseq_get_seq_number(cseq)+1);
belle_sip_header_cseq_set_seq_number(cseq,belle_sip_header_cseq_get_seq_number(cseq)+2); /*+2 if initial reg was challenged*/
belle_sip_header_expires_t* expires_header=(belle_sip_header_expires_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_EXPIRES);
belle_sip_header_expires_set_expires(expires_header,0);
if (use_transaction){
......@@ -171,7 +171,7 @@ belle_sip_request_t* register_user_at_domain(belle_sip_stack_t * stack
belle_sip_request_t *req,*copy;
char identity[256];
char uri[256];
number_of_challange=0;
if (transport)
snprintf(uri,sizeof(uri),"sip:%s;transport=%s",domain,transport);
else snprintf(uri,sizeof(uri),"sip:%s",domain);
......
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