[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21050 - gnunet/src/core
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21050 - gnunet/src/core |
Date: |
Thu, 19 Apr 2012 21:37:03 +0200 |
Author: grothoff
Date: 2012-04-19 21:37:03 +0200 (Thu, 19 Apr 2012)
New Revision: 21050
Modified:
gnunet/src/core/core.h
gnunet/src/core/core_api.c
gnunet/src/core/gnunet-service-core_clients.c
Log:
-remove ATS 0-termination in NotifyTrafficMessage (#2275)
Modified: gnunet/src/core/core.h
===================================================================
--- gnunet/src/core/core.h 2012-04-19 19:36:30 UTC (rev 21049)
+++ gnunet/src/core/core.h 2012-04-19 19:37:03 UTC (rev 21050)
@@ -222,12 +222,11 @@
*/
struct GNUNET_PeerIdentity peer;
- /**
- * First of the ATS information blocks (we must have at least
- * one due to the 0-termination requirement).
+ /* Followed by ATS information blocks:
+ * struct GNUNET_ATS_Information ats[ats_count]
*/
- struct GNUNET_ATS_Information ats;
+ /* Followed by payload (message or just header), variable size */
};
Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c 2012-04-19 19:36:30 UTC (rev 21049)
+++ gnunet/src/core/core_api.c 2012-04-19 19:37:03 UTC (rev 21050)
@@ -907,19 +907,18 @@
return;
}
ntm = (const struct NotifyTrafficMessage *) msg;
-
ats_count = ntohl (ntm->ats_count);
if ((msize <
sizeof (struct NotifyTrafficMessage) +
ats_count * sizeof (struct GNUNET_ATS_Information) +
- sizeof (struct GNUNET_MessageHeader)) ||
- (GNUNET_ATS_ARRAY_TERMINATOR != ntohl ((&ntm->ats)[ats_count].type)))
+ sizeof (struct GNUNET_MessageHeader)) )
{
GNUNET_break (0);
reconnect_later (h);
return;
}
- em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1];
+ ats = (const struct GNUNET_ATS_Information*) &ntm[1];
+ em = (const struct GNUNET_MessageHeader *) &ats[ats_count];
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %u and size %u from peer `%4s'\n",
ntohs (em->type), ntohs (em->size), GNUNET_i2s (&ntm->peer));
@@ -954,7 +953,7 @@
return;
}
if (GNUNET_OK !=
- h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats,
+ h->handlers[hpos].callback (h->cls, &ntm->peer, em, ats,
ats_count))
{
/* error in processing, do not process other messages! */
@@ -962,7 +961,7 @@
}
}
if (NULL != h->inbound_notify)
- h->inbound_notify (h->cls, &ntm->peer, em, &ntm->ats, ats_count);
+ h->inbound_notify (h->cls, &ntm->peer, em, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND:
if (msize < sizeof (struct NotifyTrafficMessage))
@@ -982,14 +981,14 @@
if ((msize <
sizeof (struct NotifyTrafficMessage) +
ats_count * sizeof (struct GNUNET_ATS_Information) +
- sizeof (struct GNUNET_MessageHeader)) ||
- (GNUNET_ATS_ARRAY_TERMINATOR != ntohl ((&ntm->ats)[ats_count].type)))
+ sizeof (struct GNUNET_MessageHeader)) )
{
GNUNET_break (0);
reconnect_later (h);
return;
}
- em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1];
+ ats = (const struct GNUNET_ATS_Information*) &ntm[1];
+ em = (const struct GNUNET_MessageHeader *) &ats[ats_count];
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received notification about transmission to `%s'.\n",
GNUNET_i2s (&ntm->peer));
@@ -1007,7 +1006,7 @@
GNUNET_break (0);
break;
}
- h->outbound_notify (h->cls, &ntm->peer, em, &ntm->ats, ats_count);
+ h->outbound_notify (h->cls, &ntm->peer, em, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_CORE_SEND_READY:
if (msize != sizeof (struct SendMessageReady))
Modified: gnunet/src/core/gnunet-service-core_clients.c
===================================================================
--- gnunet/src/core/gnunet-service-core_clients.c 2012-04-19 19:36:30 UTC
(rev 21049)
+++ gnunet/src/core/gnunet-service-core_clients.c 2012-04-19 19:37:03 UTC
(rev 21050)
@@ -846,11 +846,9 @@
ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND);
ntm->ats_count = htonl (atsi_count);
ntm->peer = *sender;
- a = &ntm->ats;
+ a = (struct GNUNET_ATS_Information*) &ntm[1];
memcpy (a, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
- a[atsi_count].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
- a[atsi_count].value = htonl (0);
- memcpy (&a[atsi_count + 1], msg, msize);
+ memcpy (&a[atsi_count], msg, msize);
send_to_all_clients (sender, &ntm->header, GNUNET_YES, options,
ntohs (msg->type));
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21050 - gnunet/src/core,
gnunet <=