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