139528Sdfr/*
239528Sdfr * Copyright (c) 1983, 1993
339528Sdfr *	The Regents of the University of California.  All rights reserved.
439528Sdfr *
539528Sdfr * Redistribution and use in source and binary forms, with or without
639528Sdfr * modification, are permitted provided that the following conditions
739528Sdfr * are met:
839528Sdfr * 1. Redistributions of source code must retain the above copyright
939528Sdfr *    notice, this list of conditions and the following disclaimer.
1039528Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1139528Sdfr *    notice, this list of conditions and the following disclaimer in the
1239528Sdfr *    documentation and/or other materials provided with the distribution.
1339528Sdfr * 4. Neither the name of the University nor the names of its contributors
1439528Sdfr *    may be used to endorse or promote products derived from this software
1539528Sdfr *    without specific prior written permission.
1639528Sdfr *
1739528Sdfr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1839528Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1939528Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2039528Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2139528Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2239528Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2339528Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2439528Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2539528Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2639528Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2739528Sdfr * SUCH DAMAGE.
2839528Sdfr */
2939528Sdfr
3084221Sdillon#include <sys/cdefs.h>
3184221Sdillon__FBSDID("$FreeBSD$");
3284221Sdillon
3339528Sdfr#if defined(LIBC_SCCS) && !defined(lint)
3439528Sdfrstatic char sccsid[] = "@(#)inet_ntoa.c	8.1 (Berkeley) 6/4/93";
3539528Sdfr#endif /* LIBC_SCCS and not lint */
3639528Sdfr
3739528Sdfr#include <sys/types.h>
3839528Sdfr#include <sys/socket.h>
3939528Sdfr#include <netinet/in.h>
4039528Sdfr#include <arpa/inet.h>
4139536Sjkh#include "stand.h"
4239528Sdfr
4339528Sdfr/*
4439528Sdfr * Convert network-format internet address
4539528Sdfr * to base 256 d.d.d.d representation.
4639528Sdfr */
4739528Sdfrchar *
4839528Sdfrinet_ntoa(in)
4939528Sdfr	struct in_addr in;
5039528Sdfr{
5139528Sdfr	static const char fmt[] = "%u.%u.%u.%u";
5239528Sdfr	static char ret[sizeof "255.255.255.255"];
5339607Sdfr	unsigned char *src = (unsigned char *) &in;
5439528Sdfr
5539528Sdfr	sprintf(ret, fmt, src[0], src[1], src[2], src[3]);
5639528Sdfr	return (ret);
5739528Sdfr}
5839528Sdfr
5939528Sdfr/*
6039528Sdfr * Weak aliases for applications that use certain private entry points,
6139528Sdfr * and fail to include <arpa/inet.h>.
6239528Sdfr */
6339528Sdfr#undef inet_ntoa
6439528Sdfr__weak_reference(__inet_ntoa, inet_ntoa);
65