net: Add helper to print the verdict as string

For debugging purposes it would be nice to see the verdict
printed as a string instead of number.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2024-03-31 22:33:31 +03:00 committed by Carles Cufí
parent 9a9f6f3d96
commit 00502a8894
2 changed files with 14 additions and 0 deletions

View file

@ -203,6 +203,7 @@ int net_ipv6_send_fragmented_pkt(struct net_if *iface, struct net_pkt *pkt,
uint16_t pkt_len);
#endif
extern const char *net_verdict2str(enum net_verdict verdict);
extern const char *net_proto2str(int family, int proto);
extern char *net_byte_to_hex(char *ptr, uint8_t byte, char base, bool pad);
extern char *net_sprint_ll_addr_buf(const uint8_t *ll, uint8_t ll_len,

View file

@ -36,6 +36,19 @@ char *net_sprint_addr(sa_family_t af, const void *addr)
return net_addr_ntop(af, addr, s, NET_IPV6_ADDR_LEN);
}
const char *net_verdict2str(enum net_verdict verdict)
{
if (verdict == NET_OK) {
return "NET_OK";
} else if (verdict == NET_CONTINUE) {
return "NET_CONTINUE";
} else if (verdict == NET_DROP) {
return "NET_DROP";
}
return "<unknown>";
}
const char *net_proto2str(int family, int proto)
{
if (family == AF_INET || family == AF_INET6) {