aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-04-19 19:37:03 +0000
committerChristian Grothoff <christian@grothoff.org>2012-04-19 19:37:03 +0000
commit368629854cbdcdd5ee8c40f3f27e4e77f8e60e90 (patch)
tree82a769caca46986f16b28ce1ee4b147ca12da304 /src/core
parent879fe24200b5e0e451dbc4f8fa76cf240d0b7eec (diff)
downloadgnunet-368629854cbdcdd5ee8c40f3f27e4e77f8e60e90.tar.gz
gnunet-368629854cbdcdd5ee8c40f3f27e4e77f8e60e90.zip
-remove ATS 0-termination in NotifyTrafficMessage (#2275)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.h7
-rw-r--r--src/core/core_api.c19
-rw-r--r--src/core/gnunet-service-core_clients.c6
3 files changed, 14 insertions, 18 deletions
diff --git a/src/core/core.h b/src/core/core.h
index 9b342c3eb..53c828037 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -222,12 +222,11 @@ struct NotifyTrafficMessage
222 */ 222 */
223 struct GNUNET_PeerIdentity peer; 223 struct GNUNET_PeerIdentity peer;
224 224
225 /** 225 /* Followed by ATS information blocks:
226 * First of the ATS information blocks (we must have at least 226 * struct GNUNET_ATS_Information ats[ats_count]
227 * one due to the 0-termination requirement).
228 */ 227 */
229 struct GNUNET_ATS_Information ats;
230 228
229 /* Followed by payload (message or just header), variable size */
231}; 230};
232 231
233 232
diff --git a/src/core/core_api.c b/src/core/core_api.c
index 1a4b23333..d6cb68213 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -907,19 +907,18 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
907 return; 907 return;
908 } 908 }
909 ntm = (const struct NotifyTrafficMessage *) msg; 909 ntm = (const struct NotifyTrafficMessage *) msg;
910
911 ats_count = ntohl (ntm->ats_count); 910 ats_count = ntohl (ntm->ats_count);
912 if ((msize < 911 if ((msize <
913 sizeof (struct NotifyTrafficMessage) + 912 sizeof (struct NotifyTrafficMessage) +
914 ats_count * sizeof (struct GNUNET_ATS_Information) + 913 ats_count * sizeof (struct GNUNET_ATS_Information) +
915 sizeof (struct GNUNET_MessageHeader)) || 914 sizeof (struct GNUNET_MessageHeader)) )
916 (GNUNET_ATS_ARRAY_TERMINATOR != ntohl ((&ntm->ats)[ats_count].type)))
917 { 915 {
918 GNUNET_break (0); 916 GNUNET_break (0);
919 reconnect_later (h); 917 reconnect_later (h);
920 return; 918 return;
921 } 919 }
922 em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1]; 920 ats = (const struct GNUNET_ATS_Information*) &ntm[1];
921 em = (const struct GNUNET_MessageHeader *) &ats[ats_count];
923 LOG (GNUNET_ERROR_TYPE_DEBUG, 922 LOG (GNUNET_ERROR_TYPE_DEBUG,
924 "Received message of type %u and size %u from peer `%4s'\n", 923 "Received message of type %u and size %u from peer `%4s'\n",
925 ntohs (em->type), ntohs (em->size), GNUNET_i2s (&ntm->peer)); 924 ntohs (em->type), ntohs (em->size), GNUNET_i2s (&ntm->peer));
@@ -954,7 +953,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
954 return; 953 return;
955 } 954 }
956 if (GNUNET_OK != 955 if (GNUNET_OK !=
957 h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats, 956 h->handlers[hpos].callback (h->cls, &ntm->peer, em, ats,
958 ats_count)) 957 ats_count))
959 { 958 {
960 /* error in processing, do not process other messages! */ 959 /* error in processing, do not process other messages! */
@@ -962,7 +961,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
962 } 961 }
963 } 962 }
964 if (NULL != h->inbound_notify) 963 if (NULL != h->inbound_notify)
965 h->inbound_notify (h->cls, &ntm->peer, em, &ntm->ats, ats_count); 964 h->inbound_notify (h->cls, &ntm->peer, em, ats, ats_count);
966 break; 965 break;
967 case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND: 966 case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND:
968 if (msize < sizeof (struct NotifyTrafficMessage)) 967 if (msize < sizeof (struct NotifyTrafficMessage))
@@ -982,14 +981,14 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
982 if ((msize < 981 if ((msize <
983 sizeof (struct NotifyTrafficMessage) + 982 sizeof (struct NotifyTrafficMessage) +
984 ats_count * sizeof (struct GNUNET_ATS_Information) + 983 ats_count * sizeof (struct GNUNET_ATS_Information) +
985 sizeof (struct GNUNET_MessageHeader)) || 984 sizeof (struct GNUNET_MessageHeader)) )
986 (GNUNET_ATS_ARRAY_TERMINATOR != ntohl ((&ntm->ats)[ats_count].type)))
987 { 985 {
988 GNUNET_break (0); 986 GNUNET_break (0);
989 reconnect_later (h); 987 reconnect_later (h);
990 return; 988 return;
991 } 989 }
992 em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1]; 990 ats = (const struct GNUNET_ATS_Information*) &ntm[1];
991 em = (const struct GNUNET_MessageHeader *) &ats[ats_count];
993 LOG (GNUNET_ERROR_TYPE_DEBUG, 992 LOG (GNUNET_ERROR_TYPE_DEBUG,
994 "Received notification about transmission to `%s'.\n", 993 "Received notification about transmission to `%s'.\n",
995 GNUNET_i2s (&ntm->peer)); 994 GNUNET_i2s (&ntm->peer));
@@ -1007,7 +1006,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
1007 GNUNET_break (0); 1006 GNUNET_break (0);
1008 break; 1007 break;
1009 } 1008 }
1010 h->outbound_notify (h->cls, &ntm->peer, em, &ntm->ats, ats_count); 1009 h->outbound_notify (h->cls, &ntm->peer, em, ats, ats_count);
1011 break; 1010 break;
1012 case GNUNET_MESSAGE_TYPE_CORE_SEND_READY: 1011 case GNUNET_MESSAGE_TYPE_CORE_SEND_READY:
1013 if (msize != sizeof (struct SendMessageReady)) 1012 if (msize != sizeof (struct SendMessageReady))
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c
index 200f15c8e..621f8604a 100644
--- a/src/core/gnunet-service-core_clients.c
+++ b/src/core/gnunet-service-core_clients.c
@@ -846,11 +846,9 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
846 ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND); 846 ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND);
847 ntm->ats_count = htonl (atsi_count); 847 ntm->ats_count = htonl (atsi_count);
848 ntm->peer = *sender; 848 ntm->peer = *sender;
849 a = &ntm->ats; 849 a = (struct GNUNET_ATS_Information*) &ntm[1];
850 memcpy (a, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count); 850 memcpy (a, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
851 a[atsi_count].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR); 851 memcpy (&a[atsi_count], msg, msize);
852 a[atsi_count].value = htonl (0);
853 memcpy (&a[atsi_count + 1], msg, msize);
854 send_to_all_clients (sender, &ntm->header, GNUNET_YES, options, 852 send_to_all_clients (sender, &ntm->header, GNUNET_YES, options,
855 ntohs (msg->type)); 853 ntohs (msg->type));
856} 854}