Changeset View
Changeset View
Standalone View
Standalone View
sbin/ping6/ping6.c
Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | |||||
#define F_AUTHHDR 0x0200 | #define F_AUTHHDR 0x0200 | ||||
#define F_ENCRYPT 0x0400 | #define F_ENCRYPT 0x0400 | ||||
#endif /*IPSEC_POLICY_IPSEC*/ | #endif /*IPSEC_POLICY_IPSEC*/ | ||||
#endif /*IPSEC*/ | #endif /*IPSEC*/ | ||||
#define F_NODEADDR 0x0800 | #define F_NODEADDR 0x0800 | ||||
#define F_FQDN 0x1000 | #define F_FQDN 0x1000 | ||||
#define F_INTERFACE 0x2000 | #define F_INTERFACE 0x2000 | ||||
#define F_SRCADDR 0x4000 | #define F_SRCADDR 0x4000 | ||||
#define F_HOSTNAME 0x10000 | #define F_NUMERIC 0x10000 | ||||
#define F_FQDNOLD 0x20000 | #define F_FQDNOLD 0x20000 | ||||
#define F_NIGROUP 0x40000 | #define F_NIGROUP 0x40000 | ||||
#define F_SUPTYPES 0x80000 | #define F_SUPTYPES 0x80000 | ||||
#define F_NOMINMTU 0x100000 | #define F_NOMINMTU 0x100000 | ||||
#define F_ONCE 0x200000 | #define F_ONCE 0x200000 | ||||
#define F_AUDIBLE 0x400000 | #define F_AUDIBLE 0x400000 | ||||
#define F_MISSED 0x800000 | #define F_MISSED 0x800000 | ||||
#define F_DONTFRAG 0x1000000 | #define F_DONTFRAG 0x1000000 | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
#ifdef IPSEC_POLICY_IPSEC | #ifdef IPSEC_POLICY_IPSEC | ||||
#define ADDOPTS "P:" | #define ADDOPTS "P:" | ||||
#else | #else | ||||
#define ADDOPTS "AE" | #define ADDOPTS "AE" | ||||
#endif /*IPSEC_POLICY_IPSEC*/ | #endif /*IPSEC_POLICY_IPSEC*/ | ||||
#endif | #endif | ||||
while ((ch = getopt(argc, argv, | while ((ch = getopt(argc, argv, | ||||
"a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwWx:X:" ADDOPTS)) != -1) { | "a:b:c:Ddfg:h:I:i:l:mnNop:qrRS:s:tvwWx:X:" ADDOPTS)) != -1) { | ||||
#undef ADDOPTS | #undef ADDOPTS | ||||
switch (ch) { | switch (ch) { | ||||
case 'a': | case 'a': | ||||
{ | { | ||||
char *cp; | char *cp; | ||||
options &= ~F_NOUSERDATA; | options &= ~F_NOUSERDATA; | ||||
options |= F_NODEADDR; | options |= F_NODEADDR; | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | case 'f': | ||||
errx(1, "Must be superuser to flood ping"); | errx(1, "Must be superuser to flood ping"); | ||||
} | } | ||||
options |= F_FLOOD; | options |= F_FLOOD; | ||||
setbuf(stdout, (char *)NULL); | setbuf(stdout, (char *)NULL); | ||||
break; | break; | ||||
case 'g': | case 'g': | ||||
gateway = optarg; | gateway = optarg; | ||||
break; | break; | ||||
case 'H': | |||||
options |= F_HOSTNAME; | |||||
break; | |||||
case 'h': /* hoplimit */ | case 'h': /* hoplimit */ | ||||
hoplimit = strtol(optarg, &e, 10); | hoplimit = strtol(optarg, &e, 10); | ||||
if (*optarg == '\0' || *e != '\0') | if (*optarg == '\0' || *e != '\0') | ||||
errx(1, "illegal hoplimit %s", optarg); | errx(1, "illegal hoplimit %s", optarg); | ||||
if (255 < hoplimit || hoplimit < -1) | if (255 < hoplimit || hoplimit < -1) | ||||
errx(1, | errx(1, | ||||
"illegal hoplimit -- %s", optarg); | "illegal hoplimit -- %s", optarg); | ||||
break; | break; | ||||
Show All 37 Lines | |||||
#ifdef IPV6_USE_MIN_MTU | #ifdef IPV6_USE_MIN_MTU | ||||
mflag++; | mflag++; | ||||
break; | break; | ||||
#else | #else | ||||
errx(1, "-%c is not supported on this platform", ch); | errx(1, "-%c is not supported on this platform", ch); | ||||
/*NOTREACHED*/ | /*NOTREACHED*/ | ||||
#endif | #endif | ||||
case 'n': | case 'n': | ||||
options &= ~F_HOSTNAME; | options |= F_NUMERIC; | ||||
break; | break; | ||||
case 'N': | case 'N': | ||||
options |= F_NIGROUP; | options |= F_NIGROUP; | ||||
nig_oldmcprefix++; | nig_oldmcprefix++; | ||||
break; | break; | ||||
case 'o': | case 'o': | ||||
options |= F_ONCE; | options |= F_ONCE; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 1,758 Lines • ▼ Show 20 Lines | |||||
/* ARGSUSED */ | /* ARGSUSED */ | ||||
static void | static void | ||||
onint(int notused __unused) | onint(int notused __unused) | ||||
{ | { | ||||
/* | /* | ||||
* When doing reverse DNS lookups, the seenint flag might not | * When doing reverse DNS lookups, the seenint flag might not | ||||
* be noticed for a while. Just exit if we get a second SIGINT. | * be noticed for a while. Just exit if we get a second SIGINT. | ||||
*/ | */ | ||||
if ((options & F_HOSTNAME) && seenint != 0) | if (!(options & F_NUMERIC) && seenint != 0) | ||||
_exit(nreceived ? 0 : 2); | _exit(nreceived ? 0 : 2); | ||||
} | } | ||||
/* | /* | ||||
* summary -- | * summary -- | ||||
* Print out statistics. | * Print out statistics. | ||||
*/ | */ | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | |||||
* a hostname. | * a hostname. | ||||
*/ | */ | ||||
static const char * | static const char * | ||||
pr_addr(struct sockaddr *addr, int addrlen) | pr_addr(struct sockaddr *addr, int addrlen) | ||||
{ | { | ||||
static char buf[NI_MAXHOST]; | static char buf[NI_MAXHOST]; | ||||
int flag = 0; | int flag = 0; | ||||
if ((options & F_HOSTNAME) == 0) | if ((options & F_NUMERIC) != 0) | ||||
flag |= NI_NUMERICHOST; | flag |= NI_NUMERICHOST; | ||||
if (cap_getnameinfo(capdns, addr, addrlen, buf, sizeof(buf), NULL, 0, | if (cap_getnameinfo(capdns, addr, addrlen, buf, sizeof(buf), NULL, 0, | ||||
flag) == 0) | flag) == 0) | ||||
return (buf); | return (buf); | ||||
else | else | ||||
return "?"; | return "?"; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 257 Lines • Show Last 20 Lines |