Author: grothoff Date: 2006-08-06 22:28:15 -0700 (Sun, 06 Aug 2006) New Revision: 3214
Modified: GNUnet/src/applications/tracekit/Makefile.am GNUnet/src/applications/tracekit/gnunet-tracekit.c GNUnet/src/applications/tracekit/tracekit.c GNUnet/src/applications/tracekit/tracekit.h GNUnet/todo Log: fixing tracekit Modified: GNUnet/src/applications/tracekit/Makefile.am =================================================================== --- GNUnet/src/applications/tracekit/Makefile.am 2006-08-07 04:47:47 UTC (rev 3213) +++ GNUnet/src/applications/tracekit/Makefile.am 2006-08-07 05:28:15 UTC (rev 3214) @@ -3,7 +3,12 @@ plugindir = $(libdir)/GNUnet LDADD = \ - $(top_builddir)/src/util/libgnunetutil.la + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \ + $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \ + $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \ + $(top_builddir)/src/util/cron/libgnunetutil_cron.la \ + $(top_builddir)/src/util/config_impl/libgnunetutil_config.la bin_PROGRAMS = \ gnunet-tracekit Modified: GNUnet/src/applications/tracekit/gnunet-tracekit.c =================================================================== --- GNUnet/src/applications/tracekit/gnunet-tracekit.c 2006-08-07 04:47:47 UTC (rev 3213) +++ GNUnet/src/applications/tracekit/gnunet-tracekit.c 2006-08-07 05:28:15 UTC (rev 3214) @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2001, 2002, 2004 Christian Grothoff (and other contributing authors) + (C) 2001, 2002, 2004, 2006 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -26,140 +26,66 @@ #include "platform.h" #include "gnunet_protocols.h" +#include "gnunet_util_network_client.h" +#include "gnunet_util_config_impl.h" +#include "gnunet_util_crypto.h" +#include "gnunet_util_error_loggers.h" #include "tracekit.h" -#define TRACEKIT_VERSION "0.0.4" +static struct SEMAPHORE * doneSem; -static Semaphore * doneSem; +static struct GE_Context * ectx; +static struct GC_Configuration * cfg; + /** - * Parse the options, set the timeout. - * @param argc the number of options - * @param argv the option list (including keywords) - * @return OK on error, SYSERR if we should exit + * All gnunet-tracekit command line options */ -static int parseOptions(int argc, - char ** argv) { - int option_index; - int c; +static struct CommandLineOption gnunettracekitOptions[] = { + COMMAND_LINE_OPTION_CFG_FILE, /* -c */ + { 'D', "depth", "DEPTH", + gettext_noop("probe network to the given DEPTH"), 1, + &gnunet_getopt_configure_set_option, "GNUNET-TRACEKIT:HOPS" }, + { 'F', "format", "FORMAT", + gettext_noop("specify output format; 0 for human readable output, 1 for dot, 2 for vcg"), 1, + &gnunet_getopt_configure_set_option, "GNUNET-TRACEKIT:FORMAT" }, + COMMAND_LINE_OPTION_HELP(gettext_noop("Start GNUnet transport benchmarking tool.")), /* -h */ + COMMAND_LINE_OPTION_HOSTNAME, /* -H */ + COMMAND_LINE_OPTION_LOGGING, /* -L */ + { 'P', "priority", "PRIO", + gettext_noop("use PRIO for the priority of the trace request"), 1, + &gnunet_getopt_configure_set_option, "GNUNET-TRACEKIT:PRIORITY" }, + COMMAND_LINE_OPTION_VERSION(PACKAGE_VERSION), /* -v */ + { 'W', "wait", "DELAY", + gettext_noop("wait DELAY seconds for replies"), 1, + &gnunet_getopt_configure_set_option, "GNUNET-TRACEKIT:WAIT" }, + COMMAND_LINE_OPTION_END, +}; - FREENONNULL(setConfigurationString("GNUNETD", - "LOGFILE", - NULL)); - while (1) { - static struct GNoption long_options[] = { - LONG_DEFAULT_OPTIONS, - { "depth", 1, 0, 'D' }, - { "format", 1, 0, 'F' }, - { "priority", 1, 0, 'P' }, - { "wait", 1, 0, 'W' }, - { 0,0,0,0 } - }; - option_index = 0; - c = GNgetopt_long(argc, - argv, - "vhdc:L:H:W:D:F:P:", - long_options, - &option_index); - if (c == -1) - break; /* No more flags to process */ - if (YES == parseDefaultOptions(c, GNoptarg)) - continue; - switch(c) { - case 'D': { - unsigned int depth; - if (1 != sscanf(GNoptarg, "%ud", &depth)) { - GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER, - _("You must pass a number to the `%s' option.\n"), - "-D"); - return SYSERR; - } else { - setConfigurationInt("GNUNET-TRACEKIT", - "HOPS", - depth); - } - break; - } - case 'F': { - unsigned int format; - if (1 != sscanf(GNoptarg, "%ud", &format)) { - GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER, - _("You must pass a number to the `%s' option.\n"), - "-F"); - return SYSERR; - } else { - setConfigurationInt("GNUNET-TRACEKIT", - "FORMAT", - format); - } - break; - } - case 'h': { - static Help help[] = { - HELP_CONFIG, - { 'D', "depth", "DEPTH", - gettext_noop("probe network to the given DEPTH") }, - { 'F', "format", "FORMAT", - gettext_noop("specify output format; 0 for human readable output, 1 for dot, 2 for vcg") }, - HELP_HELP, - HELP_LOGLEVEL, - { 'P', "priority", "PRIO", - gettext_noop("use PRIO for the priority of the trace request") }, - HELP_VERSION, - { 'W', "wait", "DELAY", - gettext_noop("wait DELAY seconds for replies") }, - HELP_END, - }; - formatHelp("gnunet-tracekit [OPTIONS]", - _("Trace GNUnet network topology."), - help); - return SYSERR; - } - case 'P': { - unsigned int prio; - if (1 != sscanf(GNoptarg, "%ud", &prio)) { - GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER, - _("You must pass a number to the `%s' option.\n"), - "-P"); - return SYSERR; - } else { - setConfigurationInt("GNUNET-TRACEKIT", - "PRIORITY", - prio); - } - break; - } - case 'W': { - unsigned int wait; - if (1 != sscanf(GNoptarg, "%ud", &wait)) { - GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER, - _("You must pass a number to the `%s' option.\n"), - "-W"); - return SYSERR; - } else { - setConfigurationInt("GNUNET-TRACEKIT", - "WAIT", - wait); - } - break; - } - case 'v': - printf("GNUnet v%s, gnunet-tracekit v%s\n", - VERSION, - TRACEKIT_VERSION); - return SYSERR; - default: - GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER, - _("Use --help to get a list of options.\n")); - return SYSERR; - } /* end of parsing commandline */ - } /* while (1) */ - return OK; +static unsigned int +getConfigurationInt(const char * sec, + const char * opt, + unsigned int max) { + unsigned long long val; + + GC_get_configuration_value_number(cfg, + sec, + opt, + 0, + max, + 0, + &val); + return (unsigned int) val; } -static void * receiveThread(GNUNET_TCP_SOCKET * sock) { +static void run_shutdown(void * unused) { + GNUNET_SHUTDOWN_INITIATE(); +} + +static void * receiveThread(void * cls) { + struct ClientServerConnection * sock = cls; CS_tracekit_reply_MESSAGE * buffer; - int format; + unsigned long long format; PeerIdentity * peersSeen; unsigned int psCount; unsigned int psSize; @@ -177,14 +103,27 @@ prSize = 1; peersResponding = MALLOC(prSize * sizeof(PeerIdentity)); buffer = MALLOC(MAX_BUFFER_SIZE); - format = getConfigurationInt("GNUNET-TRACEKIT", - "FORMAT"); + if (-1 == + GC_get_configuration_value_number(cfg, + "GNUNET-TRACEKIT", + "FORMAT", + 0, + 2, + 0, + &format)) { + printf(_("Format specification invalid. " + "Use 0 for user-readable, 1 for dot, 2 for vcg.\n")); + SEMAPHORE_UP(doneSem); + FREE(peersResponding); + FREE(peersSeen); + return NULL; + } if (format == 1) printf("digraph G {\n"); if (format == 2) printf("graph: {\n"); - while (OK == readFromSocket(sock, - (CS_MESSAGE_HEADER**)&buffer)) { + while (OK == connection_read(sock, + (MESSAGE_HEADER**)&buffer)) { int count; EncName enc; @@ -229,10 +168,6 @@ case 2: /* deferred -- vcg needs all node data in one line */ break; - default: - printf(_("Format specification invalid. " - "Use 0 for user-readable, 1 for dot, 2 for vcg.\n")); - break; } } else { EncName other; @@ -348,28 +283,51 @@ * @param argv command line arguments * @return return value from gnunet-tracekit: 0: ok, -1: error */ -int main(int argc, char ** argv) { - GNUNET_TCP_SOCKET * sock; - PTHREAD_T messageReceiveThread; +int main(int argc, + const char ** argv) { + struct ClientServerConnection * sock; + struct PTHREAD * messageReceiveThread; void * unused; CS_tracekit_probe_MESSAGE probe; int sleepTime; + struct GE_Context * ectx; + struct CronManager * cron; - if (SYSERR == initUtil(argc, argv, &parseOptions)) - return 0; /* parse error, --help, etc. */ - sock = getClientSocket(); + ectx = GE_create_context_stderr(NO, + GE_WARNING | GE_ERROR | GE_FATAL | + GE_USER | GE_ADMIN | GE_DEVELOPER | + GE_IMMEDIATE | GE_BULK); + GE_setDefaultContext(ectx); + cfg = GC_create_C_impl(); + GE_ASSERT(ectx, cfg != NULL); + os_init(ectx); + if (-1 == gnunet_parse_options("gnunet-tracekit", + ectx, + cfg, + gnunettracekitOptions, + (unsigned int) argc, + argv)) { + GC_free(cfg); + GE_free_context(ectx); + return -1; + } + sock = client_connection_create(ectx, cfg); if (sock == NULL) { - GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, - _("Could not connect to gnunetd.\n")); - return -1; + fprintf(stderr, + _("Error establishing connection with gnunetd.\n")); + GC_free(cfg); + GE_free_context(ectx); + return 1; } doneSem = SEMAPHORE_CREATE(0); - if (0 != PTHREAD_CREATE(&messageReceiveThread, - (PThreadMain) &receiveThread, - sock, - 128 * 1024)) - DIE_STRERROR("pthread_create"); + messageReceiveThread = PTHREAD_CREATE(&receiveThread, + sock, + 128 * 1024); + if (messageReceiveThread == NULL) + GE_DIE_STRERROR(ectx, + GE_FATAL | GE_IMMEDIATE | GE_ADMIN, + "pthread_create"); probe.header.size = htons(sizeof(CS_tracekit_probe_MESSAGE)); @@ -377,35 +335,41 @@ = htons(CS_PROTO_tracekit_PROBE); probe.hops = htonl(getConfigurationInt("GNUNET-TRACEKIT", - "HOPS")); + "HOPS", + 0xFFFFFFFF)); probe.priority = htonl(getConfigurationInt("GNUNET-TRACEKIT", - "PRIORITY")); - if (SYSERR == writeToSocket(sock, - &probe.header)) { - GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, - _("Could not send request to gnunetd.\n")); + "PRIORITY", + 0xFFFFFFFF)); + if (SYSERR == connection_write(sock, + &probe.header)) { + GE_LOG(ectx, + GE_ERROR | GE_BULK | GE_USER, + _("Could not send request to gnunetd.\n")); return -1; } - startCron(); - initializeShutdownHandlers(); + cron = cron_create(ectx); + cron_start(cron); sleepTime = getConfigurationInt("GNUNET-TRACEKIT", - "WAIT"); + "WAIT", + 0xFFFFFFFF); if (sleepTime == 0) sleepTime = 5; - addCronJob((CronJob)&run_shutdown, - cronSECONDS * sleepTime, - 0, - NULL); - wait_for_shutdown(); - closeSocketTemporarily(sock); - SEMAPHORE_DOWN(doneSem); + cron_add_job(cron, + &run_shutdown, + cronSECONDS * sleepTime, + 0, + NULL); + GNUNET_SHUTDOWN_WAITFOR(); + connection_close_temporarily(sock); + SEMAPHORE_DOWN(doneSem, YES); SEMAPHORE_DESTROY(doneSem); - PTHREAD_JOIN(&messageReceiveThread, &unused); - doneShutdownHandlers(); - releaseClientSocket(sock); - stopCron(); - doneUtil(); + PTHREAD_JOIN(messageReceiveThread, &unused); + connection_destroy(sock); + cron_stop(cron); + cron_destroy(cron); + GC_free(cfg); + GE_free_context(ectx); return 0; } Modified: GNUnet/src/applications/tracekit/tracekit.c =================================================================== --- GNUnet/src/applications/tracekit/tracekit.c 2006-08-07 04:47:47 UTC (rev 3213) +++ GNUnet/src/applications/tracekit/tracekit.c 2006-08-07 05:28:15 UTC (rev 3214) @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing authors) + (C) 2001, 2002, 2003, 2004, 2006 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -29,11 +29,16 @@ #include "gnunet_protocols.h" #include "tracekit.h" -static CoreAPIForApplication * coreAPI = NULL; -static Mutex lock; -static unsigned int clientCount = 0; -static ClientHandle * clients = NULL; +static CoreAPIForApplication * coreAPI; +static struct MUTEX * lock; + +static unsigned int clientCount; + +static struct ClientHandle ** clients; + +static struct GE_Context * ectx; + typedef struct { PeerIdentity initiator; PeerIdentity replyTo; @@ -46,7 +51,7 @@ static RTE * routeTable[MAXROUTE]; static int handlep2pReply(const PeerIdentity * sender, - const P2P_MESSAGE_HEADER * message) { + const MESSAGE_HEADER * message) { unsigned int i; unsigned int hostCount; P2P_tracekit_reply_MESSAGE * reply; @@ -58,43 +63,50 @@ hostCount = (ntohs(message->size)-sizeof(P2P_tracekit_reply_MESSAGE))/sizeof(PeerIdentity); if (ntohs(message->size) != sizeof(P2P_tracekit_reply_MESSAGE)+hostCount*sizeof(PeerIdentity)) { - GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER, - _("Received invalid `%s' message from `%s'.\n"), - "P2P_tracekit_probe_MESSAGE", - &sen); + GE_LOG(ectx, + GE_WARNING | GE_BULK | GE_USER, + _("Received invalid `%s' message from `%s'.\n"), + "P2P_tracekit_probe_MESSAGE", + &sen); return SYSERR; } reply = (P2P_tracekit_reply_MESSAGE*)message; hash2enc(&reply->initiatorId.hashPubKey, &initiator); - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: Sending reply back to initiator `%s'.\n", - &initiator); - MUTEX_LOCK(&lock); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: Sending reply back to initiator `%s'.\n", + &initiator); + MUTEX_LOCK(lock); for (i=0;i<MAXROUTE;i++) { if (routeTable[i] == NULL) continue; if ( (routeTable[i]->timestamp == (TIME_T)ntohl(reply->initiatorTimestamp)) && - (equalsHashCode512(&routeTable[i]->initiator.hashPubKey, - &reply->initiatorId.hashPubKey) ) ) { - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: found matching entry in routing table\n"); - if (equalsHashCode512(&coreAPI->myIdentity->hashPubKey, - &routeTable[i]->replyTo.hashPubKey) ) { + (0 == memcmp(&routeTable[i]->initiator.hashPubKey, + &reply->initiatorId.hashPubKey, + sizeof(HashCode512)) ) ) { + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: found matching entry in routing table\n"); + if (0 == memcmp(&coreAPI->myIdentity->hashPubKey, + &routeTable[i]->replyTo.hashPubKey, + sizeof(HashCode512)) ) { unsigned int idx; CS_tracekit_reply_MESSAGE * csReply; idx = ntohl(reply->clientId); - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: I am initiator, sending to client.\n"); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: I am initiator, sending to client.\n"); if (idx >= clientCount) { GE_BREAK(ectx, 0); continue; /* discard */ } if (clients[idx] == NULL) { - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: received response on slot %u, but client already exited.\n", - idx); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: received response on slot %u, but client already exited.\n", + idx); continue; /* discard */ } @@ -117,9 +129,10 @@ hash2enc(&routeTable[i]->replyTo.hashPubKey, &hop); - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: forwarding to next hop `%s'\n", - &hop); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: forwarding to next hop `%s'\n", + &hop); coreAPI->unicast(&routeTable[i]->replyTo, message, routeTable[i]->priority, @@ -127,7 +140,7 @@ } } } - MUTEX_UNLOCK(&lock); + MUTEX_UNLOCK(lock); return OK; } @@ -155,8 +168,9 @@ static void transmit(const PeerIdentity * id, void * cls) { P2P_tracekit_probe_MESSAGE * pro = cls; - if (! hostIdentityEquals(id, - &pro->initiatorId)) + if (0 != memcmp(id, + &pro->initiatorId, + sizeof(PeerIdentity))) coreAPI->unicast(id, &pro->header, ntohl(pro->priority), @@ -164,7 +178,7 @@ } static int handlep2pProbe(const PeerIdentity * sender, - const P2P_MESSAGE_HEADER * message) { + const MESSAGE_HEADER * message) { P2P_tracekit_reply_MESSAGE * reply; P2P_tracekit_probe_MESSAGE * msg; Tracekit_Collect_Trace_Closure closure; @@ -182,39 +196,44 @@ &sen); if (ntohs(message->size) != sizeof(P2P_tracekit_probe_MESSAGE)) { - GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER, - _("Received invalid `%s' message from `%s'.\n"), - "P2P_tracekit_probe_MESSAGE", - &sen); + GE_LOG(ectx, + GE_WARNING | GE_BULK | GE_USER, + _("Received invalid `%s' message from `%s'.\n"), + "P2P_tracekit_probe_MESSAGE", + &sen); return SYSERR; } - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: received probe\n"); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: received probe\n"); TIME(&now); msg = (P2P_tracekit_probe_MESSAGE*) message; if ((TIME_T)ntohl(msg->timestamp) > 3600 + now) { - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: probe has timestamp in the far future (%d > %d), dropping\n", - ntohl(msg->timestamp), - 3600 + now); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: probe has timestamp in the far future (%d > %d), dropping\n", + ntohl(msg->timestamp), + 3600 + now); return SYSERR; /* Timestamp is more than 1h in the future. Invalid! */ } hash2enc(&msg->initiatorId.hashPubKey, &init); - MUTEX_LOCK(&lock); + MUTEX_LOCK(lock); /* test if already processed */ for (i=0;i<MAXROUTE;i++) { if (routeTable[i] == NULL) continue; if ( (routeTable[i]->timestamp == (TIME_T)ntohl(msg->timestamp)) && - equalsHashCode512(&routeTable[i]->initiator.hashPubKey, - &msg->initiatorId.hashPubKey) ) { - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT-PROBE %d from `%s' received twice (slot %d), ignored\n", - ntohl(msg->timestamp), - &init, - i); - MUTEX_UNLOCK(&lock); + 0 == memcmp(&routeTable[i]->initiator.hashPubKey, + &msg->initiatorId.hashPubKey, + sizeof(HashCode512)) ) { + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT-PROBE %d from `%s' received twice (slot %d), ignored\n", + ntohl(msg->timestamp), + &init, + i); + MUTEX_UNLOCK(lock); return OK; } } @@ -238,9 +257,10 @@ } } if (sel == -1) { - MUTEX_UNLOCK(&lock); - GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER, - _("TRACEKIT: routing table full, trace request dropped\n")); + MUTEX_UNLOCK(lock); + GE_LOG(ectx, + GE_INFO | GE_REQUEST | GE_USER, + _("TRACEKIT: routing table full, trace request dropped\n")); return OK; } if (routeTable[sel] == NULL) @@ -253,13 +273,14 @@ = msg->initiatorId; routeTable[sel]->replyTo = *sender; - MUTEX_UNLOCK(&lock); - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT-PROBE started at %d by peer `%s' received, processing in slot %d with %u hops\n", - ntohl(msg->timestamp), - &init, - sel, - ntohl(msg->hopsToGo)); + MUTEX_UNLOCK(lock); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT-PROBE started at %d by peer `%s' received, processing in slot %d with %u hops\n", + ntohl(msg->timestamp), + &init, + sel, + ntohl(msg->hopsToGo)); hops = ntohl(msg->hopsToGo); /* forward? */ if (hops > 0) { @@ -313,27 +334,29 @@ return OK; } -static int csHandle(ClientHandle client, - const CS_MESSAGE_HEADER * message) { +static int csHandle(struct ClientHandle * client, + const MESSAGE_HEADER * message) { int i; int idx; CS_tracekit_probe_MESSAGE * csProbe; P2P_tracekit_probe_MESSAGE p2pProbe; - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: client sends probe request\n"); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: client sends probe request\n"); /* build probe, broadcast */ csProbe = (CS_tracekit_probe_MESSAGE*) message; if (ntohs(csProbe->header.size) != sizeof(CS_tracekit_probe_MESSAGE) ) { - GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER, - _("TRACEKIT: received invalid `%s' message\n"), - "CS_tracekit_probe_MESSAGE"); + GE_LOG(ectx, + GE_WARNING | GE_BULK | GE_USER, + _("TRACEKIT: received invalid `%s' message\n"), + "CS_tracekit_probe_MESSAGE"); return SYSERR; } - MUTEX_LOCK(&lock); + MUTEX_LOCK(lock); idx = -1; for (i=0;i<clientCount;i++) { if (clients[i] == client) { @@ -353,10 +376,11 @@ idx = clientCount-1; } clients[idx] = client; - MUTEX_UNLOCK(&lock); - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: client joins in slot %u.\n", - idx); + MUTEX_UNLOCK(lock); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: client joins in slot %u.\n", + idx); p2pProbe.header.size = htons(sizeof(P2P_tracekit_probe_MESSAGE)); @@ -378,15 +402,16 @@ return OK; } -static void clientExitHandler(ClientHandle c) { +static void clientExitHandler(struct ClientHandle * c) { int i; - MUTEX_LOCK(&lock); + MUTEX_LOCK(lock); for (i=0;i<clientCount;i++) if (clients[i] == c) { - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT: client in slot %u exits.\n", - i); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT: client in slot %u exits.\n", + i); clients[i] = NULL; break; } @@ -399,19 +424,21 @@ GROW(clients, clientCount, i); - MUTEX_UNLOCK(&lock); + MUTEX_UNLOCK(lock); } int initialize_module_tracekit(CoreAPIForApplication * capi) { int ok = OK; - MUTEX_CREATE(&lock); + ectx = capi->ectx; + lock = MUTEX_CREATE(NO); coreAPI = capi; - GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, - "TRACEKIT registering handlers %d %d and %d\n", - P2P_PROTO_tracekit_PROBE, - P2P_PROTO_tracekit_REPLY, - CS_PROTO_tracekit_PROBE); + GE_LOG(ectx, + GE_DEBUG | GE_REQUEST | GE_USER, + "TRACEKIT registering handlers %d %d and %d\n", + P2P_PROTO_tracekit_PROBE, + P2P_PROTO_tracekit_REPLY, + CS_PROTO_tracekit_PROBE); memset(routeTable, 0, MAXROUTE*sizeof(RTE*)); @@ -426,9 +453,12 @@ if (SYSERR == capi->registerClientHandler(CS_PROTO_tracekit_PROBE, (CSHandler)&csHandle)) ok = SYSERR; - setConfigurationString("ABOUT", - "tracekit", - gettext_noop("allows mapping of the network topology")); + GE_ASSERT(capi->ectx, + 0 == GC_set_configuration_value_string(capi->cfg, + capi->ectx, + "ABOUT", + "tracekit", + gettext_noop("allows mapping of the network topology"))); return ok; } @@ -441,7 +471,7 @@ &handlep2pReply); coreAPI->unregisterClientExitHandler(&clientExitHandler); coreAPI->unregisterClientHandler(CS_PROTO_tracekit_PROBE, - (CSHandler)&csHandle); + &csHandle); for (i=0;i<MAXROUTE;i++) { FREENONNULL(routeTable[i]); routeTable[i] = NULL; @@ -449,7 +479,8 @@ GROW(clients, clientCount, 0); - MUTEX_DESTROY(&lock); + MUTEX_DESTROY(lock); + lock = NULL; coreAPI = NULL; } Modified: GNUnet/src/applications/tracekit/tracekit.h =================================================================== --- GNUnet/src/applications/tracekit/tracekit.h 2006-08-07 04:47:47 UTC (rev 3213) +++ GNUnet/src/applications/tracekit/tracekit.h 2006-08-07 05:28:15 UTC (rev 3214) @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing authors) + (C) 2001, 2002, 2003, 2004, 2006 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -29,7 +29,7 @@ #include "gnunet_core.h" typedef struct { - P2P_MESSAGE_HEADER header; + MESSAGE_HEADER header; /** * When was this probe started? (NBO) @@ -60,7 +60,7 @@ } P2P_tracekit_probe_MESSAGE; typedef struct { - P2P_MESSAGE_HEADER header; + MESSAGE_HEADER header; /** * Which peer is the ultimate receiver of this @@ -99,7 +99,7 @@ typedef struct { - CS_MESSAGE_HEADER header; + MESSAGE_HEADER header; /** * How many more hops should this probe go (NBO) @@ -113,7 +113,7 @@ } CS_tracekit_probe_MESSAGE; typedef struct { - CS_MESSAGE_HEADER header; + MESSAGE_HEADER header; /** * Which peer is the ultimate responder responsible Modified: GNUnet/todo =================================================================== --- GNUnet/todo 2006-08-07 04:47:47 UTC (rev 3213) +++ GNUnet/todo 2006-08-07 05:28:15 UTC (rev 3214) @@ -26,12 +26,12 @@ * applications: + fragmentation, identity, pingpong, session, transport, stats, topology_default, state, getoption, advertising, - traffic, ecrs_core, template, tbench compile + traffic, ecrs_core, template, tbench, tracekit compile + bootstrap_http: maybe switch to libwww? + for fs: fs (18500), gap (2800) + rest: sqstore_mysql, dht, chat, kvstore_sqlite, sqstore_mysql, rpc, testbed, - topology_f2f, vpn, tracekit + topology_f2f, vpn * setup: + nothing compiles - adapt util testcases and main GNUnet codebase _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn