bcmp is obsolete
[unix-history] / usr / src / sbin / ping / ping.c
index 8260077..e5a5aa4 100644 (file)
@@ -1,6 +1,6 @@
 /*
 /*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1989, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Mike Muuss.
  *
  * This code is derived from software contributed to Berkeley by
  * Mike Muuss.
@@ -9,13 +9,13 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
- All rights reserved.\n";
+static char copyright[] =
+"@(#) Copyright (c) 1989, 1993\n\
      The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)ping.c     5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)ping.c     8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -214,7 +214,7 @@ main(argc, argv)
                usage();
        target = *argv;
 
                usage();
        target = *argv;
 
-       bzero((char *)&whereto, sizeof(struct sockaddr));
+       memset(&whereto, 0, sizeof(struct sockaddr));
        to = (struct sockaddr_in *)&whereto;
        to->sin_family = AF_INET;
        to->sin_addr.s_addr = inet_addr(target);
        to = (struct sockaddr_in *)&whereto;
        to->sin_family = AF_INET;
        to->sin_addr.s_addr = inet_addr(target);
@@ -228,7 +228,7 @@ main(argc, argv)
                        exit(1);
                }
                to->sin_family = hp->h_addrtype;
                        exit(1);
                }
                to->sin_family = hp->h_addrtype;
-               bcopy(hp->h_addr, (caddr_t)&to->sin_addr, hp->h_length);
+               memmove(&to->sin_addr, hp->h_addr, hp->h_length);
                (void)strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
                hostname = hnamebuf;
        }
                (void)strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
                hostname = hnamebuf;
        }
@@ -567,7 +567,7 @@ pr_pack(buf, cc, from)
                                continue;
                        if (i == old_rrlen
                            && cp == (u_char *)buf + sizeof(struct ip) + 2
                                continue;
                        if (i == old_rrlen
                            && cp == (u_char *)buf + sizeof(struct ip) + 2
-                           && !bcmp((char *)cp, old_rr, i)
+                           && !memcmp(cp, old_rr, i)
                            && !(options & F_FLOOD)) {
                                (void)printf("\t(same route)");
                                i = ((i + 3) / 4) * 4;
                            && !(options & F_FLOOD)) {
                                (void)printf("\t(same route)");
                                i = ((i + 3) / 4) * 4;
@@ -576,7 +576,7 @@ pr_pack(buf, cc, from)
                                break;
                        }
                        old_rrlen = i;
                                break;
                        }
                        old_rrlen = i;
-                       bcopy((char *)cp, old_rr, i);
+                       memmove(old_rr, cp, i);
                        (void)printf("\nRR: ");
                        for (;;) {
                                l = *++cp;
                        (void)printf("\nRR: ");
                        for (;;) {
                                l = *++cp;
@@ -939,7 +939,9 @@ fill(bp, patp)
            &pat[13], &pat[14], &pat[15]);
 
        if (ii > 0)
            &pat[13], &pat[14], &pat[15]);
 
        if (ii > 0)
-               for (kk = 0; kk <= MAXPACKET - (8 + ii); kk += ii)
+               for (kk = 0;
+                   kk <= MAXPACKET - (8 + sizeof(struct timeval) + ii);
+                   kk += ii)
                        for (jj = 0; jj < ii; ++jj)
                                bp[jj + kk] = pat[jj];
        if (!(options & F_QUIET)) {
                        for (jj = 0; jj < ii; ++jj)
                                bp[jj + kk] = pat[jj];
        if (!(options & F_QUIET)) {