1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// src/inet_ntoa.c
|
4 |
|
|
//
|
5 |
|
|
//==========================================================================
|
6 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
7 |
|
|
//
|
8 |
|
|
// -------------------------------------------
|
9 |
|
|
//
|
10 |
|
|
// Portions of this software may have been derived from OpenBSD,
|
11 |
|
|
// FreeBSD or other sources, and are covered by the appropriate
|
12 |
|
|
// copyright disclaimers included herein.
|
13 |
|
|
//
|
14 |
|
|
// Portions created by Red Hat are
|
15 |
|
|
// Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
|
16 |
|
|
//
|
17 |
|
|
// -------------------------------------------
|
18 |
|
|
//
|
19 |
|
|
//####BSDCOPYRIGHTEND####
|
20 |
|
|
//==========================================================================
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
/*
|
24 |
|
|
* Copyright 1994, 1995 Massachusetts Institute of Technology
|
25 |
|
|
*
|
26 |
|
|
* Permission to use, copy, modify, and distribute this software and
|
27 |
|
|
* its documentation for any purpose and without fee is hereby
|
28 |
|
|
* granted, provided that both the above copyright notice and this
|
29 |
|
|
* permission notice appear in all copies, that both the above
|
30 |
|
|
* copyright notice and this permission notice appear in all
|
31 |
|
|
* supporting documentation, and that the name of M.I.T. not be used
|
32 |
|
|
* in advertising or publicity pertaining to distribution of the
|
33 |
|
|
* software without specific, written prior permission. M.I.T. makes
|
34 |
|
|
* no representations about the suitability of this software for any
|
35 |
|
|
* purpose. It is provided "as is" without express or implied
|
36 |
|
|
* warranty.
|
37 |
|
|
*
|
38 |
|
|
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
39 |
|
|
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
40 |
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
41 |
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
42 |
|
|
* SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
43 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
44 |
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
45 |
|
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
46 |
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
47 |
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
48 |
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
49 |
|
|
* SUCH DAMAGE.
|
50 |
|
|
*
|
51 |
|
|
* $FreeBSD: src/sys/libkern/inet_ntoa.c,v 1.2.16.1 2000/08/03 01:03:45 peter Exp $
|
52 |
|
|
*/
|
53 |
|
|
|
54 |
|
|
#include <sys/param.h>
|
55 |
|
|
#include <netinet/in.h>
|
56 |
|
|
|
57 |
|
|
char *
|
58 |
|
|
inet_ntoa(struct in_addr ina)
|
59 |
|
|
{
|
60 |
|
|
static char buf[4*sizeof "123"];
|
61 |
|
|
unsigned char *ucp = (unsigned char *)&ina;
|
62 |
|
|
|
63 |
|
|
diag_sprintf(buf, "%d.%d.%d.%d",
|
64 |
|
|
ucp[0] & 0xff,
|
65 |
|
|
ucp[1] & 0xff,
|
66 |
|
|
ucp[2] & 0xff,
|
67 |
|
|
ucp[3] & 0xff);
|
68 |
|
|
return buf;
|
69 |
|
|
}
|
70 |
|
|
|