aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-02-11 11:22:07 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-02-11 11:22:07 +0000
commit57562efaac37da015040ba5ade24afb549c67023 (patch)
tree39ffe0ff8bc6b1d19080395352e210df9d720adb /src
parent83fecbfc0feddabc908125bde4434907fbe1c1f6 (diff)
downloadgnunet-57562efaac37da015040ba5ade24afb549c67023.tar.gz
gnunet-57562efaac37da015040ba5ade24afb549c67023.zip
commit before removing address ids
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-ats-solver-eval.c130
-rw-r--r--src/ats/gnunet-ats-solver-eval.h1
2 files changed, 95 insertions, 36 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c
index 64480ada1..aea4f7495 100644
--- a/src/ats/gnunet-ats-solver-eval.c
+++ b/src/ats/gnunet-ats-solver-eval.c
@@ -83,6 +83,41 @@ print_generator_type (enum GeneratorType g)
83 } 83 }
84} 84}
85 85
86struct AddressLookupCtx
87{
88 struct ATS_Address *res;
89 char *plugin;
90 char *addr;
91 unsigned int address_id;
92};
93
94int find_address_it (void *cls,
95 const struct GNUNET_PeerIdentity *key,
96 void *value)
97{
98 struct AddressLookupCtx *ctx = cls;
99 struct ATS_Address *addr = value;
100
101 if ( (0 == strcmp (ctx->plugin, addr->plugin)) &&
102 (0 == strcmp (ctx->addr, addr->addr)) )
103 {
104 ctx->res = addr;
105 return GNUNET_NO;
106 }
107 return GNUNET_YES;
108}
109
110static struct TestPeer *
111find_peer_by_id (int id)
112{
113 struct TestPeer *cur;
114 for (cur = peer_head; NULL != cur; cur = cur->next)
115 if (cur->id == id)
116 return cur;
117 return NULL;
118}
119
120
86/** 121/**
87 * Logging 122 * Logging
88 */ 123 */
@@ -218,9 +253,29 @@ static void
218set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 253set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
219{ 254{
220 struct PropertyGenerator *pg = cls; 255 struct PropertyGenerator *pg = cls;
256 struct TestPeer *p;
221 double pref_value; 257 double pref_value;
258 struct GNUNET_ATS_Information atsi;
259
222 pg->set_task = GNUNET_SCHEDULER_NO_TASK; 260 pg->set_task = GNUNET_SCHEDULER_NO_TASK;
223 261
262 if (NULL == (p = find_peer_by_id (pg->peer)))
263 {
264 GNUNET_break (0);
265 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
266 "Setting property generation for unknown peer %u\n", pg->peer);
267 return;
268 }
269
270 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains_value (sh->addresses,
271 &p->peer_id, pg->address))
272 {
273 GNUNET_break (0);
274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
275 "Setting property generation for unknown address %u\n", pg->address_id);
276 return;
277 }
278
224 pref_value = get_property (pg); 279 pref_value = get_property (pg);
225 280
226 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 281 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
@@ -228,10 +283,15 @@ set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
228 pg->peer, pg->address_id, 283 pg->peer, pg->address_id,
229 GNUNET_ATS_print_property_type (pg->ats_property), pref_value); 284 GNUNET_ATS_print_property_type (pg->ats_property), pref_value);
230 285
231 /* set performance here! 286
232 GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle, 287 atsi.type = pg->ats_property;
233 &p->dest->id, p->pg->kind, pref_value, GNUNET_ATS_PREFERENCE_END); 288 atsi.value = (uint32_t) pref_value;
234*/ 289
290 /* set performance here! */
291 sh->env.sf.s_bulk_start (sh->solver);
292 GAS_normalization_normalize_property (sh->addresses, pg->address, &atsi, 1);
293 sh->env.sf.s_bulk_stop (sh->solver);
294
235 295
236 switch (pg->ats_property) { 296 switch (pg->ats_property) {
237 case GNUNET_ATS_PREFERENCE_BANDWIDTH: 297 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
@@ -296,6 +356,7 @@ GNUNET_ATS_solver_generate_property_stop (struct PropertyGenerator *pg)
296struct PropertyGenerator * 356struct PropertyGenerator *
297GNUNET_ATS_solver_generate_property_start (unsigned int peer, 357GNUNET_ATS_solver_generate_property_start (unsigned int peer,
298 unsigned int address_id, 358 unsigned int address_id,
359 struct ATS_Address *ats_address,
299 enum GeneratorType type, 360 enum GeneratorType type,
300 long int base_value, 361 long int base_value,
301 long int value_rate, 362 long int value_rate,
@@ -309,6 +370,7 @@ GNUNET_ATS_solver_generate_property_start (unsigned int peer,
309 GNUNET_CONTAINER_DLL_insert (prop_gen_head, prop_gen_tail, pg); 370 GNUNET_CONTAINER_DLL_insert (prop_gen_head, prop_gen_tail, pg);
310 pg->type = type; 371 pg->type = type;
311 pg->peer = peer; 372 pg->peer = peer;
373 pg->address = ats_address;
312 pg->address_id = address_id; 374 pg->address_id = address_id;
313 pg->ats_property = ats_property; 375 pg->ats_property = ats_property;
314 pg->base_value = base_value; 376 pg->base_value = base_value;
@@ -1530,16 +1592,6 @@ timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
1530 GNUNET_SYSERR); 1592 GNUNET_SYSERR);
1531} 1593}
1532 1594
1533static struct TestPeer *
1534find_peer_by_id (int id)
1535{
1536 struct TestPeer *cur;
1537 for (cur = peer_head; NULL != cur; cur = cur->next)
1538 if (cur->id == id)
1539 return cur;
1540 return NULL;
1541}
1542
1543struct ATS_Address * 1595struct ATS_Address *
1544create_ats_address (const struct GNUNET_PeerIdentity *peer, 1596create_ats_address (const struct GNUNET_PeerIdentity *peer,
1545 const char *plugin_name, 1597 const char *plugin_name,
@@ -1591,27 +1643,6 @@ enforce_add_address (struct GNUNET_ATS_TEST_Operation *op)
1591 1643
1592} 1644}
1593 1645
1594struct AddressLookupCtx
1595{
1596 struct ATS_Address *res;
1597 struct GNUNET_ATS_TEST_Operation *op;
1598};
1599
1600int find_address_it (void *cls,
1601 const struct GNUNET_PeerIdentity *key,
1602 void *value)
1603{
1604 struct AddressLookupCtx *ctx = cls;
1605 struct ATS_Address *addr = value;
1606
1607 if ( (0 == strcmp (ctx->op->plugin, addr->plugin)) &&
1608 (0 == strcmp (ctx->op->address, addr->addr)) )
1609 {
1610 ctx->res = addr;
1611 return GNUNET_NO;
1612 }
1613 return GNUNET_YES;
1614}
1615 1646
1616static void 1647static void
1617enforce_del_address (struct GNUNET_ATS_TEST_Operation *op) 1648enforce_del_address (struct GNUNET_ATS_TEST_Operation *op)
@@ -1627,7 +1658,8 @@ enforce_del_address (struct GNUNET_ATS_TEST_Operation *op)
1627 return; 1658 return;
1628 } 1659 }
1629 1660
1630 ctx.op = op; 1661 ctx.plugin = op->plugin;
1662 ctx.addr = op->address;
1631 ctx.res = NULL; 1663 ctx.res = NULL;
1632 GNUNET_CONTAINER_multipeermap_get_multiple (sh->addresses, &p->peer_id, 1664 GNUNET_CONTAINER_multipeermap_get_multiple (sh->addresses, &p->peer_id,
1633 find_address_it, &ctx); 1665 find_address_it, &ctx);
@@ -1659,8 +1691,34 @@ enforce_start_property (struct GNUNET_ATS_TEST_Operation *op)
1659 GNUNET_free (pg); 1691 GNUNET_free (pg);
1660 } 1692 }
1661 1693
1694 struct TestPeer *p;
1695 struct AddressLookupCtx ctx;
1696
1697 if (NULL == (p = find_peer_by_id (op->peer_id)))
1698 {
1699 GNUNET_break (0);
1700 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1701 "Starting property generation for unknown peer %u\n", op->peer_id);
1702 return;
1703 }
1704
1705 ctx.plugin = op->plugin;
1706 ctx.addr = op->address;
1707 ctx.res = NULL;
1708 GNUNET_CONTAINER_multipeermap_get_multiple (sh->addresses, &p->peer_id,
1709 find_address_it, &ctx);
1710 if (NULL == ctx.res)
1711 {
1712 GNUNET_break (0);
1713 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1714 "Starting property generation for unknown address for peer %u\n",
1715 op->peer_id);
1716 return;
1717 }
1718
1662 GNUNET_ATS_solver_generate_property_start (op->peer_id, 1719 GNUNET_ATS_solver_generate_property_start (op->peer_id,
1663 op->address_id, 1720 op->address_id,
1721 ctx.res,
1664 op->gen_type, 1722 op->gen_type,
1665 op->base_rate, 1723 op->base_rate,
1666 op->max_rate, 1724 op->max_rate,
diff --git a/src/ats/gnunet-ats-solver-eval.h b/src/ats/gnunet-ats-solver-eval.h
index 8c8e1c459..4fa69e59d 100644
--- a/src/ats/gnunet-ats-solver-eval.h
+++ b/src/ats/gnunet-ats-solver-eval.h
@@ -202,6 +202,7 @@ struct PropertyGenerator
202 unsigned int peer; 202 unsigned int peer;
203 unsigned int address_id; 203 unsigned int address_id;
204 204
205 struct ATS_Address *address;
205 uint32_t ats_property; 206 uint32_t ats_property;
206 207
207 long int base_value; 208 long int base_value;