- struct BenchmarkPeer *me = cls;
- struct BenchmarkPeer *remote;
- struct PendingMessages *pm;
-
- remote = find_peer (other);
-
- if (NULL == remote)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
-
- if (NULL != me->cth)
- {
- pm = GNUNET_malloc (sizeof (struct PendingMessages));
- pm->target = (*other);
- GNUNET_CONTAINER_DLL_insert_tail (me->p_head, me->p_tail, pm);
- return GNUNET_OK;
- }
-
- if (GNUNET_NO == remote->master)
- {
- GNUNET_break (0);
- return GNUNET_OK;
- }
-
- me->messages_received ++;
- /* send echo */
- me->cth = GNUNET_CORE_notify_transmit_ready (me->ch,
- GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES,
- &remote->id,
- TEST_MESSAGE_SIZE, &core_send_echo_ready, me);
- return GNUNET_OK;
+ int c_m;
+ struct BenchmarkPeer *me = cls;
+ struct BenchmarkPartner *p = NULL;
+ for (c_m = 0; c_m < num_masters; c_m++)
+ {
+ /* Find a partner with other as destination */
+ if (0 == memcmp (other, &me->partners[c_m].dest->id,
+ sizeof(struct GNUNET_PeerIdentity)))
+ {
+ p = &me->partners[c_m];
+ break;
+ }
+ }
+ if (NULL == p)
+ {
+ GNUNET_break(0);
+ return GNUNET_SYSERR;
+ }
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Slave [%u]: Received PING from [%u], sending PONG\n", me->no,
+ p->dest->no);
+
+ p->messages_received++;
+ p->bytes_received += TEST_MESSAGE_SIZE;
+ p->me->total_messages_received++;
+ p->me->total_bytes_received += TEST_MESSAGE_SIZE;
+
+ if (GNUNET_YES == test_core)
+ {
+ GNUNET_assert (NULL == p->cth);
+ p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0,
+ GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE,
+ &comm_send_pong_ready, p);
+ }
+ else
+ {
+ GNUNET_assert (NULL == p->tth);
+ p->tth = GNUNET_TRANSPORT_notify_transmit_ready (me->th, &p->dest->id,
+ TEST_MESSAGE_SIZE, 0, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready,
+ p);
+ }
+ return GNUNET_OK;