traceroute(8): make WARNS=3 clean

Also fixes an operator precedence bug for TCP tracerouting
This commit is contained in:
Ulrich Spörlein 2010-12-04 14:19:27 +00:00
parent d180d7efa2
commit f02cd756de
5 changed files with 13 additions and 15 deletions

View File

@ -56,13 +56,14 @@ struct aslookup {
};
void *
as_setup(char *server)
as_setup(const char *server)
{
struct aslookup *asn;
struct addrinfo hints, *res0, *res;
FILE *f;
int s, error;
s = -1;
if (server == NULL)
server = getenv("RA_SERVER");
if (server == NULL)

View File

@ -30,6 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
void *as_setup(char *);
void *as_setup(const char *);
unsigned int as_lookup(void *, char *, sa_family_t);
void as_shutdown(void *);

View File

@ -71,14 +71,14 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf)
{
register int fd, nipaddr;
#ifdef HAVE_SOCKADDR_SA_LEN
register int n;
size_t n;
#endif
register struct ifreq *ifrp, *ifend, *ifnext, *mp;
register struct sockaddr_in *sin;
register struct ifaddrlist *al;
struct ifconf ifc;
struct ifreq ibuf[(32 * 1024) / sizeof(struct ifreq)], ifr;
#define MAX_IPADDR (sizeof(ibuf) / sizeof(ibuf[0]))
#define MAX_IPADDR ((int)(sizeof(ibuf) / sizeof(ibuf[0])))
static struct ifaddrlist ifaddrlist[MAX_IPADDR];
char device[sizeof(ifr.ifr_name) + 1];
@ -91,10 +91,10 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf)
ifc.ifc_buf = (caddr_t)ibuf;
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 ||
ifc.ifc_len < sizeof(struct ifreq)) {
ifc.ifc_len < (int)sizeof(struct ifreq)) {
if (errno == EINVAL)
(void)sprintf(errbuf,
"SIOCGIFCONF: ifreq struct too small (%d bytes)",
"SIOCGIFCONF: ifreq struct too small (%zu bytes)",
sizeof(ibuf));
else
(void)sprintf(errbuf, "SIOCGIFCONF: %s",

View File

@ -220,7 +220,6 @@ static const char rcsid[] =
#include <netinet/ip_var.h>
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
@ -1424,7 +1423,7 @@ tcp_check(const u_char *data, int seq)
return (ntohs(tcp->th_sport) == ident
&& ntohs(tcp->th_dport) == port + (fixedPort ? 0 : seq))
&& tcp->th_seq == (ident << 16) | (port + seq);
&& tcp->th_seq == (((tcp_seq)ident << 16) | (port + seq));
}
void
@ -1497,19 +1496,17 @@ u_short
p_cksum(struct ip *ip, u_short *data, int len)
{
static struct ipovly ipo;
u_short sumh, sumd;
u_long sumt;
u_short sum[2];
ipo.ih_pr = ip->ip_p;
ipo.ih_len = htons(len);
ipo.ih_src = ip->ip_src;
ipo.ih_dst = ip->ip_dst;
sumh = in_cksum((u_short*)&ipo, sizeof(ipo)); /* pseudo ip hdr cksum */
sumd = in_cksum((u_short*)data, len); /* payload data cksum */
sumt = (sumh << 16) | (sumd);
sum[1] = in_cksum((u_short*)&ipo, sizeof(ipo)); /* pseudo ip hdr cksum */
sum[0] = in_cksum(data, len); /* payload data cksum */
return ~in_cksum((u_short*)&sumt, sizeof(sumt));
return ~in_cksum(sum, sizeof(sum));
}
/*

View File

@ -31,7 +31,7 @@ LDADD= -lipsec
CFLAGS+= -I${TRACEROUTE_DISTDIR}
WARNS?= 0
WARNS?= 3
version.c: ${TRACEROUTE_DISTDIR}/VERSION
@rm -f ${.TARGET}