inet_ntoa.c revision 7088
11590Srgrimes
21590Srgrimes/*
31590Srgrimes * Copyright 1994, 1995 Massachusetts Institute of Technology
41590Srgrimes *
51590Srgrimes * Permission to use, copy, modify, and distribute this software and
61590Srgrimes * its documentation for any purpose and without fee is hereby
71590Srgrimes * granted, provided that both the above copyright notice and this
81590Srgrimes * permission notice appear in all copies, that both the above
91590Srgrimes * copyright notice and this permission notice appear in all
101590Srgrimes * supporting documentation, and that the name of M.I.T. not be used
111590Srgrimes * in advertising or publicity pertaining to distribution of the
121590Srgrimes * software without specific, written prior permission.  M.I.T. makes
131590Srgrimes * no representations about the suitability of this software for any
141590Srgrimes * purpose.  It is provided "as is" without express or implied
151590Srgrimes * warranty.
161590Srgrimes *
171590Srgrimes * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
181590Srgrimes * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
191590Srgrimes * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
201590Srgrimes * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
211590Srgrimes * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
221590Srgrimes * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
231590Srgrimes * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
241590Srgrimes * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
251590Srgrimes * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
261590Srgrimes * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
271590Srgrimes * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281590Srgrimes * SUCH DAMAGE.
291590Srgrimes */
30132671Scharnier
311590Srgrimes#include <sys/param.h>
321590Srgrimes#include <sys/systm.h>
33132671Scharnier
3427753Scharnier#include <netinet/in.h>
351590Srgrimes
36132671Scharnierchar *
37132671Scharnierinet_ntoa(struct in_addr ina)
38132671Scharnier{
391590Srgrimes	static char buf[4*sizeof "123"];
401590Srgrimes	unsigned char *ucp = (unsigned char *)&ina;
411590Srgrimes
421590Srgrimes	sprintf(buf, "%d.%d.%d.%d",
4314543Sdg		ucp[0] & 0xff,
441590Srgrimes		ucp[1] & 0xff,
451590Srgrimes		ucp[2] & 0xff,
461590Srgrimes		ucp[3] & 0xff);
471590Srgrimes	return buf;
481590Srgrimes}
491590Srgrimes
501590Srgrimes