/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <netinet/in_systm.h>
#include <netinet/if_ether.h>
#include <netdb.h>
#include <string.h>
#include <signal.h>
#include <setjmp.h>
#include "snoop.h"
struct hostdata {
char *h_hostname;
int h_pktsout;
int h_pktsin;
};
struct hostdata4 {
char *h4_hostname;
int h4_pktsout;
int h4_pktsin;
};
struct hostdata6 {
char *h6_hostname;
int h6_pktsout;
int h6_pktsin;
};
/* ARGSUSED */
static void
wakeup(int n)
{
}
extern char *inet_ntoa();
static struct hostdata *
{
register struct hostdata4 *h;
int error_num;
return ((struct hostdata *)h);
}
/* not found. Put it in */
/*
* Set an alarm here so we don't get held up by
* an unresponsive name server.
* Give it 3 sec to do its work.
*/
if (np)
}
(void) snoop_alarm(0, wakeup);
}
return (retval);
}
static struct hostdata *
{
struct hostdata6 *h;
int error_num;
char *addname;
h = h->h6_next) {
return ((struct hostdata *)h);
}
/* not in the hash table, put it in */
/*
* Set an alarm here so we don't get held up by
* an unresponsive name server.
* Give it 3 sec to do its work.
*/
(void) snoop_alarm(0, wakeup);
} else {
}
else {
}
return (retval);
}
static struct hostdata *
{
int hashval;
char *np;
static struct hostdata h;
int ind;
switch (family) {
case AF_INET:
if (n == NULL)
goto alloc_failed;
if (n->h_hostname == NULL)
goto alloc_failed;
break;
case AF_INET6:
if (n == NULL)
goto alloc_failed;
if (n->h_hostname == NULL)
goto alloc_failed;
sizeof (struct in6_addr));
break;
default:
family);
exit(1);
}
*hp = n;
if (np) {
if (aliases) {
for (ind = 0;
ind++) {
}
}
}
sizeof (aname));
if (np) {
if (aliases) {
for (ind = 0;
ind++) {
}
}
}
} else {
family);
}
}
return (n);
if (n)
free(n);
aname[0] = '\0';
h.h_hostname = aname;
return (&h);
}
char *
{
switch (family) {
case AF_INET:
case AF_INET6:
}
family);
exit(1);
/* NOTREACHED */
}
void
char *fname;
{
FILE *f;
unsigned int addrv4;
int family;
void *naddr;
if (f == NULL) {
return;
}
continue;
}
continue;
(*alias != '#')) {
}
/* Note: certain addresses such as broadcast are skipped */
}
(void) fclose(f);
}
/*
* lgetipnodebyname: looks up hostname in cached address data. This allows
* filtering on hostnames from the .names file to work properly, and
* avoids name clashes between domains. Note that only the first of the
* ipv4, ipv6, or v4mapped address will be returned, because the
* cache does not contain information on multi-homed hosts.
*/
/*ARGSUSED*/
struct hostent *
{
int i;
struct hostdata4 *h;
int ind;
h_name[0] = '\0';
for (i = 0; i < MAXADDRS; i++)
ind = 0;
/* ipv6 lookup */
for (i = 0; i < MAXHASH; i++) {
/* too many addresses */
return (hp);
}
/* found ipv6 addr */
ind++;
}
}
}
}
/* ipv4 or v4mapped lookup */
for (i = 0; i < MAXHASH; i++) {
/* too many addresses */
return (hp);
}
/* found ipv4 addr */
sizeof (struct in_addr);
(char *)&h->h4_addr;
ind++;
} else {
/* found v4mapped addr */
sizeof (struct in6_addr);
&h->h4_addr,
ind++;
}
}
}
}
}
}