aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/core/address.h
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light/src/hicn/core/address.h')
-rw-r--r--hicn-light/src/hicn/core/address.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/hicn-light/src/hicn/core/address.h b/hicn-light/src/hicn/core/address.h
index d13fc99ed..f1f2ac1e0 100644
--- a/hicn-light/src/hicn/core/address.h
+++ b/hicn-light/src/hicn/core/address.h
@@ -18,8 +18,8 @@
* \brief Address
*/
-#ifndef HICN_ADDRESS_H
-#define HICN_ADDRESS_H
+#ifndef HICNLIGHT_ADDRESS_H
+#define HICNLIGHT_ADDRESS_H
#include <netinet/in.h>
@@ -61,6 +61,15 @@ int address_from_ip_port(address_t * address, int family, ip_address_t * addr, u
}))
#define ADDRESS4_LOCALHOST(port) ADDRESS4(INADDR_LOOPBACK, (port))
+
+/**
+ * @brief Helper function to avoid macro expansion in c++ tests. Wrapper around 'ADDRESS4_LOCALHOST()'.
+ *
+ * @param port
+ * @return address_t
+ */
+address_t _ADDRESS4_LOCALHOST(uint16_t port);
+
#define ADDRESS4_ANY(port) ADDRESS4(INADDR_ANY, (port))
#define ADDRESS6(ip, port) (*(address_t*) &((struct sockaddr_in6) {\
@@ -84,5 +93,13 @@ extern const char * _address_family_str[];
#define address6_empty(address) (memcmp(address6_ip(address).s6_addr, &in6addr_any, sizeof(struct in6_addr)) == 0)
#define address_empty(address) (address_family(address) == AF_INET ? address4_empty(address) : address6_empty(address))
-#endif /* HICN_ADDRESS_H */
+/**
+ * @brief Return the string representation of the IP address provided.
+ *
+ * @param[in] address Address to obtain the string representation from.
+ * @param[in, out] buffer String to store the string representation of the address. It contains "N/A" in case of failure (see return value).
+ * @return int 0 if success, failure otherwise.
+ */
+int address_to_string(const address_t *address, char *buffer);
+#endif /* HICNLIGHT_ADDRESS_H */