Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys libkern just got an inet_addr(), but it won't compile, n...



details:   https://anonhg.NetBSD.org/src/rev/2d7f594df9dd
branches:  trunk
changeset: 471812:2d7f594df9dd
user:      ross <ross%NetBSD.org@localhost>
date:      Mon Apr 12 01:05:01 1999 +0000

description:
libkern just got an inet_addr(), but it won't compile, no prototype. Cleanup...
* Add prototype to libkern.h.
* Remove the almost-identical-copy from libsa/net.[ch].
* Change its type back to the (wrong, but harmless) historical one. (u_long)
* Kill the XXX local prototype in nfs_bootparam.c

diffstat:

 sys/lib/libkern/inet_addr.c |  12 +++++-
 sys/lib/libkern/libkern.h   |   3 +-
 sys/lib/libsa/net.c         |  84 +--------------------------------------------
 sys/lib/libsa/net.h         |   3 +-
 sys/nfs/nfs_bootparam.c     |   3 +-
 5 files changed, 15 insertions(+), 90 deletions(-)

diffs (179 lines):

diff -r 62c6e6d8b618 -r 2d7f594df9dd sys/lib/libkern/inet_addr.c
--- a/sys/lib/libkern/inet_addr.c       Mon Apr 12 00:52:44 1999 +0000
+++ b/sys/lib/libkern/inet_addr.c       Mon Apr 12 01:05:01 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet_addr.c,v 1.1 1997/12/12 20:14:01 gwr Exp $        */
+/*     $NetBSD: inet_addr.c,v 1.2 1999/04/12 01:05:01 ross Exp $       */
 
 /* Copyright (c) 1996 by Internet Software Consortium.
  *
@@ -23,6 +23,14 @@
 
 #include <sys/types.h>
 
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#else
+#include <lib/libkern/libkern.h>
+#endif
+
 /*
  * Warning - these are not the standard definitions,
  * but are the minimum sufficient for this source.
@@ -36,7 +44,7 @@
  * Ascii internet address interpretation routine.
  * The value returned is in network order.
  */
-u_int32_t
+u_long
 inet_addr(src)
        const char *src;
 {
diff -r 62c6e6d8b618 -r 2d7f594df9dd sys/lib/libkern/libkern.h
--- a/sys/lib/libkern/libkern.h Mon Apr 12 00:52:44 1999 +0000
+++ b/sys/lib/libkern/libkern.h Mon Apr 12 01:05:01 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libkern.h,v 1.23 1998/07/31 23:44:41 perry Exp $       */
+/*     $NetBSD: libkern.h,v 1.24 1999/04/12 01:05:01 ross Exp $        */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -171,3 +171,4 @@
 char   *strncpy __P((char *, const char *, size_t));
 char   *strrchr __P((const char *, int));
 int     strncasecmp __P((const char *, const char *, size_t));
+u_long  inet_addr __P((const char *));
diff -r 62c6e6d8b618 -r 2d7f594df9dd sys/lib/libsa/net.c
--- a/sys/lib/libsa/net.c       Mon Apr 12 00:52:44 1999 +0000
+++ b/sys/lib/libsa/net.c       Mon Apr 12 01:05:01 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net.c,v 1.21 1999/02/11 09:10:44 pk Exp $      */
+/*     $NetBSD: net.c,v 1.22 1999/04/12 01:05:01 ross Exp $    */
 
 /*
  * Copyright (c) 1992 Regents of the University of California.
@@ -349,88 +349,6 @@
        }
 }
 
-/*
- * Like inet_addr() in the C library, but we only accept base-10.
- * Return values are in network order.
- */
-n_long
-inet_addr(cp)
-       char *cp;
-{
-       register u_long val;
-       register int n;
-       register char c;
-       u_int parts[4];
-       register u_int *pp = parts;
-
-       for (;;) {
-               /*
-                * Collect number up to ``.''.
-                * Values are specified as for C:
-                * 0x=hex, 0=octal, other=decimal.
-                */
-               val = 0;
-               while ((c = *cp) != '\0') {
-                       if (c >= '0' && c <= '9') {
-                               val = (val * 10) + (c - '0');
-                               cp++;
-                               continue;
-                       }
-                       break;
-               }
-               if (*cp == '.') {
-                       /*
-                        * Internet format:
-                        *      a.b.c.d
-                        *      a.b.c   (with c treated as 16-bits)
-                        *      a.b     (with b treated as 24 bits)
-                        */
-                       if (pp >= parts + 3 || val > 0xff)
-                               goto bad;
-                       *pp++ = val, cp++;
-               } else
-                       break;
-       }
-       /*
-        * Check for trailing characters.
-        */
-       if (*cp != '\0')
-               goto bad;
-
-       /*
-        * Concoct the address according to
-        * the number of parts specified.
-        */
-       n = pp - parts + 1;
-       switch (n) {
-
-       case 1:                         /* a -- 32 bits */
-               break;
-
-       case 2:                         /* a.b -- 8.24 bits */
-               if (val > 0xffffff)
-                       goto bad;
-               val |= parts[0] << 24;
-               break;
-
-       case 3:                         /* a.b.c -- 8.8.16 bits */
-               if (val > 0xffff)
-                       goto bad;
-               val |= (parts[0] << 24) | (parts[1] << 16);
-               break;
-
-       case 4:                         /* a.b.c.d -- 8.8.8.8 bits */
-               if (val > 0xff)
-                       goto bad;
-               val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
-               break;
-       }
-
-       return (htonl(val));
- bad:
-       return (htonl(INADDR_NONE));
-}
-
 char *
 inet_ntoa(ia)
        struct in_addr ia;
diff -r 62c6e6d8b618 -r 2d7f594df9dd sys/lib/libsa/net.h
--- a/sys/lib/libsa/net.h       Mon Apr 12 00:52:44 1999 +0000
+++ b/sys/lib/libsa/net.h       Mon Apr 12 01:05:01 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net.h,v 1.11 1999/02/11 09:10:44 pk Exp $      */
+/*     $NetBSD: net.h,v 1.12 1999/04/12 01:05:01 ross Exp $    */
 
 /*
  * Copyright (c) 1993 Adam Glass 
@@ -114,7 +114,6 @@
 int    in_cksum __P((void *, int));
 char   *inet_ntoa __P((struct in_addr));
 char   *intoa __P((n_long));           /* similar to inet_ntoa */
-n_long inet_addr __P((char *));
 int    in_cksum __P((void *, int));
 n_long ip_convertaddr __P((char *));
 
diff -r 62c6e6d8b618 -r 2d7f594df9dd sys/nfs/nfs_bootparam.c
--- a/sys/nfs/nfs_bootparam.c   Mon Apr 12 00:52:44 1999 +0000
+++ b/sys/nfs/nfs_bootparam.c   Mon Apr 12 01:05:01 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_bootparam.c,v 1.12 1999/04/11 22:15:25 gwr Exp $   */
+/*     $NetBSD: nfs_bootparam.c,v 1.13 1999/04/12 01:05:01 ross Exp $  */
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -111,7 +111,6 @@
        struct nfs_diskless *nd;
        struct proc *procp;
 {
-       extern u_int32_t inet_addr __P((char *)); /* XXX libkern */
        struct ifnet *ifp = nd->nd_ifp;
        struct in_addr my_ip, arps_ip, gw_ip;
        struct sockaddr_in bp_sin;



Home | Main Index | Thread Index | Old Index