[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4928 - in GNUnet/src: applications/advertising application
From: |
gnunet |
Subject: |
[GNUnet-SVN] r4928 - in GNUnet/src: applications/advertising applications/identity include |
Date: |
Mon, 4 Jun 2007 22:18:48 -0600 (MDT) |
Author: grothoff
Date: 2007-06-04 22:18:47 -0600 (Mon, 04 Jun 2007)
New Revision: 4928
Modified:
GNUnet/src/applications/advertising/advertising.c
GNUnet/src/applications/advertising/bootstrap.c
GNUnet/src/applications/identity/Makefile.am
GNUnet/src/applications/identity/identity.c
GNUnet/src/applications/identity/identitytest.c
GNUnet/src/include/gnunet_identity_lib.h
Log:
more stats
Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c 2007-06-05 02:05:38 UTC
(rev 4927)
+++ GNUnet/src/applications/advertising/advertising.c 2007-06-05 04:18:47 UTC
(rev 4928)
@@ -78,6 +78,22 @@
static int stat_hello_in;
+static int stat_hello_nat_in;
+
+static int stat_hello_verified;
+
+static int stat_hello_update;
+
+static int stat_hello_discard;
+
+static int stat_hello_no_transport;
+
+static int stat_hello_ping_busy;
+
+static int stat_hello_noselfad;
+
+static int stat_hello_send_error;
+
static int stat_hello_out;
static int stat_hello_fwd;
@@ -114,6 +130,8 @@
static void callAddHost(void * cls) {
P2P_hello_MESSAGE * helo = cls;
+ if (stats != NULL)
+ stats->change(stat_hello_verified, 1);
identity->addHost(helo);
FREE(helo);
}
@@ -140,7 +158,8 @@
/* first verify that it is actually a valid hello */
msg = (P2P_hello_MESSAGE* ) message;
- if (ntohs(msg->header.size) != P2P_hello_MESSAGE_size(msg)) {
+ if ( (ntohs(msg->header.size) < sizeof(P2P_hello_MESSAGE)) ||
+ (ntohs(msg->header.size) != P2P_hello_MESSAGE_size(msg)) ) {
GE_BREAK(ectx, 0);
return SYSERR;
}
@@ -204,6 +223,8 @@
(which is OK since we never attempt to
connect to a NAT). */
identity->addHost(msg);
+ if (stats != NULL)
+ stats->change(stat_hello_nat_in, 1);
return OK;
}
@@ -224,6 +245,8 @@
TTL has changed); thus we can 'trust' it without playing
ping-pong */
identity->addHost(msg);
+ if (stats != NULL)
+ stats->change(stat_hello_update, 1);
FREE(copy);
return OK;
}
@@ -285,6 +308,8 @@
Download),
(unsigned int) P2P_hello_MESSAGE_size(msg));
#endif
+ if (stats != NULL)
+ stats->change(stat_hello_discard, 1);
return SYSERR;
}
lasthelloMsg = now;
@@ -297,8 +322,11 @@
/* Establish session as advertised in the hello */
tsession = transport->connect(msg);
- if (tsession == NULL)
+ if (tsession == NULL) {
+ if (stats != NULL)
+ stats->change(stat_hello_no_transport, 1);
return SYSERR; /* could not connect */
+ }
/* build message to send, ping must contain return-information,
such as a selection of our hellos... */
@@ -309,7 +337,6 @@
GE_ASSERT(ectx, mtu > P2P_MESSAGE_OVERHEAD);
mtu -= P2P_MESSAGE_OVERHEAD;
}
- buffer = MALLOC(mtu);
copy = MALLOC(P2P_hello_MESSAGE_size(msg));
memcpy(copy,
msg,
@@ -321,13 +348,15 @@
rand());
if (ping == NULL) {
res = SYSERR;
- FREE(buffer);
GE_LOG(ectx,
GE_INFO | GE_REQUEST | GE_USER,
_("Could not send hellos+PING, ping buffer full.\n"));
transport->disconnect(tsession);
+ if (stats != NULL)
+ stats->change(stat_hello_ping_busy, 1);
return SYSERR;
}
+ buffer = MALLOC(mtu);
if (mtu > ntohs(ping->size)) {
heloEnd = transport->getAdvertisedhellos(mtu - ntohs(ping->size),
buffer);
@@ -337,12 +366,15 @@
heloEnd = -2;
}
if (heloEnd <= 0) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("`%s' failed (%d, %u). Will not send PING.\n"),
- "getAdvertisedhellos",
- heloEnd,
- mtu - ntohs(ping->size));
+ GE_LOG(ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("`%s' failed (%d, %u). Will not send PING.\n"),
+ "getAdvertisedhellos",
+ heloEnd,
+ mtu - ntohs(ping->size));
FREE(buffer);
+ if (stats != NULL)
+ stats->change(stat_hello_noselfad, 1);
transport->disconnect(tsession);
return SYSERR;
}
@@ -357,8 +389,12 @@
if ( (res == OK) &&
(SYSERR == coreAPI->sendPlaintext(tsession,
buffer,
- heloEnd)) )
+ heloEnd)) ) {
+
+ if (stats != NULL)
+ stats->change(stat_hello_send_error, 1);
res = SYSERR;
+ }
if (res == OK) {
if (stats != NULL)
stats->change(stat_plaintextPingSent, 1);
@@ -800,6 +836,14 @@
stats = capi->requestService("stats");
if (stats != NULL) {
stat_hello_in = stats->create(gettext_noop("# Peer advertisements
received"));
+ stat_hello_nat_in = stats->create(gettext_noop("# Peer advertisements of
type NAT received"));
+ stat_hello_verified = stats->create(gettext_noop("# Peer advertisements
confirmed via PONG"));
+ stat_hello_update = stats->create(gettext_noop("# Peer advertisements
updating earlier HELLOs"));
+ stat_hello_discard = stats->create(gettext_noop("# Peer advertisements
discarded due to load"));
+ stat_hello_no_transport = stats->create(gettext_noop("# Peer
advertisements for unsupported transport"));
+ stat_hello_ping_busy = stats->create(gettext_noop("# Peer advertisements
not confirmed due to ping busy"));
+ stat_hello_noselfad = stats->create(gettext_noop("# Peer advertisements
not confirmed due to lack of self ad"));
+ stat_hello_send_error = stats->create(gettext_noop("# Peer advertisements
not confirmed due to send error"));
stat_hello_out = stats->create(gettext_noop("# Self advertisments
transmitted"));
stat_hello_fwd = stats->create(gettext_noop("# Foreign advertisements
forwarded"));
stat_plaintextPingSent
Modified: GNUnet/src/applications/advertising/bootstrap.c
===================================================================
--- GNUnet/src/applications/advertising/bootstrap.c 2007-06-05 02:05:38 UTC
(rev 4927)
+++ GNUnet/src/applications/advertising/bootstrap.c 2007-06-05 04:18:47 UTC
(rev 4928)
@@ -143,9 +143,9 @@
char * data;
now = get_time();
- if (coreAPI->forAllConnectedNodes(NULL, NULL) >= 3) {
+ if (coreAPI->forAllConnectedNodes(NULL, NULL) >= 4) {
/* still change delta and lastTest; even
- if the peer _briefly_ drops below 4
+ if the peer _briefly_ drops below 5
connections, we don't want it to immediately
go for the hostlist... */
delta = 5 * cronMINUTES;
Modified: GNUnet/src/applications/identity/Makefile.am
===================================================================
--- GNUnet/src/applications/identity/Makefile.am 2007-06-05 02:05:38 UTC
(rev 4927)
+++ GNUnet/src/applications/identity/Makefile.am 2007-06-05 04:18:47 UTC
(rev 4928)
@@ -26,7 +26,7 @@
clientapi.c
libgnunetidentity_api_la_LIBADD = \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
+ $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
$(top_builddir)/src/util/network_client/libgnunetutil_network_client.la
@@ -41,4 +41,5 @@
identitytest_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/applications/identity/libgnunetidentity_api.la \
$(top_builddir)/src/server/libgnunetcore.la
Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2007-06-05 02:05:38 UTC (rev
4927)
+++ GNUnet/src/applications/identity/identity.c 2007-06-05 04:18:47 UTC (rev
4928)
@@ -1265,7 +1265,7 @@
static int identityRequestInfoHandler(struct ClientHandle * sock,
const MESSAGE_HEADER * message) {
- forEachHost(get_time(),
+ forEachHost(0,
&hostInfoIterator,
sock);
return coreAPI->sendValueToClient(sock,
Modified: GNUnet/src/applications/identity/identitytest.c
===================================================================
--- GNUnet/src/applications/identity/identitytest.c 2007-06-05 02:05:38 UTC
(rev 4927)
+++ GNUnet/src/applications/identity/identitytest.c 2007-06-05 04:18:47 UTC
(rev 4928)
@@ -28,13 +28,18 @@
#include "gnunet_util.h"
#include "gnunet_protocols.h"
#include "gnunet_identity_service.h"
+#include "gnunet_identity_lib.h"
#include "gnunet_transport_service.h"
#include "gnunet_core.h"
#include "gnunet_util_config_impl.h"
+#include "gnunet_util_network_client.h"
#include "core.h"
static struct CronManager * cron;
+static struct GC_Configuration * cfg;
+
+
#define ASSERT(cond) do { \
if (!cond) { \
printf("Assertion failed at %s:%d\n", \
@@ -52,24 +57,24 @@
PeerIdentity pid;
const PublicKey * pkey;
Signature sig;
- P2P_hello_MESSAGE * helo;
+ P2P_hello_MESSAGE * hello;
transport = requestService("transport");
identity = requestService("identity");
cron_start(cron);
/* give cron job chance to run */
PTHREAD_SLEEP(5 * cronSECONDS);
- helo = transport->createhello(ANY_PROTOCOL_NUMBER);
- if (NULL == helo) {
+ hello = transport->createhello(ANY_PROTOCOL_NUMBER);
+ if (NULL == hello) {
printf("Cannot run test, failed to create any hello.\n");
cron_stop(cron);
releaseService(identity);
releaseService(transport);
return SYSERR;
}
- identity->addHost(helo);
- pid = helo->senderIdentity;
- FREE(helo);
+ identity->addHost(hello);
+ pid = hello->senderIdentity;
+ FREE(hello);
identity->changeHostTrust
(&pid,
@@ -110,9 +115,33 @@
return OK;
}
+static int hcb(void * data,
+ const PeerIdentity * identity,
+ const char * address,
+ cron_t last_message,
+ unsigned int trust,
+ unsigned int bpmFromPeer) {
+ int * ret = data;
+
+ /* TODO: do something meaningful */
+ return OK;
+}
+
+static int runClientTest() {
+ struct ClientServerConnection * sock;
+ int ret;
+
+ ret = OK;
+ sock = client_connection_create(NULL, cfg);
+ gnunet_identity_request_peer_infos(sock,
+ &hcb,
+ &ret);
+ connection_destroy(sock);
+ return ret;
+}
+
int main(int argc, char *argv[]) {
int err;
- struct GC_Configuration * cfg;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
@@ -128,6 +157,8 @@
err = 0;
if (OK != runTest())
err = 1;
+ if (OK != runClientTest())
+ err = 1;
doneCore();
cron_destroy(cron);
GC_free(cfg);
Modified: GNUnet/src/include/gnunet_identity_lib.h
===================================================================
--- GNUnet/src/include/gnunet_identity_lib.h 2007-06-05 02:05:38 UTC (rev
4927)
+++ GNUnet/src/include/gnunet_identity_lib.h 2007-06-05 04:18:47 UTC (rev
4928)
@@ -39,7 +39,9 @@
/**
- * Inform gnunetd about another peer.
+ * Inform gnunetd about another peer. The given
+ * HELLO will be subjected to evaluation for validity
+ * just like HELLOs received from other peers.
*
* @param sock socket to talk to gnunetd over
* @return OK on success, SYSERR on error
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4928 - in GNUnet/src: applications/advertising applications/identity include,
gnunet <=