diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-08 23:20:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-08 23:20:42 +0000 |
commit | a983a0267109b1b6a8e16e476e2f2956a8771b94 (patch) | |
tree | 79bcae73cdb7b87b4f55d4396e79baea76ef53a6 /src/peerinfo | |
parent | a3f8ef5b89dc44fc3acfb8f081a502f3409e4224 (diff) | |
download | gnunet-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')
-rw-r--r-- | src/peerinfo/gnunet-service-peerinfo.c | 13 | ||||
-rw-r--r-- | src/peerinfo/test_peerinfo_api.c | 26 |
2 files changed, 22 insertions, 17 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index e453621d2..fc7cc781f 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -117,23 +117,22 @@ make_info_message (const struct HostEntry *he) | |||
117 | * Address iterator that causes expired entries to be discarded. | 117 | * Address iterator that causes expired entries to be discarded. |
118 | * | 118 | * |
119 | * @param cls pointer to the current time | 119 | * @param cls pointer to the current time |
120 | * @param tname name of the transport | 120 | * @param address the address |
121 | * @param expiration expiration time for the address | 121 | * @param expiration expiration time for the address |
122 | * @param addr the address | ||
123 | * @param addrlen length of addr in bytes | ||
124 | * @return GNUNET_NO if expiration smaller than the current time | 122 | * @return GNUNET_NO if expiration smaller than the current time |
125 | */ | 123 | */ |
126 | static int | 124 | static int |
127 | discard_expired (void *cls, const char *tname, | 125 | discard_expired (void *cls, |
128 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 126 | const struct GNUNET_HELLO_Address *address, |
129 | uint16_t addrlen) | 127 | struct GNUNET_TIME_Absolute expiration) |
130 | { | 128 | { |
131 | const struct GNUNET_TIME_Absolute *now = cls; | 129 | const struct GNUNET_TIME_Absolute *now = cls; |
132 | 130 | ||
133 | if (now->abs_value > expiration.abs_value) | 131 | if (now->abs_value > expiration.abs_value) |
134 | { | 132 | { |
135 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 133 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
136 | _("Removing expired address of transport `%s'\n"), tname); | 134 | _("Removing expired address of transport `%s'\n"), |
135 | address->transport_name); | ||
137 | return GNUNET_NO; | 136 | return GNUNET_NO; |
138 | } | 137 | } |
139 | return GNUNET_OK; | 138 | return GNUNET_OK; |
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; | |||
45 | static unsigned int retries; | 45 | static unsigned int retries; |
46 | 46 | ||
47 | static int | 47 | static int |
48 | check_it (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration, | 48 | check_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 | } |