]> git.saurik.com Git - apple/xnu.git/blame - bsd/libkern/inet_ntoa.c
xnu-344.21.73.tar.gz
[apple/xnu.git] / bsd / libkern / inet_ntoa.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
d7e50217
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
d7e50217
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26/*
27 * Copyright 1994, 1995 Massachusetts Institute of Technology
28 *
29 * Permission to use, copy, modify, and distribute this software and
30 * its documentation for any purpose and without fee is hereby
31 * granted, provided that both the above copyright notice and this
32 * permission notice appear in all copies, that both the above
33 * copyright notice and this permission notice appear in all
34 * supporting documentation, and that the name of M.I.T. not be used
35 * in advertising or publicity pertaining to distribution of the
36 * software without specific, written prior permission. M.I.T. makes
37 * no representations about the suitability of this software for any
38 * purpose. It is provided "as is" without express or implied
39 * warranty.
40 *
41 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
42 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
43 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
45 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
47 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
48 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
51 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * SUCH DAMAGE.
53 */
54
55#include <sys/param.h>
56#include <sys/systm.h>
57
58#include <netinet/in.h>
59
60char *
61inet_ntoa(struct in_addr ina)
62{
63 static char buf[4*sizeof "123"];
64 unsigned char *ucp = (unsigned char *)&ina;
65
66 sprintf(buf, "%d.%d.%d.%d",
67 ucp[0] & 0xff,
68 ucp[1] & 0xff,
69 ucp[2] & 0xff,
70 ucp[3] & 0xff);
71 return buf;
72}
73