/* we're clearly running a test, don't daemonize */
proc = do_start_process (GNUNET_NO,
NULL, loprefix, binary, "-c", config,
-#if DEBUG_ARM
- "-L", "DEBUG",
-#endif
/* no daemonization! */
lopostfix, NULL);
}
{
proc = do_start_process (GNUNET_NO,
NULL, loprefix, binary, "-c", config,
-#if DEBUG_ARM
- "-L", "DEBUG",
-#endif
"-d", lopostfix, NULL);
}
GNUNET_free (binary);
#include "gnunet_ats_service.h"
#include "ats_api.h"
-#define DEBUG_ATS GNUNET_EXTRA_LOGGING
-
#define LOG(kind,...) GNUNET_log_from (kind, "ats-api", __VA_ARGS__)
/**
struct GNUNET_ATS_SuggestionContext *asc = cls;
struct AllocationRecord *ar = value;
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Suggesting address for peer `%s', starting with i:%u/o:%u bytes/s\n",
GNUNET_h2s (key), asc->atc->total_bps_in / 32,
asc->atc->total_bps_out / 32);
-#endif
-
/* trivial strategy: pick first available address... */
asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr,
ar->plugin_addr_len, ar->session,
{
struct GNUNET_ATS_SuggestionContext *asc;
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "Looking up suggested address for peer `%s'\n",
GNUNET_i2s (peer));
-#endif
asc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestionContext));
asc->cb = cb;
asc->cb_cls = cb_cls;
{
struct GNUNET_ATS_SchedulingHandle *atc;
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS init\n");
-#endif
atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SchedulingHandle));
atc->cfg = cfg;
atc->alloc_cb = alloc_cb;
void
GNUNET_ATS_shutdown (struct GNUNET_ATS_SchedulingHandle *atc)
{
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS shutdown\n");
-#endif
if (GNUNET_SCHEDULER_NO_TASK != atc->ba_task)
{
GNUNET_SCHEDULER_cancel (atc->ba_task);
arnew->plugin_addr_len)))))
return GNUNET_YES; /* no match */
/* records match */
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating session for peer `%s' plugin `%s'\n",
GNUNET_h2s (key), arold->plugin_name);
-#endif
if (arnew->session != arold->session)
{
arold->session = arnew->session;
{
if (arold->ats[c_old].type == arnew->ats[c_new].type)
{
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found type %i, old value=%i new value=%i\n",
ntohl (arold->ats[c_old].type), ntohl (arold->ats[c_old].value),
ntohl (arnew->ats[c_new].value));
-#endif
arold->ats[c_old].value = arnew->ats[c_new].value;
found = GNUNET_YES;
}
/* Add new value */
if (found == GNUNET_NO)
{
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "Added new type %i new value=%i\n",
ntohl (arnew->ats[c_new].type), ntohl (arnew->ats[c_new].value));
LOG (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n", arold->ats_count);
-#endif
GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1);
GNUNET_assert (arold->ats_count >= 2);
arold->ats[arold->ats_count - 2].type = arnew->ats[c_new].type;
arold->ats[arold->ats_count - 2].value = arnew->ats[c_new].value;
arold->ats[arold->ats_count - 1].type = htonl (0);
arold->ats[arold->ats_count - 1].value = htonl (0);
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n", arold->ats_count);
-#endif
}
c_new++;
}
struct AllocationRecord *ar;
struct UpdateSessionContext usc;
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n", GNUNET_i2s (peer));
-#endif
-
(void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &disconnect_peer,
atc);
ar = create_allocation_record (plugin_name, session, plugin_addr,
GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_SchedulingHandle *atc,
const struct GNUNET_PeerIdentity *peer)
{
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnected from peer %s\n",
GNUNET_i2s (peer));
-#endif
(void) GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers,
&peer->hashPubKey,
&disconnect_peer, atc);
struct AllocationRecord *ar;
struct UpdateSessionContext usc;
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s', plugin `%s'\n",
GNUNET_i2s (peer), plugin_name);
-#endif
ar = create_allocation_record (plugin_name, session, plugin_addr,
plugin_addr_len, ats, ats_count);
usc.atc = atc;
destroy_allocation_record (NULL, &peer->hashPubKey, ar);
return;
}
-#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding new address for peer `%s', plugin `%s'\n", GNUNET_i2s (peer),
plugin_name);
-#endif
ar->connected = GNUNET_NO;
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (atc->peers,
rim->reserve_inbound = htonl (amount);
rim->preference_change = GNUNET_htonll (preference);
rim->peer = *peer;
-#if DEBUG_ATS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Queueing CHANGE PREFERENCE request for peer `%s' with RIM %u\n",
GNUNET_i2s (peer), (unsigned int) pr->rim_id);
-#endif
GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head,
h->control_pending_tail, cm);
pr->pcic = info;
}
else
{
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Delivering message of type %u to %s\n", ntohs (message->type),
GNUNET_i2s (&car->target));
-#endif
GSC_CLIENTS_deliver_message (&car->target, NULL, 0, message,
ntohs (message->size),
GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
if (client == NULL)
return;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p has disconnected from core service.\n", client);
-#endif
c = find_client (client);
if (c == NULL)
return; /* client never sent INIT */
cnm->ats_count = htonl (atsi_count);
a = (struct GNUNET_ATS_Information *) &cnm[1];
memcpy (a, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
"NOTIFY_CONNECT");
-#endif
cnm->peer = *neighbour;
send_to_client (client, &cnm->header, GNUNET_NO);
}
{
struct NeighbourMessageEntry *m;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Destroying neighbour entry for peer `%4s'\n",
GNUNET_i2s (&n->peer));
-#endif
while (NULL != (m = n->message_head))
{
GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
if (buf == NULL)
{
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmission of message of type %u and size %u failed\n",
(unsigned int)
ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
(unsigned int) m->size);
-#endif
GNUNET_free (m);
process_queue (n);
return 0;
GNUNET_assert (size >= m->size);
memcpy (cbuf, &m[1], m->size);
ret = m->size;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Copied message of type %u and size %u into transport buffer for `%4s'\n",
(unsigned int)
ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
(unsigned int) ret, GNUNET_i2s (&n->peer));
-#endif
GNUNET_free (m);
process_queue (n);
GNUNET_STATISTICS_update (GSC_stats,
GSC_SESSIONS_solicit (&n->peer);
return;
}
-#if DEBUG_CORE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n",
(unsigned int) m->size, GNUNET_i2s (&n->peer),
(unsigned long long)
GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value);
-#endif
n->th =
GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size, 0,
GNUNET_TIME_absolute_get_remaining
GNUNET_break (0);
return;
}
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n",
GNUNET_i2s (peer));
-#endif
n = GNUNET_malloc (sizeof (struct Neighbour));
n->peer = *peer;
GNUNET_assert (GNUNET_OK ==
{
struct Neighbour *n;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%4s' disconnected from us; received notification from transport.\n",
GNUNET_i2s (peer));
-#endif
n = find_neighbour (peer);
if (n == NULL)
{
struct Neighbour *n;
uint16_t type;
-#if DEBUG_CORE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %u from `%4s', demultiplexing.\n",
(unsigned int) ntohs (message->type), GNUNET_i2s (peer));
-#endif
if (0 == memcmp (peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
session = find_session (pid);
if (NULL == session)
return;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying session for peer `%4s'\n",
GNUNET_i2s (&session->peer));
-#endif
if (GNUNET_SCHEDULER_NO_TASK != session->cork_task)
{
GNUNET_SCHEDULER_cancel (session->cork_task);
{
struct Session *session;
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating session for peer `%4s'\n",
GNUNET_i2s (peer));
-#endif
session = GNUNET_malloc (sizeof (struct Session));
session->tmap = GSC_TYPEMAP_create ();
session->peer = *peer;
session = find_session (&car->target);
if (session == NULL)
{
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Dropped client request for transmission (am disconnected)\n");
-#endif
GNUNET_break (0); /* should have been rejected earlier */
GSC_CLIENTS_reject_request (car);
return;
GSC_CLIENTS_reject_request (car);
return;
}
-#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received client transmission request. queueing\n");
-#endif
GNUNET_CONTAINER_DLL_insert (session->active_client_request_head,
session->active_client_request_tail, car);
try_transmission (session);
#include "gnunet_statistics_service.h"
#include "gnunet_datacache_plugin.h"
-#define DEBUG_DATACACHE GNUNET_EXTRA_LOGGING
#define LOG(kind,...) GNUNET_log_from (kind, "datacache", __VA_ARGS__)
{
struct GNUNET_DATACACHE_Handle *h = cls;
-#if DEBUG_DATACACHE
LOG (GNUNET_ERROR_TYPE_DEBUG, "Content under key `%s' discarded\n",
GNUNET_h2s (key));
-#endif
GNUNET_assert (h->utilization >= size);
h->utilization -= size;
GNUNET_CONTAINER_bloomfilter_remove (h->filter, key);
GNUNET_break (0);
return GNUNET_SYSERR;
}
-#if DEBUG_DATACACHE
LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n",
GNUNET_h2s (key));
-#endif
GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size,
GNUNET_NO);
GNUNET_CONTAINER_bloomfilter_add (h->filter, key);
{
GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1,
GNUNET_NO);
-#if DEBUG_DATACACHE
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n",
GNUNET_h2s (key));
-#endif
if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key))
{
GNUNET_STATISTICS_update (h->stats,
gettext_noop
("# requests filtered by bloom filter"), 1,
GNUNET_NO);
-#if DEBUG_DATACACHE
LOG (GNUNET_ERROR_TYPE_DEBUG, "Bloomfilter filters request for key `%s'\n",
GNUNET_h2s (key));
-#endif
return 0; /* can not be present */
}
return h->api->get (h->api->cls, key, type, iter, iter_cls);
#include "gnunet_mysql_lib.h"
#include <mysql/mysql.h>
-#define DEBUG_DATACACHE_MYSQL GNUNET_EXTRA_LOGGING
/**
* Estimate of the per-entry overhead (including indices).
#include "gnunet_datacache_plugin.h"
#include <postgresql/libpq-fe.h>
-#define DEBUG_POSTGRES GNUNET_EXTRA_LOGGING
+#define LOG(kind,...) GNUNET_log_from (kind, "datacache-postgres", __VA_ARGS__)
/**
* Per-entry overhead estimate
GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared",
(type == 0) ? "getk" : "getkt"))
{
-#if DEBUG_POSTGRES
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres",
- "Ending iteration (postgres error)\n");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Ending iteration (postgres error)\n");
return 0;
}
if (0 == (cnt = PQntuples (res)))
{
/* no result */
-#if DEBUG_POSTGRES
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres",
- "Ending iteration (no more results)\n");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Ending iteration (no more results)\n");
PQclear (res);
return 0;
}
GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, i, 0));
type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1));
size = PQgetlength (res, i, 2);
-#if DEBUG_POSTGRES
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres",
- "Found result of size %u bytes and type %u in database\n",
- (unsigned int) size, (unsigned int) type);
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found result of size %u bytes and type %u in database\n",
+ (unsigned int) size, (unsigned int) type);
if (GNUNET_SYSERR ==
iter (iter_cls, expiration_time, key, size, PQgetvalue (res, i, 2),
(enum GNUNET_BLOCK_Type) type))
{
-#if DEBUG_POSTGRES
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres",
- "Ending iteration (client error)\n");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Ending iteration (client error)\n");
PQclear (res);
return cnt;
}
if (GNUNET_OK !=
GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", "getm"))
{
-#if DEBUG_POSTGRES
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres",
- "Ending iteration (postgres error)\n");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Ending iteration (postgres error)\n");
return 0;
}
if (0 == PQntuples (res))
{
/* no result */
-#if DEBUG_POSTGRES
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres",
- "Ending iteration (no more results)\n");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Ending iteration (no more results)\n");
PQclear (res);
return GNUNET_SYSERR;
}
api->get = &postgres_plugin_get;
api->put = &postgres_plugin_put;
api->del = &postgres_plugin_del;
- GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datacache-postgres",
- _("Postgres datacache running\n"));
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _("Postgres datacache running\n"));
return api;
}
#include "gnunet_datacache_plugin.h"
#include <sqlite3.h>
-#define DEBUG_DATACACHE_SQLITE GNUNET_EXTRA_LOGGING
-
#define LOG(kind,...) GNUNET_log_from (kind, "datacache-sqlite", __VA_ARGS__)
#define LOG_STRERROR_FILE(kind,op,fn) GNUNET_log_from_strerror_file (kind, "datacache-sqlite", op, fn)
sqlite3_stmt *stmt;
int64_t dval;
-#if DEBUG_DATACACHE_SQLITE
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' of %u bytes with key `%4s' and expiration %llums\n",
"PUT", (unsigned int) size, GNUNET_h2s (key),
(unsigned long long)
GNUNET_TIME_absolute_get_remaining (discard_time).rel_value);
-#endif
dval = (int64_t) discard_time.abs_value;
if (dval < 0)
dval = INT64_MAX;
int64_t ntime;
now = GNUNET_TIME_absolute_get ();
-#if DEBUG_DATACACHE_SQLITE
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' for key `%4s'\n", "GET",
GNUNET_h2s (key));
-#endif
if (sq_prepare
(plugin->dbh,
"SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?",
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite_step");
sqlite3_finalize (stmt);
-#if DEBUG_DATACACHE_SQLITE
LOG (GNUNET_ERROR_TYPE_DEBUG,
"No content found when processing `%s' for key `%4s'\n", "GET",
GNUNET_h2s (key));
-#endif
return 0;
}
total = sqlite3_column_int (stmt, 0);
sqlite3_finalize (stmt);
if ((total == 0) || (iter == NULL))
{
-#if DEBUG_DATACACHE_SQLITE
if (0 == total)
LOG (GNUNET_ERROR_TYPE_DEBUG,
"No content found when processing `%s' for key `%4s'\n", "GET",
GNUNET_h2s (key));
-#endif
return total;
}
if (ntime == INT64_MAX)
exp = GNUNET_TIME_UNIT_FOREVER_ABS;
cnt++;
-#if DEBUG_DATACACHE_SQLITE
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found %u-byte result when processing `%s' for key `%4s'\n",
(unsigned int) size, "GET", GNUNET_h2s (key));
-#endif
if (GNUNET_OK != iter (iter_cls, exp, key, size, dat, type))
{
sqlite3_finalize (stmt);
sqlite3_stmt *dstmt;
GNUNET_HashCode hc;
-#if DEBUG_DATACACHE_SQLITE
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s'\n", "DEL");
-#endif
stmt = NULL;
dstmt = NULL;
if (sq_prepare
stmt = sqlite3_next_stmt (plugin->dbh, NULL);
while (stmt != NULL)
{
-#if DEBUG_SQLITE
LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing statement %p\n", stmt);
-#endif
result = sqlite3_finalize (stmt);
-#if DEBUG_SQLITE
if (result != SQLITE_OK)
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to close statement %p: %d\n",
+ LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to close statement %p: %d\n"),
stmt, result);
-#endif
stmt = sqlite3_next_stmt (plugin->dbh, NULL);
}
result = sqlite3_close (plugin->dbh);
#ifndef DATASTORE_H
#define DATASTORE_H
-#define DEBUG_DATASTORE GNUNET_EXTRA_LOGGING
#include "gnunet_util_lib.h"
&delete_expired, NULL);
return GNUNET_SYSERR;
}
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deleting content `%s' of type %u that expired %llu ms ago\n",
GNUNET_h2s (key), type,
(unsigned long long) (now.abs_value - expiration.abs_value));
-#endif
min_expiration = now;
GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), size,
GNUNET_YES);
if (NULL == key)
return GNUNET_SYSERR;
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deleting %llu bytes of low-priority (%u) content `%s' of type %u at %llu ms prior to expiration (still trying to free another %llu bytes)\n",
(unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD),
GNUNET_h2s (key), type,
(unsigned long long) GNUNET_TIME_absolute_get_remaining (expiration).rel_value,
*need);
-#endif
if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need)
*need = 0;
else
{
unsigned long long last;
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asked to free up %llu bytes of cache space\n", need);
-#endif
last = 0;
while ((need > 0) && (last != need))
{
if (GNUNET_YES == cleaning_done)
{
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Shutdown in progress, aborting transmission.\n");
-#endif
+ _("Shutdown in progress, aborting transmission.\n"));
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
GNUNET_free (msg);
return;
struct StatusMessage *sm;
size_t slen;
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting `%s' message with value %d and message `%s'\n",
"STATUS", code, msg != NULL ? msg : "(none)");
-#endif
slen = (msg == NULL) ? 0 : strlen (msg) + 1;
sm = GNUNET_malloc (sizeof (struct StatusMessage) + slen);
sm->header.size = htons (sizeof (struct StatusMessage) + slen);
if (key == NULL)
{
/* transmit 'DATA_END' */
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' message\n",
"DATA_END");
-#endif
end = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader));
end->size = htons (sizeof (struct GNUNET_MessageHeader));
end->type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END);
dm->uid = GNUNET_htonll (uid);
dm->key = *key;
memcpy (&dm[1], data, size);
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting `%s' message for `%s' of type %u with expiration %llu (now: %llu)\n",
"DATA", GNUNET_h2s (key), type,
(unsigned long long) expiration.abs_value,
(unsigned long long) GNUNET_TIME_absolute_get ().abs_value);
-#endif
GNUNET_STATISTICS_update (stats, gettext_noop ("# results found"), 1,
GNUNET_NO);
transmit (client, &dm->header);
uint64_t amount;
uint32_t entries;
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "RESERVE");
-#endif
amount = GNUNET_ntohll (msg->amount);
entries = ntohl (msg->entries);
used = payload + reserved;
int rid = ntohl (msg->rid);
unsigned long long rem;
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n",
"RELEASE_RESERVE");
-#endif
next = reservations;
prev = NULL;
while (NULL != (pos = next))
reserved -= rem;
GNUNET_STATISTICS_set (stats, gettext_noop ("# reserved"), reserved,
GNUNET_NO);
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Returning %llu remaining reserved bytes to storage pool\n",
rem);
-#endif
GNUNET_free (pos);
transmit_status (client, GNUNET_OK, NULL);
return;
GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes stored"), size,
GNUNET_YES);
GNUNET_CONTAINER_bloomfilter_add (filter, &dm->key);
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully stored %u bytes of type %u under key `%s'\n",
size, ntohl (dm->type), GNUNET_h2s (&dm->key));
-#endif
}
transmit_status (client, ret, msg);
GNUNET_free_non_null (msg);
(0 ==
memcmp (&dm[1], data, size))))
{
-#if DEBUG_MYSQL
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Result already present in datastore\n");
-#endif
/* FIXME: change API to allow increasing 'replication' counter */
if ((ntohl (dm->priority) > 0) ||
(GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value >
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' request for `%s' of type %u\n", "PUT",
GNUNET_h2s (&dm->key), ntohl (dm->type));
-#endif
rid = ntohl (dm->rid);
size = ntohl (dm->size);
if (rid > 0)
return;
}
msg = (const struct GetMessage *) message;
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' request for `%s' of type %u\n", "GET",
GNUNET_h2s (&msg->key), ntohl (msg->type));
-#endif
GNUNET_STATISTICS_update (stats, gettext_noop ("# GET requests received"), 1,
GNUNET_NO);
GNUNET_SERVER_client_keep (client);
(GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key)))
{
/* don't bother database... */
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Empty result set for `%s' request for `%s' (bloomfilter).\n",
"GET", GNUNET_h2s (&msg->key));
-#endif
GNUNET_STATISTICS_update (stats,
gettext_noop
("# requests filtered by bloomfilter"), 1,
1, GNUNET_NO);
msg = (const struct UpdateMessage *) message;
emsg = NULL;
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request for %llu\n",
"UPDATE", (unsigned long long) GNUNET_ntohll (msg->uid));
-#endif
ret =
plugin->api->update (plugin->api->cls, GNUNET_ntohll (msg->uid),
(int32_t) ntohl (msg->priority),
handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n",
"GET_REPLICATION");
-#endif
GNUNET_STATISTICS_update (stats,
gettext_noop
("# GET REPLICATION requests received"), 1,
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n",
"GET_ZERO_ANONYMITY");
-#endif
GNUNET_STATISTICS_update (stats,
gettext_noop
("# GET ZERO ANONYMITY requests received"), 1,
if (key == NULL)
{
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No further matches for `%s' request.\n", "REMOVE");
-#endif
transmit_status (client, GNUNET_NO, _("Content not found"));
GNUNET_SERVER_client_drop (client);
return GNUNET_OK; /* last item */
}
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Item %llu matches `%s' request for key `%s' and type %u.\n",
(unsigned long long) uid, "REMOVE", GNUNET_h2s (key), type);
-#endif
GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes removed (explicit request)"),
size, GNUNET_YES);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' request for `%s' of type %u\n", "REMOVE",
GNUNET_h2s (&dm->key), ntohl (dm->type));
-#endif
GNUNET_STATISTICS_update (stats, gettext_noop ("# REMOVE requests received"),
1, GNUNET_NO);
GNUNET_SERVER_client_keep (client);
handle_drop (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "DROP");
-#endif
do_drop = GNUNET_YES;
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
GNUNET_assert (stats_worked == GNUNET_NO);
stats_worked = GNUNET_YES;
payload += value;
-#if DEBUG_SQLITE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notification from statistics about existing payload (%llu), new payload is %llu\n",
- abs_value, payload);
-#endif
+ value, payload);
return GNUNET_OK;
}
static void
unload_plugin (struct DatastorePlugin *plug)
{
-#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Datastore service is unloading plugin...\n");
-#endif
GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
GNUNET_free (plug->lib_name);
GNUNET_free (plug->short_name);
GNUNET_BLOCK_evaluate (GDS_block_context, type, key, ctx->reply_bf,
ctx->reply_bf_mutator, ctx->xquery,
ctx->xquery_size, rdata, rdata_size);
-#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found reply for query %s in datacache, evaluation result is %d\n",
GNUNET_h2s (key), (int) eval);
-#endif
ctx->eval = eval;
switch (eval)
{
* @brief IPC messages between DNS API and DNS service
* @author Christian Grothoff
*/
-#ifndef DNS_NEW_H
-#define DNS_NEW_H
+#ifndef DNS_H
+#define DNS_H
GNUNET_NETWORK_STRUCT_BEGIN
return;
}
GNUNET_free_non_null (rr->payload);
-#if DEBUG_DNS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Changing DNS reply according to client specifications\n"));
-#endif
+ "Changing DNS reply according to client specifications\n");
rr->payload = GNUNET_malloc (msize);
rr->payload_length = msize;
memcpy (rr->payload, &resp[1], msize);
*/
/**
- * @file applications/fs/fsui/basic_fsui_test.c
- * @brief testcase for fsui (upload-search-download-unindex)
+ * @file fs/test_fs.c
+ * @brief testcase for FS (upload-search-download-unindex)
* @author Christian Grothoff
*/
return (ok == GNUNET_YES) ? 0 : 1;
}
-/* end of basic_fsui_test.c */
+/* end of test_fs.c */
struct GNUNET_NAT_Handle *h;
struct sockaddr_in sa;
-#if DEBUG_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking for connection reversal with %x and code %u\n",
(unsigned int) dst_ipv4, (unsigned int) dport);
-#endif
h = GNUNET_NAT_register (cfg, is_tcp, dport, 0, NULL, NULL, NULL, NULL, NULL);
memset (&sa, 0, sizeof (sa));
sa.sin_family = AF_INET;
if (-1 ==
GNUNET_NETWORK_socket_send (ctx->s, &ctx->data, sizeof (ctx->data)))
{
-#if DEBUG_NAT
GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send");
-#endif
}
GNUNET_NETWORK_socket_shutdown (ctx->s, SHUT_RDWR);
}
#endif
sa.sin_addr.s_addr = dst_ipv4;
sa.sin_port = htons (dport);
-#if DEBUG_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TCP message to `%s'\n",
GNUNET_a2s ((struct sockaddr *) &sa, sizeof (sa)));
-#endif
if ((GNUNET_OK !=
GNUNET_NETWORK_socket_connect (s, (const struct sockaddr *) &sa,
sizeof (sa))) && (errno != EINPROGRESS))
#endif
sa.sin_addr.s_addr = dst_ipv4;
sa.sin_port = htons (dport);
-#if DEBUG_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending UDP packet to `%s'\n",
GNUNET_a2s ((struct sockaddr *) &sa, sizeof (sa)));
-#endif
if (-1 ==
GNUNET_NETWORK_socket_sendto (s, &data, sizeof (data),
(const struct sockaddr *) &sa, sizeof (sa)))
const struct GNUNET_NAT_TestMessage *tm;
uint16_t dport;
-#if DEBUG_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received test request\n");
-#endif
tm = (const struct GNUNET_NAT_TestMessage *) msg;
dport = ntohs (tm->dport);
if (0 == dport)
lal->addrlen = arg_size;
lal->source = src;
GNUNET_CONTAINER_DLL_insert (h->lal_head, h->lal_tail, lal);
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address `%s' from source %d\n",
GNUNET_a2s (arg, arg_size), src);
-#endif
if (NULL != h->address_callback)
h->address_callback (h->callback_cls, GNUNET_YES, arg, arg_size);
}
GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf));
if (bytes < 1)
{
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Finished reading from server stdout with code: %d\n", bytes);
-#endif
if (0 != GNUNET_OS_process_kill (h->server_proc, SIGTERM))
GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "nat", "kill");
GNUNET_OS_process_wait (h->server_proc);
return;
}
sin_addr.sin_port = htons ((uint16_t) port);
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "gnunet-helper-nat-server read: %s:%d\n", mybuf,
port);
-#endif
h->reversal_callback (h->callback_cls, (const struct sockaddr *) &sin_addr,
sizeof (sin_addr));
h->server_read_task =
(h->server_stdout =
GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES))))
{
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting `%s' at `%s'\n",
"gnunet-helper-nat-server", h->internal_address);
-#endif
/* Start the server process */
h->server_proc =
GNUNET_OS_start_process (GNUNET_NO, NULL, h->server_stdout,
struct in_addr in_addr;
unsigned int i;
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Registered with NAT service at port %u with %u IP bound local addresses\n",
(unsigned int) adv_port, num_addrs);
-#endif
h = GNUNET_malloc (sizeof (struct GNUNET_NAT_Handle));
h->server_retry_delay = GNUNET_TIME_UNIT_SECONDS;
h->cfg = cfg;
return GNUNET_SYSERR;
}
GNUNET_snprintf (port_as_string, sizeof (port_as_string), "%d", h->adv_port);
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
_("Running gnunet-helper-nat-client %s %s %u\n"), h->internal_address,
inet4, (unsigned int) h->adv_port);
-#endif
proc =
GNUNET_OS_start_process (GNUNET_NO,
NULL, NULL, "gnunet-helper-nat-client",
#define NAT_H
#include "gnunet_util_lib.h"
-#define DEBUG_NAT GNUNET_EXTRA_LOGGING
GNUNET_NETWORK_STRUCT_BEGIN
if (NULL == line)
{
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "UPnP unmap done\n");
-#endif
GNUNET_OS_command_stop (mini->unmap_cmd);
mini->unmap_cmd = NULL;
GNUNET_free (mini);
* often are the same, but it might... */
GNUNET_snprintf (pstr, sizeof (pstr), "%u",
(unsigned int) ntohs (mini->current_addr.sin_port));
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Unmapping port %u with UPnP\n",
ntohs (mini->current_addr.sin_port));
-#endif
mini->unmap_cmd =
GNUNET_OS_command_run (&process_unmap_output, mini, UNMAP_TIMEOUT,
"upnpc", "upnpc", "-d", pstr,
sa = (const struct sockaddr_in *) addr;
if (h->data != sa->sin_port)
{
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received connection reversal request for wrong port\n");
-#endif
return; /* wrong port */
}
/* report success */
{
if (data == tst->data)
tst->report (tst->report_cls, GNUNET_OK);
-#if DEBUG_NAT
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received data mismatches expected value\n");
-#endif
}
-#if DEBUG_NAT
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Failed to receive data from inbound connection\n");
-#endif
}
{
if (data == tst->data)
tst->report (tst->report_cls, GNUNET_OK);
-#if DEBUG_NAT
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received data mismatches expected value\n");
-#endif
}
-#if DEBUG_NAT
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Failed to receive data from inbound connection\n");
-#endif
GNUNET_NETWORK_socket_close (na->sock);
GNUNET_free (na);
}
GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept");
return; /* odd error */
}
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got an inbound connection, waiting for data\n");
-#endif
wl = GNUNET_malloc (sizeof (struct NatActivity));
wl->sock = s;
wl->h = tst;
return;
if (addrlen != sizeof (struct sockaddr_in))
return; /* ignore IPv6 here */
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Asking gnunet-nat-server to connect to `%s'\n",
GNUNET_a2s (addr, addrlen));
-#endif
sa = (const struct sockaddr_in *) addr;
msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAT_TEST);
{
struct GNUNET_NSE_ClientMessage em;
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n");
-#endif
GNUNET_SERVER_notification_context_add (nc, client);
setup_estimate_message (&em);
GNUNET_SERVER_notification_context_unicast (nc, client, &em.header,
d = get_matching_bits_delay (matching_bits);
i = (uint32_t) (d / (double) (hop_count_max + 1));
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Randomizing flood using latencies up to %u ms\n",
(unsigned int) i);
-#endif
ret.rel_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, i + 1);
return ret;
#else
#else
ret = GNUNET_TIME_UNIT_ZERO;
#endif
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting previous round behind schedule in %llu ms\n",
(unsigned long long) ret.rel_value);
-#endif
return ret;
case 0:
/* current round is based on best-known matching_bits */
dist_delay = get_matching_bits_delay (matching_bits);
dist_delay += get_delay_randomization (matching_bits).rel_value;
ret.rel_value = (uint64_t) dist_delay;
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"For round %llu, delay for %u matching bits is %llu ms\n",
(unsigned long long) current_timestamp.abs_value,
(unsigned int) matching_bits,
(unsigned long long) ret.rel_value);
-#endif
/* now consider round start time and add delay to it */
tgt = GNUNET_TIME_absolute_add (current_timestamp, ret);
return GNUNET_TIME_absolute_get_remaining (tgt);
1, GNUNET_NO);
return 0;
}
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"In round %llu, sending to `%s' estimate with %u bits\n",
(unsigned long long)
timestamp).abs_value,
GNUNET_i2s (&peer_entry->id),
(unsigned int) ntohl (size_estimate_messages[idx].matching_bits));
-#endif
if (ntohl (size_estimate_messages[idx].hop_count) == 0)
GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO);
GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1,
if (nse_work_required <= count_leading_zeroes (&result))
{
my_proof = counter;
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work found: %llu!\n",
(unsigned long long) GNUNET_ntohll (counter));
-#endif
write_proof ();
setup_flood_message (estimate_index, current_timestamp);
return;
}
if (my_proof / (100 * ROUND_SIZE) < counter / (100 * ROUND_SIZE))
{
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing proofs currently at %llu\n",
(unsigned long long) counter);
-#endif
/* remember progress every 100 rounds */
my_proof = counter;
write_proof ();
{
struct NSEPeerEntry *peer_entry;
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected to us\n",
GNUNET_i2s (peer));
-#endif
peer_entry = GNUNET_malloc (sizeof (struct NSEPeerEntry));
peer_entry->id = *peer;
GNUNET_assert (GNUNET_OK ==
{
struct NSEPeerEntry *pos;
-#if DEBUG_NSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' disconnected from us\n",
GNUNET_i2s (peer));
-#endif
pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
if (NULL == pos)
{
h->client = NULL;
}
-#if DEBUG_NSE
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling task to reconnect to nse service in %llu ms.\n",
h->reconnect_delay.rel_value);
-#endif
h->reconnect_task =
GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
if (h->reconnect_delay.rel_value == 0)
if (buf == NULL)
{
/* Connect error... */
-#if DEBUG_NSE
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Shutdown while trying to transmit `%s' request.\n", "START");
-#endif
reschedule_connect (h);
return 0;
}
-#if DEBUG_NSE
LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "START");
-#endif
GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
msg = (struct GNUNET_MessageHeader *) buf;
/* shutdown, just give up */
return;
}
-#if DEBUG_NSE
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to network size estimation service.\n");
-#endif
GNUNET_assert (h->client == NULL);
h->client = GNUNET_CLIENT_connect ("nse", h->cfg);
GNUNET_assert (h->client != NULL);
#include "gnunet_scheduler_lib.h"
#include "gnunet_nse_service.h"
-#define DEBUG_NSE GNUNET_YES
-
#define START_ARM GNUNET_YES
static struct GNUNET_NSE_Handle *h;
char *const argv[] = { "test-nse-api",
"-c",
"test_nse.conf",
-#if DEBUG_NSE
- "-L", "DEBUG",
-#else
"-L", "WARNING",
-#endif
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
int ret;
GNUNET_log_setup ("test_nse_api",
-#if DEBUG_NSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
ret = check ();
-
return ret;
}
check_it (void *cls, const struct GNUNET_HELLO_Address *address,
struct GNUNET_TIME_Absolute expiration)
{
-#if DEBUG
if (addrlen > 0)
{
- FPRINTF (stderr, "name: %s, addr: %s\n", tname, (const char *) addr);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "name: %s, addr: %s\n", tname, (const char *) addr);
}
-#endif
return GNUNET_OK;
}
process (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Message *hello, const char *err_msg)
{
- if (peer == NULL)
+ if (NULL != peer)
{
-#if DEBUG
- FPRINTF (stderr, "Process received NULL response\n");
-#endif
- }
- else
- {
-#if DEBUG
- FPRINTF (stderr, "Processed a peer\n");
-#endif
numpeers++;
if (0 && (hello != NULL))
GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &check_it, NULL);
char *const argv[] = { "perf-peerinfo-api",
"-c",
"test_peerinfo_api_data.conf",
-#if DEBUG_PEERINFO
- "-L", "DEBUG",
-#else
"-L", "ERROR",
-#endif
NULL
};
#if START_SERVICE
proc =
GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-peerinfo",
"gnunet-service-peerinfo",
-#if DEBUG_PEERINFO
- "-L", "DEBUG",
-#else
"-L", "ERROR",
-#endif
"-c", "test_peerinfo_api_data.conf", NULL);
#endif
GNUNET_assert (NULL != proc);
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_close (proc);
proc = NULL;
-
#endif
return ok;
}
int ret = 0;
GNUNET_log_setup ("perf_peerinfo_api",
-#if DEBUG_PEERINFO
- "DEBUG",
-#else
"ERROR",
-#endif
NULL);
ret = check ();
GNUNET_DISK_directory_remove ("/tmp/test-gnunet-peerinfo");
char *const argv[] = { "test-peerinfo-api",
"-c",
"test_peerinfo_api_data.conf",
-#if DEBUG_PEERINFO
- "-L", "DEBUG",
-#endif
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
proc =
GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-peerinfo",
"gnunet-service-peerinfo",
-#if DEBUG_PEERINFO
- "-L", "DEBUG",
-#endif
"-c", "test_peerinfo_api_data.conf", NULL);
GNUNET_assert (NULL != proc);
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
int ret = 0;
GNUNET_log_setup ("test_peerinfo_api",
-#if DEBUG_PEERINFO
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
ret = check ();
GNUNET_DISK_directory_remove ("/tmp/test-gnunet-peerinfo");
#include "gnunet_scheduler_lib.h"
#include "gnunet_statistics_service.h"
-#define DEBUG_STATISTICS GNUNET_EXTRA_LOGGING
#define START_SERVICE GNUNET_YES
char *const argv[] = { "test-statistics-api",
"-c",
"test_statistics_api_data.conf",
-#if DEBUG_STATISTICS
- "-L", "DEBUG",
-#else
"-L", "WARNING",
-#endif
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
proc =
GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics",
"gnunet-service-statistics",
-#if DEBUG_STATISTICS
- "-L", "DEBUG",
-#endif
"-c", "test_statistics_api_data.conf", NULL);
#endif
GNUNET_assert (NULL != proc);
proc =
GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics",
"gnunet-service-statistics",
-#if DEBUG_STATISTICS
- "-L", "DEBUG",
-#endif
"-c", "test_statistics_api_data.conf", NULL);
#endif
GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options,
int ret;
GNUNET_log_setup ("test_statistics_api",
-#if DEBUG_STATISTICS
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
ret = check ();
if (NULL == message)
goto end;
type = ntohs (message->type);
-#if DEBUG_TRANSPORT
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received Message with type %u\n", type);
-#endif
-
switch (type)
{
case GNUNET_MESSAGE_TYPE_HELLO:
GST_validation_handle_hello (message);
return ret;
case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"Processing `%s' from `%s'\n", "PING",
(sender_address !=
NULL) ? GST_plugins_a2s (&address) : "<inbound>");
-#endif
GST_validation_handle_ping (peer, message, &address, session);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"Processing `%s' from `%s'\n", "PONG",
(sender_address !=
NULL) ? GST_plugins_a2s (&address) : "<inbound>");
-#endif
GST_validation_handle_pong (peer, message);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
* this connections seem to go extra-slow */
GNUNET_ATS_address_update (GST_ats, &address, session, ats, ats_count);
#endif
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Allowing receive from peer %s to continue in %llu ms\n",
GNUNET_i2s (peer), (unsigned long long) ret.rel_value);
-#endif
return ret;
}
struct GNUNET_HELLO_Address address;
GNUNET_assert (strlen (transport_name) > 0);
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n",
session, GNUNET_i2s (peer));
-#endif
if (NULL != session)
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"transport-ats",
/* ATS tells me to disconnect from peer */
if ((bw_in == 0) && (bw_out == 0))
{
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ATS tells me to disconnect from peer `%s'\n",
GNUNET_i2s (&address->peer));
-#endif
GST_neighbours_force_disconnect (&address->peer);
return;
}
GNUNET_free (our_hello);
our_hello = GNUNET_HELLO_create (&GST_my_public_key, &address_generator, &gc);
GNUNET_assert (NULL != our_hello);
-
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"Refreshed my `%s', new size is %d\n", "HELLO",
GNUNET_HELLO_size (our_hello));
-#endif
-
GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# refreshed my HELLO"), 1,
GNUNET_NO);
if (NULL != hello_cb)
{
struct OwnAddressList *al;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- (add_remove ==
- GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" :
- "Removing `%s':%s from the set of our addresses\n",
- GST_plugins_a2s (address), p->short_name);
-#endif
+ (addremove ==
+ GNUNET_YES) ? "Adding `%s' to the set of our addresses\n" :
+ "Removing `%s' from the set of our addresses\n",
+ GST_plugins_a2s (address));
GNUNET_assert (address != NULL);
if (GNUNET_NO == addremove)
{
n->state_reset = GNUNET_SCHEDULER_NO_TASK;
if (n->state == S_CONNECTED)
return;
-
-#if DEBUG_TRANSPORT
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
("# failed connection attempts due to timeout"), 1,
GNUNET_NO);
-#endif
-
/* resetting state */
if (n->state == S_FAST_RECONNECT)
n->transmission_task = GNUNET_SCHEDULER_add_now (&transmission_task, n);
}
}
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message of type %u was %s\n",
ntohs (((struct GNUNET_MessageHeader *) mq->message_buf)->type),
(success == GNUNET_OK) ? "successful" : "FAILED");
-#endif
if (NULL != mq->cont)
mq->cont (mq->cont_cls, success);
GNUNET_free (mq);
if (n->address == NULL)
{
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n",
GNUNET_i2s (&n->id));
-#endif
GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);
GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK);
send_disconnect_cont (void *cls, const struct GNUNET_PeerIdentity *target,
int result)
{
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending DISCONNECT message to peer `%4s': %i\n",
GNUNET_i2s (target), result);
-#endif
}
size_t ret;
struct SessionDisconnectMessage disconnect_msg;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending DISCONNECT message to peer `%4s'\n",
GNUNET_i2s (&n->id));
-#endif
-
disconnect_msg.header.size = htons (sizeof (struct SessionDisconnectMessage));
disconnect_msg.header.type =
htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
{
struct NeighbourMapEntry *n = value;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
-#endif
if (S_CONNECTED == n->state)
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
{
struct QuotaSetMessage q_msg;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending outbound quota of %u Bps for peer `%s' to all clients\n",
ntohl (quota.value__), GNUNET_i2s (target));
-#endif
q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
q_msg.quota = quota;
if ((GNUNET_NO == success) &&
((n->state == S_NOT_CONNECTED) || (n->state == S_CONNECT_SENT)))
{
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %p, asking ATS for new address \n",
GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
-#endif
change_state (n, S_NOT_CONNECTED);
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->ats_suggest);
}
break;
case S_FAST_RECONNECT:
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successful fast reconnect to peer `%s'\n",
GNUNET_i2s (&n->id));
-#endif
change_state (n, S_CONNECTED);
neighbours_connected++;
GNUNET_STATISTICS_set (GST_stats, gettext_noop ("# peers connected"), neighbours_connected,
}
/* sending failed, ask for next address */
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to send CONNECT_MSG to peer `%4s' with address '%s' session %X, asking ATS for new address \n",
GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session);
-#endif
if (n->state != S_NOT_CONNECTED)
change_state (n, S_NOT_CONNECTED);
GNUNET_assert (strlen (cc->address->transport_name) > 0);
{
struct NeighbourMapEntry *n;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Unknown peer `%s', creating new neighbour\n", GNUNET_i2s (peer));
-#endif
n = GNUNET_malloc (sizeof (struct NeighbourMapEntry));
n->id = *peer;
n->state = S_NOT_CONNECTED;
{
return;
}
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to peer `%s'\n",
GNUNET_i2s (target));
-#endif
if (0 ==
memcmp (target, &GST_my_identity, sizeof (struct GNUNET_PeerIdentity)))
{
if (n == NULL)
n = setup_neighbour (target);
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking ATS for suggested address to connect to peer `%s'\n",
GNUNET_i2s (&n->id));
-#endif
-
GNUNET_ATS_suggest_address (GST_ats, &n->id);
}
/* This can happen during shutdown */
return;
}
-
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n",
session, GNUNET_i2s (peer));
-#endif
-
n = lookup_neighbour (peer);
if (NULL == n)
return;
gettext_noop
("# messages not sent (no such peer or not connected)"),
1, GNUNET_NO);
-#if DEBUG_TRANSPORT
if (n == NULL)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Could not send message to peer `%s': unknown neighbour",
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Could not send message to peer `%s': not connected\n",
GNUNET_i2s (target));
-#endif
if (NULL != cont)
cont (cont_cls, GNUNET_SYSERR);
return;
gettext_noop
("# messages not sent (no such peer or not connected)"),
1, GNUNET_NO);
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Could not send message to peer `%s': no address available\n",
GNUNET_i2s (target));
-#endif
-
if (NULL != cont)
cont (cont_cls, GNUNET_SYSERR);
return;
if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, size))
{
n->quota_violation_count++;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Bandwidth quota (%u b/s) violation detected (total of %u).\n",
n->in_tracker.available_bytes_per_s__,
n->quota_violation_count);
-#endif
/* Discount 32k per violation */
GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, -32 * 1024);
}
ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 32 * 1024);
if (ret.rel_value > 0)
{
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n",
(unsigned long long) n->in_tracker.
consumption_since_last_update__,
(unsigned int) n->in_tracker.available_bytes_per_s__,
(unsigned long long) ret.rel_value);
-#endif
GNUNET_STATISTICS_update (GST_stats,
gettext_noop ("# ms throttling suggested"),
(int64_t) ret.rel_value, GNUNET_NO);
n->latency =
GNUNET_TIME_absolute_get_difference (n->keep_alive_sent,
GNUNET_TIME_absolute_get ());
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Latency for peer `%s' is %llu ms\n",
GNUNET_i2s (&n->id), n->latency.rel_value);
-#endif
-
if (n->latency.rel_value == GNUNET_TIME_relative_get_forever ().rel_value)
{
1, GNUNET_NO);
return;
}
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Setting inbound quota of %u Bps for peer `%s' to all clients\n",
ntohl (quota.value__), GNUNET_i2s (&n->id));
-#endif
GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, quota);
if (0 != ntohl (quota.value__))
return;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s' due to `%s'\n",
GNUNET_i2s (&n->id), "SET_QUOTA");
-#endif
if (is_connected (n))
GNUNET_STATISTICS_update (GST_stats,
gettext_noop ("# disconnects due to quota of 0"),
const struct SessionDisconnectMessage *sdm;
GNUNET_HashCode hc;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received DISCONNECT message from peer `%s'\n",
GNUNET_i2s (peer));
-#endif
-
if (ntohs (msg->size) != sizeof (struct SessionDisconnectMessage))
{
// GNUNET_break_op (0);
neighbours_connected++;
GNUNET_STATISTICS_set (GST_stats, gettext_noop ("# peers connected"), neighbours_connected,
GNUNET_NO);
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session,
__LINE__);
-#endif
connect_notify_cb (callback_cls, &n->id, ats, ats_count);
send_outbound_quota (peer, n->bandwidth_out);
{
struct NeighbourMapEntry *n;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ACK message from peer `%s'\n",
GNUNET_i2s (peer));
-#endif
-
if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), n->session,
__LINE__);
-#endif
connect_notify_cb (callback_cls, &n->id, ats, ats_count);
send_outbound_quota (peer, n->bandwidth_out);
}
struct NeighbourMapEntry *n;
struct BlackListCheckContext *bcc = cls;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Blacklist check due to CONNECT message: `%s'\n",
GNUNET_i2s (peer),
(result == GNUNET_OK) ? "ALLOWED" : "FORBIDDEN");
-#endif
-
/* not allowed */
if (GNUNET_OK != result)
{
struct BlackListCheckContext *bcc = NULL;
struct NeighbourMapEntry *n;
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received CONNECT message from peer `%s'\n", GNUNET_i2s (peer));
-#endif
-
if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
{
GNUNET_break_op (0);
PONG_SIGNATURE_LIFETIME.rel_value / 4)
{
/* create / update cached sig */
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating PONG signature to indicate ownership.\n");
-#endif
*sig_cache_exp = GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME);
pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp);
GNUNET_assert (GNUNET_OK ==
GNUNET_NO);
return;
}
-#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Address validated for peer `%s' with plugin `%s': `%s'\n",
- GNUNET_i2s (sender), tname, GST_plugins_a2s (tname, addr,
- addrlen));
-#endif
-
+ GNUNET_i2s (sender), tname, GST_plugins_a2s (&address));
/* validity achieved, remember it! */
ve->expecting_pong = GNUNET_NO;
ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION);
if (session->inbound == GNUNET_NO)
{
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Using outbound client session %p to send to `%s'\n", session,
GNUNET_i2s (&session->target));
-#endif
-
client_send (session, msg);
res = msgbuf_size;
}
if (session->inbound == GNUNET_YES)
{
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Using inbound server %p session to send to `%s'\n", session,
GNUNET_i2s (&session->target));
-#endif
-
server_send (session, msg);
res = msgbuf_size;
}
/* Report addresses to transport service */
start_report_addresses (plugin);
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Plugin `%s' loaded\n", plugin->name);
-#endif
-
return api;
}
s = plugin->head;
while (s != NULL)
{
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Disconnecting `%s' \n", GNUNET_i2s (&s->target));
-#endif
if (s->inbound == GNUNET_NO)
GNUNET_assert (GNUNET_OK == client_disconnect (s));
else
s = s->next;
}
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Stopping server\n");
-#endif
/* Stop server */
server_stop (plugin);
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Stopping client\n");
-#endif
/* Stop client */
client_stop (plugin);
s = t;
}
-
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Plugin `%s' unloaded\n", plugin->name);
-#endif
-
GNUNET_free_non_null (plugin->server_addr_v4);
GNUNET_free_non_null (plugin->server_addr_v6);
GNUNET_free (plugin);
GNUNET_free (api);
-
return NULL;
}
}
GNUNET_free (key_file);
GNUNET_free (cert_file);
-#if DEBUG_HTTP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TLS certificate loaded\n");
-#endif
-
return res;
}
#endif
return GNUNET_SYSERR;
}
server_reschedule (plugin, plugin->server_v6, GNUNET_NO);
-
-
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"%s server component started on port %u\n", plugin->name,
plugin->port);
-#endif
return res;
}
GNUNET_free_non_null (plugin->key);
#endif
-#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"%s server component stopped\n", plugin->name);
-#endif
}
if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON !=
ntohs (msg->header.type))
return;
-#if DEBUG_UDP_BROADCASTING
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received beacon with %u bytes from peer `%s' via address `%s'\n",
ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
udp_address_to_string (NULL, &mc->addr, sizeof (mc->addr)));
-#endif
struct GNUNET_ATS_Information atsi[2];
/* setup ATS */
if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON !=
ntohs (msg->header.type))
return;
-#if DEBUG_UDP_BROADCASTING
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received beacon with %u bytes from peer `%s' via address `%s'\n",
ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
udp_address_to_string (NULL, &mc->addr, sizeof (mc->addr)));
-#endif
struct GNUNET_ATS_Information atsi[2];
if (addrlen == sizeof (struct sockaddr_in))
{
-#if DEBUG_UDP_BROADCASTING
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received IPv4 HELLO beacon broadcast with %i bytes from address %s\n",
size, GNUNET_a2s ((const struct sockaddr *) addr, addrlen));
-#endif
struct Mstv4Context *mc;
mc = GNUNET_malloc (sizeof (struct Mstv4Context));
}
else if (addrlen == sizeof (struct sockaddr_in6))
{
-#if DEBUG_UDP_BROADCASTING
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received IPv6 HELLO beacon broadcast with %i bytes from address %s\n",
size, GNUNET_a2s ((const struct sockaddr *) &addr, addrlen));
-#endif
struct Mstv6Context *mc;
mc = GNUNET_malloc (sizeof (struct Mstv6Context));
if (addr != NULL)
{
-#if DEBUG_UDP_BROADCASTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "address %s for interface %s %p\n ",
GNUNET_a2s (addr, addrlen), name, addr);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_a2s (broadcast_addr, addrlen), name, broadcast_addr);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ",
GNUNET_a2s (netmask, addrlen), name, netmask);
-#endif
/* Collecting broadcast addresses */
if (broadcast_addr != NULL)
}
else
{
-#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting running\n");
-#endif
plugin->send_ipv6_broadcast_task =
GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin);
plugin->broadcast_ipv6 = GNUNET_YES;
}
else
{
-#if DEBUG_UDP
LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 Broadcasting stopped\n");
-#endif
}
if (plugin->send_ipv6_broadcast_task != GNUNET_SCHEDULER_NO_TASK)
#define DEBUG_TRANSPORT GNUNET_EXTRA_LOGGING
-#define DEBUG_TRANSPORT_TIMEOUT GNUNET_EXTRA_LOGGING
-
-#define DEBUG_TRANSPORT_DISCONNECT GNUNET_EXTRA_LOGGING
-
-#define DEBUG_TRANSPORT_API GNUNET_EXTRA_LOGGING
/**
* For how long do we allow unused bandwidth
{
struct Neighbour *n;
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating entry for neighbour `%4s'.\n",
GNUNET_i2s (pid));
-#endif
n = GNUNET_malloc (sizeof (struct Neighbour));
n->id = *pid;
n->h = h;
GNUNET_assert (h->client != NULL);
if (msg == NULL)
{
-#if DEBUG_TRANSPORT_API
- LOG (GNUNET_ERROR_TYPE_INFO,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Error receiving from transport service, disconnecting temporarily.\n");
-#endif
disconnect_and_schedule_reconnect (h);
return;
}
GNUNET_break (0);
break;
}
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Receiving (my own) `%s' message, I am `%4s'.\n", "HELLO",
GNUNET_i2s (&me));
-#endif
GNUNET_free_non_null (h->my_hello);
h->my_hello = NULL;
if (size < sizeof (struct GNUNET_MessageHeader))
break;
}
ats = (const struct GNUNET_ATS_Information *) &cim[1];
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n",
"CONNECT", GNUNET_i2s (&cim->id));
-#endif
n = neighbour_find (h, &cim->id);
if (n != NULL)
{
}
dim = (const struct DisconnectInfoMessage *) msg;
GNUNET_break (ntohl (dim->reserved) == 0);
-#if DEBUG_TRANSPORT_API_DISCONNECT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n",
"DISCONNECT", GNUNET_i2s (&dim->peer));
-#endif
n = neighbour_find (h, &dim->peer);
if (n == NULL)
{
break;
}
okm = (const struct SendOkMessage *) msg;
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message, transmission %s.\n",
"SEND_OK", ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed");
-#endif
n = neighbour_find (h, &okm->peer);
if (n == NULL)
break;
}
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_RECV:
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message.\n", "RECV");
-#endif
if (size <
sizeof (struct InboundMessage) + sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break (0);
break;
}
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u from `%4s'.\n",
ntohs (imm->type), GNUNET_i2s (&im->peer));
-#endif
n = neighbour_find (h, &im->peer);
if (n == NULL)
{
h->rec (h->cls, &im->peer, imm, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA:
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message.\n", "SET_QUOTA");
-#endif
if (size != sizeof (struct QuotaSetMessage))
{
GNUNET_break (0);
{
GNUNET_CONTAINER_DLL_remove (h->control_head, h->control_tail, th);
nret = th->notify (th->notify_cls, size, &cbuf[ret]);
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Added %u bytes of control message at %u\n",
nret, ret);
-#endif
GNUNET_free (th);
ret += nret;
size -= nret;
}
/* if there are more pending messages, try to schedule those */
schedule_transmission (h);
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes to transport service\n",
ret);
-#endif
return ret;
}
n->th = NULL;
GNUNET_assert (n == GNUNET_CONTAINER_heap_remove_root (h->ready_heap));
n->hn = NULL;
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Signalling timeout for transmission to peer %s due to congestion\n",
GNUNET_i2s (&n->id));
-#endif
GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
GNUNET_free (th);
}
return; /* no pending messages */
size = n->th->notify_size + sizeof (struct OutboundMessage);
}
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Calling notify_transmit_ready\n");
-#endif
h->cth =
GNUNET_CLIENT_notify_transmit_ready (h->client, size,
GNUNET_TIME_UNIT_FOREVER_REL,
n->th->notify_size);
else
return; /* no work to be done */
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling next transmission to service in %llu ms\n",
(unsigned long long) delay.rel_value);
-#endif
h->quota_task =
GNUNET_SCHEDULER_add_delayed (delay, &schedule_transmission_task, h);
}
{
struct GNUNET_TRANSPORT_TransmitHandle *th;
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Control transmit of %u bytes requested\n",
size);
-#endif
th = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TransmitHandle));
th->notify = notify;
th->notify_cls = notify_cls;
if (buf == NULL)
{
/* Can only be shutdown, just give up */
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Shutdown while trying to transmit `%s' request.\n", "START");
-#endif
return 0;
}
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "START");
-#endif
GNUNET_assert (size >= sizeof (struct StartMessage));
s.header.size = htons (sizeof (struct StartMessage));
s.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_START);
/* shutdown, just give up */
return;
}
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n");
-#endif
GNUNET_assert (h->client == NULL);
GNUNET_assert (h->control_head == NULL);
GNUNET_assert (h->control_tail == NULL);
th->notify (th->notify_cls, 0, NULL);
GNUNET_free (th);
}
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling task to reconnect to transport service in %llu ms.\n",
h->reconnect_delay.rel_value);
-#endif
h->reconnect_task =
GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
if (h->reconnect_delay.rel_value == 0)
GNUNET_free (pid);
return 0;
}
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting `%s' request with respect to `%4s'.\n", "REQUEST_CONNECT",
GNUNET_i2s (pid));
-#endif
GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage));
msg.header.size = htons (sizeof (struct TransportRequestConnectMessage));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT);
if (buf == NULL)
{
-#if DEBUG_TRANSPORT_TIMEOUT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Timeout while trying to transmit `%s' request.\n", "HELLO");
-#endif
GNUNET_free (msg);
return 0;
}
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "HELLO");
-#endif
ssize = ntohs (msg->size);
GNUNET_assert (size >= ssize);
memcpy (buf, msg, ssize);
}
msg = GNUNET_malloc (size);
memcpy (msg, hello, size);
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Offering `%s' message of `%4s' to transport for validation.\n", "HELLO",
GNUNET_i2s (&peer));
-#endif
schedule_control_transmit (handle, size, &send_hello, msg);
}
void
GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
{
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
-#endif
/* this disconnects all neighbours... */
if (handle->reconnect_task == GNUNET_SCHEDULER_NO_TASK)
disconnect_and_schedule_reconnect (handle);
delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, size);
if (delay.rel_value > timeout.rel_value)
delay.rel_value = 0; /* notify immediately (with failure) */
-#if DEBUG_TRANSPORT_API
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Bandwidth tracker allows next transmission to peer %s in %llu ms\n",
GNUNET_i2s (target), (unsigned long long) delay.rel_value);
-#endif
n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value);
schedule_transmission (handle);
return th;
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
-#define DEBUG 0
+#define EXTRA_CHECKS 0
/**
* Node in the heap.
};
-#if DEBUG
+#if EXTRA_CHECKS
/**
* Check if internal invariants hold for the given node.
*
insert_node (heap, heap->root, root->right_child);
}
GNUNET_free (root);
-#if DEBUG
+#if EXTRA_CHECKS
GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 1));
CHECK (heap->root);
if (heap->walk_pos == node)
heap->walk_pos = NULL;
GNUNET_free (node);
-#if DEBUG
+#if EXTRA_CHECKS
CHECK (heap->root);
GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 1));
struct GNUNET_CONTAINER_HeapNode *node,
GNUNET_CONTAINER_HeapCostType new_cost)
{
-#if DEBUG
+#if EXTRA_CHECKS
GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 1));
CHECK (heap->root);
#endif
remove_node (node);
-#if DEBUG
+#if EXTRA_CHECKS
CHECK (heap->root);
GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 2));
heap->root = node;
else
insert_node (heap, heap->root, node);
-#if DEBUG
+#if EXTRA_CHECKS
CHECK (heap->root);
GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
(heap->size == heap->root->tree_size + 1));
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
-#if DEBUG_RESOLVER
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolver asked to look up `%s'.\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resolver asked to look up `%s'.\n",
hostname);
-#endif
get_ip_from_hostname (client, hostname, af);
return;
}
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
-#if DEBUG_RESOLVER
{
char buf[INET6_ADDRSTRLEN];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Resolver asked to look up IP address `%s'.\n"),
+ "Resolver asked to look up IP address `%s'.\n",
inet_ntop (af, ip, buf, sizeof (buf)));
}
-#endif
get_ip_as_string (client, af, ip);
}
#include "gnunet_common.h"
-#define DEBUG_RESOLVER GNUNET_EXTRA_LOGGING
-
GNUNET_NETWORK_STRUCT_BEGIN
/**
GNUNET_assert (NULL == req_tail);
if (NULL != client)
{
-#if DEBUG_RESOLVER
LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from DNS service\n");
-#endif
GNUNET_CLIENT_disconnect (client);
client = NULL;
}
struct GNUNET_RESOLVER_RequestHandle *rh = cls;
uint16_t size;
-#if DEBUG_RESOLVER
LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving response from DNS service\n");
-#endif
if (msg == NULL)
{
char buf[INET6_ADDRSTRLEN];
reconnect ();
return;
}
-#if DEBUG_RESOLVER
- LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolver returns `%s' for IP `%s'.\n"),
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s' for IP `%s'.\n",
hostname, GNUNET_a2s ((const void *) &rh[1], rh->data_len));
-#endif
if (rh->was_transmitted != GNUNET_SYSERR)
rh->name_callback (rh->cls, hostname);
rh->received_response = GNUNET_YES;
msg->direction = htonl (rh->direction);
msg->af = htonl (rh->af);
memcpy (&msg[1], &rh[1], rh->data_len);
-#if DEBUG_RESOLVER
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting DNS resolution request to DNS service\n");
-#endif
if (GNUNET_OK !=
GNUNET_CLIENT_transmit_and_get_response (client, &msg->header,
GNUNET_TIME_absolute_get_remaining
return; /* no work pending */
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
-#if DEBUG_RESOLVER
LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to DNS service\n");
-#endif
client = GNUNET_CLIENT_connect ("resolver", resolver_cfg);
if (NULL == client)
{
break;
}
}
-#if DEBUG_RESOLVER
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Will try to connect to DNS service in %llu ms\n",
(unsigned long long) backoff.rel_value);
-#endif
GNUNET_assert (NULL != resolver_cfg);
r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL);
backoff = GNUNET_TIME_relative_multiply (backoff, 2);
char *result;
result = no_resolve (rh->af, &rh[1], rh->data_len);
-#if DEBUG_RESOLVER
- LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolver returns `%s'.\n"), result);
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s'.\n", result);
if (result != NULL)
{
rh->name_callback (rh->cls, result);
"gethostname");
return NULL;
}
-#if DEBUG_RESOLVER
- LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our FQDN `%s'\n"), hostname);
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolving our FQDN `%s'\n", hostname);
host = gethostbyname (hostname);
if (NULL == host)
{
"gethostname");
return NULL;
}
-#if DEBUG_RESOLVER
- LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our hostname `%s'\n"), hostname);
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolving our hostname `%s'\n", hostname);
return GNUNET_RESOLVER_ip_get (hostname, af, timeout, callback, cls);
}
#include "gnunet_configuration_lib.h"
#include "gnunet_disk_lib.h"
-#define DEBUG GNUNET_EXTRA_LOGGING
/* Test Configuration Diffs Options */
enum
ADD_NEW_ENTRY,
REMOVE_SECTION,
REMOVE_ENTRY,
- COMPARE
-#if DEBUG
- , PRINT
-#endif
+ COMPARE,
+ PRINT
};
static struct GNUNET_CONFIGURATION_Handle *cfg;