Changeset View
Changeset View
Standalone View
Standalone View
sbin/ping6/ping6.c
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | |||||
static char BSPACE = '\b'; /* characters written for flood */ | static char BSPACE = '\b'; /* characters written for flood */ | ||||
static char BBELL = '\a'; /* characters written for AUDIBLE */ | static char BBELL = '\a'; /* characters written for AUDIBLE */ | ||||
static char DOT = '.'; | static char DOT = '.'; | ||||
static char *hostname; | static char *hostname; | ||||
static int ident; /* process id to identify our packets */ | static int ident; /* process id to identify our packets */ | ||||
static u_int8_t nonce[8]; /* nonce field for node information */ | static u_int8_t nonce[8]; /* nonce field for node information */ | ||||
static int hoplimit = -1; /* hoplimit */ | static int hoplimit = -1; /* hoplimit */ | ||||
static int tclass = -1; /* traffic class */ | static int tclass = -1; /* traffic class */ | ||||
static int pcp = -2; /* vlan priority code point */ | |||||
static u_char *packet = NULL; | static u_char *packet = NULL; | ||||
static cap_channel_t *capdns; | static cap_channel_t *capdns; | ||||
/* counters */ | /* counters */ | ||||
static long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ | static long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ | ||||
static long npackets; /* max packets to transmit */ | static long npackets; /* max packets to transmit */ | ||||
static long nreceived; /* # of packets we got back */ | static long nreceived; /* # of packets we got back */ | ||||
static long nrepeats; /* number of duplicates */ | static long nrepeats; /* number of duplicates */ | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
#ifdef IPSEC_POLICY_IPSEC | #ifdef IPSEC_POLICY_IPSEC | ||||
#define ADDOPTS "P:" | #define ADDOPTS "P:" | ||||
#else | #else | ||||
#define ADDOPTS "ZE" | #define ADDOPTS "ZE" | ||||
#endif /*IPSEC_POLICY_IPSEC*/ | #endif /*IPSEC_POLICY_IPSEC*/ | ||||
#endif | #endif | ||||
while ((ch = getopt(argc, argv, | while ((ch = getopt(argc, argv, | ||||
"k:b:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:z:" ADDOPTS)) != -1) { | "k:b:C:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:z:" ADDOPTS)) != -1) { | ||||
#undef ADDOPTS | #undef ADDOPTS | ||||
switch (ch) { | switch (ch) { | ||||
case 'k': | case 'k': | ||||
{ | { | ||||
char *cp; | char *cp; | ||||
options &= ~F_NOUSERDATA; | options &= ~F_NOUSERDATA; | ||||
options |= F_NODEADDR; | options |= F_NODEADDR; | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | #if defined(SO_SNDBUF) && defined(SO_RCVBUF) | ||||
if (errno || !*optarg || *e || | if (errno || !*optarg || *e || | ||||
lsockbufsize > INT_MAX) | lsockbufsize > INT_MAX) | ||||
errx(1, "invalid socket buffer size"); | errx(1, "invalid socket buffer size"); | ||||
#else | #else | ||||
errx(1, | errx(1, | ||||
"-b option ignored: SO_SNDBUF/SO_RCVBUF socket options not supported"); | "-b option ignored: SO_SNDBUF/SO_RCVBUF socket options not supported"); | ||||
#endif | #endif | ||||
break; | break; | ||||
case 'C': /* vlan priority code point */ | |||||
pcp = strtol(optarg, &e, 10); | |||||
if (*optarg == '\0' || *e != '\0') | |||||
errx(1, "illegal vlan pcp %s", optarg); | |||||
if (7 < pcp || pcp < -1) | |||||
errx(1, "illegal vlan pcp -- %s", optarg); | |||||
break; | |||||
case 'c': | case 'c': | ||||
npackets = strtol(optarg, &e, 10); | npackets = strtol(optarg, &e, 10); | ||||
if (npackets <= 0 || *optarg == '\0' || *e != '\0') | if (npackets <= 0 || *optarg == '\0' || *e != '\0') | ||||
errx(1, | errx(1, | ||||
"illegal number of packets -- %s", optarg); | "illegal number of packets -- %s", optarg); | ||||
break; | break; | ||||
case 'D': | case 'D': | ||||
options |= F_DONTFRAG; | options |= F_DONTFRAG; | ||||
▲ Show 20 Lines • Show All 521 Lines • ▼ Show 20 Lines | if (hoplimit != -1) { | ||||
scmsgp = CMSG_NXTHDR(&smsghdr, scmsgp); | scmsgp = CMSG_NXTHDR(&smsghdr, scmsgp); | ||||
} | } | ||||
if (tclass != -1) { | if (tclass != -1) { | ||||
if (setsockopt(ssend, IPPROTO_IPV6, IPV6_TCLASS, | if (setsockopt(ssend, IPPROTO_IPV6, IPV6_TCLASS, | ||||
&tclass, sizeof(tclass)) == -1) | &tclass, sizeof(tclass)) == -1) | ||||
err(1, "setsockopt(IPV6_TCLASS)"); | err(1, "setsockopt(IPV6_TCLASS)"); | ||||
} | |||||
if (pcp != -2) { | |||||
if (setsockopt(ssend, IPPROTO_IPV6, IPV6_VLAN_PCP, | |||||
&pcp, sizeof(pcp)) == -1) | |||||
err(1, "setsockopt(IPV6_VLAN_PCP)"); | |||||
} | } | ||||
if (argc > 1) { /* some intermediate addrs are specified */ | if (argc > 1) { /* some intermediate addrs are specified */ | ||||
int hops; | int hops; | ||||
int rthdrlen; | int rthdrlen; | ||||
rthdrlen = inet6_rth_space(IPV6_RTHDR_TYPE_0, argc - 1); | rthdrlen = inet6_rth_space(IPV6_RTHDR_TYPE_0, argc - 1); | ||||
scmsgp->cmsg_len = CMSG_LEN(rthdrlen); | scmsgp->cmsg_len = CMSG_LEN(rthdrlen); | ||||
▲ Show 20 Lines • Show All 1,927 Lines • Show Last 20 Lines |