summaryrefslogtreecommitdiff
path: root/lib/printip.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/printip.c')
-rw-r--r--lib/printip.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/printip.c b/lib/printip.c
index fb91208e9f6b7..82c0ff4ecd780 100644
--- a/lib/printip.c
+++ b/lib/printip.c
@@ -1,22 +1,41 @@
/*
- * Copyright (C) 2002-2005 by Darren Reed.
+ * Copyright (C) 2012 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
- * $Id: printip.c,v 1.3.4.1 2006/06/16 17:21:12 darrenr Exp $
+ * $Id$
*/
#include "ipf.h"
-void printip(addr)
-u_32_t *addr;
+void
+printip(family, addr)
+ int family;
+ u_32_t *addr;
{
struct in_addr ipa;
- ipa.s_addr = *addr;
- if (ntohl(ipa.s_addr) < 256)
- printf("%lu", (u_long)ntohl(ipa.s_addr));
+ if (family == AF_INET) {
+ ipa.s_addr = *addr;
+ if (ntohl(ipa.s_addr) < 256)
+ PRINTF("%lu", (u_long)ntohl(ipa.s_addr));
+ else
+ PRINTF("%s", inet_ntoa(ipa));
+ }
+#ifdef AF_INET6
+ else if (family == AF_INET6) {
+ char buf[INET6_ADDRSTRLEN + 1];
+ const char *str;
+
+ buf[0] = '\0';
+ str = inet_ntop(AF_INET6, addr, buf, sizeof(buf) - 1);
+ if (str != NULL)
+ PRINTF("%s", str);
+ else
+ PRINTF("???");
+ }
+#endif
else
- printf("%s", inet_ntoa(ipa));
+ PRINTF("?(%d)?", family);
}