*/
struct GNUNET_CONTAINER_MultiHashMap *peers;
+ /**
+ * Identity of this peer.
+ */
+ struct GNUNET_PeerIdentity me;
+
/**
* ID of reconnect task (if any).
*/
const struct GNUNET_CORE_MessageHandler *mh;
GNUNET_CORE_StartupCallback init;
GNUNET_CORE_PeerConfigurationInfoCallback pcic;
- struct GNUNET_PeerIdentity my_identity;
struct PeerRecord *pr;
struct GNUNET_CORE_TransmitHandle *th;
unsigned int hpos;
GNUNET_CRYPTO_hash (&m->publicKey,
sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
- &my_identity.hashPubKey);
- init (h->cls, h, &my_identity, &m->publicKey);
+ &h->me.hashPubKey);
+ init (h->cls, h, &h->me, &m->publicKey);
}
break;
case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT:
"Received notification about connection from `%s'.\n",
GNUNET_i2s (&cnm->peer));
#endif
+ if (0 == memcmp (&h->me,
+ &cnm->peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ /* disconnect from self!? */
+ GNUNET_break (0);
+ return;
+ }
pr = GNUNET_CONTAINER_multihashmap_get (h->peers,
&cnm->peer.hashPubKey);
if (pr != NULL)
return;
}
dnm = (const struct DisconnectNotifyMessage *) msg;
+ if (0 == memcmp (&h->me,
+ &dnm->peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ /* connection to self!? */
+ GNUNET_break (0);
+ return;
+ }
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received notification about disconnect from `%s'.\n",
return;
}
psnm = (const struct PeerStatusNotifyMessage *) msg;
+ if (0 == memcmp (&h->me,
+ &psnm->peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ /* self-change!? */
+ GNUNET_break (0);
+ return;
+ }
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received notification about status change by `%s'.\n",
return;
}
ntm = (const struct NotifyTrafficMessage *) msg;
+ if (0 == memcmp (&h->me,
+ &ntm->peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ /* self-change!? */
+ GNUNET_break (0);
+ return;
+ }
em = (const struct GNUNET_MessageHeader *) &ntm[1];
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
return;
}
ntm = (const struct NotifyTrafficMessage *) msg;
+ if (0 == memcmp (&h->me,
+ &ntm->peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ /* self-change!? */
+ GNUNET_break (0);
+ return;
+ }
em = (const struct GNUNET_MessageHeader *) &ntm[1];
pr = GNUNET_CONTAINER_multihashmap_get (h->peers,
&ntm->peer.hashPubKey);
return;
}
smr = (const struct SendMessageReady *) msg;
+ if (0 == memcmp (&h->me,
+ &smr->peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ /* self-change!? */
+ GNUNET_break (0);
+ return;
+ }
pr = GNUNET_CONTAINER_multihashmap_get (h->peers,
&smr->peer.hashPubKey);
if (pr == NULL)
return;
}
cim = (const struct ConfigurationInfoMessage*) msg;
+ if (0 == memcmp (&h->me,
+ &cim->peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ /* self-change!? */
+ GNUNET_break (0);
+ return;
+ }
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received notification about configuration update for `%s'.\n",
static struct PeerContext p2;
+static GNUNET_SCHEDULER_TaskIdentifier err_task;
static int ok;
}
+static size_t
+transmit_ready (void *cls, size_t size, void *buf)
+{
+ struct PeerContext *p = cls;
+ struct GNUNET_MessageHeader *m;
+
+ GNUNET_assert (ok == 4);
+ OKPP;
+ GNUNET_assert (p == &p1);
+ GNUNET_assert (buf != NULL);
+ m = (struct GNUNET_MessageHeader *) buf;
+ m->type = htons (MTYPE);
+ m->size = htons (sizeof (struct GNUNET_MessageHeader));
+ err_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120),
+ &terminate_task_error, NULL);
+
+ return sizeof (struct GNUNET_MessageHeader);
+}
+
+
static void
connect_notify (void *cls,
const struct GNUNET_PeerIdentity *peer,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Encrypted connection established to peer `%4s'\n",
GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking core (1) for transmission to peer `%4s'\n",
+ GNUNET_i2s (&p2.id));
+ if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch,
+ 0,
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
+ &p2.id,
+ sizeof (struct GNUNET_MessageHeader),
+ &transmit_ready, &p1))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
+ GNUNET_i2s (&p2.id));
+ }
}
}
-static GNUNET_SCHEDULER_TaskIdentifier err_task;
-
static int
process_mtype (void *cls,
};
-static size_t
-transmit_ready (void *cls, size_t size, void *buf)
-{
- struct PeerContext *p = cls;
- struct GNUNET_MessageHeader *m;
-
- GNUNET_assert (ok == 4);
- OKPP;
- GNUNET_assert (p == &p1);
- GNUNET_assert (buf != NULL);
- m = (struct GNUNET_MessageHeader *) buf;
- m->type = htons (MTYPE);
- m->size = htons (sizeof (struct GNUNET_MessageHeader));
- err_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120), &terminate_task_error, NULL);
-
- return sizeof (struct GNUNET_MessageHeader);
-}
-
-
-
static void
init_notify (void *cls,
struct GNUNET_CORE_Handle *server,
OKPP;
GNUNET_assert (cls == &p2);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asking core (1) for transmission to peer `%4s'\n",
+ "Asking core (1) to connect to peer `%4s'\n",
GNUNET_i2s (&p2.id));
-
- if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch,
- 0,
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
- &p2.id,
- sizeof (struct GNUNET_MessageHeader),
- &transmit_ready, &p1))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
- GNUNET_i2s (&p2.id));
- }
-
+ GNUNET_CORE_peer_request_connect (p1.ch,
+ GNUNET_TIME_UNIT_SECONDS,
+ &p2.id,
+ NULL, NULL);
}
}