@@ -, +, @@ --- clockdiff.c | 16 ++++++++-------- ping.c | 32 ++++++++++++++++---------------- ping6.c | 6 +++--- ping_common.c | 8 ++++---- ping_common.h | 2 +- rdisc.c | 40 ++++++++++++++++++++-------------------- tftpd.c | 24 ++++++++++++------------ traceroute6.c | 10 +++++----- 8 files changed, 69 insertions(+), 69 deletions(-) --- a/clockdiff.c +++ a/clockdiff.c @@ -44,11 +44,11 @@ void usage(void) __attribute__((noreturn)); } \ } -int in_cksum(u_short *addr, int len) +int in_cksum(unsigned short *addr, int len) { union word { char c[2]; - u_short s; + unsigned short s; } u; int sum = 0; @@ -71,7 +71,7 @@ int in_cksum(u_short *addr, int len) /* * Odd number of bytes. */ - u.c[0] = *(u_char *)addr; + u.c[0] = *(unsigned char *)addr; } if (len == -1) { /* The last mbuf has odd # of bytes. Follow the @@ -112,7 +112,7 @@ int ip_opt_len = 0; int measure_delta; int measure_delta1; -static u_short seqno, seqno0, acked; +static unsigned short seqno, seqno0, acked; long rtt = 1000; long min_rtt; long rtt_sigma = 0; @@ -132,7 +132,7 @@ measure(struct sockaddr_in * addr) long min1, min2, diff; long delta1, delta2; struct timeval tv1, tout; - u_char packet[PACKET_IN], opacket[64]; + unsigned char packet[PACKET_IN], opacket[64]; struct icmphdr *icp = (struct icmphdr *) packet; struct icmphdr *oicp = (struct icmphdr *) opacket; struct iphdr *ip = (struct iphdr *) packet; @@ -194,7 +194,7 @@ empty: (void)gettimeofday (&tv1, (struct timezone *)0); *(__u32*)(oicp+1) = htonl((tv1.tv_sec % (24*60*60)) * 1000 + tv1.tv_usec / 1000); - oicp->checksum = in_cksum((u_short *)oicp, sizeof(*oicp) + 12); + oicp->checksum = in_cksum((unsigned short *)oicp, sizeof(*oicp) + 12); count = sendto(sock_raw, (char *)opacket, sizeof(*oicp)+12, 0, (struct sockaddr *)addr, sizeof(struct sockaddr_in)); @@ -309,7 +309,7 @@ measure_opt(struct sockaddr_in * addr) long min1, min2, diff; long delta1, delta2; struct timeval tv1, tout; - u_char packet[PACKET_IN], opacket[64]; + unsigned char packet[PACKET_IN], opacket[64]; struct icmphdr *icp = (struct icmphdr *) packet; struct icmphdr *oicp = (struct icmphdr *) opacket; struct iphdr *ip = (struct iphdr *) packet; @@ -372,7 +372,7 @@ empty: gettimeofday (&tv1, NULL); ((__u32*)(oicp+1))[0] = htonl((tv1.tv_sec % (24*60*60)) * 1000 + tv1.tv_usec / 1000); - oicp->checksum = in_cksum((u_short *)oicp, sizeof(*oicp)+12); + oicp->checksum = in_cksum((unsigned short *)oicp, sizeof(*oicp)+12); count = sendto(sock_raw, (char *)opacket, sizeof(*oicp)+12, 0, (struct sockaddr *)addr, sizeof(struct sockaddr_in)); --- a/ping.c +++ a/ping.c @@ -91,7 +91,7 @@ struct sockaddr_in whereto; /* who to ping */ int optlen = 0; int settos = 0; /* Set TOS, Precendence or other QOS options */ int icmp_sock; /* socket file descriptor */ -u_char outpack[0x10000]; +unsigned char outpack[0x10000]; int maxpacket = sizeof(outpack); static int broadcast_pings = 0; @@ -100,7 +100,7 @@ static char *pr_addr(__u32); static void pr_options(unsigned char * cp, int hlen); static void pr_iph(struct iphdr *ip); static void usage(void) __attribute__((noreturn)); -static u_short in_cksum(const u_short *addr, int len, u_short salt); +static unsigned short in_cksum(const unsigned short *addr, int len, unsigned short salt); static void pr_icmph(__u8 type, __u8 code, __u32 info, struct icmphdr *icp); static int parsetos(char *str); @@ -122,7 +122,7 @@ main(int argc, char **argv) struct hostent *hp; int ch, hold, packlen; int socket_errno; - u_char *packet; + unsigned char *packet; char *target; #ifdef USE_IDN char *hnamebuf = NULL; @@ -575,7 +575,7 @@ main(int argc, char **argv) if (datalen >= sizeof(struct timeval)) /* can we time transfer */ timing = 1; packlen = datalen + MAXIPLEN + MAXICMPLEN; - if (!(packet = (u_char *)malloc((u_int)packlen))) { + if (!(packet = (unsigned char *)malloc((unsigned int)packlen))) { fprintf(stderr, "ping: out of memory.\n"); exit(2); } @@ -720,13 +720,13 @@ int send_probe() cc = datalen + 8; /* skips ICMP portion */ /* compute ICMP checksum here */ - icp->checksum = in_cksum((u_short *)icp, cc, 0); + icp->checksum = in_cksum((unsigned short *)icp, cc, 0); if (timing && !(options&F_LATENCY)) { struct timeval tmp_tv; gettimeofday(&tmp_tv, NULL); memcpy(icp+1, &tmp_tv, sizeof(tmp_tv)); - icp->checksum = in_cksum((u_short *)&tmp_tv, sizeof(tmp_tv), ~icp->checksum); + icp->checksum = in_cksum((unsigned short *)&tmp_tv, sizeof(tmp_tv), ~icp->checksum); } do { @@ -779,7 +779,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv) /* Now the ICMP part */ cc -= hlen; icp = (struct icmphdr *)(buf + hlen); - csfailed = in_cksum((u_short *)icp, cc, 0); + csfailed = in_cksum((unsigned short *)icp, cc, 0); if (icp->type == ICMP_ECHOREPLY) { if (icp->un.echo.id != ident) @@ -894,17 +894,17 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv) #if BYTE_ORDER == LITTLE_ENDIAN # define ODDBYTE(v) (v) #elif BYTE_ORDER == BIG_ENDIAN -# define ODDBYTE(v) ((u_short)(v) << 8) +# define ODDBYTE(v) ((unsigned short)(v) << 8) #else -# define ODDBYTE(v) htons((u_short)(v) << 8) +# define ODDBYTE(v) htons((unsigned short)(v) << 8) #endif -u_short -in_cksum(const u_short *addr, register int len, u_short csum) +unsigned short +in_cksum(const unsigned short *addr, register int len, unsigned short csum) { register int nleft = len; - const u_short *w = addr; - register u_short answer; + const unsigned short *w = addr; + register unsigned short answer; register int sum = csum; /* @@ -920,7 +920,7 @@ in_cksum(const u_short *addr, register int len, u_short csum) /* mop up an odd byte, if necessary */ if (nleft == 1) - sum += ODDBYTE(*(u_char *)w); /* le16toh() may be unavailable on old systems */ + sum += ODDBYTE(*(unsigned char *)w); /* le16toh() may be unavailable on old systems */ /* * add back carry outs from top 16 bits to low 16 bits @@ -1238,10 +1238,10 @@ void pr_options(unsigned char * cp, int hlen) void pr_iph(struct iphdr *ip) { int hlen; - u_char *cp; + unsigned char *cp; hlen = ip->ihl << 2; - cp = (u_char *)ip + 20; /* point to options */ + cp = (unsigned char *)ip + 20; /* point to options */ printf("Vr HL TOS Len ID Flg off TTL Pro cks Src Dst Data\n"); printf(" %1x %1x %02x %04x %04x", --- a/ping6.c +++ a/ping6.c @@ -149,7 +149,7 @@ struct cmsghdr *srcrt; #endif struct sockaddr_in6 whereto; /* who to ping */ -u_char outpack[MAXPACKET]; +unsigned char outpack[MAXPACKET]; int maxpacket = sizeof(outpack); static unsigned char cmsgbuf[4096]; @@ -695,7 +695,7 @@ static int hextoui(const char *str) int main(int argc, char *argv[]) { int ch, hold, packlen; - u_char *packet; + unsigned char *packet; char *target; struct addrinfo hints, *ai; int gai; @@ -1074,7 +1074,7 @@ int main(int argc, char *argv[]) timing = 1; } packlen = datalen + 8 + 4096 + 40 + 8; /* 4096 for rthdr */ - if (!(packet = (u_char *)malloc((u_int)packlen))) { + if (!(packet = (unsigned char *)malloc((unsigned int)packlen))) { fprintf(stderr, "ping: out of memory.\n"); exit(2); } --- a/ping_common.c +++ a/ping_common.c @@ -209,7 +209,7 @@ static void fill(char *patp) int ii, jj, kk; int pat[16]; char *cp; - u_char *bp = outpack+8; + unsigned char *bp = outpack+8; #ifdef USE_IDN setlocale(LC_ALL, "C"); @@ -672,7 +672,7 @@ void setup(int icmp_sock) if (!(options & F_PINGFILLED)) { int i; - u_char *p = outpack+8; + unsigned char *p = outpack+8; /* Do not forget about case of small datalen, * fill timestamp area too! @@ -958,13 +958,13 @@ restamp: printf(" (BAD CHECKSUM!)"); /* check the data */ - cp = ((u_char*)ptr) + sizeof(struct timeval); + cp = ((unsigned char*)ptr) + sizeof(struct timeval); dp = &outpack[8 + sizeof(struct timeval)]; for (i = sizeof(struct timeval); i < datalen; ++i, ++cp, ++dp) { if (*cp != *dp) { printf("\nwrong data byte #%d should be 0x%x but was 0x%x", i, *dp, *cp); - cp = (u_char*)ptr + sizeof(struct timeval); + cp = (unsigned char*)ptr + sizeof(struct timeval); for (i = sizeof(struct timeval); i < datalen; ++i, ++cp) { if ((i % 32) == sizeof(struct timeval)) printf("\n#%d\t", i); --- a/ping_common.h +++ a/ping_common.h @@ -118,7 +118,7 @@ static inline bitmap_t rcvd_test(__u16 seq) return A(bit) & B(bit); } -extern u_char outpack[]; +extern unsigned char outpack[]; extern int maxpacket; extern int datalen; --- a/rdisc.c +++ a/rdisc.c @@ -119,11 +119,11 @@ static void init(void); /* For router advertisement */ struct icmp_ra { - u_char icmp_type; /* type of message, see below */ - u_char icmp_code; /* type sub code */ - u_short icmp_cksum; /* ones complement cksum of struct */ - u_char icmp_num_addrs; - u_char icmp_wpa; /* Words per address */ + unsigned char icmp_type; /* type of message, see below */ + unsigned char icmp_code; /* type sub code */ + unsigned short icmp_cksum; /* ones complement cksum of struct */ + unsigned char icmp_num_addrs; + unsigned char icmp_wpa; /* Words per address */ short icmp_lifetime; }; @@ -208,7 +208,7 @@ static void graceful_finish(void); static void finish(void); static void timer(void); static void initifs(void); -static u_short in_cksum(u_short *addr, int len); +static unsigned short in_cksum(unsigned short *addr, int len); static int logging = 0; @@ -460,7 +460,7 @@ next: timer(); /* start things going */ for (;;) { - u_char packet[MAXPACKET]; + unsigned char packet[MAXPACKET]; int len = sizeof (packet); socklen_t fromlen = sizeof (from); int cc; @@ -540,7 +540,7 @@ void timer() void solicitor(struct sockaddr_in *sin) { - static u_char outpack[MAXPACKET]; + static unsigned char outpack[MAXPACKET]; struct icmphdr *icp = (struct icmphdr *) ALLIGN(outpack); int packetlen, i; @@ -555,7 +555,7 @@ solicitor(struct sockaddr_in *sin) packetlen = 8; /* Compute ICMP checksum here */ - icp->checksum = in_cksum( (u_short *)icp, packetlen ); + icp->checksum = in_cksum( (unsigned short *)icp, packetlen ); if (isbroadcast(sin)) i = sendbcast(s, (char *)outpack, packetlen); @@ -584,7 +584,7 @@ solicitor(struct sockaddr_in *sin) void advertise(struct sockaddr_in *sin, int lft) { - static u_char outpack[MAXPACKET]; + static unsigned char outpack[MAXPACKET]; struct icmp_ra *rap = (struct icmp_ra *) ALLIGN(outpack); struct icmp_ra_addr *ap; int packetlen, i, cc; @@ -615,7 +615,7 @@ advertise(struct sockaddr_in *sin, int lft) rap->icmp_num_addrs++; /* Compute ICMP checksum here */ - rap->icmp_cksum = in_cksum( (u_short *)rap, packetlen ); + rap->icmp_cksum = in_cksum( (unsigned short *)rap, packetlen ); if (isbroadcast(sin)) cc = sendbcastif(s, (char *)outpack, packetlen, @@ -749,7 +749,7 @@ pr_pack(char *buf, int cc, struct sockaddr_in *from) /* TBD verify that the link is multicast or broadcast */ /* XXX Find out the link it came in over? */ - if (in_cksum((u_short *)ALLIGN(buf+hlen), cc)) { + if (in_cksum((unsigned short *)ALLIGN(buf+hlen), cc)) { if (verbose) logtrace("ICMP %s from %s: Bad checksum\n", pr_type((int)rap->icmp_type), @@ -838,7 +838,7 @@ pr_pack(char *buf, int cc, struct sockaddr_in *from) /* TBD verify that the link is multicast or broadcast */ /* XXX Find out the link it came in over? */ - if (in_cksum((u_short *)ALLIGN(buf+hlen), cc)) { + if (in_cksum((unsigned short *)ALLIGN(buf+hlen), cc)) { if (verbose) logtrace("ICMP %s from %s: Bad checksum\n", pr_type((int)icp->type), @@ -914,16 +914,16 @@ pr_pack(char *buf, int cc, struct sockaddr_in *from) #if BYTE_ORDER == LITTLE_ENDIAN # define ODDBYTE(v) (v) #elif BYTE_ORDER == BIG_ENDIAN -# define ODDBYTE(v) ((u_short)(v) << 8) +# define ODDBYTE(v) ((unsigned short)(v) << 8) #else -# define ODDBYTE(v) htons((u_short)(v) << 8) +# define ODDBYTE(v) htons((unsigned short)(v) << 8) #endif -u_short in_cksum(u_short *addr, int len) +unsigned short in_cksum(unsigned short *addr, int len) { register int nleft = len; - register u_short *w = addr; - register u_short answer; + register unsigned short *w = addr; + register unsigned short answer; register int sum = 0; /* @@ -939,7 +939,7 @@ u_short in_cksum(u_short *addr, int len) /* mop up an odd byte, if necessary */ if( nleft == 1 ) - sum += ODDBYTE(*(u_char *)w); /* le16toh() may be unavailable on old systems */ + sum += ODDBYTE(*(unsigned char *)w); /* le16toh() may be unavailable on old systems */ /* * add back carry outs from top 16 bits to low 16 bits @@ -1263,7 +1263,7 @@ join(int sock, struct sockaddr_in *sin) int support_multicast() { int sock; - u_char ttl = 1; + unsigned char ttl = 1; sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) { --- a/tftpd.c +++ a/tftpd.c @@ -363,8 +363,8 @@ void sendfile(struct formats *pf) nak(errno + 100); goto abort; } - dp->th_opcode = htons((u_short)DATA); - dp->th_block = htons((u_short)block); + dp->th_opcode = htons((unsigned short)DATA); + dp->th_block = htons((unsigned short)block); timeout = 0; (void) setjmp(timeoutbuf); @@ -383,8 +383,8 @@ send_data: syslog(LOG_ERR, "tftpd: read: %m\n"); goto abort; } - ap->th_opcode = ntohs((u_short)ap->th_opcode); - ap->th_block = ntohs((u_short)ap->th_block); + ap->th_opcode = ntohs((unsigned short)ap->th_opcode); + ap->th_block = ntohs((unsigned short)ap->th_block); if (ap->th_opcode == ERROR) goto abort; @@ -429,8 +429,8 @@ void recvfile(struct formats *pf) ap = (struct tftphdr *)ackbuf; do { timeout = 0; - ap->th_opcode = htons((u_short)ACK); - ap->th_block = htons((u_short)block); + ap->th_opcode = htons((unsigned short)ACK); + ap->th_block = htons((unsigned short)block); block++; (void) setjmp(timeoutbuf); send_ack: @@ -448,8 +448,8 @@ send_ack: syslog(LOG_ERR, "tftpd: read: %m\n"); goto abort; } - dp->th_opcode = ntohs((u_short)dp->th_opcode); - dp->th_block = ntohs((u_short)dp->th_block); + dp->th_opcode = ntohs((unsigned short)dp->th_opcode); + dp->th_block = ntohs((unsigned short)dp->th_block); if (dp->th_opcode == ERROR) goto abort; if (dp->th_opcode == DATA) { @@ -474,8 +474,8 @@ send_ack: write_behind(file, pf->f_convert); (void) fclose(file); /* close data file */ - ap->th_opcode = htons((u_short)ACK); /* send the "final" ack */ - ap->th_block = htons((u_short)(block)); + ap->th_opcode = htons((unsigned short)ACK); /* send the "final" ack */ + ap->th_block = htons((unsigned short)(block)); (void) send(peer, ackbuf, 4, confirmed); signal(SIGALRM, justquit); /* just quit on timeout */ @@ -519,8 +519,8 @@ void nak(int error) register struct errmsg *pe; tp = (struct tftphdr *)buf; - tp->th_opcode = htons((u_short)ERROR); - tp->th_code = htons((u_short)error); + tp->th_opcode = htons((unsigned short)ERROR); + tp->th_code = htons((unsigned short)error); for (pe = errmsgs; pe->e_code >= 0; pe++) if (pe->e_code == error) break; --- a/traceroute6.c +++ a/traceroute6.c @@ -288,10 +288,10 @@ char copyright[] = #define Fprintf (void)fprintf #define Printf (void)printf -u_char packet[512]; /* last inbound (icmp) packet */ +unsigned char packet[512]; /* last inbound (icmp) packet */ int wait_for_reply(int, struct sockaddr_in6 *, struct in6_addr *, int); -int packet_ok(u_char *buf, int cc, struct sockaddr_in6 *from, +int packet_ok(unsigned char *buf, int cc, struct sockaddr_in6 *from, struct in6_addr *to, int seq, struct timeval *); void send_probe(int seq, int ttl); double deltaT (struct timeval *, struct timeval *); @@ -314,7 +314,7 @@ char *hostname; int nprobes = 3; int max_ttl = 30; pid_t ident; -u_short port = 32768+666; /* start udp dest port # for probe packets */ +unsigned short port = 32768+666; /* start udp dest port # for probe packets */ int options; /* socket options */ int verbose; int waittime = 5; /* time to wait for response (in seconds) */ @@ -821,12 +821,12 @@ char * pr_type(unsigned char t) } -int packet_ok(u_char *buf, int cc, struct sockaddr_in6 *from, +int packet_ok(unsigned char *buf, int cc, struct sockaddr_in6 *from, struct in6_addr *to, int seq, struct timeval *tv) { struct icmp6_hdr *icp; - u_char type, code; + unsigned char type, code; icp = (struct icmp6_hdr *) buf; --