Example #1
0
void kad_setup( void ) {
	int s4, s6;

	s4 = -1;
	s6 = -1;

	/* Let the DHT output debug text */
	if( gconf->verbosity == VERBOSITY_DEBUG ) {
		dht_debug = stdout;
	}

	dht_lock_init();

	if( gconf->af == AF_INET ) {
		s4 = net_bind( "DHT", DHT_ADDR4, gconf->dht_port, gconf->dht_ifce, IPPROTO_UDP, AF_INET );
		net_add_handler( s4, &dht_handler );
	} else {
		s6 = net_bind( "DHT", DHT_ADDR6, gconf->dht_port, gconf->dht_ifce, IPPROTO_UDP, AF_INET6 );
		net_add_handler( s6, &dht_handler );
	}

	/* Init the DHT.  Also set the sockets into non-blocking mode. */
	if( dht_init( s4, s6, gconf->node_id, (UCHAR*) "KN\0\0") < 0 ) {
		log_err( "DHT: Failed to initialize the DHT." );
	}
}
Example #2
0
void kad_setup( void ) {
	UCHAR node_id[SHA1_BIN_LENGTH];
	int s4, s6;

	s4 = -1;
	s6 = -1;

	/* Let the DHT output debug text */
	if( gconf->verbosity == VERBOSITY_DEBUG ) {
		dht_debug = stdout;
	}

	bytes_from_hex( node_id, gconf->node_id_str, strlen( gconf->node_id_str ) );

	dht_lock_init();

	if( gconf->af == AF_INET ) {
		s4 = net_bind( "KAD", DHT_ADDR4, gconf->dht_port, gconf->dht_ifname, IPPROTO_UDP, AF_INET );
		net_add_handler( s4, &dht_handler );
	} else {
		s6 = net_bind( "KAD", DHT_ADDR6, gconf->dht_port, gconf->dht_ifname, IPPROTO_UDP, AF_INET6 );
		net_add_handler( s6, &dht_handler );
	}

	/* Init the DHT.  Also set the sockets into non-blocking mode. */
	if( dht_init( s4, s6, node_id, (UCHAR*) "KN\0\0") < 0 ) {
		log_err( "KAD: Failed to initialize the DHT." );
	}
}
Example #3
0
void cmd_setup( void ) {
	int sock;

	if( str_isZero( gconf->cmd_port ) ) {
		return;
	}

	sock = net_bind( "CMD", "::1", gconf->cmd_port, NULL, IPPROTO_UDP, AF_INET6 );
	net_add_handler( sock, &cmd_remote_handler );

	if( gconf->is_daemon == 0 && gconf->cmd_disable_stdin == 0 ) {
		/* Wait for other messages to be displayed */
		sleep( 1 );

		fprintf( stdout, "Press Enter for help.\n" );
		net_add_handler( STDIN_FILENO, &cmd_console_handler );
	}
}
Example #4
0
void web_setup( void ) {
	int sock;

	if( str_isZero( gconf->web_port ) ) {
		return;
	}

	sock = net_bind( "WEB", "localhost", gconf->web_port, NULL, IPPROTO_TCP, AF_UNSPEC );
	net_add_handler( sock, &web_handler );
}
Example #5
0
void lpd_setup( void ) {
	int sock;

	g_packet_limit = PACKET_LIMIT_MAX;

	if( addr_parse( &g_lpd_addr, gconf->lpd_addr, LPD_PORT, gconf->af ) != 0 ) {
		log_err( "BOOT: Failed to parse IP address for '%s'.", gconf->lpd_addr );
	}

	if( gconf->lpd_disable ) {
		return;
	}

	sock = create_receive_socket();
	net_add_handler( sock, &handle_mcast );
}
Example #6
0
void lpd_setup( void ) {

	g_packet_limit = PACKET_LIMIT_MAX;
	if( addr_parse( &g_lpd_addr, gconf->lpd_addr, DHT_PORT_MCAST, gconf->af ) != 0 ) {
		log_err( "BOOT: Failed to parse IP address for '%s'.", gconf->lpd_addr );
	}

	if( gconf->lpd_disable ) {
		return;
	}

	/*
	* Use different sockets for sending and receiving because
	* MacOSX does not seem to allow it to be the same.
	*/
	g_sock_send = create_send_socket();
	g_sock_recv = create_receive_socket();

	net_add_handler( g_sock_recv, &bootstrap_handle_mcast );
}