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