static int on_new_connection(void *userdata, unsigned int revents){ belle_sip_socket_t child; struct sockaddr_storage addr; socklen_t slen=sizeof(addr); belle_sip_tls_listening_point_t *lp=(belle_sip_tls_listening_point_t*)userdata; belle_sip_stream_listening_point_t *super=(belle_sip_stream_listening_point_t*)lp; child=accept(super->server_sock,(struct sockaddr*)&addr,&slen); if (child==(belle_sip_socket_t)-1){ belle_sip_error("Listening point [%p] accept() failed on TLS server socket: %s",lp,belle_sip_get_socket_error_string()); belle_sip_stream_listening_point_destroy_server_socket(super); belle_sip_stream_listening_point_setup_server_socket(super,on_new_connection); return BELLE_SIP_STOP; } belle_sip_message("New connection arriving on TLS, not handled !"); close_socket(child); return BELLE_SIP_CONTINUE; }
static int on_new_connection(void *userdata, unsigned int events){ belle_sip_socket_t child; struct sockaddr_storage addr; socklen_t slen=sizeof(addr); belle_sip_stream_listening_point_t *lp=(belle_sip_stream_listening_point_t*)userdata; belle_sip_channel_t *chan; child=accept(lp->server_sock,(struct sockaddr*)&addr,&slen); if (child==(belle_sip_socket_t)-1){ belle_sip_error("Listening point [%p] accept() failed on TCP server socket: %s",lp,belle_sip_get_socket_error_string()); belle_sip_stream_listening_point_destroy_server_socket(lp); belle_sip_stream_listening_point_setup_server_socket(lp,on_new_connection); return BELLE_SIP_STOP; } belle_sip_message("New connection arriving !"); chan=belle_sip_stream_channel_new_child(lp->base.stack,child,(struct sockaddr*)&addr,slen); if (chan) belle_sip_listening_point_add_channel((belle_sip_listening_point_t*)lp,chan); return BELLE_SIP_CONTINUE; }
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); }