diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-12-07 15:32:46 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-12-07 15:32:46 +0000 |
commit | 375cb861fb99d7fd9237cfdcf83c58fb9eb05141 (patch) | |
tree | 9ed16b0fd4970d687271ea56e07f7bce8d339a4b /src/ats/gnunet-service-ats_addresses_simplistic.c | |
parent | f2c0db0346a1a18c932b2654126aa49fa8daf57f (diff) | |
download | gnunet-375cb861fb99d7fd9237cfdcf83c58fb9eb05141.tar.gz gnunet-375cb861fb99d7fd9237cfdcf83c58fb9eb05141.zip |
mod
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses_simplistic.c')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_simplistic.c | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c index baab09e90..1e7b468d5 100644 --- a/src/ats/gnunet-service-ats_addresses_simplistic.c +++ b/src/ats/gnunet-service-ats_addresses_simplistic.c | |||
@@ -36,26 +36,62 @@ | |||
36 | */ | 36 | */ |
37 | struct GAS_SIMPLISTIC_Handle | 37 | struct GAS_SIMPLISTIC_Handle |
38 | { | 38 | { |
39 | |||
39 | unsigned int active_addresses; | 40 | unsigned int active_addresses; |
41 | |||
42 | /** | ||
43 | * Network type array | ||
44 | * | ||
45 | * quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; | ||
46 | * | ||
47 | */ | ||
40 | int *quota_net; | 48 | int *quota_net; |
49 | |||
50 | /** | ||
51 | * Array of inbound quotas | ||
52 | * | ||
53 | */ | ||
41 | unsigned long long *quota_in; | 54 | unsigned long long *quota_in; |
55 | |||
56 | /** | ||
57 | * Array of outbound quotas | ||
58 | * | ||
59 | */ | ||
42 | unsigned long long *quota_out; | 60 | unsigned long long *quota_out; |
43 | }; | ||
44 | 61 | ||
62 | /** | ||
63 | * Active addresses per network type | ||
64 | */ | ||
65 | unsigned int *active_addresses_per_net; | ||
66 | }; | ||
45 | 67 | ||
46 | /** | 68 | /** |
47 | * Init the simplistic problem solving component | 69 | * Init the simplistic problem solving component |
48 | * | 70 | * |
71 | * Quotas: | ||
72 | * network[i] contains the network type as type GNUNET_ATS_NetworkType[i] | ||
73 | * out_quota[i] contains outbound quota for network type i | ||
74 | * in_quota[i] contains inbound quota for network type i | ||
75 | * | ||
76 | * Example | ||
77 | * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN} | ||
78 | * network[2] == GNUNET_ATS_NET_LAN | ||
79 | * out_quota[2] == 65353 | ||
80 | * in_quota[2] == 65353 | ||
81 | * | ||
49 | * @param cfg configuration handle | 82 | * @param cfg configuration handle |
50 | * @param stats the GNUNET_STATISTICS handle | 83 | * @param stats the GNUNET_STATISTICS handle |
84 | * @param network array of GNUNET_ATS_NetworkType with length dest_length | ||
85 | * @param out_quota array of outbound quotas | ||
86 | * param in_quota array of outbound quota | ||
51 | * @return handle for the solver on success, NULL on fail | 87 | * @return handle for the solver on success, NULL on fail |
52 | */ | 88 | */ |
53 | void * | 89 | void * |
54 | GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 90 | GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
55 | const struct GNUNET_STATISTICS_Handle *stats, | 91 | const struct GNUNET_STATISTICS_Handle *stats, |
56 | int *network, | 92 | int *network, |
57 | unsigned long long *out_dest, | 93 | unsigned long long *out_quota, |
58 | unsigned long long *in_dest, | 94 | unsigned long long *in_quota, |
59 | int dest_length) | 95 | int dest_length) |
60 | { | 96 | { |
61 | struct GAS_SIMPLISTIC_Handle *solver = GNUNET_malloc (sizeof (struct GAS_SIMPLISTIC_Handle)); | 97 | struct GAS_SIMPLISTIC_Handle *solver = GNUNET_malloc (sizeof (struct GAS_SIMPLISTIC_Handle)); |
@@ -64,10 +100,12 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
64 | memcpy (solver->quota_net, network, dest_length * sizeof (int)); | 100 | memcpy (solver->quota_net, network, dest_length * sizeof (int)); |
65 | 101 | ||
66 | solver->quota_in = GNUNET_malloc (dest_length * sizeof (unsigned long long)); | 102 | solver->quota_in = GNUNET_malloc (dest_length * sizeof (unsigned long long)); |
67 | memcpy (solver->quota_in, out_dest, dest_length * sizeof (int)); | 103 | memcpy (solver->quota_in, in_quota, dest_length * sizeof (int)); |
68 | 104 | ||
69 | solver->quota_out = GNUNET_malloc (dest_length * sizeof (unsigned long long)); | 105 | solver->quota_out = GNUNET_malloc (dest_length * sizeof (unsigned long long)); |
70 | memcpy (solver->quota_out, out_dest, dest_length * sizeof (unsigned long long)); | 106 | memcpy (solver->quota_out, out_quota, dest_length * sizeof (unsigned long long)); |
107 | |||
108 | solver->active_addresses_per_net = GNUNET_malloc (dest_length * sizeof (unsigned int)); | ||
71 | 109 | ||
72 | return solver; | 110 | return solver; |
73 | } | 111 | } |
@@ -86,6 +124,7 @@ GAS_simplistic_done (void *solver) | |||
86 | GNUNET_free (s->quota_net); | 124 | GNUNET_free (s->quota_net); |
87 | GNUNET_free (s->quota_in); | 125 | GNUNET_free (s->quota_in); |
88 | GNUNET_free (s->quota_out); | 126 | GNUNET_free (s->quota_out); |
127 | GNUNET_free (s->active_addresses_per_net); | ||
89 | GNUNET_free (s); | 128 | GNUNET_free (s); |
90 | } | 129 | } |
91 | 130 | ||
@@ -212,8 +251,6 @@ update_bw_simple_it (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
212 | aa->assigned_bw_in.value__ = htonl (UINT32_MAX / s->active_addresses); | 251 | aa->assigned_bw_in.value__ = htonl (UINT32_MAX / s->active_addresses); |
213 | aa->assigned_bw_out.value__ = htonl (UINT32_MAX / s->active_addresses); | 252 | aa->assigned_bw_out.value__ = htonl (UINT32_MAX / s->active_addresses); |
214 | 253 | ||
215 | //send_bw_notification (aa); | ||
216 | |||
217 | return GNUNET_OK; | 254 | return GNUNET_OK; |
218 | } | 255 | } |
219 | 256 | ||
@@ -284,7 +321,7 @@ GAS_simplistic_address_change_preference (void *solver, | |||
284 | enum GNUNET_ATS_PreferenceKind kind, | 321 | enum GNUNET_ATS_PreferenceKind kind, |
285 | float score) | 322 | float score) |
286 | { | 323 | { |
287 | 324 | /* FIXME : implement this */ | |
288 | } | 325 | } |
289 | 326 | ||
290 | /* end of gnunet-service-ats_addresses_simplistic.c */ | 327 | /* end of gnunet-service-ats_addresses_simplistic.c */ |