[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25289 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25289 - gnunet/src/ats |
Date: |
Thu, 6 Dec 2012 13:17:31 +0100 |
Author: wachs
Date: 2012-12-06 13:17:31 +0100 (Thu, 06 Dec 2012)
New Revision: 25289
Modified:
gnunet/src/ats/test_ats_api_scheduling_add_address.c
Log:
changes
Modified: gnunet/src/ats/test_ats_api_scheduling_add_address.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_add_address.c 2012-12-06
11:35:00 UTC (rev 25288)
+++ gnunet/src/ats/test_ats_api_scheduling_add_address.c 2012-12-06
12:17:31 UTC (rev 25289)
@@ -51,7 +51,17 @@
*/
static struct PeerContext p;
+/**
+ * HELLO address
+ */
+struct GNUNET_HELLO_Address test_hello_address;
+/**
+ * Session
+ */
+static void *test_session;
+
+
static void
create_test_address (struct Test_Address *dest, char * plugin, void *session,
void *addr, size_t addrlen)
{
@@ -96,6 +106,41 @@
free_test_address (&test_addr);
}
+static int
+compare_addresses (const struct GNUNET_HELLO_Address *address1, void *session1,
+ const struct GNUNET_HELLO_Address *address2, void *session2)
+{
+ if (0 != memcmp (&address1->peer, &address2->peer, sizeof (struct
GNUNET_PeerIdentity)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid peer
id'\n");
+ return GNUNET_SYSERR;
+ }
+ if (0 != strcmp (address1->transport_name, address2->transport_name))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid
plugin'\n");
+ return GNUNET_SYSERR;
+ }
+ if (address1->address_length != address2->address_length)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid address
length'\n");
+ return GNUNET_SYSERR;
+
+ }
+ else if (0 != memcmp (address1->address, address2->address,
address2->address_length))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid
address'\n");
+ return GNUNET_SYSERR;
+ }
+ if (session1 != session2)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggestion with invalid session1
%p vs session2 %p'\n",
+ session1, session2);
+ return GNUNET_SYSERR;
+
+ }
+ return GNUNET_OK;
+}
+
static void
address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
struct Session *session,
@@ -126,10 +171,21 @@
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for correct address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 0;
+
}
+
+ if (GNUNET_OK == compare_addresses (address, session, &test_hello_address,
test_session))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback with correct address
`%s'\n",
+ GNUNET_i2s (&address->peer));
+ ret = 0;
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback with invalid address
`%s'\n",
+ GNUNET_i2s (&address->peer));
+ ret = 0;
+ }
GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
GNUNET_SCHEDULER_add_now (&end, NULL);
}
@@ -139,7 +195,7 @@
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
- struct GNUNET_HELLO_Address hello_address;
+
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
/* Connect to ATS scheduling */
@@ -166,13 +222,15 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
GNUNET_i2s_full(&p.id));
- create_test_address (&test_addr, "test", &test_addr, "test", strlen ("test")
+ 1);
+
/* Adding address without session */
- hello_address.peer = p.id;
- hello_address.transport_name = test_addr.plugin;
- hello_address.address = test_addr.addr;
- hello_address.address_length = test_addr.addr_len;
- GNUNET_ATS_address_add (sched_ats, &hello_address, test_addr.session, NULL,
0);
+ test_session = &test_addr;
+ create_test_address (&test_addr, "test", test_session, "test", strlen
("test") + 1);
+ test_hello_address.peer = p.id;
+ test_hello_address.transport_name = test_addr.plugin;
+ test_hello_address.address = test_addr.addr;
+ test_hello_address.address_length = test_addr.addr_len;
+ GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, NULL,
0);
GNUNET_ATS_suggest_address (sched_ats, &p.id);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25289 - gnunet/src/ats,
gnunet <=