Changeset View
Changeset View
Standalone View
Standalone View
sbin/ping/ping6.c
- This file was moved from sbin/ping6/ping6.c.
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | |||||
#ifdef IPSEC | #ifdef IPSEC | ||||
#include <netipsec/ah.h> | #include <netipsec/ah.h> | ||||
#include <netipsec/ipsec.h> | #include <netipsec/ipsec.h> | ||||
#endif | #endif | ||||
#include <md5.h> | #include <md5.h> | ||||
#include "main.h" | |||||
#include "ping6.h" | |||||
struct tv32 { | struct tv32 { | ||||
u_int32_t tv32_sec; | u_int32_t tv32_sec; | ||||
u_int32_t tv32_nsec; | u_int32_t tv32_nsec; | ||||
}; | }; | ||||
#define MAXPACKETLEN 131072 | #define MAXPACKETLEN 131072 | ||||
#define IP6LEN 40 | #define IP6LEN 40 | ||||
#define ICMP6ECHOLEN 8 /* icmp echo header len excluding time */ | #define ICMP6ECHOLEN 8 /* icmp echo header len excluding time */ | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
static struct iovec smsgiov; | static struct iovec smsgiov; | ||||
static char *scmsg = 0; | static char *scmsg = 0; | ||||
static volatile sig_atomic_t seenint; | static volatile sig_atomic_t seenint; | ||||
#ifdef SIGINFO | #ifdef SIGINFO | ||||
static volatile sig_atomic_t seeninfo; | static volatile sig_atomic_t seeninfo; | ||||
#endif | #endif | ||||
int main(int, char *[]); | |||||
static cap_channel_t *capdns_setup(void); | static cap_channel_t *capdns_setup(void); | ||||
static void fill(char *, char *); | static void fill(char *, char *); | ||||
static int get_hoplim(struct msghdr *); | static int get_hoplim(struct msghdr *); | ||||
static int get_pathmtu(struct msghdr *); | static int get_pathmtu(struct msghdr *); | ||||
static struct in6_pktinfo *get_rcvpktinfo(struct msghdr *); | static struct in6_pktinfo *get_rcvpktinfo(struct msghdr *); | ||||
static void onsignal(int); | static void onsignal(int); | ||||
static void onint(int); | static void onint(int); | ||||
static size_t pingerlen(void); | static size_t pingerlen(void); | ||||
Show All 11 Lines | |||||
static void pr_exthdrs(struct msghdr *); | static void pr_exthdrs(struct msghdr *); | ||||
static void pr_ip6opt(void *, size_t); | static void pr_ip6opt(void *, size_t); | ||||
static void pr_rthdr(void *, size_t); | static void pr_rthdr(void *, size_t); | ||||
static int pr_bitrange(u_int32_t, int, int); | static int pr_bitrange(u_int32_t, int, int); | ||||
static void pr_retip(struct ip6_hdr *, u_char *); | static void pr_retip(struct ip6_hdr *, u_char *); | ||||
static void summary(void); | static void summary(void); | ||||
static int setpolicy(int, char *); | static int setpolicy(int, char *); | ||||
static char *nigroup(char *, int); | static char *nigroup(char *, int); | ||||
static void usage(void); | |||||
int | int | ||||
main(int argc, char *argv[]) | ping6(int argc, char *argv[]) | ||||
{ | { | ||||
struct timespec last, intvl; | struct timespec last, intvl; | ||||
struct sockaddr_in6 from, *sin6; | struct sockaddr_in6 from, *sin6; | ||||
struct addrinfo hints, *res; | struct addrinfo hints, *res; | ||||
struct sigaction si_sa; | struct sigaction si_sa; | ||||
int cc, i; | int cc, i; | ||||
int almost_done, ch, hold, packlen, preload, optval, error; | int almost_done, ch, hold, packlen, preload, optval, error; | ||||
int nig_oldmcprefix = -1; | int nig_oldmcprefix = -1; | ||||
▲ Show 20 Lines • Show All 41 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) { | "6k:b:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:" ADDOPTS)) != -1) { | ||||
#undef ADDOPTS | #undef ADDOPTS | ||||
switch (ch) { | switch (ch) { | ||||
case '6': | |||||
/* This options is processed in main(). */ | |||||
asomers: s/options/option/ | |||||
jansucanUnsubmitted Done Inline ActionsFixed. jansucan: Fixed. | |||||
break; | |||||
case 'k': | case 'k': | ||||
{ | { | ||||
char *cp; | char *cp; | ||||
options &= ~F_NOUSERDATA; | options &= ~F_NOUSERDATA; | ||||
options |= F_NODEADDR; | options |= F_NODEADDR; | ||||
for (cp = optarg; *cp != '\0'; cp++) { | for (cp = optarg; *cp != '\0'; cp++) { | ||||
switch (*cp) { | switch (*cp) { | ||||
▲ Show 20 Lines • Show All 2,426 Lines • ▼ Show 20 Lines | if (nig_oldmcprefix) { | ||||
/* RFC 4620 */ | /* RFC 4620 */ | ||||
bcopy(digest, &in6.s6_addr[13], 3); | bcopy(digest, &in6.s6_addr[13], 3); | ||||
} | } | ||||
if (inet_ntop(AF_INET6, &in6, hbuf, sizeof(hbuf)) == NULL) | if (inet_ntop(AF_INET6, &in6, hbuf, sizeof(hbuf)) == NULL) | ||||
return NULL; | return NULL; | ||||
return strdup(hbuf); | return strdup(hbuf); | ||||
} | |||||
static void | |||||
usage(void) | |||||
{ | |||||
(void)fprintf(stderr, | |||||
#if defined(IPSEC) && !defined(IPSEC_POLICY_IPSEC) | |||||
"Z" | |||||
#endif | |||||
"usage: ping6 [-" | |||||
"aADd" | |||||
#if defined(IPSEC) && !defined(IPSEC_POLICY_IPSEC) | |||||
"E" | |||||
#endif | |||||
"fHnNoOq" | |||||
#ifdef IPV6_USE_MIN_MTU | |||||
"u" | |||||
#endif | |||||
"vyY] " | |||||
"[-b bufsiz] [-c count] [-e gateway]\n" | |||||
" [-I interface] [-i wait] [-k addrtype] [-l preload] " | |||||
"[-m hoplimit]\n" | |||||
" [-p pattern]" | |||||
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) | |||||
" [-P policy]" | |||||
#endif | |||||
" [-S sourceaddr] [-s packetsize]\n" | |||||
" [-t timeout] [-W waittime] [hops ...] host\n"); | |||||
exit(1); | |||||
} | } | ||||
static cap_channel_t * | static cap_channel_t * | ||||
capdns_setup(void) | capdns_setup(void) | ||||
{ | { | ||||
cap_channel_t *capcas, *capdnsloc; | cap_channel_t *capcas, *capdnsloc; | ||||
#ifdef WITH_CASPER | #ifdef WITH_CASPER | ||||
const char *types[2]; | const char *types[2]; | ||||
Show All 21 Lines |
s/options/option/