0
  *   ˆl–Ãa¾”ji?u@?pÜŠbÑ¿¿ƒy·_†I|¥�+ÃÂ !t    /*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#ifndef ISC_NET_H
#define ISC_NET_H 1

/*****
***** Module Info
*****/

/*! \file
 * \brief
 * Basic Networking Types
 *
 * This module is responsible for defining the following basic networking
 * types:
 *
 *\li		struct in_addr
 *\li		struct in6_addr
 *\li		struct in6_pktinfo
 *\li		struct sockaddr
 *\li		struct sockaddr_in
 *\li		struct sockaddr_in6
 *\li		struct sockaddr_storage
 *\li		in_port_t
 *
 * It ensures that the AF_ and PF_ macros are defined.
 *
 * It declares ntoh[sl]() and hton[sl]().
 *
 * It declares inet_ntop(), and inet_pton().
 *
 * It ensures that #INADDR_LOOPBACK, #INADDR_ANY, #IN6ADDR_ANY_INIT,
 * IN6ADDR_V4MAPPED_INIT, in6addr_any, and in6addr_loopback are available.
 *
 * It ensures that IN_MULTICAST() is available to check for multicast
 * addresses.
 *
 * MP:
 *\li	No impact.
 *
 * Reliability:
 *\li	No anticipated impact.
 *
 * Resources:
 *\li	N/A.
 *
 * Security:
 *\li	No anticipated impact.
 *
 * Standards:
 *\li	BSD Socket API
 *\li	RFC2553
 */

/***
 *** Imports.
 ***/
#include <inttypes.h>

#include <isc/lang.h>
#include <isc/platform.h>
#include <isc/types.h>

#include <arpa/inet.h> /* Contractual promise. */
#include <net/if.h>
#include <netinet/in.h> /* Contractual promise. */
#include <sys/socket.h> /* Contractual promise. */
#include <sys/types.h>

#ifndef IN6ADDR_LOOPBACK_INIT
#ifdef s6_addr
/*% IPv6 address loopback init */
#define IN6ADDR_LOOPBACK_INIT                                                  \
	{                                                                      \
		{                                                              \
			{                                                      \
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 \
			}                                                      \
		}                                                              \
	}
#else /* ifdef s6_addr */
#define IN6ADDR_LOOPBACK_INIT                                          \
	{                                                              \
		{                                                      \
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 \
		}                                                      \
	}
#endif /* ifdef s6_addr */
#endif /* ifndef IN6ADDR_LOOPBACK_INIT */

#ifndef IN6ADDR_V4MAPPED_INIT
#ifdef s6_addr
/*% IPv6 v4mapped prefix init */
#define IN6ADDR_V4MAPPED_INIT                                                \
	{                                                                    \
		{                                                            \
			{                                                    \
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0, \
					0, 0, 0                              \
			}                                                    \
		}                                                            \
	}
#else /* ifdef s6_addr */
#define IN6ADDR_V4MAPPED_INIT                                                \
	{                                                                    \
		{                                                            \
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 0, 0, 0 \
		}                                                            \
	}
#endif /* ifdef s6_addr */
#endif /* ifndef IN6ADDR_V4MAPPED_INIT */

#ifndef IN6_IS_ADDR_V4MAPPED
/*% Is IPv6 address V4 mapped? */
#define IN6_IS_ADDR_V4MAPPED(x)                                \
	(memcmp((x)->s6_addr, in6addr_any.s6_addr, 10) == 0 && \
	 (x)->s6_addr[10] == 0xff && (x)->s6_addr[11] == 0xff)
#endif /* ifndef IN6_IS_ADDR_V4MAPPED */

#ifndef IN6_IS_ADDR_V4COMPAT
/*% Is IPv6 address V4 compatible? */
#define IN6_IS_ADDR_V