Skip to content
Browse files

net: ip: Helper for getting used network address family as string

This helper can be used in debugging the used network address family.

Signed-off-by: Jukka Rissanen <>
  • Loading branch information...
jukkar committed Apr 14, 2019
1 parent 98a8e29 commit 3ebe60a3ba6c8fe59746487496b0134120721297
Showing with 28 additions and 0 deletions.
  1. +10 −0 include/net/net_ip.h
  2. +18 −0 subsys/net/ip/utils.c
@@ -1320,6 +1320,16 @@ static inline u8_t net_priority2vlan(enum net_priority priority)
return (u8_t)net_vlan2priority(priority);

* @brief Return network address family value as a string. This is only usable
* for debugging.
* @param family Network address family code
* @return Network address family as a string, or NULL if family is unknown.
const char *net_family2str(sa_family_t family);

#ifdef __cplusplus
@@ -848,3 +848,21 @@ int net_bytes_from_str(u8_t *buf, int buf_len, const char *src)

return 0;

const char *net_family2str(sa_family_t family)
switch (family) {
return "AF_UNSPEC";
case AF_INET:
return "AF_INET";
case AF_INET6:
return "AF_INET6";
return "AF_PACKET";
case AF_CAN:
return "AF_CAN";

return NULL;

0 comments on commit 3ebe60a

Please sign in to comment.
You can’t perform that action at this time.