- connection_count--;
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# active connections"),
- -1,
- GNUNET_NO);
-}
-
-static int dll_contains ( char * uri)
-{
- struct GNUNET_Hostlist * actual = dll_head;
-
- if (dll_size == 0)
- return GNUNET_NO;
- actual = dll_head;
-
- while ( GNUNET_YES )
- {
- if ( 0 == strcmp(actual->hostlist_uri,uri) ) return GNUNET_YES;
- if (actual == dll_tail) break;
- actual = actual->next;
- }
-
- return GNUNET_NO;
-}
-
-struct GNUNET_Hostlist * dll_get ( char * uri )
-{
- struct GNUNET_Hostlist * actual = dll_head;
-
- if (dll_size == 0)
- return NULL;
- actual = dll_head;
-
- while ( GNUNET_YES)
- {
- if ( 0 == strcmp(actual->hostlist_uri,uri) ) return actual;
- if (actual == dll_tail) break;
- actual = actual->next;
- }
-
- return NULL;
-}
-
-struct GNUNET_Hostlist * dll_get_lowest_quality ( )
-{
- struct GNUNET_Hostlist * actual = dll_head;
- struct GNUNET_Hostlist * lowest = NULL;
-
- if (dll_size == 0)
- return lowest;
-
- lowest = dll_tail;
- actual = dll_head;
-
- while ( GNUNET_YES)
- {
- if ( actual->quality < lowest->quality) lowest = actual;
- if (actual == dll_tail) break;
- actual = actual->next;
- }
-
- return lowest;
-}
-
-static int dll_insert ( struct GNUNET_Hostlist * elem)
-{
- if (dll_size <= MAX_NUMBER_HOSTLISTS)
- {
- GNUNET_CONTAINER_DLL_insert(dll_head, dll_tail,elem);
- dll_size++;
- return GNUNET_OK;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Maximum number of %u for hostlist entries reached, \n", MAX_NUMBER_HOSTLISTS );
- return GNUNET_SYSERR;
-}
-
-static int dll_remove ( struct GNUNET_Hostlist * elem)
-{
- if ( GNUNET_YES == dll_contains (elem->hostlist_uri))
- {
- GNUNET_CONTAINER_DLL_remove(dll_head, dll_tail,elem);
- dll_size--;
- return GNUNET_OK;
- }
- return GNUNET_SYSERR;
-}
-
-void create_dummy_entries ()
-{
-
- /* test */
- struct GNUNET_Hostlist * hostlist1;
- hostlist1 = GNUNET_malloc ( sizeof (struct GNUNET_Hostlist) );
- char * str = "uri_1";
-
- GNUNET_CRYPTO_hash_create_random ( GNUNET_CRYPTO_QUALITY_WEAK , &hostlist1->peer.hashPubKey);
- hostlist1->hello_count = 0;
- hostlist1->hostlist_uri = GNUNET_malloc ( strlen(str) +1 );
- strcpy(hostlist1->hostlist_uri,str);
- hostlist1->time_creation = GNUNET_TIME_absolute_get();
- hostlist1->time_last_usage = GNUNET_TIME_absolute_get_zero();
- hostlist1->quality = HOSTLIST_INITIAL - 100;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding test peer '%s' with URI %s and quality %u to dll \n", GNUNET_h2s (&hostlist1->peer.hashPubKey) , hostlist1->hostlist_uri, hostlist1->quality);
- dll_insert (hostlist1);
-
- struct GNUNET_Hostlist * hostlist2;
- hostlist2 = GNUNET_malloc ( sizeof (struct GNUNET_Hostlist) );
- char * str2 = "uri_2";
-
- GNUNET_CRYPTO_hash_create_random ( GNUNET_CRYPTO_QUALITY_WEAK , &hostlist2->peer.hashPubKey);
- hostlist2->hello_count = 0;
- hostlist2->hostlist_uri = GNUNET_malloc ( strlen(str2) +1 );
- strcpy(hostlist2->hostlist_uri,str2);
- hostlist2->time_creation = GNUNET_TIME_absolute_get();
- hostlist2->time_last_usage = GNUNET_TIME_absolute_get_zero();
- hostlist2->quality = HOSTLIST_INITIAL - 200;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding test peer '%s' with URI %s and quality %u to dll \n", GNUNET_h2s (&hostlist2->peer.hashPubKey) , hostlist2->hostlist_uri, hostlist2->quality);
- dll_insert (hostlist2);
-
- struct GNUNET_Hostlist * hostlist3;
- hostlist3 = GNUNET_malloc ( sizeof (struct GNUNET_Hostlist) );
- char * str3 = "uri_3";
-
- GNUNET_CRYPTO_hash_create_random ( GNUNET_CRYPTO_QUALITY_WEAK , &hostlist3->peer.hashPubKey);
- hostlist3->hello_count = 0;
- hostlist3->hostlist_uri = GNUNET_malloc ( strlen(str3) +1 );
- strcpy(hostlist3->hostlist_uri,str3);
- hostlist3->time_creation = GNUNET_TIME_absolute_get();
- hostlist3->time_last_usage = GNUNET_TIME_absolute_get_zero();
- hostlist3->quality = HOSTLIST_INITIAL - 300;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding test peer '%s' with URI %s and quality %u to dll \n", GNUNET_h2s (&hostlist3->peer.hashPubKey) , hostlist3->hostlist_uri, hostlist3->quality);
- dll_insert (hostlist3);
-
-
- struct GNUNET_Hostlist * hostlist4;
- hostlist4 = GNUNET_malloc ( sizeof (struct GNUNET_Hostlist) );
- char * str4 = "uri_4";
-
- GNUNET_CRYPTO_hash_create_random ( GNUNET_CRYPTO_QUALITY_WEAK , &hostlist4->peer.hashPubKey);
- hostlist4->hello_count = 0;
- hostlist4->hostlist_uri = GNUNET_malloc ( strlen(str4) +1 );
- strcpy(hostlist4->hostlist_uri,str4);
- hostlist4->time_creation = GNUNET_TIME_absolute_get();
- hostlist4->time_last_usage = GNUNET_TIME_absolute_get_zero();
- hostlist4->quality = HOSTLIST_INITIAL - 400;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding test peer '%s' with URI %s and quality %u to dll \n", GNUNET_h2s (&hostlist4->peer.hashPubKey) , hostlist4->hostlist_uri, hostlist4->quality);
- dll_insert (hostlist4);