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." ); } }
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." ); } }