Changeset View
Changeset View
Standalone View
Standalone View
head/sbin/ping6/ping6.c
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | |||||
static u_char outpack[MAXPACKETLEN]; | static u_char outpack[MAXPACKETLEN]; | ||||
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 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:" ADDOPTS)) != -1) { | "k:b: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 216 Lines • ▼ Show 20 Lines | case 't': | ||||
timerclear(&itv.it_interval); | timerclear(&itv.it_interval); | ||||
timerclear(&itv.it_value); | timerclear(&itv.it_value); | ||||
itv.it_value.tv_sec = (time_t)alarmtimeout; | itv.it_value.tv_sec = (time_t)alarmtimeout; | ||||
if (setitimer(ITIMER_REAL, &itv, NULL) != 0) | if (setitimer(ITIMER_REAL, &itv, NULL) != 0) | ||||
err(1, "setitimer"); | err(1, "setitimer"); | ||||
} | } | ||||
break; | break; | ||||
case 'z': /* traffic class */ | |||||
tclass = strtol(optarg, &e, 10); | |||||
if (*optarg == '\0' || *e != '\0') | |||||
errx(1, "illegal traffic class %s", optarg); | |||||
if (255 < tclass || tclass < -1) | |||||
errx(1, | |||||
"illegal traffic class -- %s", optarg); | |||||
break; | |||||
#ifdef IPSEC | #ifdef IPSEC | ||||
#ifdef IPSEC_POLICY_IPSEC | #ifdef IPSEC_POLICY_IPSEC | ||||
case 'P': | case 'P': | ||||
options |= F_POLICY; | options |= F_POLICY; | ||||
if (!strncmp("in", optarg, 2)) { | if (!strncmp("in", optarg, 2)) { | ||||
if ((policy_in = strdup(optarg)) == NULL) | if ((policy_in = strdup(optarg)) == NULL) | ||||
errx(1, "strdup"); | errx(1, "strdup"); | ||||
} else if (!strncmp("out", optarg, 3)) { | } else if (!strncmp("out", optarg, 3)) { | ||||
▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
if (hoplimit != -1) { | if (hoplimit != -1) { | ||||
scmsgp->cmsg_len = CMSG_LEN(sizeof(int)); | scmsgp->cmsg_len = CMSG_LEN(sizeof(int)); | ||||
scmsgp->cmsg_level = IPPROTO_IPV6; | scmsgp->cmsg_level = IPPROTO_IPV6; | ||||
scmsgp->cmsg_type = IPV6_HOPLIMIT; | scmsgp->cmsg_type = IPV6_HOPLIMIT; | ||||
memcpy(CMSG_DATA(scmsgp), &hoplimit, sizeof(hoplimit)); | memcpy(CMSG_DATA(scmsgp), &hoplimit, sizeof(hoplimit)); | ||||
scmsgp = CMSG_NXTHDR(&smsghdr, scmsgp); | scmsgp = CMSG_NXTHDR(&smsghdr, scmsgp); | ||||
} | |||||
if (tclass != -1) { | |||||
if (setsockopt(ssend, IPPROTO_IPV6, IPV6_TCLASS, | |||||
&tclass, sizeof(tclass)) == -1) | |||||
err(1, "setsockopt(IPV6_TCLASS)"); | |||||
} | } | ||||
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 |