Commit 19f8d20a authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Add option to disable server sockets.

parent db4b816f
...@@ -35,6 +35,7 @@ set(PACKAGE_URL "") ...@@ -35,6 +35,7 @@ set(PACKAGE_URL "")
set(VERSION "${PACKAGE_VERSION}") set(VERSION "${PACKAGE_VERSION}")
option(ENABLE_SERVER_SOCKETS "Enable server sockets" ON)
option(ENABLE_STATIC "Build static library (default is shared library)." OFF) option(ENABLE_STATIC "Build static library (default is shared library)." OFF)
option(ENABLE_TLS "Enable TLS support" ON) option(ENABLE_TLS "Enable TLS support" ON)
option(ENABLE_TUNNEL "Enable tunnel support" OFF) option(ENABLE_TUNNEL "Enable tunnel support" OFF)
......
...@@ -76,3 +76,5 @@ ...@@ -76,3 +76,5 @@
#cmakedefine HAVE_CU_GET_SUITE #cmakedefine HAVE_CU_GET_SUITE
#cmakedefine HAVE_TUNNEL #cmakedefine HAVE_TUNNEL
#cmakedefine ENABLE_SERVER_SOCKETS
...@@ -238,6 +238,19 @@ AC_SUBST(TLS_CFLAGS) ...@@ -238,6 +238,19 @@ AC_SUBST(TLS_CFLAGS)
AC_SUBST(TLS_LIBS) AC_SUBST(TLS_LIBS)
AC_SUBST(TLS_PC) 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, AC_ARG_ENABLE(tunnel,
[AS_HELP_STRING([--enable-tunnel], [Enable tunnel support (default=no)])]) [AS_HELP_STRING([--enable-tunnel], [Enable tunnel support (default=no)])])
if test "$enable_tunnel" = "yes" ; then if test "$enable_tunnel" = "yes" ; then
......
...@@ -69,16 +69,22 @@ typedef struct belle_sip_stream_listening_point belle_sip_stream_listening_point ...@@ -69,16 +69,22 @@ typedef struct belle_sip_stream_listening_point belle_sip_stream_listening_point
struct belle_sip_stream_listening_point{ struct belle_sip_stream_listening_point{
belle_sip_listening_point_t base; belle_sip_listening_point_t base;
#ifdef ENABLE_SERVER_SOCKETS
belle_sip_socket_t server_sock; belle_sip_socket_t server_sock;
belle_sip_source_t *source; 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_BEGIN(belle_sip_stream_listening_point_t,belle_sip_listening_point_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END 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_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_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 ); 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); belle_sip_listening_point_t * belle_sip_stream_listening_point_new(belle_sip_stack_t *s, const char *ipaddress, int port);
/*tls*/ /*tls*/
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
#include "belle_sip_internal.h" #include "belle_sip_internal.h"
#ifdef ENABLE_SERVER_SOCKETS
static int on_new_connection(void *userdata, unsigned int events); static int on_new_connection(void *userdata, unsigned int events);
...@@ -31,9 +32,12 @@ void belle_sip_stream_listening_point_destroy_server_socket(belle_sip_stream_lis ...@@ -31,9 +32,12 @@ void belle_sip_stream_listening_point_destroy_server_socket(belle_sip_stream_lis
lp->source=NULL; lp->source=NULL;
} }
} }
#endif /* ENABLE_SERVER_SOCKETS */
static void belle_sip_stream_listening_point_uninit(belle_sip_stream_listening_point_t *lp){ 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); 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){ static belle_sip_channel_t *stream_create_channel(belle_sip_listening_point_t *lp, const belle_sip_hop_t *hop){
...@@ -58,6 +62,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_stream_listening_point_t) ...@@ -58,6 +62,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_stream_listening_point_t)
} }
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END 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){ static belle_sip_socket_t create_server_socket(const char *addr, int port, int *family){
struct addrinfo hints={0}; struct addrinfo hints={0};
struct addrinfo *res=NULL; struct addrinfo *res=NULL;
...@@ -142,13 +147,23 @@ void belle_sip_stream_listening_point_init(belle_sip_stream_listening_point_t *o ...@@ -142,13 +147,23 @@ void belle_sip_stream_listening_point_init(belle_sip_stream_listening_point_t *o
belle_sip_stream_listening_point_setup_server_socket(obj, on_new_connection_cb); 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_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); 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); belle_sip_stream_listening_point_init(lp,s,ipaddress,port,on_new_connection);
if (lp->server_sock==(belle_sip_socket_t)-1){ if (lp->server_sock==(belle_sip_socket_t)-1){
belle_sip_object_unref(lp); belle_sip_object_unref(lp);
return NULL; return NULL;
} }
#endif /* ENABLE_SERVER_SOCKETS */
return BELLE_SIP_LISTENING_POINT(lp); return BELLE_SIP_LISTENING_POINT(lp);
} }
...@@ -49,6 +49,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_tls_listening_point_t) ...@@ -49,6 +49,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_tls_listening_point_t)
} }
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END
#ifdef ENABLE_SERVER_SOCKETS
static int on_new_connection(void *userdata, unsigned int revents){ static int on_new_connection(void *userdata, unsigned int revents){
belle_sip_socket_t child; belle_sip_socket_t child;
struct sockaddr_storage addr; struct sockaddr_storage addr;
...@@ -67,10 +68,15 @@ static int on_new_connection(void *userdata, unsigned int revents){ ...@@ -67,10 +68,15 @@ static int on_new_connection(void *userdata, unsigned int revents){
close_socket(child); close_socket(child);
return BELLE_SIP_CONTINUE; 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_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); 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); 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 */
lp->verify_ctx=belle_tls_verify_policy_new(); lp->verify_ctx=belle_tls_verify_policy_new();
......
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