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