diff options
author | wollman <wollman@FreeBSD.org> | 1995-03-16 17:32:27 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1995-03-16 17:32:27 +0000 |
commit | 8882d76eda0f65db86b70a8641d460198eb851a8 (patch) | |
tree | 5c2d441929d3849ef1585bf6a45ffbf8efc7b3b3 /sys/libkern | |
parent | 9c613cfeaeb4019f90ec8d3ffdfc4142386b7463 (diff) | |
download | FreeBSD-src-8882d76eda0f65db86b70a8641d460198eb851a8.zip FreeBSD-src-8882d76eda0f65db86b70a8641d460198eb851a8.tar.gz |
Add inet_ntoa() and replace ARP's private routine with same.
Diffstat (limited to 'sys/libkern')
-rw-r--r-- | sys/libkern/Makefile | 10 | ||||
-rw-r--r-- | sys/libkern/inet_ntoa.c | 49 |
2 files changed, 54 insertions, 5 deletions
diff --git a/sys/libkern/Makefile b/sys/libkern/Makefile index 1dc9785..d2383d2 100644 --- a/sys/libkern/Makefile +++ b/sys/libkern/Makefile @@ -1,15 +1,15 @@ # @(#)Makefile 7.9 (Berkeley) 6/1/93 -# $Id: Makefile,v 1.6 1995/01/10 01:57:56 bde Exp $ +# $Id: Makefile,v 1.7 1995/02/27 09:16:02 ugen Exp $ .undef NOPROFILE LIB= kern CFLAGS+= -I${.CURDIR} -I${.CURDIR}/.. -DKERNEL SRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c bcmp.c cmpdi2.c divdi3.c \ - ffs.c iordi3.c locc.c lshldi3.c lshrdi3.c mcount.c moddi3.c \ - muldi3.c negdi2.c notdi2.c qdivrem.c random.c rindex.c scanc.c \ - skpc.c strcat.c strcmp.c strcpy.c strlen.c strncmp.c strncpy.c \ - subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c + ffs.c iordi3.c inet_ntoa.c locc.c lshldi3.c lshrdi3.c mcount.c \ + moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c random.c rindex.c \ + scanc.c skpc.c strcat.c strcmp.c strcpy.c strlen.c strncmp.c \ + strncpy.c subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c .if exists(${.CURDIR}/${MACHINE}/Makefile.inc) .PATH: ${.CURDIR}/${MACHINE} diff --git a/sys/libkern/inet_ntoa.c b/sys/libkern/inet_ntoa.c new file mode 100644 index 0000000..dcc6078 --- /dev/null +++ b/sys/libkern/inet_ntoa.c @@ -0,0 +1,49 @@ + +/* + * Copyright 1994, 1995 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/systm.h> + +#include <netinet/in.h> + +char * +inet_ntoa(struct in_addr ina) +{ + static char buf[4*sizeof "123"]; + unsigned char *ucp = (unsigned char *)&ina; + + sprintf(buf, "%d.%d.%d.%d", + ucp[0] & 0xff, + ucp[1] & 0xff, + ucp[2] & 0xff, + ucp[3] & 0xff); + return buf; +} + |