net: Fix IPv6 address debug print

The allocated space for IPv6 string was too short by 10 chars
which meant that full IPv6 address was not printed correctly.

Change-Id: I9c7f3f118f486f88e769aaadf09d100a1d4fd6bc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-10-25 21:50:44 +03:00
parent d6540e8517
commit 750a93df40
8 changed files with 15 additions and 14 deletions

View file

@ -166,6 +166,7 @@ struct net_addr {
0, 0, 0, 0, 0, 0, 0, 0, 1 } } }
#define INET6_ADDRSTRLEN 46
#define NET_IPV6_ADDR_LEN sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")
#define INADDR_ANY 0

View file

@ -538,8 +538,8 @@ int net_conn_register(enum net_ip_protocol proto,
#if NET_DEBUG
do {
char dst[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
char src[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
char dst[NET_IPV6_ADDR_LEN];
char src[NET_IPV6_ADDR_LEN];
prepare_register_debug_print(dst, sizeof(dst),
src, sizeof(src),

View file

@ -46,7 +46,7 @@ static enum net_verdict handle_echo_request(struct net_buf *buf)
* the addresses etc.
*/
#if NET_DEBUG > 0
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out),
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->dst));
@ -217,7 +217,7 @@ int net_icmpv6_send_error(struct net_buf *orig, uint8_t type, uint8_t code,
#if NET_DEBUG > 0
do {
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out),
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->dst));
NET_DBG("Sending ICMPv6 Error Message type %d code %d param %d"

View file

@ -710,7 +710,7 @@ static inline void handle_ns_neighbor(struct net_buf *buf,
#if NET_DEBUG
#define dbg_addr(action, pkt_str, src, dst) \
do { \
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; \
char out[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), net_sprint_ipv6_addr(dst)); \
\
@ -727,8 +727,8 @@ static inline void handle_ns_neighbor(struct net_buf *buf,
#define dbg_addr_with_tgt(action, pkt_str, src, dst, target) \
do { \
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; \
char tgt[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; \
char out[NET_IPV6_ADDR_LEN]; \
char tgt[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), net_sprint_ipv6_addr(dst)); \
snprintf(tgt, sizeof(tgt), net_sprint_ipv6_addr(target)); \

View file

@ -328,7 +328,7 @@ static inline enum net_verdict process_ipv6_pkt(struct net_buf *buf)
#if NET_DEBUG > 0
do {
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out), net_sprint_ipv6_addr(&hdr->dst));
NET_DBG("IPv6 packet len %d received from %s to %s",
real_len, net_sprint_ipv6_addr(&hdr->src), out);

View file

@ -71,7 +71,7 @@ static inline char *net_sprint_ll_addr(const uint8_t *ll, uint8_t ll_len)
static inline char *net_sprint_ip_addr_ptr(const uint8_t *ptr, uint8_t len)
{
static char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
static char buf[NET_IPV6_ADDR_LEN];
return net_sprint_ip_addr_buf(ptr, len, (char *)buf, sizeof(buf));
}

View file

@ -248,7 +248,7 @@ static int nbr_nexthop_put(struct net_nbr *nbr)
#if NET_DEBUG
#define net_route_info(str, route, dst) \
do { \
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; \
char out[NET_IPV6_ADDR_LEN]; \
struct in6_addr *naddr = net_route_get_nexthop(route); \
\
NET_ASSERT_INFO(naddr, "Unknown nexthop address"); \
@ -373,7 +373,7 @@ struct net_route_entry *net_route_add(struct net_if *iface,
node);
#if NET_DEBUG
do {
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
char out[NET_IPV6_ADDR_LEN];
struct in6_addr *tmp;
struct net_linkaddr_storage *llstorage;

View file

@ -218,7 +218,7 @@ NET_NBR_TABLE_INIT(NET_NBR_LOCAL, rpl_parents, net_rpl_neighbor_pool,
#if NET_DEBUG
#define net_rpl_info(buf, req) \
do { \
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; \
char out[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), \
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->dst)); \
@ -239,7 +239,7 @@ NET_NBR_TABLE_INIT(NET_NBR_LOCAL, rpl_parents, net_rpl_neighbor_pool,
#define net_rpl_dao_ack_info(buf, src, dst, id, seq) \
do { \
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; \
char out[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), net_sprint_ipv6_addr(dst)); \
NET_DBG("Send DAO-ACK (id %d, seq %d) from %s to %s", \
@ -396,7 +396,7 @@ static void net_rpl_print_neighbors(void)
#if NET_DEBUG
#define net_route_info(str, route, addr, len, nexthop) \
do { \
char out[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; \
char out[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), \
net_sprint_ipv6_addr(addr)); \