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:
parent
b9c97d86c2
commit
44e985bf8c
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user