Introduce UIPLIB_IPV6_MAX_STR_LEN

This commit is contained in:
Simon Duquennoy 2018-05-15 13:39:49 -07:00
parent 5eaaa4d6b6
commit ff1f57509a
4 changed files with 7 additions and 3 deletions

View File

@ -156,7 +156,7 @@ uiplib_ip4addrconv(const char *addrstr, uip_ip4addr_t *ipaddr)
void
uiplib_ipaddr_print(const uip_ipaddr_t *addr)
{
char buf[40];
char buf[UIPLIB_IPV6_MAX_STR_LEN];
uiplib_ipaddr_snprint(buf, sizeof(buf), addr);
printf("%s", buf);
}

View File

@ -82,6 +82,10 @@ int uiplib_ip6addrconv(const char *addrstr, uip_ip6addr_t *addr);
* @{
*/
/* The maxium length of an IPv6 string, including terminating null bytes
* fd01:0002:0003:0004:0005:0006:0007:0008 => 39 + 1 bytes */
#define UIPLIB_IPV6_MAX_STR_LEN 40
/**
* Print an IP address using printf().
*

View File

@ -56,7 +56,7 @@
void
shell_output_6addr(shell_output_func output, const uip_ipaddr_t *ipaddr)
{
char buf[40];
char buf[UIPLIB_IPV6_MAX_STR_LEN];
uiplib_ipaddr_snprint(buf, sizeof(buf), ipaddr);
SHELL_OUTPUT(output, "%s", buf);
}

View File

@ -85,7 +85,7 @@ struct log_module all_modules[] = {
void
log_6addr(const uip_ipaddr_t *ipaddr)
{
char buf[40];
char buf[UIPLIB_IPV6_MAX_STR_LEN];
uiplib_ipaddr_snprint(buf, sizeof(buf), ipaddr);
LOG_OUTPUT("%s", buf);
}