Commit a25069ed authored by Simon Morlat's avatar Simon Morlat

It is now possible to specify -2 (BELLE_SIP_LISTENING_POINT_DONT_BIND) to...

It is now possible to specify -2 (BELLE_SIP_LISTENING_POINT_DONT_BIND) to request no server socket to be created.
This removes the need for the build-time ENABLE_SERVER_SOCKET option.
parent fe6bb8c5
......@@ -37,7 +37,6 @@ set(VERSION "${PACKAGE_VERSION}")
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
option(ENABLE_RTP_MAP_ALWAYS_IN_SDP "Always include rtpmap in SDP." OFF)
option(ENABLE_SERVER_SOCKETS "Enable server sockets" ON)
option(ENABLE_STRICT "Build with strict compile options." YES)
option(ENABLE_TUNNEL "Enable tunnel support" OFF)
option(ENABLE_TESTS "Enable compilation of tests" ON)
......
......@@ -245,19 +245,6 @@ AC_SUBST(TLS_CFLAGS)
AC_SUBST(TLS_LIBS)
AC_SUBST(TLS_PC)
AC_ARG_ENABLE(server_sockets,
[AS_HELP_STRING([--disable-server-sockets], [Disable server sockets creation])],
[case "${enableval}" in
yes) server_sockets_enabled=true ;;
no) server_sockets_enabled=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-server-sockets) ;;
esac],
[server_sockets_enabled=yes]
)
if test "x$server_sockets_enabled" = "xyes" ; then
AC_DEFINE(ENABLE_SERVER_SOCKETS,1,[Defined when server sockets are enabled])
fi
AC_ARG_ENABLE(tunnel,
[AS_HELP_STRING([--enable-tunnel], [Enable tunnel support (default=no)])])
if test "$enable_tunnel" = "yes" ; then
......
......@@ -22,6 +22,11 @@
BELLE_SIP_BEGIN_DECLS
/*This is passed as port information to listening point URIs and means that it shall use a random port.*/
#define BELLE_SIP_LISTENING_POINT_RANDOM_PORT (-1)
/*This is passed as port information to listening point URIs and means that it shall not bind.*/
#define BELLE_SIP_LISTENING_POINT_DONT_BIND (-2)
BELLESIP_EXPORT const char *belle_sip_listening_point_get_ip_address(const belle_sip_listening_point_t *lp);
BELLESIP_EXPORT int belle_sip_listening_point_get_port(const belle_sip_listening_point_t *lp);
BELLESIP_EXPORT const char *belle_sip_listening_point_get_transport(const belle_sip_listening_point_t *lp);
......
......@@ -69,22 +69,18 @@ typedef struct belle_sip_stream_listening_point belle_sip_stream_listening_point
struct belle_sip_stream_listening_point{
belle_sip_listening_point_t base;
#ifdef ENABLE_SERVER_SOCKETS
belle_sip_socket_t server_sock;
belle_sip_source_t *source;
#endif /* ENABLE_SERVER_SOCKETS */
};
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_stream_listening_point_t,belle_sip_listening_point_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
#ifdef ENABLE_SERVER_SOCKETS
void belle_sip_stream_listening_point_setup_server_socket(belle_sip_stream_listening_point_t *obj, belle_sip_source_func_t on_new_connection_cb );
void belle_sip_stream_listening_point_destroy_server_socket(belle_sip_stream_listening_point_t *lp);
void belle_sip_stream_listening_point_init(belle_sip_stream_listening_point_t *obj, belle_sip_stack_t *s, const char *ipaddress, int port, belle_sip_source_func_t on_new_connection_cb );
#else
void belle_sip_stream_listening_point_init(belle_sip_stream_listening_point_t *obj, belle_sip_stack_t *s, const char *ipaddress, int port );
#endif /* ENABLE_SERVER_SOCKETS */
belle_sip_listening_point_t * belle_sip_stream_listening_point_new(belle_sip_stack_t *s, const char *ipaddress, int port);
/*tls*/
......
......@@ -17,7 +17,6 @@
*/
#include "belle_sip_internal.h"
#ifdef ENABLE_SERVER_SOCKETS
static int on_new_connection(void *userdata, unsigned int events);
......@@ -32,12 +31,9 @@ void belle_sip_stream_listening_point_destroy_server_socket(belle_sip_stream_lis
lp->source=NULL;
}
}
#endif /* ENABLE_SERVER_SOCKETS */
static void belle_sip_stream_listening_point_uninit(belle_sip_stream_listening_point_t *lp){
#ifdef ENABLE_SERVER_SOCKETS
belle_sip_stream_listening_point_destroy_server_socket(lp);
#endif /* ENABLE_SERVER_SOCKETS */
}
static belle_sip_channel_t *stream_create_channel(belle_sip_listening_point_t *lp, const belle_sip_hop_t *hop){
......@@ -62,7 +58,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_stream_listening_point_t)
}
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END
#ifdef ENABLE_SERVER_SOCKETS
static belle_sip_socket_t create_server_socket(const char *addr, int * port, int *family){
struct addrinfo hints={0};
struct addrinfo *res=NULL;
......@@ -165,28 +161,19 @@ static int on_new_connection(void *userdata, unsigned int events){
void belle_sip_stream_listening_point_init(belle_sip_stream_listening_point_t *obj, belle_sip_stack_t *s, const char *ipaddress, int port, belle_sip_source_func_t on_new_connection_cb ){
belle_sip_listening_point_init((belle_sip_listening_point_t*)obj,s,ipaddress,port);
belle_sip_stream_listening_point_setup_server_socket(obj, on_new_connection_cb);
if (port != BELLE_SIP_LISTENING_POINT_DONT_BIND) belle_sip_stream_listening_point_setup_server_socket(obj, on_new_connection_cb);
}
#else
void belle_sip_stream_listening_point_init(belle_sip_stream_listening_point_t *obj, belle_sip_stack_t *s, const char *ipaddress, int port ){
belle_sip_listening_point_init((belle_sip_listening_point_t*)obj,s,ipaddress,port);
}
#endif /* ENABLE_SERVER_SOCKETS */
belle_sip_listening_point_t * belle_sip_stream_listening_point_new(belle_sip_stack_t *s, const char *ipaddress, int port){
belle_sip_stream_listening_point_t *lp=belle_sip_object_new(belle_sip_stream_listening_point_t);
#ifdef ENABLE_SERVER_SOCKETS
belle_sip_stream_listening_point_init(lp,s,ipaddress,port,on_new_connection);
if (lp->server_sock==(belle_sip_socket_t)-1){
if (port != BELLE_SIP_LISTENING_POINT_DONT_BIND && lp->server_sock==(belle_sip_socket_t)-1){
belle_sip_object_unref(lp);
return NULL;
}
#else
belle_sip_stream_listening_point_init(lp,s,ipaddress,port);
#endif /* ENABLE_SERVER_SOCKETS */
return BELLE_SIP_LISTENING_POINT(lp);
}
......@@ -45,7 +45,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_tls_listening_point_t)
}
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END
#ifdef ENABLE_SERVER_SOCKETS
static int on_new_connection(void *userdata, unsigned int revents){
belle_sip_socket_t child;
struct sockaddr_storage addr;
......@@ -64,18 +64,12 @@ static int on_new_connection(void *userdata, unsigned int revents){
belle_sip_close_socket(child);
return BELLE_SIP_CONTINUE;
}
#endif /* ENABLE_SERVER_SOCKETS */
belle_sip_listening_point_t * belle_sip_tls_listening_point_new(belle_sip_stack_t *s, const char *ipaddress, int port){
belle_sip_tls_listening_point_t *lp=belle_sip_object_new(belle_sip_tls_listening_point_t);
#ifdef ENABLE_SERVER_SOCKETS
belle_sip_stream_listening_point_init((belle_sip_stream_listening_point_t*)lp,s,ipaddress,port,on_new_connection);
#else
belle_sip_stream_listening_point_init((belle_sip_stream_listening_point_t*)lp,s,ipaddress,port);
#endif /* ENABLE_SERVER_SOCKETS */
belle_sip_stream_listening_point_init((belle_sip_stream_listening_point_t*)lp,s,ipaddress,port,on_new_connection);
lp->crypto_config=belle_tls_crypto_config_new();
return BELLE_SIP_LISTENING_POINT(lp);
}
......
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