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
This commit is contained in:
ross 1999-04-12 01:05:01 +00:00
parent f9a07c51b8
commit 4634c0e3d4
5 changed files with 15 additions and 90 deletions

View File

@ -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;
{

View File

@ -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 *));

View File

@ -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;

View File

@ -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 *));

View File

@ -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;