diff options
-rw-r--r-- | sbin/ping/ping.c | 14 | ||||
-rw-r--r-- | sbin/ping6/ping6.c | 59 |
2 files changed, 37 insertions, 36 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index caae637633e..d5a59337a2a 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.75 2006/03/23 03:30:49 deraadt Exp $ */ +/* $OpenBSD: ping.c,v 1.76 2006/04/10 08:05:13 deraadt Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; #else -static const char rcsid[] = "$OpenBSD: ping.c,v 1.75 2006/03/23 03:30:49 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: ping.c,v 1.76 2006/04/10 08:05:13 deraadt Exp $"; #endif #endif /* not lint */ @@ -356,7 +356,7 @@ main(int argc, char *argv[]) if (datalen >= sizeof(struct tvi)) /* can we time transfer */ timing = 1; packlen = datalen + MAXIPLEN + MAXICMPLEN; - if (!(packet = (u_char *)malloc((u_int)packlen))) + if (!(packet = malloc((size_t)packlen))) err(1, "malloc"); if (!(options & F_PINGFILLED)) for (i = sizeof(struct tvi); i < datalen; ++i) @@ -515,7 +515,7 @@ main(int argc, char *argv[]) continue; } fromlen = sizeof(from); - if ((cc = recvfrom(s, (char *)packet, packlen, 0, + if ((cc = recvfrom(s, packet, packlen, 0, (struct sockaddr *)&from, &fromlen)) < 0) { if (errno == EINTR) continue; @@ -616,7 +616,7 @@ pinger(void) (void)gettimeofday(&tv, (struct timezone *)NULL); tvi.tv_sec = htonl(tv.tv_sec); tvi.tv_usec = htonl(tv.tv_usec); - memcpy((u_int *)&outpack[8], &tvi, sizeof tvi); + memcpy(&outpack[8], &tvi, sizeof tvi); } cc = datalen + 8; /* skips ICMP portion */ @@ -633,7 +633,7 @@ pinger(void) ip->ip_sum = in_cksum((u_short *)outpackhdr, cc); } - i = sendto(s, (char *)packet, cc, 0, (struct sockaddr *)&whereto, + i = sendto(s, packet, cc, 0, (struct sockaddr *)&whereto, sizeof(whereto)); if (i < 0 || i != cc) { @@ -760,7 +760,7 @@ pr_pack(char *buf, int cc, struct sockaddr_in *from) /* We've got something other than an ECHOREPLY */ if (!(options & F_VERBOSE)) return; - ip2 = (struct ip *) (buf + hlen + sizeof (struct icmp)); + ip2 = (struct ip *)(buf + hlen + sizeof (struct icmp)); hlen2 = ip2->ip_hl << 2; if (cc >= hlen2 + 8 && check_icmph((struct ip *)(icp + sizeof (struct icmp))) != 1) diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 499f3c66b4d..168c10d7e4d 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping6.c,v 1.63 2006/03/17 16:11:06 otto Exp $ */ +/* $OpenBSD: ping6.c,v 1.64 2006/04/10 08:05:14 deraadt Exp $ */ /* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */ /* @@ -214,7 +214,6 @@ char *hostname; int ident; /* process id to identify our packets */ u_int8_t nonce[8]; /* nonce field for node information */ int hoplimit = -1; /* hoplimit */ -int pathmtu = 0; /* path MTU for the destination. 0 = unspec. */ /* counters */ long npackets; /* max packets to transmit */ @@ -271,7 +270,9 @@ int pr_bitrange(u_int32_t, int, int); void pr_retip(struct ip6_hdr *, u_char *); void summary(void); void tvsub(struct timeval *, struct timeval *); +#ifdef IPSEC_POLICY_IPSEC int setpolicy(int, char *); +#endif char *nigroup(char *); void usage(void); @@ -612,7 +613,7 @@ main(int argc, char *argv[]) if (!res->ai_addr) errx(1, "getaddrinfo failed"); - (void)memcpy(&dst, res->ai_addr, res->ai_addrlen); + memcpy(&dst, res->ai_addr, res->ai_addrlen); if ((s = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) @@ -643,7 +644,7 @@ main(int argc, char *argv[]) warnx("gateway resolves to multiple addresses"); if (setsockopt(s, IPPROTO_IPV6, IPV6_NEXTHOP, - gres->ai_addr, gres->ai_addrlen)) { + gres->ai_addr, gres->ai_addrlen)) { err(1, "setsockopt(IPV6_NEXTHOP)"); } @@ -659,20 +660,20 @@ main(int argc, char *argv[]) #ifdef IPV6_RECVHOPOPTS if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPOPTS, &opton, - sizeof(opton))) + (socklen_t)sizeof(opton))) err(1, "setsockopt(IPV6_RECVHOPOPTS)"); #else /* old adv. API */ if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPOPTS, &opton, - sizeof(opton))) + (socklen_t)sizeof(opton))) err(1, "setsockopt(IPV6_HOPOPTS)"); #endif #ifdef IPV6_RECVDSTOPTS if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVDSTOPTS, &opton, - sizeof(opton))) + (socklen_t)sizeof(opton))) err(1, "setsockopt(IPV6_RECVDSTOPTS)"); #else /* old adv. API */ if (setsockopt(s, IPPROTO_IPV6, IPV6_DSTOPTS, &opton, - sizeof(opton))) + (socklen_t)sizeof(opton))) err(1, "setsockopt(IPV6_DSTOPTS)"); #endif #ifdef IPV6_RECVRTHDRDSTOPTS @@ -708,7 +709,7 @@ main(int argc, char *argv[]) packlen = 2048 + IP6LEN + ICMP6ECHOLEN + EXTRA; } - if (!(packet = (u_char *)malloc((u_int)packlen))) + if (!(packet = malloc(packlen))) err(1, "Unable to allocate packet"); if (!(options & F_PINGFILLED)) for (i = ICMP6ECHOLEN; i < packlen; ++i) @@ -722,19 +723,19 @@ main(int argc, char *argv[]) hold = 1; if (options & F_SO_DEBUG) - (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&hold, - sizeof(hold)); + (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, &hold, + (socklen_t)sizeof(hold)); optval = IPV6_DEFHLIM; if (IN6_IS_ADDR_MULTICAST(&dst.sin6_addr)) if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, - &optval, sizeof(optval)) == -1) + &optval, (socklen_t)sizeof(optval)) == -1) err(1, "IPV6_MULTICAST_HOPS"); #ifdef IPV6_USE_MIN_MTU if (mflag != 1) { optval = mflag > 1 ? 0 : 1; if (setsockopt(s, IPPROTO_IPV6, IPV6_USE_MIN_MTU, - &optval, sizeof(optval)) == -1) + &optval, (socklen_t)sizeof(optval)) == -1) err(1, "setsockopt(IPV6_USE_MIN_MTU)"); } #ifdef IPV6_RECVPATHMTU @@ -791,7 +792,7 @@ main(int argc, char *argv[]) ICMP6_FILTER_SETPASSALL(&filt); } if (setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, &filt, - sizeof(filt)) < 0) + (socklen_t)sizeof(filt)) < 0) err(1, "setsockopt(ICMP6_FILTER)"); } #endif /*ICMP6_FILTER*/ @@ -806,7 +807,7 @@ main(int argc, char *argv[]) err(1, "setsockopt(IPV6_RECVRTHDR)"); #else /* old adv. API */ if (setsockopt(s, IPPROTO_IPV6, IPV6_RTHDR, &opton, - sizeof(opton))) + (socklen_t)sizeof(opton))) err(1, "setsockopt(IPV6_RTHDR)"); #endif } @@ -833,7 +834,7 @@ main(int argc, char *argv[]) /* set IP6 packet options */ if (ip6optlen) { - if ((scmsg = (char *)malloc(ip6optlen)) == 0) + if ((scmsg = malloc(ip6optlen)) == 0) errx(1, "can't allocate enough memory"); smsghdr.msg_control = (caddr_t)scmsg; smsghdr.msg_controllen = ip6optlen; @@ -987,13 +988,12 @@ main(int argc, char *argv[]) if (datalen > sockbufsize) warnx("you need -b to increase socket buffer size"); if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &sockbufsize, - sizeof(sockbufsize)) < 0) + (socklen_t)sizeof(sockbufsize)) < 0) err(1, "setsockopt(SO_SNDBUF)"); if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &sockbufsize, - sizeof(sockbufsize)) < 0) + (socklen_t)sizeof(sockbufsize)) < 0) err(1, "setsockopt(SO_RCVBUF)"); - } - else { + } else { if (datalen > 8 * 1024) /*XXX*/ warnx("you need -b to increase socket buffer size"); /* @@ -1003,8 +1003,8 @@ main(int argc, char *argv[]) * to get some stuff for /etc/ethers. */ hold = 48 * 1024; - setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&hold, - sizeof(hold)); + setsockopt(s, SOL_SOCKET, SO_RCVBUF, &hold, + (socklen_t)sizeof(hold)); } #endif @@ -1012,21 +1012,21 @@ main(int argc, char *argv[]) #ifndef USE_SIN6_SCOPE_ID #ifdef IPV6_RECVPKTINFO if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &optval, - sizeof(optval)) < 0) + (socklen_t)sizeof(optval)) < 0) warn("setsockopt(IPV6_RECVPKTINFO)"); /* XXX err? */ #else /* old adv. API */ if (setsockopt(s, IPPROTO_IPV6, IPV6_PKTINFO, &optval, - sizeof(optval)) < 0) + (socklen_t)sizeof(optval)) < 0) warn("setsockopt(IPV6_PKTINFO)"); /* XXX err? */ #endif #endif /* USE_SIN6_SCOPE_ID */ #ifdef IPV6_RECVHOPLIMIT if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &optval, - sizeof(optval)) < 0) + (socklen_t)sizeof(optval)) < 0) warn("setsockopt(IPV6_RECVHOPLIMIT)"); /* XXX err? */ #else /* old adv. API */ if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPLIMIT, &optval, - sizeof(optval)) < 0) + (socklen_t)sizeof(optval)) < 0) warn("setsockopt(IPV6_HOPLIMIT)"); /* XXX err? */ #endif @@ -1125,7 +1125,7 @@ main(int argc, char *argv[]) } else if (cc == 0) continue; - m.msg_name = (caddr_t)&from; + m.msg_name = &from; m.msg_namelen = sizeof(from); memset(&iov, 0, sizeof(iov)); iov[0].iov_base = (caddr_t)packet; @@ -1342,7 +1342,7 @@ pinger(void) errx(1, "internal error; length mismatch"); #endif - smsghdr.msg_name = (caddr_t)&dst; + smsghdr.msg_name = &dst; smsghdr.msg_namelen = sizeof(dst); memset(&iov, 0, sizeof(iov)); iov[0].iov_base = (caddr_t)outpack; @@ -1666,7 +1666,8 @@ pr_pack(u_char *buf, int cc, struct msghdr *mhdr) putchar(')'); goto fqdnend; } - ttl = (int32_t)ntohl(*(u_long *)&buf[off+ICMP6ECHOLEN+8]); + ttl = (int32_t)ntohl(*(u_long *) + &buf[off+ICMP6ECHOLEN+8]); if (comma) printf(","); if (!(ni->ni_flags & NI_FQDN_FLAG_VALIDTTL)) { |