aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_scheduling.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-22 21:43:13 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-22 21:43:13 +0000
commit03c7d2c186ae7371ce5be6fddd376faf90c44e53 (patch)
tree1a961bd69ed3f758a218df2d5166ffea7a000870 /src/ats/gnunet-service-ats_scheduling.c
parent8c0022803d0a2f74b8f8e3fbbbb9afddf2b621bc (diff)
downloadgnunet-03c7d2c186ae7371ce5be6fddd376faf90c44e53.tar.gz
gnunet-03c7d2c186ae7371ce5be6fddd376faf90c44e53.zip
also simplify message format for AddressSuggestionMessage
Diffstat (limited to 'src/ats/gnunet-service-ats_scheduling.c')
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c61
1 files changed, 14 insertions, 47 deletions
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index d89b274a4..65645d1f0 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -89,70 +89,37 @@ GAS_scheduling_remove_client (struct GNUNET_SERVER_Client *client)
89 * clients. 89 * clients.
90 * 90 *
91 * @param peer peer for which this is an address suggestion 91 * @param peer peer for which this is an address suggestion
92 * @param plugin_name 0-termintated string specifying the transport plugin
93 * @param plugin_addr binary address for the plugin to use
94 * @param plugin_addr_len number of bytes in @a plugin_addr
95 * @param local_address_info the local address for the address
96 * @param session_id session ID to use for the given client 92 * @param session_id session ID to use for the given client
97 * @param atsi performance data for the address
98 * @param atsi_count number of performance records in @a atsi
99 * @param bandwidth_out assigned outbound bandwidth 93 * @param bandwidth_out assigned outbound bandwidth
100 * @param bandwidth_in assigned inbound bandwidth 94 * @param bandwidth_in assigned inbound bandwidth
101 */ 95 */
102void 96void
103GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *peer, 97GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *peer,
104 const char *plugin_name,
105 const void *plugin_addr,
106 size_t plugin_addr_len,
107 uint32_t local_address_info,
108 uint32_t session_id, 98 uint32_t session_id,
109 const struct GNUNET_ATS_Information *atsi,
110 uint32_t atsi_count,
111 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 99 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
112 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 100 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
113{ 101{
114 struct AddressSuggestionMessage *msg; 102 struct AddressSuggestionMessage msg;
115 size_t plugin_name_length = strlen (plugin_name) + 1; 103
116 size_t msize = 104 if (NULL == my_client)
117 sizeof (struct AddressSuggestionMessage) +
118 atsi_count * sizeof (struct GNUNET_ATS_Information) + plugin_addr_len +
119 plugin_name_length;
120 char buf[msize] GNUNET_ALIGN;
121 struct GNUNET_ATS_Information *atsp;
122 char *addrp;
123
124 if (my_client == NULL)
125 return; 105 return;
126 GNUNET_STATISTICS_update (GSA_stats, "# address suggestions made", 1, 106 GNUNET_STATISTICS_update (GSA_stats,
107 "# address suggestions made", 1,
127 GNUNET_NO); 108 GNUNET_NO);
128 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); 109 msg.header.size = htons (sizeof (struct AddressSuggestionMessage));
129 GNUNET_assert (atsi_count < 110 msg.header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION);
130 GNUNET_SERVER_MAX_MESSAGE_SIZE / 111 msg.peer = *peer;
131 sizeof (struct GNUNET_ATS_Information)); 112 msg.session_id = htonl (session_id);
132 msg = (struct AddressSuggestionMessage *) buf; 113 msg.bandwidth_out = bandwidth_out;
133 msg->header.size = htons (msize); 114 msg.bandwidth_in = bandwidth_in;
134 msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION);
135 msg->ats_count = htonl (atsi_count);
136 msg->peer = *peer;
137 msg->address_length = htons (plugin_addr_len);
138 msg->plugin_name_length = htons (plugin_name_length);
139 msg->address_local_info = htonl (local_address_info);
140 msg->session_id = htonl (session_id);
141 msg->bandwidth_out = bandwidth_out;
142 msg->bandwidth_in = bandwidth_in;
143 atsp = (struct GNUNET_ATS_Information *) &msg[1];
144 memcpy (atsp, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
145 addrp = (char *) &atsp[atsi_count];
146 memcpy (addrp, plugin_addr, plugin_addr_len);
147 strcpy (&addrp[plugin_addr_len], plugin_name);
148
149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
150 "ATS sends quota for peer `%s': (in/out) %u/%u\n", 116 "ATS sends quota for peer `%s': (in/out) %u/%u\n",
151 GNUNET_i2s (peer), 117 GNUNET_i2s (peer),
152 (unsigned int) ntohl (bandwidth_in.value__), 118 (unsigned int) ntohl (bandwidth_in.value__),
153 (unsigned int) ntohl (bandwidth_out.value__)); 119 (unsigned int) ntohl (bandwidth_out.value__));
154 120 GNUNET_SERVER_notification_context_unicast (nc,
155 GNUNET_SERVER_notification_context_unicast (nc, my_client, &msg->header, 121 my_client,
122 &msg.header,
156 GNUNET_YES); 123 GNUNET_YES);
157} 124}
158 125