1 /* $FreeBSD$ */ 2 3 /* 4 * Copyright (C) 2012 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * $Id$ 9 */ 10 11 #include "ipf.h" 12 13 14 void 15 printip(family, addr) 16 int family; 17 u_32_t *addr; 18 { 19 struct in_addr ipa; 20 21 if (family == AF_INET) { 22 ipa.s_addr = *addr; 23 if (ntohl(ipa.s_addr) < 256) 24 PRINTF("%lu", (u_long)ntohl(ipa.s_addr)); 25 else 26 PRINTF("%s", inet_ntoa(ipa)); 27 } 28 #ifdef USE_INET6 29 else if (family == AF_INET6) { 30 char buf[INET6_ADDRSTRLEN + 1]; 31 const char *str; 32 33 buf[0] = '\0'; 34 str = inet_ntop(AF_INET6, addr, buf, sizeof(buf) - 1); 35 if (str != NULL) 36 PRINTF("%s", str); 37 else 38 PRINTF("???"); 39 } 40 #endif 41 else 42 PRINTF("?(%d)?", family); 43 } 44