1/* $NetBSD$ */ 2 3/* 4 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 2000, 2001 Internet Software Consortium. 6 * 7 * Permission to use, copy, modify, and/or distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20/* Id: ipv6.h,v 1.16 2007/06/19 23:47:23 tbox Exp */ 21 22#ifndef LWRES_IPV6_H 23#define LWRES_IPV6_H 1 24 25/***** 26 ***** Module Info 27 *****/ 28 29/*! \file lwres/ipv6.h 30 * IPv6 definitions for systems which do not support IPv6. 31 */ 32 33/*** 34 *** Imports. 35 ***/ 36 37#include <lwres/int.h> 38#include <lwres/platform.h> 39 40/*** 41 *** Types. 42 ***/ 43 44/*% in6_addr structure */ 45struct in6_addr { 46 union { 47 lwres_uint8_t _S6_u8[16]; 48 lwres_uint16_t _S6_u16[8]; 49 lwres_uint32_t _S6_u32[4]; 50 } _S6_un; 51}; 52/*@{*/ 53/*% IP v6 types */ 54#define s6_addr _S6_un._S6_u8 55#define s6_addr8 _S6_un._S6_u8 56#define s6_addr16 _S6_un._S6_u16 57#define s6_addr32 _S6_un._S6_u32 58/*@}*/ 59 60#define IN6ADDR_ANY_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}} 61#define IN6ADDR_LOOPBACK_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}} 62 63LIBLWRES_EXTERNAL_DATA extern const struct in6_addr in6addr_any; 64LIBLWRES_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback; 65 66/*% used in getaddrinfo.c and getnameinfo.c */ 67struct sockaddr_in6 { 68#ifdef LWRES_PLATFORM_HAVESALEN 69 lwres_uint8_t sin6_len; 70 lwres_uint8_t sin6_family; 71#else 72 lwres_uint16_t sin6_family; 73#endif 74 lwres_uint16_t sin6_port; 75 lwres_uint32_t sin6_flowinfo; 76 struct in6_addr sin6_addr; 77 lwres_uint32_t sin6_scope_id; 78}; 79 80#ifdef LWRES_PLATFORM_HAVESALEN 81#define SIN6_LEN 1 82#endif 83 84/*% in6_pktinfo structure */ 85struct in6_pktinfo { 86 struct in6_addr ipi6_addr; /*%< src/dst IPv6 address */ 87 unsigned int ipi6_ifindex; /*%< send/recv interface index */ 88}; 89 90/*! 91 * Unspecified IPv6 address 92 */ 93#define IN6_IS_ADDR_UNSPECIFIED(a) \ 94 (((a)->s6_addr32[0] == 0) && \ 95 ((a)->s6_addr32[1] == 0) && \ 96 ((a)->s6_addr32[2] == 0) && \ 97 ((a)->s6_addr32[3] == 0)) 98 99/* 100 * Loopback 101 */ 102#define IN6_IS_ADDR_LOOPBACK(a) \ 103 (((a)->s6_addr32[0] == 0) && \ 104 ((a)->s6_addr32[1] == 0) && \ 105 ((a)->s6_addr32[2] == 0) && \ 106 ((a)->s6_addr32[3] == htonl(1))) 107 108/* 109 * IPv4 compatible 110 */ 111#define IN6_IS_ADDR_V4COMPAT(a) \ 112 (((a)->s6_addr32[0] == 0) && \ 113 ((a)->s6_addr32[1] == 0) && \ 114 ((a)->s6_addr32[2] == 0) && \ 115 ((a)->s6_addr32[3] != 0) && \ 116 ((a)->s6_addr32[3] != htonl(1))) 117 118/* 119 * Mapped 120 */ 121#define IN6_IS_ADDR_V4MAPPED(a) \ 122 (((a)->s6_addr32[0] == 0) && \ 123 ((a)->s6_addr32[1] == 0) && \ 124 ((a)->s6_addr32[2] == htonl(0x0000ffff))) 125 126#endif /* LWRES_IPV6_H */ 127