Commit 8e6c12d1 authored by jehan's avatar jehan

add random sip port selection

add linphone_core_get_port
parent 5689b5d8
......@@ -136,5 +136,11 @@ void linphone_address_destroy(LinphoneAddress *u){
sal_address_destroy(u);
}
int linphone_address_get_port_int(const LinphoneAddress *u) {
return sal_address_get_port_int(u);
}
const char* linphone_address_get_port(const LinphoneAddress *u) {
return sal_address_get_port(u);
}
/** @} */
......@@ -646,9 +646,16 @@ static void sip_config_read(LinphoneCore *lc)
}
linphone_core_enable_ipv6(lc,ipv6);
memset(&tr,0,sizeof(tr));
tr.udp_port=lp_config_get_int(lc->config,"sip","sip_port",5060);
tr.tcp_port=lp_config_get_int(lc->config,"sip","sip_tcp_port",0);
if (lp_config_get_int(lc->config,"sip","sip_random_port",0)) {
tr.udp_port=(0xDFF&+random())+1024;
} else {
tr.udp_port=lp_config_get_int(lc->config,"sip","sip_port",5060);
}
if (lp_config_get_int(lc->config,"sip","sip_tcp_random_port",0)) {
tr.tcp_port=(0xDFF&+random())+1024;
} else {
tr.tcp_port=lp_config_get_int(lc->config,"sip","sip_tcp_port",0);
}
/*start listening on ports*/
linphone_core_set_sip_transports(lc,&tr);
......
......@@ -75,6 +75,15 @@ const char *linphone_address_get_scheme(const LinphoneAddress *u);
const char *linphone_address_get_display_name(const LinphoneAddress* u);
const char *linphone_address_get_username(const LinphoneAddress *u);
const char *linphone_address_get_domain(const LinphoneAddress *u);
/**
* Get port number as an integer value.
*
*/
int linphone_address_get_port_int(const LinphoneAddress *u);
/**
* Get port number, null if not present.
*/
const char* linphone_address_get_port(const LinphoneAddress *u);
void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name);
void linphone_address_set_username(LinphoneAddress *uri, const char *username);
void linphone_address_set_domain(LinphoneAddress *uri, const char *host);
......
......@@ -48,6 +48,9 @@ const char *sal_address_get_display_name(const SalAddress* addr);
char *sal_address_get_display_name_unquoted(const SalAddress *addr);
const char *sal_address_get_username(const SalAddress *addr);
const char *sal_address_get_domain(const SalAddress *addr);
const char * sal_address_get_port(const SalAddress *addr);
int sal_address_get_port_int(const SalAddress *uri);
void sal_address_set_display_name(SalAddress *addr, const char *display_name);
void sal_address_set_username(SalAddress *addr, const char *username);
void sal_address_set_domain(SalAddress *addr, const char *host);
......
......@@ -1758,4 +1758,16 @@ void sal_set_keepalive_period(Sal *ctx,unsigned int value) {
ctx->keepalive_period=value;
eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &value);
}
const char * sal_address_get_port(const SalAddress *addr) {
const osip_from_t *u=(const osip_from_t*)addr;
return null_if_empty(u->url->port);
}
int sal_address_get_port_int(const SalAddress *uri) {
const char* port = sal_address_get_port(uri);
if (port != NULL) {
return atoi(port);
} else {
return 5060;
}
}
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