1*d4514f0bSApple OSS Distributions /*-
2*d4514f0bSApple OSS Distributions * Copyright 1994, 1995 Massachusetts Institute of Technology
3*d4514f0bSApple OSS Distributions *
4*d4514f0bSApple OSS Distributions * Permission to use, copy, modify, and distribute this software and
5*d4514f0bSApple OSS Distributions * its documentation for any purpose and without fee is hereby
6*d4514f0bSApple OSS Distributions * granted, provided that both the above copyright notice and this
7*d4514f0bSApple OSS Distributions * permission notice appear in all copies, that both the above
8*d4514f0bSApple OSS Distributions * copyright notice and this permission notice appear in all
9*d4514f0bSApple OSS Distributions * supporting documentation, and that the name of M.I.T. not be used
10*d4514f0bSApple OSS Distributions * in advertising or publicity pertaining to distribution of the
11*d4514f0bSApple OSS Distributions * software without specific, written prior permission. M.I.T. makes
12*d4514f0bSApple OSS Distributions * no representations about the suitability of this software for any
13*d4514f0bSApple OSS Distributions * purpose. It is provided "as is" without express or implied
14*d4514f0bSApple OSS Distributions * warranty.
15*d4514f0bSApple OSS Distributions *
16*d4514f0bSApple OSS Distributions * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
17*d4514f0bSApple OSS Distributions * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18*d4514f0bSApple OSS Distributions * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19*d4514f0bSApple OSS Distributions * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20*d4514f0bSApple OSS Distributions * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21*d4514f0bSApple OSS Distributions * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22*d4514f0bSApple OSS Distributions * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23*d4514f0bSApple OSS Distributions * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24*d4514f0bSApple OSS Distributions * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25*d4514f0bSApple OSS Distributions * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26*d4514f0bSApple OSS Distributions * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*d4514f0bSApple OSS Distributions * SUCH DAMAGE.
28*d4514f0bSApple OSS Distributions */
29*d4514f0bSApple OSS Distributions #include <sys/param.h>
30*d4514f0bSApple OSS Distributions #include <sys/systm.h>
31*d4514f0bSApple OSS Distributions
32*d4514f0bSApple OSS Distributions #include <netinet/in.h>
33*d4514f0bSApple OSS Distributions
34*d4514f0bSApple OSS Distributions char *
inet_ntoa(struct in_addr ina)35*d4514f0bSApple OSS Distributions inet_ntoa(struct in_addr ina)
36*d4514f0bSApple OSS Distributions {
37*d4514f0bSApple OSS Distributions static char buf[4 * sizeof "123"];
38*d4514f0bSApple OSS Distributions unsigned char *ucp = (unsigned char *)&ina;
39*d4514f0bSApple OSS Distributions
40*d4514f0bSApple OSS Distributions snprintf(buf, sizeof(buf), "%d.%d.%d.%d",
41*d4514f0bSApple OSS Distributions ucp[0] & 0xff,
42*d4514f0bSApple OSS Distributions ucp[1] & 0xff,
43*d4514f0bSApple OSS Distributions ucp[2] & 0xff,
44*d4514f0bSApple OSS Distributions ucp[3] & 0xff);
45*d4514f0bSApple OSS Distributions return buf;
46*d4514f0bSApple OSS Distributions }
47*d4514f0bSApple OSS Distributions
48*d4514f0bSApple OSS Distributions char *
inet_ntoa_r(struct in_addr ina,char * buf,size_t buflen)49*d4514f0bSApple OSS Distributions inet_ntoa_r(struct in_addr ina, char *buf, size_t buflen)
50*d4514f0bSApple OSS Distributions {
51*d4514f0bSApple OSS Distributions unsigned char *ucp = (unsigned char *)&ina;
52*d4514f0bSApple OSS Distributions
53*d4514f0bSApple OSS Distributions snprintf(buf, buflen, "%d.%d.%d.%d",
54*d4514f0bSApple OSS Distributions ucp[0] & 0xff,
55*d4514f0bSApple OSS Distributions ucp[1] & 0xff,
56*d4514f0bSApple OSS Distributions ucp[2] & 0xff,
57*d4514f0bSApple OSS Distributions ucp[3] & 0xff);
58*d4514f0bSApple OSS Distributions return buf;
59*d4514f0bSApple OSS Distributions }
60