aboutsummaryrefslogtreecommitdiff
path: root/src/ats/test_ats_simplistic.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-12-11 15:46:20 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-12-11 15:46:20 +0000
commit569cc456f08e53be0723236cb925cf3bcd67c5fd (patch)
tree1567360d3046c819150a1257e12838e1811639e7 /src/ats/test_ats_simplistic.c
parenta5dfcc53ac3fe36063227fd744a84292aec3dac5 (diff)
downloadgnunet-569cc456f08e53be0723236cb925cf3bcd67c5fd.tar.gz
gnunet-569cc456f08e53be0723236cb925cf3bcd67c5fd.zip
changes
Diffstat (limited to 'src/ats/test_ats_simplistic.c')
-rw-r--r--src/ats/test_ats_simplistic.c102
1 files changed, 0 insertions, 102 deletions
diff --git a/src/ats/test_ats_simplistic.c b/src/ats/test_ats_simplistic.c
index cf047ff43..643099485 100644
--- a/src/ats/test_ats_simplistic.c
+++ b/src/ats/test_ats_simplistic.c
@@ -91,23 +91,6 @@ unsigned long long wan_quota_out;
91 */ 91 */
92unsigned long long wan_quota_in; 92unsigned long long wan_quota_in;
93 93
94static void
95create_test_address (struct Test_Address *dest, char * plugin, void *session, void *addr, size_t addrlen)
96{
97 dest->plugin = GNUNET_strdup (plugin);
98 dest->session = session;
99 dest->addr = GNUNET_malloc (addrlen);
100 memcpy (dest->addr, addr, addrlen);
101 dest->addr_len = addrlen;
102}
103
104static void
105free_test_address (struct Test_Address *dest)
106{
107 GNUNET_free (dest->plugin);
108 GNUNET_free (dest->addr);
109}
110
111 94
112static void 95static void
113end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 96end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -135,91 +118,6 @@ end ()
135 free_test_address (&test_addr[0]); 118 free_test_address (&test_addr[0]);
136} 119}
137 120
138static int
139compare_addresses (const struct GNUNET_HELLO_Address *address1, void *session1,
140 const struct GNUNET_HELLO_Address *address2, void *session2)
141{
142 if (0 != memcmp (&address1->peer, &address2->peer, sizeof (struct GNUNET_PeerIdentity)))
143 {
144 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid peer id'\n");
145 return GNUNET_SYSERR;
146 }
147 if (0 != strcmp (address1->transport_name, address2->transport_name))
148 {
149 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid plugin'\n");
150 return GNUNET_SYSERR;
151 }
152 if (address1->address_length != address2->address_length)
153 {
154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid address length'\n");
155 return GNUNET_SYSERR;
156
157 }
158 else if (0 != memcmp (address1->address, address2->address, address2->address_length))
159 {
160 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid address'\n");
161 return GNUNET_SYSERR;
162 }
163 if (session1 != session2)
164 {
165 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid session1 %p vs session2 %p'\n",
166 session1, session2);
167 return GNUNET_SYSERR;
168
169 }
170 return GNUNET_OK;
171}
172
173
174static int
175compare_ats (const struct GNUNET_ATS_Information *ats_is, uint32_t ats_count_is,
176 const struct GNUNET_ATS_Information *ats_should, uint32_t ats_count_should)
177{
178 unsigned int c_o;
179 unsigned int c_i;
180 char *prop[] = GNUNET_ATS_PropertyStrings;
181 uint32_t type1;
182 uint32_t type2;
183 uint32_t val1;
184 uint32_t val2;
185 int res = GNUNET_OK;
186
187 for (c_o = 0; c_o < ats_count_is; c_o++)
188 {
189 for (c_i = 0; c_i < ats_count_should; c_i++)
190 {
191 type1 = ntohl(ats_is[c_o].type);
192 type2 = ntohl(ats_should[c_i].type);
193 if (type1 == type2)
194 {
195#if DEBUG_ATS_INFO
196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS type `%s'\n",
197 prop[type1]);
198#endif
199 val1 = ntohl(ats_is[c_o].value);
200 val2 = ntohl(ats_should[c_i].value);
201 if (val1 != val2)
202 {
203#if DEBUG_ATS_INFO
204 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS value `%s' not equal: %u != %u\n",
205 prop[type1],
206 val1, val2);
207#endif
208 res = GNUNET_SYSERR;
209 }
210 else
211 {
212#if DEBUG_ATS_INFO
213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS value `%s' equal: %u == %u\n",
214 prop[type1],
215 val1, val2);
216#endif
217 }
218 }
219 }
220 }
221 return res;
222}
223 121
224static void 122static void
225address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, 123address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,