aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-08 23:20:42 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-08 23:20:42 +0000
commita983a0267109b1b6a8e16e476e2f2956a8771b94 (patch)
tree79bcae73cdb7b87b4f55d4396e79baea76ef53a6 /src/ats
parenta3f8ef5b89dc44fc3acfb8f081a502f3409e4224 (diff)
downloadgnunet-a983a0267109b1b6a8e16e476e2f2956a8771b94.tar.gz
gnunet-a983a0267109b1b6a8e16e476e2f2956a8771b94.zip
refactoring how we handle peer addresses in peerinfo/ats/transport/hello subsystems -- use a struct instead of 3--4 arguments
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/ats_api_performance.c19
-rw-r--r--src/ats/ats_api_scheduling.c101
-rw-r--r--src/ats/test_ats_api_scheduling.c38
3 files changed, 78 insertions, 80 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index ca489e4a6..8ac88ec63 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -269,9 +269,10 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
269{ 269{
270 const struct PeerInformationMessage *pi; 270 const struct PeerInformationMessage *pi;
271 const struct GNUNET_ATS_Information *atsi; 271 const struct GNUNET_ATS_Information *atsi;
272 const char *address; 272 const char *plugin_address;
273 const char *plugin_name; 273 const char *plugin_name;
274 uint16_t address_length; 274 struct GNUNET_HELLO_Address address;
275 uint16_t plugin_address_length;
275 uint16_t plugin_name_length; 276 uint16_t plugin_name_length;
276 uint32_t ats_count; 277 uint32_t ats_count;
277 278
@@ -287,12 +288,12 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
287 } 288 }
288 pi = (const struct PeerInformationMessage *) msg; 289 pi = (const struct PeerInformationMessage *) msg;
289 ats_count = ntohl (pi->ats_count); 290 ats_count = ntohl (pi->ats_count);
290 address_length = ntohs (pi->address_length); 291 plugin_address_length = ntohs (pi->address_length);
291 plugin_name_length = ntohs (pi->plugin_name_length); 292 plugin_name_length = ntohs (pi->plugin_name_length);
292 atsi = (const struct GNUNET_ATS_Information *) &pi[1]; 293 atsi = (const struct GNUNET_ATS_Information *) &pi[1];
293 address = (const char *) &atsi[ats_count]; 294 plugin_address = (const char *) &atsi[ats_count];
294 plugin_name = &address[address_length]; 295 plugin_name = &plugin_address[plugin_address_length];
295 if ((address_length + plugin_name_length + 296 if ((plugin_address_length + plugin_name_length +
296 ats_count * sizeof (struct GNUNET_ATS_Information) + 297 ats_count * sizeof (struct GNUNET_ATS_Information) +
297 sizeof (struct PeerInformationMessage) != ntohs (msg->size)) || 298 sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
298 (ats_count > 299 (ats_count >
@@ -302,7 +303,11 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
302 GNUNET_break (0); 303 GNUNET_break (0);
303 return GNUNET_SYSERR; 304 return GNUNET_SYSERR;
304 } 305 }
305 ph->infocb (ph->infocb_cls, &pi->peer, plugin_name, address, address_length, 306 address.peer = pi->peer;
307 address.address = plugin_address;
308 address.address_length = plugin_address_length;
309 address.transport_name = plugin_name;
310 ph->infocb (ph->infocb_cls, &address,
306 pi->bandwidth_out, pi->bandwidth_in, atsi, ats_count); 311 pi->bandwidth_out, pi->bandwidth_in, atsi, ats_count);
307 return GNUNET_OK; 312 return GNUNET_OK;
308} 313}
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index c2e7c0ea9..0885f53e9 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -440,11 +440,12 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
440 struct GNUNET_ATS_SchedulingHandle *sh = cls; 440 struct GNUNET_ATS_SchedulingHandle *sh = cls;
441 const struct AddressSuggestionMessage *m; 441 const struct AddressSuggestionMessage *m;
442 const struct GNUNET_ATS_Information *atsi; 442 const struct GNUNET_ATS_Information *atsi;
443 const char *address; 443 const char *plugin_address;
444 const char *plugin_name; 444 const char *plugin_name;
445 uint16_t address_length; 445 uint16_t plugin_address_length;
446 uint16_t plugin_name_length; 446 uint16_t plugin_name_length;
447 uint32_t ats_count; 447 uint32_t ats_count;
448 struct GNUNET_HELLO_Address address;
448 449
449 if (NULL == msg) 450 if (NULL == msg)
450 { 451 {
@@ -470,12 +471,12 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
470 } 471 }
471 m = (const struct AddressSuggestionMessage *) msg; 472 m = (const struct AddressSuggestionMessage *) msg;
472 ats_count = ntohl (m->ats_count); 473 ats_count = ntohl (m->ats_count);
473 address_length = ntohs (m->address_length); 474 plugin_address_length = ntohs (m->address_length);
474 atsi = (const struct GNUNET_ATS_Information *) &m[1]; 475 atsi = (const struct GNUNET_ATS_Information *) &m[1];
475 address = (const char *) &atsi[ats_count]; 476 plugin_address = (const char *) &atsi[ats_count];
476 plugin_name = &address[address_length]; 477 plugin_name = &plugin_address[plugin_address_length];
477 plugin_name_length = ntohs (m->plugin_name_length); 478 plugin_name_length = ntohs (m->plugin_name_length);
478 if ((address_length + plugin_name_length + 479 if ((plugin_address_length + plugin_name_length +
479 ats_count * sizeof (struct GNUNET_ATS_Information) + 480 ats_count * sizeof (struct GNUNET_ATS_Information) +
480 sizeof (struct AddressSuggestionMessage) != ntohs (msg->size)) || 481 sizeof (struct AddressSuggestionMessage) != ntohs (msg->size)) ||
481 (ats_count > 482 (ats_count >
@@ -500,9 +501,11 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
500 GNUNET_break (0); 501 GNUNET_break (0);
501 } 502 }
502 } 503 }
503 504 address.peer = m->peer;
504 sh->suggest_cb (sh->suggest_cb_cls, &m->peer, plugin_name, address, 505 address.address = plugin_address;
505 address_length, s, m->bandwidth_out, 506 address.address_length = plugin_address_length;
507 address.transport_name = plugin_name;
508 sh->suggest_cb (sh->suggest_cb_cls, &address, s, m->bandwidth_out,
506 m->bandwidth_in, atsi, ats_count); 509 m->bandwidth_in, atsi, ats_count);
507 510
508 511
@@ -637,19 +640,15 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
637 * for later use). Update bandwidth assignments. 640 * for later use). Update bandwidth assignments.
638 * 641 *
639 * @param sh handle 642 * @param sh handle
640 * @param peer identity of the new peer 643 * @param address the address
641 * @param plugin_name name of the transport plugin
642 * @param plugin_addr address (if available)
643 * @param plugin_addr_len number of bytes in plugin_addr
644 * @param session session handle (if available) 644 * @param session session handle (if available)
645 * @param ats performance data for the address 645 * @param ats performance data for the address
646 * @param ats_count number of performance records in 'ats' 646 * @param ats_count number of performance records in 'ats'
647 */ 647 */
648void 648void
649GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, 649GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
650 const struct GNUNET_PeerIdentity *peer, 650 const struct GNUNET_HELLO_Address *address,
651 const char *plugin_name, const void *plugin_addr, 651 struct Session *session,
652 size_t plugin_addr_len, struct Session *session,
653 const struct GNUNET_ATS_Information *ats, 652 const struct GNUNET_ATS_Information *ats,
654 uint32_t ats_count) 653 uint32_t ats_count)
655{ 654{
@@ -660,12 +659,12 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
660 size_t namelen; 659 size_t namelen;
661 size_t msize; 660 size_t msize;
662 661
663 namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1; 662 namelen = (address->transport_name == NULL) ? 0 : strlen (address->transport_name) + 1;
664 msize = 663 msize =
665 sizeof (struct AddressUpdateMessage) + plugin_addr_len + 664 sizeof (struct AddressUpdateMessage) + address->address_length +
666 ats_count * sizeof (struct GNUNET_ATS_Information) + namelen; 665 ats_count * sizeof (struct GNUNET_ATS_Information) + namelen;
667 if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 666 if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
668 (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 667 (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
669 (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 668 (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
670 (ats_count >= 669 (ats_count >=
671 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))) 670 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)))
@@ -681,15 +680,15 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
681 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); 680 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE);
682 m->header.size = htons (msize); 681 m->header.size = htons (msize);
683 m->ats_count = htonl (ats_count); 682 m->ats_count = htonl (ats_count);
684 m->peer = *peer; 683 m->peer = address->peer;
685 m->address_length = htons (plugin_addr_len); 684 m->address_length = htons (address->address_length);
686 m->plugin_name_length = htons (namelen); 685 m->plugin_name_length = htons (namelen);
687 m->session_id = htonl (get_session_id (sh, session, peer)); 686 m->session_id = htonl (get_session_id (sh, session, &address->peer));
688 am = (struct GNUNET_ATS_Information *) &m[1]; 687 am = (struct GNUNET_ATS_Information *) &m[1];
689 memcpy (am, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); 688 memcpy (am, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
690 pm = (char *) &am[ats_count]; 689 pm = (char *) &am[ats_count];
691 memcpy (pm, plugin_addr, plugin_addr_len); 690 memcpy (pm, address->address, address->address_length);
692 memcpy (&pm[plugin_addr_len], plugin_name, namelen); 691 memcpy (&pm[address->address_length], address->transport_name, namelen);
693 GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); 692 GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
694 do_transmit (sh); 693 do_transmit (sh);
695} 694}
@@ -699,19 +698,15 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
699 * An address is now in use or not used any more. 698 * An address is now in use or not used any more.
700 * 699 *
701 * @param sh handle 700 * @param sh handle
702 * @param peer identity of the peer 701 * @param address the address
703 * @param plugin_name name of the transport plugin
704 * @param plugin_addr address (if available)
705 * @param plugin_addr_len number of bytes in plugin_addr
706 * @param session session handle 702 * @param session session handle
707 * @param in_use GNUNET_YES if this address is now used, GNUNET_NO 703 * @param in_use GNUNET_YES if this address is now used, GNUNET_NO
708 * if address is not used any more 704 * if address is not used any more
709 */ 705 */
710void 706void
711GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, 707GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
712 const struct GNUNET_PeerIdentity *peer, 708 const struct GNUNET_HELLO_Address *address,
713 const char *plugin_name, const void *plugin_addr, 709 struct Session *session,
714 size_t plugin_addr_len, struct Session *session,
715 int in_use) 710 int in_use)
716{ 711{
717 struct PendingMessage *p; 712 struct PendingMessage *p;
@@ -720,10 +715,10 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
720 size_t namelen; 715 size_t namelen;
721 size_t msize; 716 size_t msize;
722 717
723 namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1; 718 namelen = (address->transport_name == NULL) ? 0 : strlen (address->transport_name) + 1;
724 msize = sizeof (struct AddressUseMessage) + plugin_addr_len + namelen; 719 msize = sizeof (struct AddressUseMessage) + address->address_length + namelen;
725 if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 720 if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
726 (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 721 (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
727 (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)) 722 (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
728 { 723 {
729 GNUNET_break (0); 724 GNUNET_break (0);
@@ -736,14 +731,14 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
736 m = (struct AddressUseMessage *) &p[1]; 731 m = (struct AddressUseMessage *) &p[1];
737 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE); 732 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE);
738 m->header.size = htons (msize); 733 m->header.size = htons (msize);
739 m->peer = *peer; 734 m->peer = address->peer;
740 m->in_use = htons (in_use); 735 m->in_use = htons (in_use);
741 m->address_length = htons (plugin_addr_len); 736 m->address_length = htons (address->address_length);
742 m->plugin_name_length = htons (namelen); 737 m->plugin_name_length = htons (namelen);
743 m->session_id = htonl (get_session_id (sh, session, peer)); 738 m->session_id = htonl (get_session_id (sh, session, &address->peer));
744 pm = (char *) &m[1]; 739 pm = (char *) &m[1];
745 memcpy (pm, plugin_addr, plugin_addr_len); 740 memcpy (pm, address->address, address->address_length);
746 memcpy (&pm[plugin_addr_len], plugin_name, namelen); 741 memcpy (&pm[address->address_length], address->transport_name, namelen);
747 GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); 742 GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
748 743
749 do_transmit (sh); 744 do_transmit (sh);
@@ -753,17 +748,13 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
753 * A session got destroyed, stop including it as a valid address. 748 * A session got destroyed, stop including it as a valid address.
754 * 749 *
755 * @param sh handle 750 * @param sh handle
756 * @param peer identity of the peer 751 * @param address the address
757 * @param plugin_name name of the transport plugin
758 * @param plugin_addr address (if available)
759 * @param plugin_addr_len number of bytes in plugin_addr
760 * @param session session handle that is no longer valid 752 * @param session session handle that is no longer valid
761 */ 753 */
762void 754void
763GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh, 755GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
764 const struct GNUNET_PeerIdentity *peer, 756 const struct GNUNET_HELLO_Address *address,
765 const char *plugin_name, const void *plugin_addr, 757 struct Session *session)
766 size_t plugin_addr_len, struct Session *session)
767{ 758{
768 struct PendingMessage *p; 759 struct PendingMessage *p;
769 struct AddressDestroyedMessage *m; 760 struct AddressDestroyedMessage *m;
@@ -772,10 +763,10 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
772 size_t msize; 763 size_t msize;
773 uint32_t session_id; 764 uint32_t session_id;
774 765
775 namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1; 766 namelen = (address->transport_name == NULL) ? 0 : strlen (address->transport_name) + 1;
776 msize = sizeof (struct AddressDestroyedMessage) + plugin_addr_len + namelen; 767 msize = sizeof (struct AddressDestroyedMessage) + address->address_length + namelen;
777 if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 768 if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
778 (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 769 (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
779 (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)) 770 (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
780 { 771 {
781 GNUNET_break (0); 772 GNUNET_break (0);
@@ -790,17 +781,17 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
790 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED); 781 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED);
791 m->header.size = htons (msize); 782 m->header.size = htons (msize);
792 m->reserved = htonl (0); 783 m->reserved = htonl (0);
793 m->peer = *peer; 784 m->peer = address->peer;
794 m->address_length = htons (plugin_addr_len); 785 m->address_length = htons (address->address_length);
795 m->plugin_name_length = htons (namelen); 786 m->plugin_name_length = htons (namelen);
796 session_id = get_session_id (sh, session, peer); 787 session_id = get_session_id (sh, session, &address->peer);
797 m->session_id = htonl (session_id); 788 m->session_id = htonl (session_id);
798 pm = (char *) &m[1]; 789 pm = (char *) &m[1];
799 memcpy (pm, plugin_addr, plugin_addr_len); 790 memcpy (pm, address->address, address->address_length);
800 memcpy (&pm[plugin_addr_len], plugin_name, namelen); 791 memcpy (&pm[address->address_length], address->transport_name, namelen);
801 GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); 792 GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
802 do_transmit (sh); 793 do_transmit (sh);
803 remove_session (sh, session_id, peer); 794 remove_session (sh, session_id, &address->peer);
804} 795}
805 796
806/* end of ats_api_scheduling.c */ 797/* end of ats_api_scheduling.c */
diff --git a/src/ats/test_ats_api_scheduling.c b/src/ats/test_ats_api_scheduling.c
index a2ee7f060..d24bb2c73 100644
--- a/src/ats/test_ats_api_scheduling.c
+++ b/src/ats/test_ats_api_scheduling.c
@@ -118,22 +118,22 @@ end ()
118 118
119 119
120static void 120static void
121address_suggest_cb (void *cls, const struct GNUNET_PeerIdentity *peer, 121address_suggest_cb (void *cls,
122 const char *plugin_name, const void *plugin_addr, 122 const struct GNUNET_HELLO_Address *address,
123 size_t plugin_addr_len, struct Session *session, 123 struct Session *session,
124 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 124 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
125 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 125 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
126 const struct GNUNET_ATS_Information *ats, 126 const struct GNUNET_ATS_Information *ats,
127 uint32_t ats_count) 127 uint32_t ats_count)
128{ 128{
129 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggests address `%s'\n", 129 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggests address `%s'\n",
130 GNUNET_i2s (peer)); 130 GNUNET_i2s (&address->peer));
131 131
132 GNUNET_assert (0 == 132 GNUNET_assert (0 ==
133 memcmp (peer, &p[0].id, sizeof (struct GNUNET_PeerIdentity))); 133 memcmp (&address->peer, &p[0].id, sizeof (struct GNUNET_PeerIdentity)));
134 GNUNET_assert (0 == strcmp (plugin_name, addr[0].plugin)); 134 GNUNET_assert (0 == strcmp (address->transport_name, addr[0].plugin));
135 GNUNET_assert (plugin_addr_len == addr[0].addr_len); 135 GNUNET_assert (address->address_length == addr[0].addr_len);
136 GNUNET_assert (0 == memcmp (plugin_addr, addr[0].plugin, plugin_addr_len)); 136 GNUNET_assert (0 == memcmp (address->address, addr[0].plugin, address->address_length));
137 GNUNET_assert (addr[0].session == session); 137 GNUNET_assert (addr[0].session == session);
138 138
139 139
@@ -166,6 +166,8 @@ static void
166check (void *cls, char *const *args, const char *cfgfile, 166check (void *cls, char *const *args, const char *cfgfile,
167 const struct GNUNET_CONFIGURATION_Handle *cfg) 167 const struct GNUNET_CONFIGURATION_Handle *cfg)
168{ 168{
169 struct GNUNET_HELLO_Address address0;
170
169 ret = GNUNET_SYSERR; 171 ret = GNUNET_SYSERR;
170 172
171 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 173 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
@@ -198,16 +200,18 @@ check (void *cls, char *const *args, const char *cfgfile,
198 200
199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing address creation\n"); 201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing address creation\n");
200 202
201 GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr, 203 address0.peer = p[0].id;
202 addr[0].addr_len, addr[0].session, NULL, 0); 204 address0.transport_name = addr[0].plugin;
205 address0.address = addr[0].addr;
206 address0.address_length = addr[0].addr_len;
207 GNUNET_ATS_address_update (ats, &address0, addr[0].session, NULL, 0);
203 208
204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info creation\n"); 209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info creation\n");
205 210
206 atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_UP); 211 atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_UP);
207 atsi[0].value = htonl (1024); 212 atsi[0].value = htonl (1024);
208 213
209 GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr, 214 GNUNET_ATS_address_update (ats, &address0, addr[0].session, atsi, 1);
210 addr[0].addr_len, addr[0].session, atsi, 1);
211 215
212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info update\n"); 216 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info update\n");
213 217
@@ -217,14 +221,12 @@ check (void *cls, char *const *args, const char *cfgfile,
217 atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_DOWN); 221 atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_DOWN);
218 atsi[1].value = htonl (1024); 222 atsi[1].value = htonl (1024);
219 223
220 GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr, 224 GNUNET_ATS_address_update (ats, &address0, addr[0].session, atsi, 2);
221 addr[0].addr_len, addr[0].session, atsi, 2);
222 225
223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing manual address deletion \n"); 226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing manual address deletion \n");
224 GNUNET_ATS_address_update (ats, &p[1].id, addr[0].plugin, addr[0].addr, 227 address0.peer = p[1].id; // FIXME: why? typo in old code?
225 addr[0].addr_len, addr[0].session, NULL, 0); 228 GNUNET_ATS_address_update (ats, &address0, addr[0].session, NULL, 0);
226 GNUNET_ATS_address_destroyed (ats, &p[1].id, addr[0].plugin, addr[0].addr, 229 GNUNET_ATS_address_destroyed (ats, &address0, addr[0].session);
227 addr[0].addr_len, addr[0].session);
228 230
229 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting peer `%s'\n", 231 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting peer `%s'\n",
230 GNUNET_i2s (&p[0].id)); 232 GNUNET_i2s (&p[0].id));