1/* 2 * Copyright (C) 2012 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 */ 6 7#include "ipf.h" 8 9 10ipf_dstnode_t * 11printdstlistnode(inp, copyfunc, opts, fields) 12 ipf_dstnode_t *inp; 13 copyfunc_t copyfunc; 14 int opts; 15 wordtab_t *fields; 16{ 17 ipf_dstnode_t node, *np; 18 int i; 19#ifdef USE_INET6 20 char buf[INET6_ADDRSTRLEN+1]; 21 const char *str; 22#endif 23 24 if ((*copyfunc)(inp, &node, sizeof(node))) 25 return NULL; 26 27 np = calloc(1, node.ipfd_size); 28 if (np == NULL) 29 return node.ipfd_next; 30 if ((*copyfunc)(inp, np, node.ipfd_size)) 31 return NULL; 32 33 if (fields != NULL) { 34 for (i = 0; fields[i].w_value != 0; i++) { 35 printpoolfield(np, IPLT_DSTLIST, i); 36 if (fields[i + 1].w_value != 0) 37 printf("\t"); 38 } 39 printf("\n"); 40 } else if ((opts & OPT_DEBUG) == 0) { 41 putchar(' '); 42 if (np->ipfd_dest.fd_name >= 0) 43 PRINTF("%s:", np->ipfd_names); 44 if (np->ipfd_dest.fd_addr.adf_family == AF_INET) { 45 printip(AF_INET, (u_32_t *)&np->ipfd_dest.fd_ip); 46 } else { 47#ifdef USE_INET6 48 str = inet_ntop(AF_INET6, &np->ipfd_dest.fd_ip6, 49 buf, sizeof(buf) - 1); 50 if (str != NULL) 51 PRINTF("%s", str); 52#endif 53 } 54 putchar(';'); 55 } else { 56 PRINTF("Interface: [%s]/%d\n", np->ipfd_names, 57 np->ipfd_dest.fd_name); 58#ifdef USE_INET6 59 str = inet_ntop(np->ipfd_dest.fd_addr.adf_family, 60 &np->ipfd_dest.fd_ip6, buf, sizeof(buf) - 1); 61 if (str != NULL) { 62 PRINTF("\tAddress: %s\n", str); 63 } 64#else 65 PRINTF("\tAddress: %s\n", inet_ntoa(np->ipfd_dest.fd_ip)); 66#endif 67 PRINTF( 68#ifdef USE_QUAD_T 69 "\t\tStates %d\tRef %d\tName [%s]\tUid %d\n", 70#else 71 "\t\tStates %d\tRef %d\tName [%s]\tUid %d\n", 72#endif 73 np->ipfd_states, np->ipfd_ref, 74 np->ipfd_names, np->ipfd_uid); 75 } 76 free(np); 77 return node.ipfd_next; 78} 79