Ejemplo n.º 1
0
static int belle_sip_udp_listening_point_init_socket(belle_sip_udp_listening_point_t *lp){
	lp->sock=create_udp_socket(belle_sip_uri_get_host(((belle_sip_listening_point_t*)lp)->listening_uri)
					,belle_sip_uri_get_port(((belle_sip_listening_point_t*)lp)->listening_uri),&lp->base.ai_family);
	if (lp->sock==(belle_sip_socket_t)-1){
		return -1;
	}
	if (lp->base.stack->dscp)
		belle_sip_socket_set_dscp(lp->sock,lp->base.ai_family,lp->base.stack->dscp);
	lp->source=belle_sip_socket_source_new((belle_sip_source_func_t)on_udp_data,lp,lp->sock,BELLE_SIP_EVENT_READ,-1);
	belle_sip_main_loop_add_source(((belle_sip_listening_point_t*)lp)->stack->ml,lp->source);
	return 0;
}
Ejemplo n.º 2
0
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 ){
	int port=belle_sip_uri_get_port(obj->base.listening_uri);
	
	obj->server_sock=create_server_socket(belle_sip_uri_get_host(obj->base.listening_uri),
		&port, &obj->base.ai_family);
	if (obj->server_sock==(belle_sip_socket_t)-1) return;
	belle_sip_uri_set_port(((belle_sip_listening_point_t*)obj)->listening_uri,port);
	if (obj->base.stack->dscp)
		belle_sip_socket_set_dscp(obj->server_sock,obj->base.ai_family,obj->base.stack->dscp);
	obj->source=belle_sip_socket_source_new(on_new_connection_cb,obj,obj->server_sock,BELLE_SIP_EVENT_READ,-1);
	belle_sip_main_loop_add_source(obj->base.stack->ml,obj->source);
}