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/include/gnunet_hello_lib.h | |
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/include/gnunet_hello_lib.h')
-rw-r--r-- | src/include/gnunet_hello_lib.h | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index 4e8554b52..886a41093 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h | |||
@@ -89,6 +89,30 @@ GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | |||
89 | 89 | ||
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Copy an address struct. | ||
93 | * | ||
94 | * @param address address to copy | ||
95 | * @return a copy of the address struct | ||
96 | */ | ||
97 | struct GNUNET_HELLO_Address * | ||
98 | GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); | ||
99 | |||
100 | |||
101 | /** | ||
102 | * Compare two addresses. Does NOT compare the peer identity, | ||
103 | * that is assumed already to match! | ||
104 | * | ||
105 | * @param a1 first address | ||
106 | * @param a2 second address | ||
107 | * @return 0 if the addresses are equal, -1 if a1<a2, 1 if a1>a2. | ||
108 | */ | ||
109 | int | ||
110 | GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, | ||
111 | const struct GNUNET_HELLO_Address *a2); | ||
112 | |||
113 | |||
114 | |||
115 | /** | ||
92 | * Free an address. | 116 | * Free an address. |
93 | * | 117 | * |
94 | * @param addr address to free | 118 | * @param addr address to free |
@@ -109,19 +133,17 @@ struct GNUNET_HELLO_Message; | |||
109 | * Copy the given address information into | 133 | * Copy the given address information into |
110 | * the given buffer using the format of HELLOs. | 134 | * the given buffer using the format of HELLOs. |
111 | * | 135 | * |
112 | * @param tname name of the transport plugin | 136 | * @param address address to add |
113 | * @param expiration expiration for the address | 137 | * @param expiration expiration for the address |
114 | * @param addr the address | ||
115 | * @param addr_len length of the address in bytes | ||
116 | * @param target where to copy the address | 138 | * @param target where to copy the address |
117 | * @param max maximum number of bytes to copy to target | 139 | * @param max maximum number of bytes to copy to target |
118 | * @return number of bytes copied, 0 if | 140 | * @return number of bytes copied, 0 if |
119 | * the target buffer was not big enough. | 141 | * the target buffer was not big enough. |
120 | */ | 142 | */ |
121 | size_t | 143 | size_t |
122 | GNUNET_HELLO_add_address (const char *tname, | 144 | GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, |
123 | struct GNUNET_TIME_Absolute expiration, | 145 | struct GNUNET_TIME_Absolute expiration, |
124 | const void *addr, uint16_t addr_len, char *target, | 146 | char *target, |
125 | size_t max); | 147 | size_t max); |
126 | 148 | ||
127 | 149 | ||
@@ -204,18 +226,15 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, | |||
204 | * Iterator callback to go over all addresses. | 226 | * Iterator callback to go over all addresses. |
205 | * | 227 | * |
206 | * @param cls closure | 228 | * @param cls closure |
207 | * @param tname name of the transport | 229 | * @param address the address |
208 | * @param expiration expiration time | 230 | * @param expiration expiration time |
209 | * @param addr the address | ||
210 | * @param addrlen length of the address | ||
211 | * @return GNUNET_OK to keep the address, | 231 | * @return GNUNET_OK to keep the address, |
212 | * GNUNET_NO to delete it from the HELLO | 232 | * GNUNET_NO to delete it from the HELLO |
213 | * GNUNET_SYSERR to stop iterating (but keep current address) | 233 | * GNUNET_SYSERR to stop iterating (but keep current address) |
214 | */ | 234 | */ |
215 | typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, const char *tname, | 235 | typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, |
216 | struct GNUNET_TIME_Absolute | 236 | const struct GNUNET_HELLO_Address *address, |
217 | expiration, const void *addr, | 237 | struct GNUNET_TIME_Absolute expiration); |
218 | uint16_t addrlen); | ||
219 | 238 | ||
220 | 239 | ||
221 | /** | 240 | /** |