forked from mirrors/linphone-iphone
add custom header API to proxy config
This commit is contained in:
parent
e6f1364782
commit
59758df62d
6 changed files with 53 additions and 2 deletions
|
|
@ -33,6 +33,9 @@ static void register_refresher_listener (belle_sip_refresher_t* refresher
|
|||
op->auth_info=sal_auth_info_create((belle_sip_auth_event_t*)(belle_sip_refresher_get_auth_events(refresher)->data));
|
||||
}
|
||||
sal_error_info_set(&op->error_info,SalReasonUnknown,status_code,reason_phrase,NULL);
|
||||
if (status_code>=200){
|
||||
sal_op_assign_recv_headers(op,(belle_sip_message_t*)response);
|
||||
}
|
||||
if(status_code == 200) {
|
||||
/*check service route rfc3608*/
|
||||
belle_sip_header_service_route_t* service_route;
|
||||
|
|
|
|||
|
|
@ -1148,6 +1148,21 @@ LINPHONE_PUBLIC LinphoneAVPFMode linphone_proxy_config_get_avpf_mode(const Linph
|
|||
**/
|
||||
LINPHONE_PUBLIC void linphone_proxy_config_set_avpf_mode(LinphoneProxyConfig *cfg, LinphoneAVPFMode mode);
|
||||
|
||||
/**
|
||||
* Obtain the value of a header sent by the server in last answer to REGISTER.
|
||||
* @param cfg the proxy config object
|
||||
* @param header_name the header name for which to fetch corresponding value
|
||||
* @return the value of the queried header.
|
||||
**/
|
||||
LINPHONE_PUBLIC const char *linphone_proxy_config_get_custom_header(LinphoneProxyConfig *cfg, const char *header_name);
|
||||
|
||||
/**
|
||||
* Set the value of a custom header sent to the server in REGISTERs request.
|
||||
* @param cfg the proxy config object
|
||||
* @param header_name the header name
|
||||
* @param header_value the header's value
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_proxy_config_set_custom_header(LinphoneProxyConfig *cfg, const char *header_name, const char *header_value);
|
||||
/**
|
||||
* @}
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -476,6 +476,7 @@ struct _LinphoneProxyConfig
|
|||
int expires;
|
||||
int publish_expires;
|
||||
SalOp *op;
|
||||
SalCustomHeader *sent_headers;
|
||||
char *type;
|
||||
struct _SipSetupContext *ssctx;
|
||||
int auth_failures;
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ void _linphone_proxy_config_destroy(LinphoneProxyConfig *obj){
|
|||
if (obj->contact_uri_params) ms_free(obj->contact_uri_params);
|
||||
if (obj->saved_proxy!=NULL) linphone_address_destroy(obj->saved_proxy);
|
||||
if (obj->saved_identity!=NULL) linphone_address_destroy(obj->saved_identity);
|
||||
if (obj->sent_headers!=NULL) sal_custom_header_free(obj->sent_headers);
|
||||
_linphone_proxy_config_release_ops(obj);
|
||||
}
|
||||
|
||||
|
|
@ -467,7 +468,7 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
|
|||
sal_op_release(obj->op);
|
||||
obj->op=sal_op_new(obj->lc->sal);
|
||||
|
||||
linphone_configure_op(obj->lc, obj->op, to, NULL, FALSE);
|
||||
linphone_configure_op(obj->lc, obj->op, to, obj->sent_headers, FALSE);
|
||||
linphone_address_destroy(to);
|
||||
|
||||
if ((contact=guess_contact_for_register(obj))) {
|
||||
|
|
@ -1147,6 +1148,17 @@ struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig
|
|||
return obj->lc;
|
||||
}
|
||||
|
||||
const char *linphone_proxy_config_get_custom_header(LinphoneProxyConfig *cfg, const char *header_name){
|
||||
const SalCustomHeader *ch;
|
||||
if (!cfg->op) return NULL;
|
||||
ch = sal_op_get_recv_custom_header(cfg->op);
|
||||
return sal_custom_header_find(ch, header_name);
|
||||
}
|
||||
|
||||
void linphone_proxy_config_set_custom_header(LinphoneProxyConfig *cfg, const char *header_name, const char *header_value){
|
||||
cfg->sent_headers=sal_custom_header_append(cfg->sent_headers, header_name, header_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a proxy configuration.
|
||||
* This will start registration on the proxy, if registration is enabled.
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 034131e3b566438df8445ca7f97c19f3c3774f28
|
||||
Subproject commit f6ed42c031d3df9d2ccb3b5ec7bfd8f8023c73f6
|
||||
|
|
@ -190,6 +190,25 @@ static void simple_register(){
|
|||
linphone_core_manager_destroy(lcm);
|
||||
}
|
||||
|
||||
static void register_with_custom_headers(void){
|
||||
LinphoneCoreManager *marie=linphone_core_manager_new("marie_rc");
|
||||
LinphoneProxyConfig *cfg=linphone_core_get_default_proxy_config(marie->lc);
|
||||
int initial_register_ok=marie->stat.number_of_LinphoneRegistrationOk;
|
||||
const char *value;
|
||||
|
||||
linphone_core_set_network_reachable(marie->lc, FALSE);
|
||||
linphone_proxy_config_set_custom_header(cfg, "ah-bah-ouais", "...mais bon.");
|
||||
/*unfortunately it is difficult to programmatically check that sent custom headers are actually sent.
|
||||
* A server development would be required here.*/
|
||||
|
||||
linphone_core_set_network_reachable(marie->lc, TRUE);
|
||||
wait_for(marie->lc, NULL, &marie->stat.number_of_LinphoneRegistrationOk,initial_register_ok+1);
|
||||
value=linphone_proxy_config_get_custom_header(cfg, "Server");
|
||||
CU_ASSERT_PTR_NOT_NULL(value);
|
||||
if (value) CU_ASSERT_TRUE(strstr(value, "Flexisip")!=NULL);
|
||||
linphone_core_manager_destroy(marie);
|
||||
}
|
||||
|
||||
static void simple_unregister(){
|
||||
LinphoneCoreManager* lcm = create_lcm();
|
||||
stats* counters = &lcm->stat;
|
||||
|
|
@ -814,6 +833,7 @@ test_t register_tests[] = {
|
|||
{ "Simple register", simple_register },
|
||||
{ "Simple register unregister", simple_unregister },
|
||||
{ "TCP register", simple_tcp_register },
|
||||
{ "Register with custom headers", register_with_custom_headers },
|
||||
{ "TCP register compatibility mode", simple_tcp_register_compatibility_mode },
|
||||
{ "TLS register", simple_tls_register },
|
||||
{ "TLS register with alt. name certificate", tls_alt_name_register },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue