Commit 2ee9d225 authored by Peio Rigaux's avatar Peio Rigaux

Now get custom well_known_port (either sip or sips) if set, exported well...

Now get custom well_known_port (either sip or sips) if set, exported well known port getter and setter to be used in public api
parent 6779c825
......@@ -31,6 +31,19 @@ typedef struct belle_sip_timer_config belle_sip_timer_config_t;
BELLE_SIP_BEGIN_DECLS
/**
* This only affects the resolution of SIP URI in absence of port number, and in absence of SRV record for the SIP domain. The well known ports (udp/tcp and tls/dtls) are static.
* @param well known port value
**/
BELLESIP_EXPORT void belle_sip_stack_set_well_known_port (int value);
BELLESIP_EXPORT void belle_sip_stack_set_well_known_port_tls (int value);
BELLESIP_EXPORT int belle_sip_stack_get_well_known_port (void);
BELLESIP_EXPORT int belle_sip_stack_get_well_known_port_tls (void);
BELLESIP_EXPORT belle_sip_stack_t * belle_sip_stack_new(const char *properties);
BELLESIP_EXPORT belle_sip_listening_point_t *belle_sip_stack_create_listening_point(belle_sip_stack_t *s, const char *ipaddress, int port, const char *transport);
......
......@@ -130,10 +130,18 @@ const belle_sip_uri_t* belle_sip_listening_point_get_uri(const belle_sip_listen
return lp->listening_uri;
}
int belle_sip_listening_point_get_well_known_port(const char *transport){
if (strcasecmp(transport,"UDP")==0 || strcasecmp(transport,"TCP")==0 ) return 5060;
if (strcasecmp(transport,"DTLS")==0 || strcasecmp(transport,"TLS")==0 ) return 5061;
belle_sip_error("No well known port for transport %s", transport);
return -1;
int well_known_port = belle_sip_stack_get_well_known_port();
int tls_well_known_port = belle_sip_stack_get_well_known_port_tls();
if (strcasecmp(transport,"UDP")==0 || strcasecmp(transport,"TCP")==0 ){
return well_known_port;
} else if (strcasecmp(transport,"DTLS")==0 || strcasecmp(transport,"TLS")==0 ){
return tls_well_known_port;
}
else {
belle_sip_error("belle_sip_listening_point_get_well_known_port() : Not valid transport value : %s", transport);
return -1;
}
}
belle_sip_channel_t *_belle_sip_listening_point_get_channel(belle_sip_listening_point_t *lp, const belle_sip_hop_t *hop, const struct addrinfo *addr){
......
......@@ -20,6 +20,27 @@
#include "belle_sip_internal.h"
#include "listeningpoint_internal.h"
static int belle_sip_well_known_port = 5060;
static int belle_sip_well_known_port_tls = 5061;
int belle_sip_stack_get_well_known_port(){
return belle_sip_well_known_port;
}
void belle_sip_stack_set_well_known_port(int value){
bctbx_message("belle_sip_stack_set_well_know_port() : set to [%i]", value);
belle_sip_well_known_port = value;
}
int belle_sip_stack_get_well_known_port_tls(){
return belle_sip_well_known_port_tls;
}
void belle_sip_stack_set_well_known_port_tls(int value){
bctbx_message("belle_sip_stack_set_well_know_port_tls() : set to [%i]", value);
belle_sip_well_known_port_tls = value;
}
belle_sip_hop_t* belle_sip_hop_new(const char* transport, const char *cname, const char* host,int port) {
belle_sip_hop_t* hop = belle_sip_object_new(belle_sip_hop_t);
if (transport) hop->transport=belle_sip_strdup(transport);
......@@ -61,12 +82,12 @@ belle_sip_hop_t* belle_sip_hop_new_from_generic_uri(const belle_generic_uri_t *u
int well_known_port=0;
const char *cname=NULL;
host = belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(uri),"maddr");
if (!host)
host = belle_generic_uri_get_host(uri);
else
cname=belle_generic_uri_get_host(uri);
if (strcasecmp(scheme,"http")==0) {
transport="TCP";
well_known_port=80;
......@@ -337,4 +358,3 @@ int belle_sip_stack_reconnect_to_primary_asap_enabled(const belle_sip_stack_t *s
void belle_sip_stack_set_client_bind_port(belle_sip_stack_t *stack, int port){
stack->test_bind_port = port;
}
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