From 4634c0e3d446d20566973d59d241cbce2fa1d470 Mon Sep 17 00:00:00 2001 From: ross Date: Mon, 12 Apr 1999 01:05:01 +0000 Subject: [PATCH] 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 --- 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(-) diff --git a/sys/lib/libkern/inet_addr.c b/sys/lib/libkern/inet_addr.c index 89f2b112538f..d23ac1c2d224 100644 --- a/sys/lib/libkern/inet_addr.c +++ b/sys/lib/libkern/inet_addr.c @@ -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 +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#include +#include +#else +#include +#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 --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h index 44a6f468ac41..902ef758af8b 100644 --- a/sys/lib/libkern/libkern.h +++ b/sys/lib/libkern/libkern.h @@ -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 @@ int strncmp __P((const char *, const char *, size_t)); 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 --git a/sys/lib/libsa/net.c b/sys/lib/libsa/net.c index ea6fc5198969..c8789b2839ea 100644 --- a/sys/lib/libsa/net.c +++ b/sys/lib/libsa/net.c @@ -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 @@ sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize) } } -/* - * 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 --git a/sys/lib/libsa/net.h b/sys/lib/libsa/net.h index c9af5a9eb944..e1913633cb25 100644 --- a/sys/lib/libsa/net.h +++ b/sys/lib/libsa/net.h @@ -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 @@ char *ether_sprintf __P((u_char *)); 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 --git a/sys/nfs/nfs_bootparam.c b/sys/nfs/nfs_bootparam.c index aa3ddaec2bb6..7f30558d28bf 100644 --- a/sys/nfs/nfs_bootparam.c +++ b/sys/nfs/nfs_bootparam.c @@ -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 @@ nfs_bootparam(nd, procp) 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;