aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-22 21:08:43 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-22 21:08:43 +0000
commit9c95f4ea09fa61fc193fc45873f76bf6fe6d93f3 (patch)
treec11ef2beef617c7f992fc447d3b017c9d8e667c6 /src/ats
parent0c19c26a8a2d5b05ed8fc8abfca49cce2005c9ef (diff)
downloadgnunet-9c95f4ea09fa61fc193fc45873f76bf6fe6d93f3.tar.gz
gnunet-9c95f4ea09fa61fc193fc45873f76bf6fe6d93f3.zip
split structs for address adding and updating
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/ats.h51
-rw-r--r--src/ats/ats_api_scheduling.c6
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c8
3 files changed, 58 insertions, 7 deletions
diff --git a/src/ats/ats.h b/src/ats/ats.h
index 61c3bd148..a480f5d79 100644
--- a/src/ats/ats.h
+++ b/src/ats/ats.h
@@ -75,6 +75,57 @@ struct ResetBackoffMessage
75}; 75};
76 76
77 77
78/**
79 * ATS client to ATS service: here is another address you can use.
80 */
81struct AddressAddMessage
82{
83 /**
84 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD.
85 */
86 struct GNUNET_MessageHeader header;
87
88 /**
89 * Size of the `struct GNUNET_ATS_Information` array that follows this struct.
90 */
91 uint32_t ats_count GNUNET_PACKED;
92
93 /**
94 * Identity of the peer that this address is for.
95 */
96 struct GNUNET_PeerIdentity peer;
97
98 /**
99 * Number of bytes in the address that follows this struct.
100 */
101 uint16_t address_length GNUNET_PACKED;
102
103 /**
104 * Number of bytes in the plugin name that follows this struct.
105 */
106 uint16_t plugin_name_length GNUNET_PACKED;
107
108 /**
109 * Internal number this client will henceforth use to
110 * refer to this address.
111 */
112 uint32_t session_id GNUNET_PACKED;
113
114 /**
115 * Local-only information of the address, see
116 * `enum GNUNET_HELLO_AddressInfo`.
117 */
118 uint32_t address_local_info GNUNET_PACKED;
119
120 /* followed by:
121 * - struct GNUNET_ATS_Information [ats_count];
122 * - char address[address_length]
123 * - char plugin_name[plugin_name_length] (including '\0'-termination).
124 */
125
126};
127
128
78struct AddressUpdateMessage 129struct AddressUpdateMessage
79{ 130{
80 struct GNUNET_MessageHeader header; 131 struct GNUNET_MessageHeader header;
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index 75ccd6b5b..1b729f75e 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -556,8 +556,8 @@ error_handler (void *cls,
556 556
557 557
558/** 558/**
559 * Generate the "AddressUpdateMessage" for the given 559 * Generate and transmit the `struct AddressAddMessage` for the given
560 * session record. 560 * address record.
561 * 561 *
562 * @param sh the scheduling handle to use for transmission 562 * @param sh the scheduling handle to use for transmission
563 * @param ar the address to inform the ATS service about 563 * @param ar the address to inform the ATS service about
@@ -567,7 +567,7 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh,
567 const struct GNUNET_ATS_AddressRecord *ar) 567 const struct GNUNET_ATS_AddressRecord *ar)
568{ 568{
569 struct GNUNET_MQ_Envelope *ev; 569 struct GNUNET_MQ_Envelope *ev;
570 struct AddressUpdateMessage *m; 570 struct AddressAddMessage *m;
571 struct GNUNET_ATS_Information *am; 571 struct GNUNET_ATS_Information *am;
572 char *pm; 572 char *pm;
573 size_t namelen; 573 size_t namelen;
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index 0d8b0fa25..b0a52f39c 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -241,7 +241,7 @@ GAS_handle_address_add (void *cls,
241 struct GNUNET_SERVER_Client *client, 241 struct GNUNET_SERVER_Client *client,
242 const struct GNUNET_MessageHeader *message) 242 const struct GNUNET_MessageHeader *message)
243{ 243{
244 const struct AddressUpdateMessage *m; 244 const struct AddressAddMessage *m;
245 const struct GNUNET_ATS_Information *atsi; 245 const struct GNUNET_ATS_Information *atsi;
246 const char *address; 246 const char *address;
247 const char *plugin_name; 247 const char *plugin_name;
@@ -254,13 +254,13 @@ GAS_handle_address_add (void *cls,
254 "Received `%s' message\n", 254 "Received `%s' message\n",
255 "ADDRESS_ADD"); 255 "ADDRESS_ADD");
256 size = ntohs (message->size); 256 size = ntohs (message->size);
257 if (size < sizeof (struct AddressUpdateMessage)) 257 if (size < sizeof (struct AddressAddMessage))
258 { 258 {
259 GNUNET_break (0); 259 GNUNET_break (0);
260 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 260 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
261 return; 261 return;
262 } 262 }
263 m = (const struct AddressUpdateMessage *) message; 263 m = (const struct AddressAddMessage *) message;
264 ats_count = ntohl (m->ats_count); 264 ats_count = ntohl (m->ats_count);
265 address_length = ntohs (m->address_length); 265 address_length = ntohs (m->address_length);
266 plugin_name_length = ntohs (m->plugin_name_length); 266 plugin_name_length = ntohs (m->plugin_name_length);
@@ -273,7 +273,7 @@ GAS_handle_address_add (void *cls,
273 273
274 if ((address_length + plugin_name_length + 274 if ((address_length + plugin_name_length +
275 ats_count * sizeof (struct GNUNET_ATS_Information) + 275 ats_count * sizeof (struct GNUNET_ATS_Information) +
276 sizeof (struct AddressUpdateMessage) != ntohs (message->size)) || 276 sizeof (struct AddressAddMessage) != ntohs (message->size)) ||
277 (ats_count > 277 (ats_count >
278 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) || 278 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) ||
279 ((plugin_name_length > 0) && (plugin_name[plugin_name_length - 1] != '\0'))) 279 ((plugin_name_length > 0) && (plugin_name[plugin_name_length - 1] != '\0')))