[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4962 - in GNUnet/src/applications: advertising identity tr
From: |
gnunet |
Subject: |
[GNUnet-SVN] r4962 - in GNUnet/src/applications: advertising identity transport |
Date: |
Fri, 8 Jun 2007 15:10:16 -0600 (MDT) |
Author: grothoff
Date: 2007-06-08 15:10:16 -0600 (Fri, 08 Jun 2007)
New Revision: 4962
Modified:
GNUnet/src/applications/advertising/advertising.c
GNUnet/src/applications/identity/identity.c
GNUnet/src/applications/transport/transport.c
Log:
fixing identity issues with disabled transports preventing new transports from
begin discovered
Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c 2007-06-08 20:36:00 UTC
(rev 4961)
+++ GNUnet/src/applications/advertising/advertising.c 2007-06-08 21:10:16 UTC
(rev 4962)
@@ -60,7 +60,7 @@
#define ACJ_FORWARD 2
#define ACJ_ALL (ACJ_ANNOUNCE | ACJ_FORWARD)
-#define DEBUG_ADVERTISING NO
+#define DEBUG_ADVERTISING YES
static CoreAPIForApplication * coreAPI;
@@ -156,7 +156,8 @@
int mtu;
int res;
cron_t now;
-
+ EncName enc;
+
/* first verify that it is actually a valid hello */
msg = (const P2P_hello_MESSAGE* ) message;
if ( (ntohs(msg->header.size) < sizeof(P2P_hello_MESSAGE)) ||
@@ -178,7 +179,6 @@
- sizeof(MESSAGE_HEADER),
&msg->signature,
&msg->publicKey)) {
- EncName enc;
IF_GELOG(ectx,
GE_WARNING | GE_BULK | GE_USER,
hash2enc(&msg->senderIdentity.hashPubKey,
@@ -187,12 +187,14 @@
GE_WARNING | GE_BULK | GE_USER,
_("HELLO message from `%s' has an invalid signature. Dropping.\n"),
(char*)&enc);
+ GE_BREAK(ectx, 0);
return SYSERR; /* message invalid */
}
if ((TIME_T)ntohl(msg->expirationTime) > TIME(NULL) + MAX_HELLO_EXPIRES) {
GE_LOG(ectx,
GE_WARNING | GE_BULK | GE_USER,
- _("HELLO message received is expired. Dropping.\n"));
+ _("HELLO message has expiration too far in the future.
Dropping.\n"));
+ GE_BREAK(ectx, 0);
return SYSERR;
}
if (SYSERR == transport->verifyhello(msg)) {
@@ -207,9 +209,14 @@
if (stats != NULL)
stats->change(stat_hello_in, 1);
#if DEBUG_ADVERTISING
+ IF_GELOG(ectx,
+ GE_INFO | GE_REQUEST | GE_USER,
+ hash2enc(&msg->senderIdentity.hashPubKey,
+ &enc));
GE_LOG(ectx,
GE_INFO | GE_REQUEST | GE_USER,
- "HELLO advertisement for protocol %d received.\n",
+ "HELLO advertisement from `%s' for protocol %d received.\n",
+ &enc,
ntohs(msg->protocol));
#endif
if (ntohs(msg->protocol) == NAT_PROTOCOL_NUMBER) {
@@ -286,6 +293,11 @@
return SYSERR;
}
+ /* Ok, must play PING-PONG. Add the hello to the temporary
+ (in-memory only) buffer to make it available for a short
+ time in order to play PING-PONG */
+ identity->addHostTemporarily(msg);
+
now = get_time();
if ( (sender != NULL) &&
( (now - lasthelloMsg) / cronSECONDS) *
@@ -304,7 +316,7 @@
#if DEBUG_ADVERTISING
GE_LOG(ectx,
GE_INFO | GE_BULK | GE_USER,
- "Not enough resources to verify HELLO message at this time (%u * %u
< %u * 100)\n",
+ "Not enough resources to verify HELLO message at this time (%u * %u
< %u * 10)\n",
(unsigned int) ((now - lasthelloMsg) / cronSECONDS),
(unsigned int) os_network_monitor_get_limit(coreAPI->load_monitor,
Download),
@@ -312,16 +324,11 @@
#endif
if (stats != NULL)
stats->change(stat_hello_discard, 1);
- return SYSERR;
+ return SYSERR;
}
lasthelloMsg = now;
- /* Ok, must play PING-PONG. Add the hello to the temporary
- (in-memory only) buffer to make it available for a short
- time in order to play PING-PONG */
- identity->addHostTemporarily(msg);
-
/* Establish session as advertised in the hello */
tsession = transport->connect(msg);
if (tsession == NULL) {
@@ -522,11 +529,6 @@
return; /* network load too high... */
if (0 != weak_randomi(*prob))
return; /* ignore */
-#if DEBUG_ADVERTISING
- LOG(LOG_CRON,
- "Enter `%s'.\n",
- __FUNCTION__);
-#endif
now = get_time();
sd.n = identity->forEachHost(now,
NULL,
@@ -535,9 +537,10 @@
if (sd.m == NULL)
return;
#if DEBUG_ADVERTISING
- GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER,
- _("Advertising my transport %d to selected peers.\n"),
- tapi->protocolNumber);
+ GE_LOG(ectx,
+ GE_INFO | GE_REQUEST | GE_USER,
+ _("Advertising my transport %d to selected peers.\n"),
+ tapi->protocolNumber);
#endif
identity->addHost(sd.m);
if (sd.n < 1) {
@@ -552,11 +555,6 @@
(HostIterator)&broadcastHelper,
&sd);
FREE(sd.m);
-#if DEBUG_ADVERTISING
- LOG(LOG_CRON,
- "Exit `%s'.\n",
- __FUNCTION__);
-#endif
}
/**
@@ -687,11 +685,6 @@
if (os_network_monitor_get_load(coreAPI->load_monitor,
Upload) > 100)
return; /* network load too high... */
-#if DEBUG_ADVERTISING
- LOG(LOG_CRON,
- "Enter `%s'.\n",
- __FUNCTION__);
-#endif
count = identity->forEachHost(0,
NULL,
NULL);
@@ -699,11 +692,6 @@
identity->forEachHost(0, /* ignore blacklisting */
&forwardhelloHelper,
&count);
-#if DEBUG_ADVERTISING
- LOG(LOG_CRON,
- "Exit `%s'.\n",
- __FUNCTION__);
-#endif
}
/**
Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2007-06-08 20:36:00 UTC (rev
4961)
+++ GNUnet/src/applications/identity/identity.c 2007-06-08 21:10:16 UTC (rev
4962)
@@ -439,43 +439,44 @@
GE_BREAK(NULL, 0);
return;
}
+ MUTEX_LOCK(lock_);
+ entry = findHost(&msg->senderIdentity);
+ if ( (entry != NULL) &&
+ (entry->helloCount > 0) ) {
+ MUTEX_UNLOCK(lock_);
+ return;
+ }
msg = MALLOC(P2P_hello_MESSAGE_size(tmp));
memcpy(msg,
tmp,
P2P_hello_MESSAGE_size(tmp));
- MUTEX_LOCK(lock_);
- entry = findHost(&msg->senderIdentity);
- if (entry == NULL) {
- slot = tempHostsNextSlot;
- for (i=0;i<MAX_TEMP_HOSTS;i++)
- if (0 == memcmp(&tmp->senderIdentity,
- &tempHosts[i].identity,
- sizeof(PeerIdentity)))
- slot = i;
- if (slot == tempHostsNextSlot) {
- tempHostsNextSlot++;
- if (tempHostsNextSlot >= MAX_TEMP_HOSTS)
- tempHostsNextSlot = 0;
- }
- entry = &tempHosts[slot];
- entry->identity = msg->senderIdentity;
- entry->until = 0;
- entry->delta = 0;
- for (i=0;i<entry->helloCount;i++)
- FREE(entry->hellos[i]);
- GROW(entry->hellos,
- entry->helloCount,
- 1);
- GROW(entry->protocols,
- entry->protocolCount,
- 1);
- entry->hellos[0] = msg;
- entry->protocols[0] = ntohs(msg->protocol);
- entry->strict = NO;
- entry->trust = 0;
- } else {
- FREE(msg);
+ slot = tempHostsNextSlot;
+ for (i=0;i<MAX_TEMP_HOSTS;i++)
+ if (0 == memcmp(&tmp->senderIdentity,
+ &tempHosts[i].identity,
+ sizeof(PeerIdentity)))
+ slot = i;
+ if (slot == tempHostsNextSlot) {
+ tempHostsNextSlot++;
+ if (tempHostsNextSlot >= MAX_TEMP_HOSTS)
+ tempHostsNextSlot = 0;
}
+ entry = &tempHosts[slot];
+ entry->identity = msg->senderIdentity;
+ entry->until = 0;
+ entry->delta = 0;
+ for (i=0;i<entry->helloCount;i++)
+ FREE(entry->hellos[i]);
+ GROW(entry->hellos,
+ entry->helloCount,
+ 1);
+ GROW(entry->protocols,
+ entry->protocolCount,
+ 1);
+ entry->hellos[0] = msg;
+ entry->protocols[0] = ntohs(msg->protocol);
+ entry->strict = NO;
+ entry->trust = 0;
MUTEX_UNLOCK(lock_);
}
@@ -1330,7 +1331,7 @@
id.addHostTemporarily = &addHostTemporarily;
id.addHost = &bindAddress;
id.forEachHost = &forEachHost;
- id.identity2Hello = &identity2Hello;
+ id.identity2Hello = &identity2Hello;
id.verifyPeerSignature = &verifyPeerSignature;
id.blacklistHost = &blacklistHost;
id.isBlacklistedStrict = &isBlacklistedStrict;
Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c 2007-06-08 20:36:00 UTC
(rev 4961)
+++ GNUnet/src/applications/transport/transport.c 2007-06-08 21:10:16 UTC
(rev 4962)
@@ -216,8 +216,8 @@
if (tapis[perm[i]] == NULL)
continue;
hello = identity->identity2Hello(peer,
- perm[i],
- useTempList);
+ perm[i],
+ useTempList);
if (hello == NULL)
continue;
hc++;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4962 - in GNUnet/src/applications: advertising identity transport,
gnunet <=