sender_address_len = ntohl(received_msg->sender_address_len);
GNUNET_assert(ntohs(msg->size) == (sizeof(struct GNUNET_DV_MessageReceived) + packed_msg_len + sender_address_len));
sender_address_len = ntohl(received_msg->sender_address_len);
GNUNET_assert(ntohs(msg->size) == (sizeof(struct GNUNET_DV_MessageReceived) + packed_msg_len + sender_address_len));
sender_address = GNUNET_malloc(sender_address_len);
memcpy(sender_address, &received_msg[1], sender_address_len);
packed_msg_start = (char *)&received_msg[1];
sender_address = GNUNET_malloc(sender_address_len);
memcpy(sender_address, &received_msg[1], sender_address_len);
packed_msg_start = (char *)&received_msg[1];
send_result_msg = (struct GNUNET_DV_SendResultMessage *)msg;
hash_from_uid(ntohl(send_result_msg->uid), &uidhash);
send_ctx = GNUNET_CONTAINER_multihashmap_get(handle->send_callbacks, &uidhash);
send_result_msg = (struct GNUNET_DV_SendResultMessage *)msg;
hash_from_uid(ntohl(send_result_msg->uid), &uidhash);
send_ctx = GNUNET_CONTAINER_multihashmap_get(handle->send_callbacks, &uidhash);
if (ntohl(send_result_msg->result) == 0)
{
send_ctx->cont(send_ctx->cont_cls, &send_ctx->target, GNUNET_OK);
if (ntohl(send_result_msg->result) == 0)
{
send_ctx->cont(send_ctx->cont_cls, &send_ctx->target, GNUNET_OK);
-#if DEBUG_DV
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV SEND called with message of size %d, address size %d, total size to send is %d\n", msgbuf_size, addrlen, sizeof(struct GNUNET_DV_SendMessage) + msgbuf_size + addrlen);
-#endif
+ int msize;
+#if DEBUG_DV_MESSAGES
+ dv_handle->uid_gen = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX);
+#else
- msg = GNUNET_malloc(sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size);
- msg->header.size = htons(sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size);
+#endif
+
+ msize = sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size;
+ msg = GNUNET_malloc(msize);
+ msg->header.size = htons(msize);
msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND);
memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity));
msg->msgbuf_size = htonl(msgbuf_size);
msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND);
memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity));
msg->msgbuf_size = htonl(msgbuf_size);
end_of_message = &end_of_message[addrlen];
memcpy(end_of_message, msgbuf, msgbuf_size);
add_pending(dv_handle, msg);
end_of_message = &end_of_message[addrlen];
memcpy(end_of_message, msgbuf, msgbuf_size);
add_pending(dv_handle, msg);
send_ctx->cont_cls = cont_cls;
memcpy(&send_ctx->target, target, sizeof(struct GNUNET_PeerIdentity));
send_ctx->cont_cls = cont_cls;
memcpy(&send_ctx->target, target, sizeof(struct GNUNET_PeerIdentity));
GNUNET_CONTAINER_multihashmap_put(dv_handle->send_callbacks, &uidhash, send_ctx, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
return GNUNET_OK;
GNUNET_CONTAINER_multihashmap_put(dv_handle->send_callbacks, &uidhash, send_ctx, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
return GNUNET_OK;