summaryrefslogtreecommitdiff
path: root/lib/ipaddr.h
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@users.noreply.github.com>2020-07-29 14:29:34 -0400
committerGitHub <noreply@github.com>2020-07-29 14:29:34 -0400
commit25ee44b52278c86fda27f76e932f6a12c375bf10 (patch)
treebea9a0e54e73dafb08400f7e2e435d5be7fa1e93 /lib/ipaddr.h
parent93d08879ad18f820ba00181aaf9a320471d3f7a8 (diff)
parent6894924238aa70b7031df3bf77548f1857342217 (diff)
Merge pull request #6732 from opensourcerouting/printfrr-prep
*: preparations for printfrr coccinelle run
Diffstat (limited to 'lib/ipaddr.h')
-rw-r--r--lib/ipaddr.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/ipaddr.h b/lib/ipaddr.h
index cd7f79a04e..a96c9788bc 100644
--- a/lib/ipaddr.h
+++ b/lib/ipaddr.h
@@ -33,9 +33,9 @@ extern "C" {
* Generic IP address - union of IPv4 and IPv6 address.
*/
enum ipaddr_type_t {
- IPADDR_NONE = 0,
- IPADDR_V4 = 1, /* IPv4 */
- IPADDR_V6 = 2, /* IPv6 */
+ IPADDR_NONE = AF_UNSPEC,
+ IPADDR_V4 = AF_INET,
+ IPADDR_V6 = AF_INET6,
};
struct ipaddr {
@@ -84,12 +84,8 @@ static inline int str2ipaddr(const char *str, struct ipaddr *ip)
static inline char *ipaddr2str(const struct ipaddr *ip, char *buf, int size)
{
buf[0] = '\0';
- if (ip) {
- if (IS_IPADDR_V4(ip))
- inet_ntop(AF_INET, &ip->ip.addr, buf, size);
- else if (IS_IPADDR_V6(ip))
- inet_ntop(AF_INET6, &ip->ip.addr, buf, size);
- }
+ if (ip)
+ inet_ntop(ip->ipa_type, &ip->ip.addr, buf, size);
return buf;
}
@@ -128,6 +124,10 @@ static inline bool ipaddr_isset(struct ipaddr *ip)
return (0 != memcmp(&a, ip, sizeof(struct ipaddr)));
}
+#ifdef _FRR_ATTRIBUTE_PRINTFRR
+#pragma FRR printfrr_ext "%pIA" (struct ipaddr *)
+#endif
+
#ifdef __cplusplus
}
#endif