aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo/test_peerinfo_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-08 23:20:42 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-08 23:20:42 +0000
commita983a0267109b1b6a8e16e476e2f2956a8771b94 (patch)
tree79bcae73cdb7b87b4f55d4396e79baea76ef53a6 /src/peerinfo/test_peerinfo_api.c
parenta3f8ef5b89dc44fc3acfb8f081a502f3409e4224 (diff)
downloadgnunet-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/peerinfo/test_peerinfo_api.c')
-rw-r--r--src/peerinfo/test_peerinfo_api.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c
index bbdc591f4..607c1fa4e 100644
--- a/src/peerinfo/test_peerinfo_api.c
+++ b/src/peerinfo/test_peerinfo_api.c
@@ -45,16 +45,17 @@ static struct GNUNET_PEERINFO_Handle *h;
45static unsigned int retries; 45static unsigned int retries;
46 46
47static int 47static int
48check_it (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration, 48check_it (void *cls,
49 const void *addr, uint16_t addrlen) 49 const struct GNUNET_HELLO_Address *address,
50 struct GNUNET_TIME_Absolute expiration)
50{ 51{
51 unsigned int *agc = cls; 52 unsigned int *agc = cls;
52 53
53 if (addrlen > 0) 54 if (address != NULL)
54 { 55 {
55 GNUNET_assert (0 == strcmp ("peerinfotest", tname)); 56 GNUNET_assert (0 == strcmp ("peerinfotest", address->transport_name));
56 GNUNET_assert (0 == strncmp ("Address", addr, addrlen)); 57 GNUNET_assert (0 == strncmp ("Address", address->address, address->address_length));
57 (*agc) -= (1 << (addrlen - 1)); 58 (*agc) -= (1 << (address->address_length - 1));
58 } 59 }
59 return GNUNET_OK; 60 return GNUNET_OK;
60} 61}
@@ -65,14 +66,19 @@ address_generator (void *cls, size_t max, void *buf)
65{ 66{
66 size_t *agc = cls; 67 size_t *agc = cls;
67 size_t ret; 68 size_t ret;
69 struct GNUNET_HELLO_Address address;
68 70
69 if (0 == *agc) 71 if (0 == *agc)
70 return 0; 72 return 0;
73 memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity));
74 address.address = "Address";
75 address.transport_name = "peerinfotest";
76 address.address_length = *agc;
71 ret = 77 ret =
72 GNUNET_HELLO_add_address ("peerinfotest", 78 GNUNET_HELLO_add_address (&address,
73 GNUNET_TIME_relative_to_absolute 79 GNUNET_TIME_relative_to_absolute
74 (GNUNET_TIME_UNIT_HOURS), "Address", *agc, buf, 80 (GNUNET_TIME_UNIT_HOURS), buf,
75 max); 81 max);
76 (*agc)--; 82 (*agc)--;
77 return ret; 83 return ret;
78} 84}