Commit eb411e1e authored by jehan's avatar jehan
Browse files

fix received param for ipv6 in case

parent 5b3a6d54
......@@ -439,18 +439,21 @@ struct _belle_sip_header_via {
char* transport;
char* host;
int port;
char* received;
};
static void belle_sip_header_via_destroy(belle_sip_header_via_t* via) {
if (via->protocol) belle_sip_free(via->protocol);
if (via->transport) belle_sip_free(via->transport);
if (via->host) belle_sip_free(via->host);
DESTROY_STRING(via,received)
}
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)
CLONE_STRING(belle_sip_header_via,received,via,orig)
via->port=orig->port;
}
......@@ -472,6 +475,10 @@ int belle_sip_header_via_marshal(belle_sip_header_via_t* via, char* buff,unsigne
if (via->port > 0) {
current_offset+=snprintf(buff+current_offset,buff_size-current_offset,":%i",via->port);
}
if (via->received) {
current_offset+=snprintf(buff+current_offset,buff_size-current_offset,";received=%s",via->received);
}
current_offset+=belle_sip_parameters_marshal(&via->params_list, buff,current_offset, buff_size);
return current_offset-offset;
}
......@@ -491,11 +498,12 @@ BELLE_SIP_PARSE(header_via)
GET_SET_STRING(belle_sip_header_via,protocol);
GET_SET_STRING(belle_sip_header_via,transport);
GET_SET_STRING(belle_sip_header_via,host);
GET_SET_STRING(belle_sip_header_via,received);
GET_SET_INT_PRIVATE(belle_sip_header_via,port,int,_);
GET_SET_STRING_PARAM(belle_sip_header_via,branch);
GET_SET_STRING_PARAM(belle_sip_header_via,maddr);
GET_SET_STRING_PARAM(belle_sip_header_via,received);
GET_SET_INT_PARAM_PRIVATE(belle_sip_header_via,rport,int,_)
GET_SET_INT_PARAM_PRIVATE(belle_sip_header_via,ttl,int,_)
......
......@@ -1052,14 +1052,17 @@ catch [ANTLR3_MISMATCHED_TOKEN_EXCEPTION]
via_params
: /*via_ttl | via_maddr
| via_received | via_branch
| via_extension */ generic_param [BELLE_SIP_PARAMETERS($header_via::current)];
| via_branch
| via_extension */ via_received[$header_via::current] | generic_param [BELLE_SIP_PARAMETERS($header_via::current)];
/*via_ttl
: 'ttl' EQUAL ttl;
via_maddr
: 'maddr' EQUAL host;
via_received
: 'received' EQUAL (ipv4address | ipv6address);
: 'maddr' EQUAL host;*/
via_received [belle_sip_header_via_t* object]
: {IS_TOKEN(received)}? token EQUAL via_address {belle_sip_header_via_set_received(object,(const char*)$via_address.text->chars);};
via_address: ipv4address | ipv6address;
/*
via_branch
: 'branch' EQUAL token;
via_extension
......@@ -1080,6 +1083,8 @@ other_transport
sent_by
: host {belle_sip_header_via_set_host($header_via::current,$host.ret);}
( COLON port {belle_sip_header_via_set_port($header_via::current,$port.ret);} )? ;
/*
warning
: 'Warning' HCOLON warning_value (COMMA warning_value)*;
......
......@@ -161,7 +161,7 @@ static void test_via_header(void) {
belle_sip_header_via_t* L_tmp;
belle_sip_header_t* l_next;
belle_sip_header_via_t* L_next_via;
belle_sip_header_via_t* L_via = belle_sip_header_via_parse("Via: SIP/2.0/UDP [::1]:5062;rport;received=192.169.0.4;branch=z9hG4bK368560724");
belle_sip_header_via_t* L_via = belle_sip_header_via_parse("Via: SIP/2.0/UDP [::1]:5062;rport;received=::1;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_tmp = belle_sip_header_via_parse(l_raw_header);
......@@ -175,7 +175,7 @@ static void test_via_header(void) {
CU_ASSERT_EQUAL(belle_sip_header_via_get_port(L_via),5062);
CU_ASSERT_TRUE(belle_sip_parameters_has_parameter(BELLE_SIP_PARAMETERS(L_via),"rport"));
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_received(L_via),"192.169.0.4");
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_received(L_via),"::1");
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_branch(L_via),"z9hG4bK368560724");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_via));
......
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