Commit 5f07fd35 authored by jehan's avatar jehan
Browse files

fix parsing of 2 consecutives SIP request in the same buffer (I.E ACK +

BYE)
parent 7ddd3dda
......@@ -109,7 +109,7 @@ static int get_message_start_pos(char *buff, size_t bufflen) {
static void belle_sip_channel_input_stream_reset(belle_sip_channel_input_stream_t* input_stream,int message_size) {
int message_residu=0;
if (message_size>0 && input_stream->write_ptr-input_stream->read_ptr>message_size) {
if (message_size>0 && (input_stream->write_ptr-input_stream->read_ptr)>message_size) {
/*still message available, copy a beginning of stream ?*/
message_residu = input_stream->write_ptr-input_stream->read_ptr - message_size;
memcpy(input_stream->buff
......@@ -135,15 +135,18 @@ void belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revent
belle_sip_header_content_length_t* content_length_header;
int content_length;
if (revents)
if (revents) {
num=belle_sip_channel_recv(obj,obj->input_stream.write_ptr,belle_sip_channel_input_stream_get_buff_lenght(&obj->input_stream)-1);
/*write ptr is only incremented if data were acquired from the transport*/
obj->input_stream.write_ptr+=num;
}
else
num=obj->input_stream.write_ptr-obj->input_stream.read_ptr;
if (num>0){
/*first null terminate the buff*/
obj->input_stream.write_ptr[num]='\0';
obj->input_stream.write_ptr+=num;
if (obj->input_stream.state == WAITING_MESSAGE_START) {
/*search for request*/
......@@ -204,7 +207,7 @@ void belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revent
message_ready:
obj->incoming_messages=belle_sip_list_append(obj->incoming_messages,obj->input_stream.msg);
belle_sip_channel_input_stream_reset(&obj->input_stream,message_size);
BELLE_SIP_INVOKE_LISTENERS_ARG1_ARG2(obj->listeners,belle_sip_channel_listener_t,on_event,obj,revents);
BELLE_SIP_INVOKE_LISTENERS_ARG1_ARG2(obj->listeners,belle_sip_channel_listener_t,on_event,obj,BELLE_SIP_EVENT_READ/*alway a read event*revents*/);
if (obj->input_stream.write_ptr-obj->input_stream.read_ptr>0) {
/*process residu*/
belle_sip_channel_process_data(obj,0);
......
......@@ -105,6 +105,13 @@ static int belle_sip_dialog_init_as_uas(belle_sip_dialog_t *obj, belle_sip_reque
&& belle_sip_uri_is_secure(requri)){
obj->is_secure=TRUE;
}
/* 12.1.1
*The route set MUST be set to the list of URIs in the Record-Route
* header field from the request, taken in order and preserving all URI
* parameters. If no Record-Route header field is present in the
*request, the route set MUST be set to the empty set.
*/
obj->route_set=belle_sip_list_free_with_data(obj->route_set,belle_sip_object_unref);
for(elem=belle_sip_message_get_headers((belle_sip_message_t*)req,BELLE_SIP_RECORD_ROUTE);elem!=NULL;elem=elem->next){
obj->route_set=belle_sip_list_append(obj->route_set,belle_sip_header_route_create(
(belle_sip_header_address_t*)elem->data));
......@@ -152,6 +159,13 @@ static int belle_sip_dialog_init_as_uac(belle_sip_dialog_t *obj, belle_sip_reque
&& belle_sip_uri_is_secure(requri)){
obj->is_secure=TRUE;
}
/**12.1.2
* The route set MUST be set to the list of URIs in the Record-Route
*header field from the response, taken in reverse order and preserving
*all URI parameters. If no Record-Route header field is present in
*the response, the route set MUST be set to the empty set.
**/
obj->route_set=belle_sip_list_free_with_data(obj->route_set,belle_sip_object_unref);
for(elem=belle_sip_message_get_headers((belle_sip_message_t*)resp,BELLE_SIP_RECORD_ROUTE);elem!=NULL;elem=elem->next){
obj->route_set=belle_sip_list_prepend(obj->route_set,belle_sip_header_route_create(
(belle_sip_header_address_t*)elem->data));
......
......@@ -94,7 +94,6 @@ static void belle_sip_provider_dispatch_request(belle_sip_provider_t* prov, bell
ev.request=req;
BELLE_SIP_PROVIDER_INVOKE_LISTENERS(prov,process_request_event,&ev);
}
belle_sip_object_unref(req);
}
static void belle_sip_provider_dispatch_response(belle_sip_provider_t* prov, belle_sip_response_t *msg){
......@@ -118,7 +117,6 @@ static void belle_sip_provider_dispatch_response(belle_sip_provider_t* prov, bel
event.response=msg;
BELLE_SIP_PROVIDER_INVOKE_LISTENERS(prov,process_response_event,&event);
}
belle_sip_object_unref(msg);
}
static void belle_sip_provider_dispatch_message(belle_sip_provider_t *prov, belle_sip_message_t *msg){
......
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