inet_ntoa.c revision 8876
17088Swollman
27088Swollman/*
37088Swollman * Copyright 1994, 1995 Massachusetts Institute of Technology
47088Swollman *
57088Swollman * Permission to use, copy, modify, and distribute this software and
67088Swollman * its documentation for any purpose and without fee is hereby
77088Swollman * granted, provided that both the above copyright notice and this
87088Swollman * permission notice appear in all copies, that both the above
97088Swollman * copyright notice and this permission notice appear in all
107088Swollman * supporting documentation, and that the name of M.I.T. not be used
117088Swollman * in advertising or publicity pertaining to distribution of the
127088Swollman * software without specific, written prior permission.  M.I.T. makes
137088Swollman * no representations about the suitability of this software for any
147088Swollman * purpose.  It is provided "as is" without express or implied
157088Swollman * warranty.
168876Srgrimes *
177088Swollman * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
187088Swollman * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
197088Swollman * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
207088Swollman * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
217088Swollman * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
227088Swollman * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
237088Swollman * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
247088Swollman * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
257088Swollman * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
267088Swollman * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
277088Swollman * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
287088Swollman * SUCH DAMAGE.
297088Swollman */
307088Swollman
317088Swollman#include <sys/param.h>
327088Swollman#include <sys/systm.h>
337088Swollman
347088Swollman#include <netinet/in.h>
357088Swollman
367088Swollmanchar *
377088Swollmaninet_ntoa(struct in_addr ina)
387088Swollman{
397088Swollman	static char buf[4*sizeof "123"];
407088Swollman	unsigned char *ucp = (unsigned char *)&ina;
417088Swollman
427088Swollman	sprintf(buf, "%d.%d.%d.%d",
437088Swollman		ucp[0] & 0xff,
447088Swollman		ucp[1] & 0xff,
457088Swollman		ucp[2] & 0xff,
467088Swollman		ucp[3] & 0xff);
477088Swollman	return buf;
487088Swollman}
497088Swollman
50