Commit a0a70bb2 authored by jehan's avatar jehan
Browse files

-Allow ; with empty param in URI, add option to disable rport

parent 079445bf
......@@ -66,7 +66,7 @@ BELLESIP_EXPORT int belle_sip_provider_add_authorization(belle_sip_provider_t *p
/**
* Can be used to simulate network recv error, for tests.
* @param stack
* @param prov
* @param recv_error if <=0, will cause channel error to be reported
**/
BELLESIP_EXPORT void belle_sip_provider_set_recv_error(belle_sip_provider_t *prov, int recv_error);
......@@ -82,6 +82,20 @@ BELLESIP_EXPORT void belle_sip_provider_set_recv_error(belle_sip_provider_t *pro
**/
BELLESIP_EXPORT belle_sip_dialog_t* belle_sip_provider_find_dialog(const belle_sip_provider_t *prov, const char* call_id,const char* from_tag,const char* to_tag);
/**
* Enable rport in via header. Enabled by default
* @param prov
* @return enable 0 to disable
**/
BELLESIP_EXPORT void belle_sip_provider_enable_rport(belle_sip_provider_t *prov, int enable);
/**
* get Enable rport in via header. Enabled by default
* @param prov
* @param enable 0 to disable
**/
BELLESIP_EXPORT int belle_sip_provider_is_rport_enabled(belle_sip_provider_t *prov);
BELLE_SIP_END_DECLS
#define BELLE_SIP_PROVIDER(obj) BELLE_SIP_CAST(obj,belle_sip_provider_t)
......
......@@ -502,6 +502,7 @@ struct belle_sip_provider{
belle_sip_list_t *server_transactions;
belle_sip_list_t *dialogs;
belle_sip_list_t *auth_contexts;
int rport_enabled; /*0 if rport should not be set in via header*/
};
belle_sip_provider_t *belle_sip_provider_new(belle_sip_stack_t *s, belle_sip_listening_point_t *lp);
......
......@@ -1275,7 +1275,7 @@ port returns [int ret]: DIGIT+ { $ret=atoi((const char *)$text->chars); };
uri_parameters[belle_sip_uri_t* uri]
scope { belle_sip_uri_t* current; }
@init {$uri_parameters::current=uri;}
: ( semi uri_parameter )+;
: ( semi uri_parameter? )+;
uri_parameter //all parameters are considered as other
: other_param ;
other_param
......
......@@ -200,7 +200,7 @@ static void compute_hash_from_invariants(belle_sip_message_t *msg, char *branchi
static void fix_outgoing_via(belle_sip_provider_t *p, belle_sip_channel_t *chan, belle_sip_message_t *msg){
belle_sip_header_via_t *via=BELLE_SIP_HEADER_VIA(belle_sip_message_get_header(msg,"via"));
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(via),"rport",NULL);
if (p->rport_enabled) belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(via),"rport",NULL);
if (belle_sip_header_via_get_host(via)==NULL){
const char *local_ip;
......@@ -275,6 +275,7 @@ BELLE_SIP_INSTANCIATE_VPTR(belle_sip_provider_t,belle_sip_object_t,belle_sip_pro
belle_sip_provider_t *belle_sip_provider_new(belle_sip_stack_t *s, belle_sip_listening_point_t *lp){
belle_sip_provider_t *p=belle_sip_object_new(belle_sip_provider_t);
p->stack=s;
p->rport_enabled=1;
if (lp) belle_sip_provider_add_listening_point(p,lp);
return p;
}
......@@ -840,3 +841,10 @@ void belle_sip_provider_set_recv_error(belle_sip_provider_t *prov, int recv_erro
}
}
}
void belle_sip_provider_enable_rport(belle_sip_provider_t *prov, int enable) {
prov->rport_enabled=enable;
}
int belle_sip_provider_is_rport_enabled(belle_sip_provider_t *prov) {
return prov->rport_enabled;
}
......@@ -552,6 +552,32 @@ static void test_address_header(void) {
belle_sip_object_unref(BELLE_SIP_OBJECT(laddress));
}
static void test_very_long_address_header(void) {
belle_sip_uri_t* L_uri;
const char* raw = "<sip:jehan@sip.linphone.org"
";app-id=622464153529"
";pn-type=google"
";pn-tok=APA91bHPVa4PuKOMnr6ppWb3XYUL06QO-ND4eeiw7dG49q4o_Ywzal7BxVRgH-wvqH9iB9V7h6kfb-DCiVdSpnl6CeWO25FAkM4eh6DJyWcbP7SzhKdku_-r9936kJW7-4drI6-Om4qp"
";pn-msg-str=IM_MSG"
";pn-call-str=IC_MSG"
";pn-call-snd=ring.caf"
";pn-msg-snd=msg.caf"
";>"; /*not compliant but*/
belle_sip_header_address_t* laddress = belle_sip_header_address_parse(raw);
CU_ASSERT_PTR_NOT_NULL_FATAL(laddress);
L_uri = belle_sip_header_address_get_uri(laddress);
CU_ASSERT_PTR_NOT_NULL(belle_sip_uri_get_user(L_uri));
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "sip.linphone.org");
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_user(L_uri), "jehan");
CU_ASSERT_STRING_EQUAL(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(L_uri),"pn-tok")
,"APA91bHPVa4PuKOMnr6ppWb3XYUL06QO-ND4eeiw7dG49q4o_Ywzal7BxVRgH-wvqH9iB9V7h6kfb-DCiVdSpnl6CeWO25FAkM4eh6DJyWcbP7SzhKdku_-r9936kJW7-4drI6-Om4qp");
belle_sip_object_unref(BELLE_SIP_OBJECT(laddress));
}
static void test_subscription_state_header(void) {
belle_sip_header_subscription_state_t* L_tmp;
belle_sip_header_subscription_state_t* L_subscription_state = belle_sip_header_subscription_state_parse("Subscription-State: terminated;expires=600");
......@@ -649,6 +675,7 @@ static void test_replaces_escaped_header(void) {
test_t headers_tests[] = {
{ "Address", test_address_header },
{ "Header address (very long)", test_very_long_address_header },
{ "Address with error", test_address_with_error_header },
{ "Allow", test_allow_header },
{ "Authorization", test_authorization_header },
......@@ -679,6 +706,7 @@ test_t headers_tests[] = {
{ "Via", test_via_header },
{ "WWW-Authenticate", test_www_authenticate_header },
{ "Header extension", test_header_extension }
};
test_suite_t headers_test_suite = {
......
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