diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-22 21:25:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-22 21:25:54 +0000 |
commit | 750da2796162b92c533f9666104c47407ed09e46 (patch) | |
tree | b1fe3ec2ca36854a15fd8e97760d05e9a54836b9 /src/ats | |
parent | 9c95f4ea09fa61fc193fc45873f76bf6fe6d93f3 (diff) | |
download | gnunet-750da2796162b92c533f9666104c47407ed09e46.tar.gz gnunet-750da2796162b92c533f9666104c47407ed09e46.zip |
simplifying IPC for address in use and address update
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/ats.h | 61 | ||||
-rw-r--r-- | src/ats/ats_api_scheduling.c | 41 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats.c | 3 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 123 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.h | 21 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_scheduling.c | 65 |
6 files changed, 110 insertions, 204 deletions
diff --git a/src/ats/ats.h b/src/ats/ats.h index a480f5d79..fd66013f4 100644 --- a/src/ats/ats.h +++ b/src/ats/ats.h | |||
@@ -86,7 +86,7 @@ struct AddressAddMessage | |||
86 | struct GNUNET_MessageHeader header; | 86 | struct GNUNET_MessageHeader header; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Size of the `struct GNUNET_ATS_Information` array that follows this struct. | 89 | * Length of the `struct GNUNET_ATS_Information` array that follows this struct. |
90 | */ | 90 | */ |
91 | uint32_t ats_count GNUNET_PACKED; | 91 | uint32_t ats_count GNUNET_PACKED; |
92 | 92 | ||
@@ -126,51 +126,68 @@ struct AddressAddMessage | |||
126 | }; | 126 | }; |
127 | 127 | ||
128 | 128 | ||
129 | /** | ||
130 | * Message used to notify ATS that the performance | ||
131 | * characteristics for an address have changed. | ||
132 | */ | ||
129 | struct AddressUpdateMessage | 133 | struct AddressUpdateMessage |
130 | { | 134 | { |
135 | /** | ||
136 | * Message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE. | ||
137 | */ | ||
131 | struct GNUNET_MessageHeader header; | 138 | struct GNUNET_MessageHeader header; |
132 | 139 | ||
140 | /** | ||
141 | * Length of the `struct GNUNET_ATS_Information` array that follows. | ||
142 | */ | ||
133 | uint32_t ats_count GNUNET_PACKED; | 143 | uint32_t ats_count GNUNET_PACKED; |
134 | 144 | ||
145 | /** | ||
146 | * Which peer is this about? (Technically redundant, as the | ||
147 | * @e session_id should be sufficient, but enables ATS service | ||
148 | * to find the session faster). | ||
149 | */ | ||
135 | struct GNUNET_PeerIdentity peer; | 150 | struct GNUNET_PeerIdentity peer; |
136 | 151 | ||
137 | 152 | /** | |
138 | uint16_t address_length GNUNET_PACKED; | 153 | * Internal number this client uses to refer to this address. |
139 | 154 | */ | |
140 | uint16_t plugin_name_length GNUNET_PACKED; | ||
141 | |||
142 | uint32_t session_id GNUNET_PACKED; | 155 | uint32_t session_id GNUNET_PACKED; |
143 | 156 | ||
144 | uint32_t address_local_info GNUNET_PACKED; | ||
145 | |||
146 | /* followed by: | 157 | /* followed by: |
147 | * - struct GNUNET_ATS_Information [ats_count]; | 158 | * - struct GNUNET_ATS_Information [ats_count]; |
148 | * - char address[address_length] | ||
149 | * - char plugin_name[plugin_name_length] (including '\0'-termination). | ||
150 | */ | 159 | */ |
151 | 160 | ||
152 | }; | 161 | }; |
153 | 162 | ||
163 | |||
164 | /** | ||
165 | * Message sent from ATS client to ATS service to notify | ||
166 | * it if we started (or stopped) using an address. | ||
167 | */ | ||
154 | struct AddressUseMessage | 168 | struct AddressUseMessage |
155 | { | 169 | { |
170 | /** | ||
171 | * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE. | ||
172 | */ | ||
156 | struct GNUNET_MessageHeader header; | 173 | struct GNUNET_MessageHeader header; |
157 | 174 | ||
158 | struct GNUNET_PeerIdentity peer; | 175 | /** |
159 | 176 | * Internal number this client uses to refer to this address. | |
160 | uint16_t in_use GNUNET_PACKED; | 177 | */ |
161 | |||
162 | uint16_t address_length GNUNET_PACKED; | ||
163 | |||
164 | uint16_t plugin_name_length GNUNET_PACKED; | ||
165 | |||
166 | uint32_t session_id GNUNET_PACKED; | 178 | uint32_t session_id GNUNET_PACKED; |
167 | 179 | ||
168 | uint32_t address_local_info GNUNET_PACKED; | 180 | /** |
181 | * Which peer is this about? (Technically redundant, as the | ||
182 | * @e session_id should be sufficient, but enables ATS service | ||
183 | * to find the session faster). | ||
184 | */ | ||
185 | struct GNUNET_PeerIdentity peer; | ||
169 | 186 | ||
170 | /* followed by: | 187 | /** |
171 | * - char address[address_length] | 188 | * #GNUNET_YES or #GNUNET_NO. |
172 | * - char plugin_name[plugin_name_length] (including '\0'-termination). | ||
173 | */ | 189 | */ |
190 | uint32_t in_use GNUNET_PACKED; | ||
174 | 191 | ||
175 | }; | 192 | }; |
176 | 193 | ||
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 1b729f75e..8fced8996 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -1319,8 +1319,6 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
1319 | struct GNUNET_MQ_Envelope *ev; | 1319 | struct GNUNET_MQ_Envelope *ev; |
1320 | struct AddressUpdateMessage *m; | 1320 | struct AddressUpdateMessage *m; |
1321 | struct GNUNET_ATS_Information *am; | 1321 | struct GNUNET_ATS_Information *am; |
1322 | char *pm; | ||
1323 | size_t namelen; | ||
1324 | size_t msize; | 1322 | size_t msize; |
1325 | 1323 | ||
1326 | GNUNET_array_grow (ar->ats, | 1324 | GNUNET_array_grow (ar->ats, |
@@ -1333,18 +1331,11 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
1333 | 1331 | ||
1334 | if (NULL == sh->mq) | 1332 | if (NULL == sh->mq) |
1335 | return; /* disconnected, skip for now */ | 1333 | return; /* disconnected, skip for now */ |
1336 | namelen = (NULL == ar->address->transport_name) | 1334 | msize = ar->ats_count * sizeof (struct GNUNET_ATS_Information); |
1337 | ? 0 | ||
1338 | : strlen (ar->address->transport_name) + 1; | ||
1339 | msize = ar->address->address_length + | ||
1340 | ar->ats_count * sizeof (struct GNUNET_ATS_Information) + namelen; | ||
1341 | 1335 | ||
1342 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); | 1336 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); |
1343 | m->ats_count = htonl (ar->ats_count); | 1337 | m->ats_count = htonl (ar->ats_count); |
1344 | m->peer = ar->address->peer; | 1338 | m->peer = ar->address->peer; |
1345 | m->address_length = htons (ar->address->address_length); | ||
1346 | m->address_local_info = htonl ((uint32_t) ar->address->local_info); | ||
1347 | m->plugin_name_length = htons (namelen); | ||
1348 | m->session_id = htonl (ar->slot); | 1339 | m->session_id = htonl (ar->slot); |
1349 | 1340 | ||
1350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1357,14 +1348,6 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
1357 | memcpy (am, | 1348 | memcpy (am, |
1358 | ar->ats, | 1349 | ar->ats, |
1359 | ar->ats_count * sizeof (struct GNUNET_ATS_Information)); | 1350 | ar->ats_count * sizeof (struct GNUNET_ATS_Information)); |
1360 | pm = (char *) &am[ar->ats_count]; | ||
1361 | memcpy (pm, | ||
1362 | ar->address->address, | ||
1363 | ar->address->address_length); | ||
1364 | if (NULL != ar->address->transport_name) | ||
1365 | memcpy (&pm[ar->address->address_length], | ||
1366 | ar->address->transport_name, | ||
1367 | namelen); | ||
1368 | GNUNET_MQ_send (sh->mq, ev); | 1351 | GNUNET_MQ_send (sh->mq, ev); |
1369 | } | 1352 | } |
1370 | 1353 | ||
@@ -1383,36 +1366,18 @@ GNUNET_ATS_address_set_in_use (struct GNUNET_ATS_AddressRecord *ar, | |||
1383 | struct GNUNET_ATS_SchedulingHandle *sh = ar->sh; | 1366 | struct GNUNET_ATS_SchedulingHandle *sh = ar->sh; |
1384 | struct GNUNET_MQ_Envelope *ev; | 1367 | struct GNUNET_MQ_Envelope *ev; |
1385 | struct AddressUseMessage *m; | 1368 | struct AddressUseMessage *m; |
1386 | char *pm; | ||
1387 | size_t namelen; | ||
1388 | size_t msize; | ||
1389 | 1369 | ||
1390 | ar->in_use = in_use; | 1370 | ar->in_use = in_use; |
1391 | namelen = (NULL == ar->address->transport_name) | 1371 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE); |
1392 | ? 0 | ||
1393 | : strlen (ar->address->transport_name) + 1; | ||
1394 | msize = ar->address->address_length + namelen; | ||
1395 | |||
1396 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE); | ||
1397 | m->peer = ar->address->peer; | 1372 | m->peer = ar->address->peer; |
1398 | m->in_use = htons (in_use); | 1373 | m->in_use = htonl ((uint32_t) in_use); |
1399 | m->address_length = htons (ar->address->address_length); | ||
1400 | m->address_local_info = htonl ((uint32_t) ar->address->local_info); | ||
1401 | m->plugin_name_length = htons (namelen); | ||
1402 | |||
1403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1404 | "Setting address used to %s for peer `%s', plugin `%s', session %p\n", | 1375 | "Setting address used to %s for peer `%s', plugin `%s', session %p\n", |
1405 | (GNUNET_YES == in_use) ? "YES" : "NO", | 1376 | (GNUNET_YES == in_use) ? "YES" : "NO", |
1406 | GNUNET_i2s (&ar->address->peer), | 1377 | GNUNET_i2s (&ar->address->peer), |
1407 | ar->address->transport_name, | 1378 | ar->address->transport_name, |
1408 | ar->session); | 1379 | ar->session); |
1409 | |||
1410 | m->session_id = htonl (ar->slot); | 1380 | m->session_id = htonl (ar->slot); |
1411 | pm = (char *) &m[1]; | ||
1412 | /* FIXME: no need to send the address data */ | ||
1413 | memcpy (pm, ar->address->address, ar->address->address_length); | ||
1414 | memcpy (&pm[ar->address->address_length], | ||
1415 | ar->address->transport_name, namelen); | ||
1416 | GNUNET_MQ_send (sh->mq, ev); | 1381 | GNUNET_MQ_send (sh->mq, ev); |
1417 | } | 1382 | } |
1418 | 1383 | ||
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c index db6ce6663..cf0bc0a39 100644 --- a/src/ats/gnunet-service-ats.c +++ b/src/ats/gnunet-service-ats.c | |||
@@ -165,7 +165,8 @@ run (void *cls, | |||
165 | {&GAS_handle_address_update, NULL, | 165 | {&GAS_handle_address_update, NULL, |
166 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0}, | 166 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0}, |
167 | {&GAS_handle_address_in_use, NULL, | 167 | {&GAS_handle_address_in_use, NULL, |
168 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE, 0}, | 168 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE, |
169 | sizeof (struct AddressUseMessage) }, | ||
169 | {&GAS_handle_address_destroyed, NULL, | 170 | {&GAS_handle_address_destroyed, NULL, |
170 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, 0}, | 171 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, 0}, |
171 | {&GAS_handle_reservation_request, NULL, | 172 | {&GAS_handle_reservation_request, NULL, |
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index abdc40c59..ff7b2b024 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -468,9 +468,9 @@ disassemble_ats_information (struct ATS_Address *dest, | |||
468 | static void | 468 | static void |
469 | free_address (struct ATS_Address *addr) | 469 | free_address (struct ATS_Address *addr) |
470 | { | 470 | { |
471 | GNUNET_free(addr->plugin); | 471 | GNUNET_free (addr->plugin); |
472 | GNUNET_free_non_null(addr->atsi); | 472 | GNUNET_free_non_null (addr->atsi); |
473 | GNUNET_free(addr); | 473 | GNUNET_free (addr); |
474 | } | 474 | } |
475 | 475 | ||
476 | 476 | ||
@@ -642,44 +642,69 @@ find_equivalent_address (struct GAS_Addresses_Handle *handle, | |||
642 | 642 | ||
643 | 643 | ||
644 | /** | 644 | /** |
645 | * Closure for #find_address_cb() | ||
646 | */ | ||
647 | struct FindAddressContext | ||
648 | { | ||
649 | /** | ||
650 | * Session Id to look for. | ||
651 | */ | ||
652 | uint32_t session_id; | ||
653 | |||
654 | /** | ||
655 | * Where to store matching address result. | ||
656 | */ | ||
657 | struct ATS_Address *exact_address; | ||
658 | |||
659 | }; | ||
660 | |||
661 | |||
662 | /** | ||
663 | * Find session matching given session ID. | ||
664 | * | ||
665 | * @param cls a `struct FindAddressContext` | ||
666 | * @param key peer id | ||
667 | * @param value the address to compare with | ||
668 | * @return #GNUNET_YES to continue, #GNUNET_NO if address is found | ||
669 | */ | ||
670 | static int | ||
671 | find_address_cb (void *cls, | ||
672 | const struct GNUNET_PeerIdentity *key, | ||
673 | void *value) | ||
674 | { | ||
675 | struct FindAddressContext *fac = cls; | ||
676 | struct ATS_Address *aa = value; | ||
677 | |||
678 | if (aa->session_id == fac->session_id) | ||
679 | { | ||
680 | fac->exact_address = aa; | ||
681 | return GNUNET_NO; | ||
682 | } | ||
683 | return GNUNET_YES; | ||
684 | } | ||
685 | |||
686 | |||
687 | /** | ||
645 | * Find the exact address | 688 | * Find the exact address |
646 | * | 689 | * |
647 | * @param handle the address handle to use | 690 | * @param handle the address handle to use |
648 | * @param peer peer | 691 | * @param peer peer |
649 | * @param plugin_name transport plugin name | ||
650 | * @param plugin_addr plugin address | ||
651 | * @param plugin_addr_len length of the plugin address | ||
652 | * @param local_address_info the local address for the address | ||
653 | * @param session_id session id, can never be 0 | 692 | * @param session_id session id, can never be 0 |
654 | * @return an ATS_address or NULL | 693 | * @return an ATS_address or NULL |
655 | */ | 694 | */ |
656 | static struct ATS_Address * | 695 | static struct ATS_Address * |
657 | find_exact_address (struct GAS_Addresses_Handle *handle, | 696 | find_exact_address (struct GAS_Addresses_Handle *handle, |
658 | const struct GNUNET_PeerIdentity *peer, | 697 | const struct GNUNET_PeerIdentity *peer, |
659 | const char *plugin_name, | ||
660 | const void *plugin_addr, | ||
661 | size_t plugin_addr_len, | ||
662 | uint32_t local_address_info, | ||
663 | uint32_t session_id) | 698 | uint32_t session_id) |
664 | { | 699 | { |
665 | struct ATS_Address *aa; | 700 | struct FindAddressContext fac; |
666 | struct ATS_Address *ea; | ||
667 | 701 | ||
668 | aa = create_address (peer, | 702 | fac.exact_address = NULL; |
669 | plugin_name, | 703 | fac.session_id = session_id; |
670 | plugin_addr, | 704 | GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, |
671 | plugin_addr_len, | 705 | peer, |
672 | local_address_info, | 706 | &find_address_cb, &fac); |
673 | session_id); | 707 | return fac.exact_address; |
674 | |||
675 | /* Get existing address or address with session == 0 */ | ||
676 | ea = find_equivalent_address (handle, peer, aa); | ||
677 | free_address (aa); | ||
678 | if (ea == NULL) | ||
679 | return NULL; | ||
680 | else if (ea->session_id != session_id) | ||
681 | return NULL; | ||
682 | return ea; | ||
683 | } | 708 | } |
684 | 709 | ||
685 | 710 | ||
@@ -918,28 +943,17 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
918 | 943 | ||
919 | 944 | ||
920 | /** | 945 | /** |
921 | * Update an address with a session or performance information for a peer. | 946 | * Update an address with new performance information for a peer. |
922 | * | ||
923 | * If an address was added without a session it will be updated with the | ||
924 | * session | ||
925 | * | 947 | * |
926 | * @param handle the address handle to use | 948 | * @param handle the address handle to use |
927 | * @param peer peer | 949 | * @param peer peer |
928 | * @param plugin_name transport plugin name | 950 | * @param session_id session id, never 0 |
929 | * @param plugin_addr plugin address | ||
930 | * @param plugin_addr_len length of the plugin address | ||
931 | * @param local_address_info the local address for the address | ||
932 | * @param session_id session id, can be 0 | ||
933 | * @param atsi performance information for this address | 951 | * @param atsi performance information for this address |
934 | * @param atsi_count number of performance information contained in @a atsi | 952 | * @param atsi_count number of performance information contained in @a atsi |
935 | */ | 953 | */ |
936 | void | 954 | void |
937 | GAS_addresses_update (struct GAS_Addresses_Handle *handle, | 955 | GAS_addresses_update (struct GAS_Addresses_Handle *handle, |
938 | const struct GNUNET_PeerIdentity *peer, | 956 | const struct GNUNET_PeerIdentity *peer, |
939 | const char *plugin_name, | ||
940 | const void *plugin_addr, | ||
941 | size_t plugin_addr_len, | ||
942 | uint32_t local_address_info, | ||
943 | uint32_t session_id, | 957 | uint32_t session_id, |
944 | const struct GNUNET_ATS_Information *atsi, | 958 | const struct GNUNET_ATS_Information *atsi, |
945 | uint32_t atsi_count) | 959 | uint32_t atsi_count) |
@@ -955,11 +969,10 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle, | |||
955 | GNUNET_assert (NULL != handle->addresses); | 969 | GNUNET_assert (NULL != handle->addresses); |
956 | 970 | ||
957 | /* Get existing address */ | 971 | /* Get existing address */ |
958 | aa = find_exact_address (handle, peer, plugin_name, plugin_addr, | 972 | aa = find_exact_address (handle, |
959 | plugin_addr_len, | 973 | peer, |
960 | local_address_info, | ||
961 | session_id); | 974 | session_id); |
962 | if (aa == NULL) | 975 | if (NULL == aa) |
963 | { | 976 | { |
964 | GNUNET_break (0); | 977 | GNUNET_break (0); |
965 | return; | 978 | return; |
@@ -1129,10 +1142,6 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | |||
1129 | /* Get existing address */ | 1142 | /* Get existing address */ |
1130 | ea = find_exact_address (handle, | 1143 | ea = find_exact_address (handle, |
1131 | peer, | 1144 | peer, |
1132 | plugin_name, | ||
1133 | plugin_addr, | ||
1134 | plugin_addr_len, | ||
1135 | local_address_info, | ||
1136 | session_id); | 1145 | session_id); |
1137 | if (NULL == ea) | 1146 | if (NULL == ea) |
1138 | { | 1147 | { |
@@ -1182,10 +1191,6 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | |||
1182 | * | 1191 | * |
1183 | * @param handle the address handle to use | 1192 | * @param handle the address handle to use |
1184 | * @param peer peer | 1193 | * @param peer peer |
1185 | * @param plugin_name transport plugin name | ||
1186 | * @param plugin_addr plugin address | ||
1187 | * @param plugin_addr_len length of the plugin address | ||
1188 | * @param local_address_info the local address for the address | ||
1189 | * @param session_id session id, can be 0 | 1194 | * @param session_id session id, can be 0 |
1190 | * @param in_use #GNUNET_YES if #GNUNET_NO FIXME | 1195 | * @param in_use #GNUNET_YES if #GNUNET_NO FIXME |
1191 | * @return #GNUNET_SYSERR on failure (address unknown ...) | 1196 | * @return #GNUNET_SYSERR on failure (address unknown ...) |
@@ -1193,10 +1198,6 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | |||
1193 | int | 1198 | int |
1194 | GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, | 1199 | GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, |
1195 | const struct GNUNET_PeerIdentity *peer, | 1200 | const struct GNUNET_PeerIdentity *peer, |
1196 | const char *plugin_name, | ||
1197 | const void *plugin_addr, | ||
1198 | size_t plugin_addr_len, | ||
1199 | uint32_t local_address_info, | ||
1200 | uint32_t session_id, | 1201 | uint32_t session_id, |
1201 | int in_use) | 1202 | int in_use) |
1202 | { | 1203 | { |
@@ -1209,17 +1210,13 @@ GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, | |||
1209 | if (GNUNET_NO == handle->running) | 1210 | if (GNUNET_NO == handle->running) |
1210 | return GNUNET_SYSERR; | 1211 | return GNUNET_SYSERR; |
1211 | ea = find_exact_address (handle, | 1212 | ea = find_exact_address (handle, |
1212 | peer, plugin_name, | 1213 | peer, |
1213 | plugin_addr, | ||
1214 | plugin_addr_len, | ||
1215 | local_address_info, | ||
1216 | session_id); | 1214 | session_id); |
1217 | if (NULL == ea) | 1215 | if (NULL == ea) |
1218 | { | 1216 | { |
1219 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1217 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1220 | "Trying to set unknown address `%s' `%s' `%u' to %s \n", | 1218 | "Trying to set unknown address `%s' `%u' to %s \n", |
1221 | GNUNET_i2s (peer), | 1219 | GNUNET_i2s (peer), |
1222 | plugin_name, | ||
1223 | session_id, | 1220 | session_id, |
1224 | (GNUNET_NO == in_use) ? "NO" : "YES"); | 1221 | (GNUNET_NO == in_use) ? "NO" : "YES"); |
1225 | GNUNET_break (0); | 1222 | GNUNET_break (0); |
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h index 5dea30d77..5348617be 100644 --- a/src/ats/gnunet-service-ats_addresses.h +++ b/src/ats/gnunet-service-ats_addresses.h | |||
@@ -473,10 +473,6 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
473 | * | 473 | * |
474 | * @param handle the address handle to use | 474 | * @param handle the address handle to use |
475 | * @param peer peer | 475 | * @param peer peer |
476 | * @param plugin_name transport plugin name | ||
477 | * @param plugin_addr plugin address | ||
478 | * @param plugin_addr_len length of the plugin address in @a plugin_addr | ||
479 | * @param local_address_info the local address for the address | ||
480 | * @param session_id session id, can never be 0 | 476 | * @param session_id session id, can never be 0 |
481 | * @param in_use #GNUNET_YES if #GNUNET_NO FIXME | 477 | * @param in_use #GNUNET_YES if #GNUNET_NO FIXME |
482 | * @return #GNUNET_SYSERR on failure (address unknown ...) | 478 | * @return #GNUNET_SYSERR on failure (address unknown ...) |
@@ -484,26 +480,15 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
484 | int | 480 | int |
485 | GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, | 481 | GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, |
486 | const struct GNUNET_PeerIdentity *peer, | 482 | const struct GNUNET_PeerIdentity *peer, |
487 | const char *plugin_name, | ||
488 | const void *plugin_addr, | ||
489 | size_t plugin_addr_len, | ||
490 | uint32_t local_address_info, | ||
491 | uint32_t session_id, | 483 | uint32_t session_id, |
492 | int in_use); | 484 | int in_use); |
493 | 485 | ||
494 | 486 | ||
495 | /** | 487 | /** |
496 | * Update an address with a session or performance information for a peer. | 488 | * Update an address with new performance information for a peer. |
497 | * | ||
498 | * If an address was added without a session it will be updated with the | ||
499 | * session | ||
500 | * | 489 | * |
501 | * @param handle the address handle to use | 490 | * @param handle the address handle to use |
502 | * @param peer peer | 491 | * @param peer peer |
503 | * @param plugin_name transport plugin name | ||
504 | * @param plugin_addr plugin address | ||
505 | * @param plugin_addr_len length of the plugin address | ||
506 | * @param local_address_info the local address for the address | ||
507 | * @param session_id session id, can never be 0 | 492 | * @param session_id session id, can never be 0 |
508 | * @param atsi performance information for this address | 493 | * @param atsi performance information for this address |
509 | * @param atsi_count number of performance information contained in @a atsi | 494 | * @param atsi_count number of performance information contained in @a atsi |
@@ -511,10 +496,6 @@ GAS_addresses_in_use (struct GAS_Addresses_Handle *handle, | |||
511 | void | 496 | void |
512 | GAS_addresses_update (struct GAS_Addresses_Handle *handle, | 497 | GAS_addresses_update (struct GAS_Addresses_Handle *handle, |
513 | const struct GNUNET_PeerIdentity *peer, | 498 | const struct GNUNET_PeerIdentity *peer, |
514 | const char *plugin_name, | ||
515 | const void *plugin_addr, | ||
516 | size_t plugin_addr_len, | ||
517 | uint32_t local_address_info, | ||
518 | uint32_t session_id, | 499 | uint32_t session_id, |
519 | const struct GNUNET_ATS_Information *atsi, | 500 | const struct GNUNET_ATS_Information *atsi, |
520 | uint32_t atsi_count); | 501 | uint32_t atsi_count); |
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c index b0a52f39c..685c6535d 100644 --- a/src/ats/gnunet-service-ats_scheduling.c +++ b/src/ats/gnunet-service-ats_scheduling.c | |||
@@ -311,10 +311,6 @@ GAS_handle_address_update (void *cls, | |||
311 | { | 311 | { |
312 | const struct AddressUpdateMessage *m; | 312 | const struct AddressUpdateMessage *m; |
313 | const struct GNUNET_ATS_Information *atsi; | 313 | const struct GNUNET_ATS_Information *atsi; |
314 | const char *address; | ||
315 | const char *plugin_name; | ||
316 | uint16_t address_length; | ||
317 | uint16_t plugin_name_length; | ||
318 | uint32_t ats_count; | 314 | uint32_t ats_count; |
319 | uint16_t size; | 315 | uint16_t size; |
320 | 316 | ||
@@ -330,21 +326,12 @@ GAS_handle_address_update (void *cls, | |||
330 | } | 326 | } |
331 | m = (const struct AddressUpdateMessage *) message; | 327 | m = (const struct AddressUpdateMessage *) message; |
332 | ats_count = ntohl (m->ats_count); | 328 | ats_count = ntohl (m->ats_count); |
333 | address_length = ntohs (m->address_length); | ||
334 | plugin_name_length = ntohs (m->plugin_name_length); | ||
335 | atsi = (const struct GNUNET_ATS_Information *) &m[1]; | 329 | atsi = (const struct GNUNET_ATS_Information *) &m[1]; |
336 | address = (const char *) &atsi[ats_count]; | ||
337 | if (plugin_name_length != 0) | ||
338 | plugin_name = &address[address_length]; | ||
339 | else | ||
340 | plugin_name = ""; | ||
341 | 330 | ||
342 | if ((address_length + plugin_name_length + | 331 | if ((ats_count * sizeof (struct GNUNET_ATS_Information) + |
343 | ats_count * sizeof (struct GNUNET_ATS_Information) + | ||
344 | sizeof (struct AddressUpdateMessage) != ntohs (message->size)) || | 332 | sizeof (struct AddressUpdateMessage) != ntohs (message->size)) || |
345 | (ats_count > | 333 | (ats_count > |
346 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) || | 334 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))) |
347 | ((plugin_name_length > 0) && (plugin_name[plugin_name_length - 1] != '\0'))) | ||
348 | { | 335 | { |
349 | GNUNET_break (0); | 336 | GNUNET_break (0); |
350 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 337 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -356,11 +343,8 @@ GAS_handle_address_update (void *cls, | |||
356 | GNUNET_NO); | 343 | GNUNET_NO); |
357 | GAS_addresses_update (address_handle, | 344 | GAS_addresses_update (address_handle, |
358 | &m->peer, | 345 | &m->peer, |
359 | plugin_name, | 346 | ntohl (m->session_id), |
360 | address, | 347 | atsi, ats_count); |
361 | address_length, | ||
362 | ntohl (m->address_local_info), | ||
363 | ntohl (m->session_id), atsi, ats_count); | ||
364 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 348 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
365 | } | 349 | } |
366 | 350 | ||
@@ -378,52 +362,13 @@ GAS_handle_address_in_use (void *cls, | |||
378 | const struct GNUNET_MessageHeader *message) | 362 | const struct GNUNET_MessageHeader *message) |
379 | { | 363 | { |
380 | const struct AddressUseMessage *m; | 364 | const struct AddressUseMessage *m; |
381 | const char *address; | ||
382 | const char *plugin_name; | ||
383 | int res; | 365 | int res; |
384 | uint16_t address_length; | ||
385 | uint16_t plugin_name_length; | ||
386 | uint16_t size; | ||
387 | uint16_t in_use; | ||
388 | 366 | ||
389 | size = ntohs (message->size); | ||
390 | if (size < sizeof (struct AddressUseMessage)) | ||
391 | { | ||
392 | GNUNET_break (0); | ||
393 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
394 | return; | ||
395 | } | ||
396 | m = (const struct AddressUseMessage *) message; | 367 | m = (const struct AddressUseMessage *) message; |
397 | |||
398 | address_length = ntohs (m->address_length); | ||
399 | plugin_name_length = ntohs (m->plugin_name_length); | ||
400 | |||
401 | address = (const char *) &m[1]; | ||
402 | if (plugin_name_length != 0) | ||
403 | plugin_name = &address[address_length]; | ||
404 | else | ||
405 | plugin_name = ""; | ||
406 | |||
407 | if ((address_length + plugin_name_length + | ||
408 | sizeof (struct AddressUseMessage) != ntohs (message->size)) || | ||
409 | ((plugin_name_length > 0) && | ||
410 | (plugin_name[plugin_name_length - 1] != '\0'))) | ||
411 | { | ||
412 | GNUNET_break (0); | ||
413 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
414 | return; | ||
415 | } | ||
416 | |||
417 | in_use = ntohs (m->in_use); | ||
418 | res = GAS_addresses_in_use (address_handle, | 368 | res = GAS_addresses_in_use (address_handle, |
419 | &m->peer, | 369 | &m->peer, |
420 | plugin_name, | ||
421 | address, | ||
422 | address_length, | ||
423 | ntohl (m->address_local_info), | ||
424 | ntohl (m->session_id), | 370 | ntohl (m->session_id), |
425 | in_use); | 371 | ntohl (m->in_use)); |
426 | |||
427 | if (GNUNET_OK != res) | 372 | if (GNUNET_OK != res) |
428 | { | 373 | { |
429 | GNUNET_break (0); | 374 | GNUNET_break (0); |