Kill __P(), use ANSI function declarations; WARNS=3.

This commit is contained in:
xtraeme 2005-02-09 14:09:46 +00:00
parent a8d83732cf
commit 39707ce809
2 changed files with 64 additions and 97 deletions

View File

@ -1,8 +1,10 @@
# $NetBSD: Makefile,v 1.7 2002/05/26 13:01:21 itojun Exp $ # $NetBSD: Makefile,v 1.8 2005/02/09 14:09:46 xtraeme Exp $
PROG= ping6 PROG= ping6
MAN= ping6.8 MAN= ping6.8
WARNS= 3
BINOWN= root BINOWN= root
BINMODE=4555 BINMODE=4555

View File

@ -1,4 +1,4 @@
/* $NetBSD: ping6.c,v 1.61 2004/10/29 19:20:36 dsl Exp $ */ /* $NetBSD: ping6.c,v 1.62 2005/02/09 14:09:46 xtraeme Exp $ */
/* $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */ /* $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */
/* /*
@ -77,7 +77,7 @@ static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
#else #else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: ping6.c,v 1.61 2004/10/29 19:20:36 dsl Exp $"); __RCSID("$NetBSD: ping6.c,v 1.62 2005/02/09 14:09:46 xtraeme Exp $");
#endif #endif
#endif #endif
@ -249,41 +249,38 @@ volatile sig_atomic_t seenint;
volatile sig_atomic_t seeninfo; volatile sig_atomic_t seeninfo;
#endif #endif
int main __P((int, char *[])); void fill(char *, char *);
void fill __P((char *, char *)); int get_hoplim(struct msghdr *);
int get_hoplim __P((struct msghdr *)); int get_pathmtu(struct msghdr *);
int get_pathmtu __P((struct msghdr *)); struct in6_pktinfo *get_rcvpktinfo(struct msghdr *);
struct in6_pktinfo *get_rcvpktinfo __P((struct msghdr *)); void onsignal(int);
void onsignal __P((int)); void retransmit(void);
void retransmit __P((void)); void onint(int);
void onint __P((int)); size_t pingerlen(void);
size_t pingerlen __P((void)); int pinger(void);
int pinger __P((void)); const char *pr_addr(struct sockaddr *, int);
const char *pr_addr __P((struct sockaddr *, int)); void pr_icmph(struct icmp6_hdr *, u_char *);
void pr_icmph __P((struct icmp6_hdr *, u_char *)); void pr_iph(struct ip6_hdr *);
void pr_iph __P((struct ip6_hdr *)); void pr_suptypes(struct icmp6_nodeinfo *, size_t);
void pr_suptypes __P((struct icmp6_nodeinfo *, size_t)); void pr_nodeaddr(struct icmp6_nodeinfo *, int);
void pr_nodeaddr __P((struct icmp6_nodeinfo *, int)); int myechoreply(const struct icmp6_hdr *);
int myechoreply __P((const struct icmp6_hdr *)); int mynireply(const struct icmp6_nodeinfo *);
int mynireply __P((const struct icmp6_nodeinfo *)); char *dnsdecode(const u_char **, const u_char *, const u_char *,
char *dnsdecode __P((const u_char **, const u_char *, const u_char *, char *, size_t);
char *, size_t)); void pr_pack(u_char *, int, struct msghdr *);
void pr_pack __P((u_char *, int, struct msghdr *)); void pr_exthdrs(struct msghdr *);
void pr_exthdrs __P((struct msghdr *)); void pr_ip6opt(void *);
void pr_ip6opt __P((void *)); void pr_rthdr(void *);
void pr_rthdr __P((void *)); int pr_bitrange(u_int32_t, int, int);
int pr_bitrange __P((u_int32_t, int, int)); void pr_retip(struct ip6_hdr *, u_char *);
void pr_retip __P((struct ip6_hdr *, u_char *)); void summary(void);
void summary __P((void)); void tvsub(struct timeval *, struct timeval *);
void tvsub __P((struct timeval *, struct timeval *)); int setpolicy(int, char *);
int setpolicy __P((int, char *)); char *nigroup(char *);
char *nigroup __P((char *)); void usage(void);
void usage __P((void));
int int
main(argc, argv) main(int argc, char *argv[])
int argc;
char *argv[];
{ {
struct itimerval itimer; struct itimerval itimer;
struct sockaddr_in6 from; struct sockaddr_in6 from;
@ -1143,8 +1140,7 @@ main(argc, argv)
} }
void void
onsignal(sig) onsignal(int sig)
int sig;
{ {
switch (sig) { switch (sig) {
@ -1167,7 +1163,7 @@ onsignal(sig)
* This routine transmits another ping6. * This routine transmits another ping6.
*/ */
void void
retransmit() retransmit(void)
{ {
struct itimerval itimer; struct itimerval itimer;
@ -1203,7 +1199,7 @@ retransmit()
* byte-order, to compute the round-trip time. * byte-order, to compute the round-trip time.
*/ */
size_t size_t
pingerlen() pingerlen(void)
{ {
size_t l; size_t l;
@ -1222,7 +1218,7 @@ pingerlen()
} }
int int
pinger() pinger(void)
{ {
struct icmp6_hdr *icp; struct icmp6_hdr *icp;
struct iovec iov[2]; struct iovec iov[2];
@ -1337,8 +1333,7 @@ pinger()
} }
int int
myechoreply(icp) myechoreply(const struct icmp6_hdr *icp)
const struct icmp6_hdr *icp;
{ {
if (ntohs(icp->icmp6_id) == ident) if (ntohs(icp->icmp6_id) == ident)
return 1; return 1;
@ -1347,8 +1342,7 @@ myechoreply(icp)
} }
int int
mynireply(nip) mynireply(const struct icmp6_nodeinfo *nip)
const struct icmp6_nodeinfo *nip;
{ {
if (memcmp(nip->icmp6_ni_nonce + sizeof(u_int16_t), if (memcmp(nip->icmp6_ni_nonce + sizeof(u_int16_t),
nonce + sizeof(u_int16_t), nonce + sizeof(u_int16_t),
@ -1359,12 +1353,8 @@ mynireply(nip)
} }
char * char *
dnsdecode(sp, ep, base, buf, bufsiz) dnsdecode(const u_char **sp, const u_char *ep, const u_char *base, char *buf,
const u_char **sp; size_t bufsiz)
const u_char *ep;
const u_char *base; /*base for compressed name*/
char *buf;
size_t bufsiz;
{ {
int i; int i;
const u_char *cp; const u_char *cp;
@ -1429,10 +1419,7 @@ dnsdecode(sp, ep, base, buf, bufsiz)
* program to be run without having intermingled output (or statistics!). * program to be run without having intermingled output (or statistics!).
*/ */
void void
pr_pack(buf, cc, mhdr) pr_pack(u_char *buf, int cc, struct msghdr *mhdr)
u_char *buf;
int cc;
struct msghdr *mhdr;
{ {
#define safeputc(c) printf((isprint((c)) ? "%c" : "\\%03o"), c) #define safeputc(c) printf((isprint((c)) ? "%c" : "\\%03o"), c)
struct icmp6_hdr *icp; struct icmp6_hdr *icp;
@ -1710,8 +1697,7 @@ pr_pack(buf, cc, mhdr)
} }
void void
pr_exthdrs(mhdr) pr_exthdrs(struct msghdr *mhdr)
struct msghdr *mhdr;
{ {
struct cmsghdr *cm; struct cmsghdr *cm;
@ -1846,10 +1832,7 @@ pr_rthdr(void *extbuf)
#endif /* USE_RFC2292BIS */ #endif /* USE_RFC2292BIS */
int int
pr_bitrange(v, soff, ii) pr_bitrange(u_int32_t v, int soff, int ii)
u_int32_t v;
int soff;
int ii;
{ {
int off; int off;
int i; int i;
@ -1895,9 +1878,8 @@ pr_bitrange(v, soff, ii)
} }
void void
pr_suptypes(ni, nilen) pr_suptypes(struct icmp6_nodeinfo *ni /* ni->qtype must be SUPTYPES */,
struct icmp6_nodeinfo *ni; /* ni->qtype must be SUPTYPES */ size_t nilen)
size_t nilen;
{ {
size_t clen; size_t clen;
u_int32_t v; u_int32_t v;
@ -1962,9 +1944,8 @@ pr_suptypes(ni, nilen)
} }
void void
pr_nodeaddr(ni, nilen) pr_nodeaddr(struct icmp6_nodeinfo *ni, /* ni->qtype must be NODEADDR */
struct icmp6_nodeinfo *ni; /* ni->qtype must be NODEADDR */ int nilen)
int nilen;
{ {
u_char *cp = (u_char *)(ni + 1); u_char *cp = (u_char *)(ni + 1);
char ntop_buf[INET6_ADDRSTRLEN]; char ntop_buf[INET6_ADDRSTRLEN];
@ -2029,8 +2010,7 @@ pr_nodeaddr(ni, nilen)
} }
int int
get_hoplim(mhdr) get_hoplim(struct msghdr *mhdr)
struct msghdr *mhdr;
{ {
struct cmsghdr *cm; struct cmsghdr *cm;
@ -2049,8 +2029,7 @@ get_hoplim(mhdr)
} }
struct in6_pktinfo * struct in6_pktinfo *
get_rcvpktinfo(mhdr) get_rcvpktinfo(struct msghdr *mhdr)
struct msghdr *mhdr;
{ {
struct cmsghdr *cm; struct cmsghdr *cm;
@ -2069,8 +2048,7 @@ get_rcvpktinfo(mhdr)
} }
int int
get_pathmtu(mhdr) get_pathmtu(struct msghdr *mhdr)
struct msghdr *mhdr;
{ {
#ifdef IPV6_RECVPATHMTU #ifdef IPV6_RECVPATHMTU
struct cmsghdr *cm; struct cmsghdr *cm;
@ -2130,8 +2108,7 @@ get_pathmtu(mhdr)
* be >= in. * be >= in.
*/ */
void void
tvsub(out, in) tvsub(struct timeval *out, struct timeval *in)
struct timeval *out, *in;
{ {
if ((out->tv_usec -= in->tv_usec) < 0) { if ((out->tv_usec -= in->tv_usec) < 0) {
--out->tv_sec; --out->tv_sec;
@ -2146,8 +2123,7 @@ tvsub(out, in)
*/ */
/* ARGSUSED */ /* ARGSUSED */
void void
onint(notused) onint(int notused)
int notused;
{ {
summary(); summary();
@ -2163,7 +2139,7 @@ onint(notused)
* Print out statistics. * Print out statistics.
*/ */
void void
summary() summary(void)
{ {
(void)printf("\n--- %s ping6 statistics ---\n", hostname); (void)printf("\n--- %s ping6 statistics ---\n", hostname);
@ -2211,9 +2187,7 @@ static const char *nircode[] = {
* Print a descriptive string about an ICMP header. * Print a descriptive string about an ICMP header.
*/ */
void void
pr_icmph(icp, end) pr_icmph(struct icmp6_hdr *icp, u_char *end)
struct icmp6_hdr *icp;
u_char *end;
{ {
char ntop_buf[INET6_ADDRSTRLEN]; char ntop_buf[INET6_ADDRSTRLEN];
struct nd_redirect *red; struct nd_redirect *red;
@ -2443,8 +2417,7 @@ pr_icmph(icp, end)
* Print an IP6 header. * Print an IP6 header.
*/ */
void void
pr_iph(ip6) pr_iph(struct ip6_hdr *ip6)
struct ip6_hdr *ip6;
{ {
u_int32_t flow = ip6->ip6_flow & IPV6_FLOWLABEL_MASK; u_int32_t flow = ip6->ip6_flow & IPV6_FLOWLABEL_MASK;
u_int8_t tc; u_int8_t tc;
@ -2472,9 +2445,7 @@ pr_iph(ip6)
* a hostname. * a hostname.
*/ */
const char * const char *
pr_addr(addr, addrlen) pr_addr(struct sockaddr *addr, int addrlen)
struct sockaddr *addr;
int addrlen;
{ {
static char buf[NI_MAXHOST]; static char buf[NI_MAXHOST];
int flag = 0; int flag = 0;
@ -2493,9 +2464,7 @@ pr_addr(addr, addrlen)
* Dump some info on a returned (via ICMPv6) IPv6 packet. * Dump some info on a returned (via ICMPv6) IPv6 packet.
*/ */
void void
pr_retip(ip6, end) pr_retip(struct ip6_hdr *ip6, u_char *end)
struct ip6_hdr *ip6;
u_char *end;
{ {
u_char *cp = (u_char *)ip6, nh; u_char *cp = (u_char *)ip6, nh;
int hlen; int hlen;
@ -2575,8 +2544,7 @@ pr_retip(ip6, end)
} }
void void
fill(bp, patp) fill(char *bp, char *patp)
char *bp, *patp;
{ {
int ii, jj, kk; int ii, jj, kk;
int pat[16]; int pat[16];
@ -2609,9 +2577,7 @@ fill(bp, patp)
#ifdef IPSEC #ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC #ifdef IPSEC_POLICY_IPSEC
int int
setpolicy(so, policy) setpolicy(int so, char *policy)
int so;
char *policy;
{ {
char *buf; char *buf;
@ -2632,8 +2598,7 @@ setpolicy(so, policy)
#endif #endif
char * char *
nigroup(name) nigroup(char *name)
char *name;
{ {
char *p; char *p;
char *q; char *q;
@ -2677,7 +2642,7 @@ nigroup(name)
} }
void void
usage() usage(void)
{ {
(void)fprintf(stderr, (void)fprintf(stderr,
"usage: ping6 [-dfH" "usage: ping6 [-dfH"