1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

sys: net: ipv6: add print_ipv6_addr()

This commit is contained in:
Kaspar Schleiser 2016-02-05 10:12:02 +01:00
parent b9c97d86c2
commit 44e985bf8c
2 changed files with 26 additions and 0 deletions

View File

@ -709,6 +709,13 @@ static inline int ipv6_addr_split_iface(char *addr_str)
return ipv6_addr_split(addr_str, '%', -1);
}
/**
* @brief Print IPv6 address to stdout
*
* @param[in] addr Pointer to ipv6_addr_t to print
*/
void ipv6_addr_print(const ipv6_addr_t *addr);
#ifdef __cplusplus
}
#endif

View File

@ -14,11 +14,18 @@
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "net/ipv6/addr.h"
#ifdef MODULE_FMT
#include "fmt.h"
#else
#include <stdio.h>
#endif
bool ipv6_addr_equal(const ipv6_addr_t *a, const ipv6_addr_t *b)
{
return (a->u64[0].u64 == b->u64[0].u64) &&
@ -122,6 +129,18 @@ int ipv6_addr_split(char *addr_str, char seperator, int _default)
return _default;
}
void ipv6_addr_print(const ipv6_addr_t *addr)
{
assert(addr);
char addr_str[IPV6_ADDR_MAX_STR_LEN];
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str));
#ifdef MODULE_FMT
print_str(addr_str);
#else
printf("%s", addr_str);
#endif
}
/**
* @}
*/