pp = findexistingpeer(&addr, NULL, NULL, -1, 0, NULL);
if (NULL == pp)
continue;
- if (IS_IPV6(srcadr)) {
+ if (IS_IPV6(&pp->srcadr)) {
if (pp->dstadr)
ip->dstadr6 =
(MDF_BCAST == pp->cast_flags)
static char currenthost[LENHOSTNAME]; /* current host name */
int showhostnames = 1; /* show host names by default */
-static int ai_fam_templ; /* address family */
-static int ai_fam_default; /* default address family */
+static int ai_fam_templ = AF_UNSPEC; /* address family */
+static int ai_fam_default = AF_UNSPEC; /* default address family */
static SOCKET sockfd; /* fd socket is opened on */
static int havehost = 0; /* set to 1 when host open */
int s_port = 0;
}
if (HAVE_OPT(IPV4))
- ai_fam_templ = AF_INET;
+ ai_fam_default = AF_INET;
else if (HAVE_OPT(IPV6))
- ai_fam_templ = AF_INET6;
- else
- ai_fam_templ = ai_fam_default;
+ ai_fam_default = AF_INET6;
+
+ ai_fam_templ = ai_fam_default;
if (HAVE_OPT(COMMAND)) {
int cmdct = STACKCT_OPT( COMMAND );
ai_fam_templ = AF_INET;
return -1;
}
- if (!getnetnum(str, &(argp->netnum), (char *)0, 0)) {
+ if (!getnetnum(str, &(argp->netnum), (char *)0, ai_fam_templ)) {
return 0;
}
break;
struct addrinfo hints, *ai = NULL;
ZERO(hints);
+ hints.ai_family = af;
hints.ai_flags = AI_CANONNAME;
#ifdef AI_ADDRCONFIG
hints.ai_flags |= AI_ADDRCONFIG;
if ((pcmd->nargs == 0) ||
((pcmd->argval->ival == 6) && (plist->v6_flag != 0)) ||
((pcmd->argval->ival == 4) && (plist->v6_flag == 0)))
- (void) fprintf(fp, "%-9s %s\n",
- modetoa(plist->hmode),
- nntohost(&paddr));
+ {
+ const char *strhost = nntohost(&paddr);
+ const char *straddr = stoa(&paddr);
+ (void) fprintf(fp, "%-12s %s",
+ modetoa(plist->hmode), strhost);
+ if (strcmp(strhost,straddr))
+ (void) fprintf(fp, " (%s)\n", straddr);
+ else
+ (void) fprintf(fp, "\n");
+ }
plist++;
items--;
}