Module: kamailio Branch: master Commit: 8bdee74fa6b68012919ddbb403da372187631bd9 URL: https://github.com/kamailio/kamailio/commit/8bdee74fa6b68012919ddbb403da3721...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2022-09-16T16:42:16+02:00
core: helper function to get address family name
---
Modified: src/core/ip_addr.c Modified: src/core/ip_addr.h
---
Diff: https://github.com/kamailio/kamailio/commit/8bdee74fa6b68012919ddbb403da3721... Patch: https://github.com/kamailio/kamailio/commit/8bdee74fa6b68012919ddbb403da3721...
---
diff --git a/src/core/ip_addr.c b/src/core/ip_addr.c index 77ac233eee..9c91c60e4e 100644 --- a/src/core/ip_addr.c +++ b/src/core/ip_addr.c @@ -717,6 +717,22 @@ char* get_proto_name(unsigned int proto) } }
+/** get address family name (asciiz). + * @param af - address family id + * @return string with the adderess family name or "unknown". + */ +char* get_af_name(unsigned int af) +{ + switch(af) { + case AF_INET: + return "IPv4"; + case AF_INET6: + return "IPv6"; + default: + return "unknown"; + } +} +
/** * match ip address with net address and bitmask diff --git a/src/core/ip_addr.h b/src/core/ip_addr.h index 4fcdebbe3e..7f910a49ce 100644 --- a/src/core/ip_addr.h +++ b/src/core/ip_addr.h @@ -304,6 +304,8 @@ char* get_proto_name(unsigned int proto); int get_valid_proto_string(unsigned int iproto, int utype, int vtype, str *sproto);
+char* get_af_name(unsigned int af); + #ifdef USE_MCAST /* Returns 1 if the given address is a multicast address */ int is_mcast(struct ip_addr* ip);