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) |
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 4e8554b52b..886a410935 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, /** + * Copy an address struct. + * + * @param address address to copy + * @return a copy of the address struct + */ +struct GNUNET_HELLO_Address * +GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); + + +/** + * Compare two addresses. Does NOT compare the peer identity, + * that is assumed already to match! + * + * @param a1 first address + * @param a2 second address + * @return 0 if the addresses are equal, -1 if a1<a2, 1 if a1>a2. + */ +int +GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, + const struct GNUNET_HELLO_Address *a2); + + + +/** * Free an address. * * @param addr address to free @@ -109,19 +133,17 @@ struct GNUNET_HELLO_Message; * Copy the given address information into * the given buffer using the format of HELLOs. * - * @param tname name of the transport plugin + * @param address address to add * @param expiration expiration for the address - * @param addr the address - * @param addr_len length of the address in bytes * @param target where to copy the address * @param max maximum number of bytes to copy to target * @return number of bytes copied, 0 if * the target buffer was not big enough. */ size_t -GNUNET_HELLO_add_address (const char *tname, +GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addr_len, char *target, + char *target, size_t max); @@ -204,18 +226,15 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, * Iterator callback to go over all addresses. * * @param cls closure - * @param tname name of the transport + * @param address the address * @param expiration expiration time - * @param addr the address - * @param addrlen length of the address * @return GNUNET_OK to keep the address, * GNUNET_NO to delete it from the HELLO * GNUNET_SYSERR to stop iterating (but keep current address) */ -typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, const char *tname, - struct GNUNET_TIME_Absolute - expiration, const void *addr, - uint16_t addrlen); +typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, + const struct GNUNET_HELLO_Address *address, + struct GNUNET_TIME_Absolute expiration); /** |