diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-08 23:20:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-08 23:20:42 +0000 |
commit | a983a0267109b1b6a8e16e476e2f2956a8771b94 (patch) | |
tree | 79bcae73cdb7b87b4f55d4396e79baea76ef53a6 /src/ats/test_ats_api_scheduling.c | |
parent | a3f8ef5b89dc44fc3acfb8f081a502f3409e4224 (diff) | |
download | gnunet-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/test_ats_api_scheduling.c')
-rw-r--r-- | src/ats/test_ats_api_scheduling.c | 38 |
1 files changed, 20 insertions, 18 deletions
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 | ||
120 | static void | 120 | static void |
121 | address_suggest_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | 121 | address_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 | |||
166 | check (void *cls, char *const *args, const char *cfgfile, | 166 | check (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)); |