10bb263dfSXin LI /*-
2*8a16b7a1SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause
3*8a16b7a1SPedro F. Giffuni *
465e96449SHajimu UMEMOTO * Copyright (c) 1983, 1993
565e96449SHajimu UMEMOTO * The Regents of the University of California. All rights reserved.
665e96449SHajimu UMEMOTO *
765e96449SHajimu UMEMOTO * Redistribution and use in source and binary forms, with or without
865e96449SHajimu UMEMOTO * modification, are permitted provided that the following conditions
965e96449SHajimu UMEMOTO * are met:
1065e96449SHajimu UMEMOTO * 1. Redistributions of source code must retain the above copyright
1165e96449SHajimu UMEMOTO * notice, this list of conditions and the following disclaimer.
1265e96449SHajimu UMEMOTO * 2. Redistributions in binary form must reproduce the above copyright
1365e96449SHajimu UMEMOTO * notice, this list of conditions and the following disclaimer in the
1465e96449SHajimu UMEMOTO * documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors
1665e96449SHajimu UMEMOTO * may be used to endorse or promote products derived from this software
1765e96449SHajimu UMEMOTO * without specific prior written permission.
1865e96449SHajimu UMEMOTO *
1965e96449SHajimu UMEMOTO * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2065e96449SHajimu UMEMOTO * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2165e96449SHajimu UMEMOTO * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2265e96449SHajimu UMEMOTO * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2365e96449SHajimu UMEMOTO * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2465e96449SHajimu UMEMOTO * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2565e96449SHajimu UMEMOTO * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2665e96449SHajimu UMEMOTO * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2765e96449SHajimu UMEMOTO * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2865e96449SHajimu UMEMOTO * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2965e96449SHajimu UMEMOTO * SUCH DAMAGE.
3065e96449SHajimu UMEMOTO */
3165e96449SHajimu UMEMOTO
3265e96449SHajimu UMEMOTO #include "port_before.h"
3365e96449SHajimu UMEMOTO
3465e96449SHajimu UMEMOTO #include <sys/types.h>
3565e96449SHajimu UMEMOTO #include <sys/socket.h>
3665e96449SHajimu UMEMOTO #include <netinet/in.h>
3765e96449SHajimu UMEMOTO #include <arpa/inet.h>
3865e96449SHajimu UMEMOTO
3965e96449SHajimu UMEMOTO #include <stdio.h>
4065e96449SHajimu UMEMOTO #include <string.h>
4165e96449SHajimu UMEMOTO
4265e96449SHajimu UMEMOTO #include "port_after.h"
4365e96449SHajimu UMEMOTO
44dde4a85dSHajimu UMEMOTO /*%
4565e96449SHajimu UMEMOTO * Convert network-format internet address
4665e96449SHajimu UMEMOTO * to base 256 d.d.d.d representation.
4765e96449SHajimu UMEMOTO */
4865e96449SHajimu UMEMOTO /*const*/ char *
inet_ntoa(struct in_addr in)4965e96449SHajimu UMEMOTO inet_ntoa(struct in_addr in) {
5065e96449SHajimu UMEMOTO static char ret[18];
5165e96449SHajimu UMEMOTO
5265e96449SHajimu UMEMOTO strcpy(ret, "[inet_ntoa error]");
5365e96449SHajimu UMEMOTO (void) inet_ntop(AF_INET, &in, ret, sizeof ret);
5465e96449SHajimu UMEMOTO return (ret);
5565e96449SHajimu UMEMOTO }
56ab96eeabSHajimu UMEMOTO
570c927cddSXin LI char *
inet_ntoa_r(struct in_addr in,char * buf,socklen_t size)580bb263dfSXin LI inet_ntoa_r(struct in_addr in, char *buf, socklen_t size)
590c927cddSXin LI {
600bb263dfSXin LI
610bb263dfSXin LI (void) inet_ntop(AF_INET, &in, buf, size);
620c927cddSXin LI return (buf);
630c927cddSXin LI }
640c927cddSXin LI
65ab96eeabSHajimu UMEMOTO /*
66ab96eeabSHajimu UMEMOTO * Weak aliases for applications that use certain private entry points,
67ab96eeabSHajimu UMEMOTO * and fail to include <arpa/inet.h>.
68ab96eeabSHajimu UMEMOTO */
69ab96eeabSHajimu UMEMOTO #undef inet_ntoa
70ab96eeabSHajimu UMEMOTO __weak_reference(__inet_ntoa, inet_ntoa);
710c927cddSXin LI __weak_reference(__inet_ntoa_r, inet_ntoa_r);
72dde4a85dSHajimu UMEMOTO
73dde4a85dSHajimu UMEMOTO /*! \file */
74