- struct Neighbour *n = cls;
- struct GNUNET_TIME_Relative retry;
- struct GNUNET_TIME_Relative left;
- struct MessageEntry *me;
- struct PingMessage pp;
- struct PingMessage *pm;
- struct GNUNET_CRYPTO_AesInitializationVector iv;
-
- n->keep_alive_task = GNUNET_SCHEDULER_NO_TASK;
- /* send PING */
- me = GNUNET_malloc (sizeof (struct MessageEntry) +
- sizeof (struct PingMessage));
- me->deadline = GNUNET_TIME_relative_to_absolute (MAX_PING_DELAY);
- me->priority = PING_PRIORITY;
- me->size = sizeof (struct PingMessage);
- GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail,
- n->encrypted_tail, me);
- pm = (struct PingMessage *) &me[1];
- pm->header.size = htons (sizeof (struct PingMessage));
- pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING);
- pm->iv_seed =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
- derive_iv (&iv, &n->encrypt_key, pm->iv_seed, &n->peer);
- pp.challenge = n->ping_challenge;
- pp.target = n->peer;
-#if DEBUG_HANDSHAKE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Encrypting `%s' message with challenge %u for `%4s' using key %u, IV %u (salt %u).\n",
- "PING", (unsigned int) n->ping_challenge, GNUNET_i2s (&n->peer),
- (unsigned int) n->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv,
- sizeof
- (iv)),
- pm->iv_seed);
-#endif
- do_encrypt (n, &iv, &pp.target, &pm->target,
- sizeof (struct PingMessage) - ((void *) &pm->target -
- (void *) pm));
- process_encrypted_neighbour_queue (n);
- /* reschedule PING job */
- left = GNUNET_TIME_absolute_get_remaining (get_neighbour_timeout (n));
- retry =
- GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2),
- MIN_PING_FREQUENCY);
- n->keep_alive_task =
- GNUNET_SCHEDULER_add_delayed (retry, &send_keep_alive, n);
-
+ const struct GNUNET_MessageHeader *hdr = cls;
+ struct Session *session = value;
+ struct SessionMessageEntry *m;
+ uint16_t size;
+
+ size = ntohs (hdr->size);
+ m = GNUNET_malloc (sizeof (struct SessionMessageEntry) + size);
+ memcpy (&m[1], hdr, size);
+ m->size = size;
+ GNUNET_CONTAINER_DLL_insert (session->sme_head, session->sme_tail, m);
+ try_transmission (session);
+ return GNUNET_OK;