[317] | 1 | /*
|
---|
| 2 | * TINET (TCP/IP Protocol Stack)
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
|
---|
| 5 | * Tomakomai National College of Technology, JAPAN
|
---|
| 6 | *
|
---|
| 7 | * 上記著作権者は,以下の (1)~(4) の条件か,Free Software Foundation
|
---|
| 8 | * によって公表されている GNU General Public License の Version 2 に記
|
---|
| 9 | * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
|
---|
| 10 | * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
|
---|
| 11 | * 利用と呼ぶ)することを無償で許諾する.
|
---|
| 12 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 13 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 14 | * スコード中に含まれていること.
|
---|
| 15 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 16 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 17 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 18 | * の無保証規定を掲載すること.
|
---|
| 19 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 20 | * 用できない形で再配布する場合には,次の条件を満たすこと.
|
---|
| 21 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 22 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 23 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 24 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 25 | *
|
---|
| 26 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 27 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
|
---|
| 28 | * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
|
---|
| 29 | * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
|
---|
| 30 | *
|
---|
| 31 | * @(#) $Id$
|
---|
| 32 | */
|
---|
| 33 |
|
---|
| 34 | /* $FreeBSD: src/sys/netinet6/in6.h,v 1.7.2.4 2001/07/04 09:45:23 ume Exp $ */
|
---|
| 35 | /* $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $ */
|
---|
| 36 |
|
---|
| 37 | /*
|
---|
| 38 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
---|
| 39 | * All rights reserved.
|
---|
| 40 | *
|
---|
| 41 | * Redistribution and use in source and binary forms, with or without
|
---|
| 42 | * modification, are permitted provided that the following conditions
|
---|
| 43 | * are met:
|
---|
| 44 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 45 | * notice, this list of conditions and the following disclaimer.
|
---|
| 46 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 47 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 48 | * documentation and/or other materials provided with the distribution.
|
---|
| 49 | * 3. Neither the name of the project nor the names of its contributors
|
---|
| 50 | * may be used to endorse or promote products derived from this software
|
---|
| 51 | * without specific prior written permission.
|
---|
| 52 | *
|
---|
| 53 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
---|
| 54 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
| 55 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
| 56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
---|
| 57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
| 58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
| 59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
| 60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
| 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
| 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 63 | * SUCH DAMAGE.
|
---|
| 64 | */
|
---|
| 65 |
|
---|
| 66 | /*
|
---|
| 67 | * Copyright (c) 1982, 1986, 1990, 1993
|
---|
| 68 | * The Regents of the University of California. All rights reserved.
|
---|
| 69 | *
|
---|
| 70 | * Redistribution and use in source and binary forms, with or without
|
---|
| 71 | * modification, are permitted provided that the following conditions
|
---|
| 72 | * are met:
|
---|
| 73 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 74 | * notice, this list of conditions and the following disclaimer.
|
---|
| 75 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 76 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 77 | * documentation and/or other materials provided with the distribution.
|
---|
| 78 | * 3. All advertising materials mentioning features or use of this software
|
---|
| 79 | * must display the following acknowledgement:
|
---|
| 80 | * This product includes software developed by the University of
|
---|
| 81 | * California, Berkeley and its contributors.
|
---|
| 82 | * 4. Neither the name of the University nor the names of its contributors
|
---|
| 83 | * may be used to endorse or promote products derived from this software
|
---|
| 84 | * without specific prior written permission.
|
---|
| 85 | *
|
---|
| 86 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
| 87 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
| 88 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
| 89 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
| 90 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
| 91 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
| 92 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
| 93 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
| 94 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
| 95 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 96 | * SUCH DAMAGE.
|
---|
| 97 | *
|
---|
| 98 | * @(#)in.h 8.3 (Berkeley) 1/3/94
|
---|
| 99 | */
|
---|
| 100 |
|
---|
| 101 | #ifndef _IN6_H_
|
---|
| 102 | #define _IN6_H_
|
---|
| 103 |
|
---|
| 104 | /*
|
---|
| 105 | * IPv6 アドレス構造
|
---|
| 106 | *
|
---|
| 107 | * RFC4291(RFC1884、RFC2373、RFC3513 のアップデート)
|
---|
| 108 | */
|
---|
| 109 |
|
---|
| 110 | /*
|
---|
| 111 | * IPv6 アドレス
|
---|
| 112 | */
|
---|
| 113 |
|
---|
| 114 | struct t_in6_addr {
|
---|
| 115 | union {
|
---|
| 116 | uint8_t __u6_addr8[16];
|
---|
| 117 | uint16_t __u6_addr16[8];
|
---|
| 118 | uint32_t __u6_addr32[4];
|
---|
| 119 | } __u6_addr;
|
---|
| 120 | };
|
---|
| 121 |
|
---|
| 122 | #define s6_addr __u6_addr.__u6_addr8
|
---|
| 123 | #define s6_addr8 __u6_addr.__u6_addr8
|
---|
| 124 | #define s6_addr16 __u6_addr.__u6_addr16
|
---|
| 125 | #define s6_addr32 __u6_addr.__u6_addr32
|
---|
| 126 |
|
---|
| 127 | #ifndef T_IN6_ADDR_DEFINED
|
---|
| 128 |
|
---|
| 129 | typedef struct t_in6_addr T_IN6_ADDR;
|
---|
| 130 |
|
---|
| 131 | #define T_IN6_ADDR_DEFINED
|
---|
| 132 |
|
---|
| 133 | #endif /* of #ifndef T_IN6_ADDR_DEFINED */
|
---|
| 134 |
|
---|
| 135 | /*
|
---|
| 136 | * IPv6 アドレスの初期化データ
|
---|
| 137 | */
|
---|
| 138 |
|
---|
| 139 | #define IPV6_ADDR_UNSPECIFIED_INIT \
|
---|
| 140 | {{{ UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 141 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 142 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 143 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00) }}}
|
---|
| 144 |
|
---|
| 145 | #define IPV6_ADDR_LINKLOCAL_ALLNODES_INIT \
|
---|
| 146 | {{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 147 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 148 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 149 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x01) }}}
|
---|
| 150 |
|
---|
| 151 | #define IPV6_ADDR_LINKLOCAL_ALLROUTERS_INIT \
|
---|
| 152 | {{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 153 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 154 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
| 155 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x02) }}}
|
---|
| 156 |
|
---|
| 157 | /*
|
---|
| 158 | * 特別なアドレスのチェック
|
---|
| 159 | */
|
---|
| 160 |
|
---|
| 161 | /* 無指定 */
|
---|
| 162 |
|
---|
| 163 | #define IN6_IS_ADDR_UNSPECIFIED(a) \
|
---|
| 164 | (memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR)) == 0)
|
---|
| 165 |
|
---|
| 166 | /* ループバック */
|
---|
| 167 |
|
---|
| 168 | #define IN6_IS_ADDR_LOOPBACK(a) \
|
---|
| 169 | (memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 1) == 0 && \
|
---|
| 170 | (a)->s6_addr8[15] == 0x01)
|
---|
| 171 |
|
---|
| 172 | /*
|
---|
| 173 | * スコープ ID
|
---|
| 174 | */
|
---|
| 175 |
|
---|
| 176 | #define IPV6_ADDR_SCOPE_NODELOCAL UINT_C(0x01)
|
---|
| 177 | #define IPV6_ADDR_SCOPE_LINKLOCAL UINT_C(0x02)
|
---|
| 178 | #define IPV6_ADDR_SCOPE_SITELOCAL UINT_C(0x05)
|
---|
| 179 | #define IPV6_ADDR_SCOPE_ORGLOCAL UINT_C(0x08)
|
---|
| 180 | #define IPV6_ADDR_SCOPE_GLOBAL UINT_C(0x0e)
|
---|
| 181 |
|
---|
| 182 | /*
|
---|
| 183 | * ユニキャスト・スコープ
|
---|
| 184 | *
|
---|
| 185 | * 注意: 上位 10 ビットのみチェックしなければならない。RFC2373 参照
|
---|
| 186 | */
|
---|
| 187 |
|
---|
| 188 | /* リンクローカル */
|
---|
| 189 |
|
---|
| 190 | #define IN6_IS_ADDR_LINKLOCAL(a) \
|
---|
| 191 | (((a)->s6_addr8[0] == UINT_C(0xfe)) && (((a)->s6_addr8[1] & UINT_C(0xc0)) == UINT_C(0x80)))
|
---|
| 192 |
|
---|
| 193 | /* サイトローカル */
|
---|
| 194 |
|
---|
| 195 | #define IN6_IS_ADDR_SITELOCAL(a) \
|
---|
| 196 | (((a)->s6_addr8[0] == UINT_C(0xfe)) && (((a)->s6_addr8[1] & UINT_C(0xc0)) == UINT_C(0xc0)))
|
---|
| 197 |
|
---|
| 198 | /* 集約可能ユニキャスト (グローバル) */
|
---|
| 199 |
|
---|
| 200 | #define IN6_IS_ADDR_AGGREGATE_UNICAST(a) \
|
---|
| 201 | (((a)->s6_addr8[0] & UINT_C(0xe0)) == UINT_C(0x20))
|
---|
| 202 |
|
---|
| 203 | /*
|
---|
| 204 | * マルチキャスト
|
---|
| 205 | */
|
---|
| 206 |
|
---|
| 207 | #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr8[0] == UINT_C(0xff))
|
---|
| 208 |
|
---|
| 209 | /*
|
---|
| 210 | * 同一のチェック
|
---|
| 211 | */
|
---|
| 212 |
|
---|
| 213 | #define IN6_ARE_ADDR_EQUAL(a,b) (memcmp((a), (b), sizeof(T_IN6_ADDR)) == 0)
|
---|
| 214 |
|
---|
| 215 | /*
|
---|
| 216 | * 経路制御用定義
|
---|
| 217 | */
|
---|
| 218 |
|
---|
| 219 | #define IPV6_RTHDR_TYPE_0 UINT_C(0) /* IPv6 経路制御ヘッダタイプ 0 */
|
---|
| 220 |
|
---|
| 221 | /*
|
---|
| 222 | * 規定値と制限値
|
---|
| 223 | */
|
---|
| 224 |
|
---|
| 225 | #define IPV6_DEFAULT_MULTICAST_HOPS 1 /* マルチキャスト時のホップリミットの規定値 */
|
---|
| 226 | #define ND6_INFINITE_LIFETIME 0xffffffff /* アドレスの無制限有効時間 */
|
---|
| 227 |
|
---|
| 228 | /*
|
---|
| 229 | * ITRON TCP/IPv6 アドレス/ポート番号の定義
|
---|
| 230 | */
|
---|
| 231 |
|
---|
| 232 | typedef struct t_ipv6ep {
|
---|
| 233 | T_IN6_ADDR ipaddr; /* IPv6 アドレス */
|
---|
| 234 | uint16_t portno; /* ポート番号 */
|
---|
| 235 | } T_IPV6EP;
|
---|
| 236 |
|
---|
| 237 | #define T_IPV6EP_DEFINED
|
---|
| 238 |
|
---|
| 239 | /*
|
---|
| 240 | * ITRON/TCP/IP 用 IP アドレスの定義
|
---|
| 241 | */
|
---|
| 242 |
|
---|
| 243 | #define IPV6_ADDRANY IPV6_ADDR_UNSPECIFIED_INIT
|
---|
| 244 |
|
---|
| 245 | /*
|
---|
| 246 | * 動的生成用 IPv6 TCP 受付口
|
---|
| 247 | */
|
---|
| 248 |
|
---|
| 249 | typedef struct t_tcp6_crep {
|
---|
| 250 | /* 標準 */
|
---|
| 251 | ATR repatr; /* 受付口属性 */
|
---|
| 252 | T_IPV6EP myaddr; /* 自分のアドレス */
|
---|
| 253 | /* 実装依存 */
|
---|
| 254 | } T_TCP6_CREP;
|
---|
| 255 |
|
---|
| 256 | /*
|
---|
| 257 | * 動的生成用 IPv6 UDP 通信端点
|
---|
| 258 | */
|
---|
| 259 |
|
---|
| 260 | typedef struct t_udp6_ccep {
|
---|
| 261 | /* 標準 */
|
---|
| 262 | ATR cepatr; /* UDP 通信端点属性 */
|
---|
| 263 | T_IPV6EP myaddr; /* 自分のアドレス */
|
---|
| 264 | FP callback; /* コールバック関数 */
|
---|
| 265 | /* 実装依存 */
|
---|
| 266 | } T_UDP6_CCEP;
|
---|
| 267 |
|
---|
| 268 | /*
|
---|
| 269 | * 前方参照
|
---|
| 270 | */
|
---|
| 271 |
|
---|
| 272 | #ifndef T_IFNET_DEFINED
|
---|
| 273 |
|
---|
| 274 | typedef struct t_ifnet T_IFNET;
|
---|
| 275 |
|
---|
| 276 | #define T_IFNET_DEFINED
|
---|
| 277 |
|
---|
| 278 | #endif /* of #ifndef T_IFNET_DEFINED */
|
---|
| 279 |
|
---|
| 280 | /*
|
---|
| 281 | * 全域変数
|
---|
| 282 | */
|
---|
| 283 |
|
---|
| 284 | extern const T_IN6_ADDR in6_addr_unspecified;
|
---|
| 285 | extern const T_IN6_ADDR in6_addr_linklocal_allnodes;
|
---|
| 286 | extern const T_IN6_ADDR in6_addr_linklocal_allrouters;
|
---|
| 287 |
|
---|
| 288 | #define ipv6_addrany in6_addr_unspecified
|
---|
| 289 |
|
---|
| 290 | /*
|
---|
| 291 | * TINET 独自 API
|
---|
| 292 | */
|
---|
| 293 |
|
---|
| 294 | extern char *ipv62str (char *buf, const T_IN6_ADDR *p_addr);
|
---|
| 295 | extern uint_t in6_get_maxnum_ifaddr (void);
|
---|
| 296 | extern const T_IN6_ADDR *in6_get_ifaddr (int_t index);
|
---|
| 297 | extern ER in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefixlen,
|
---|
| 298 | uint32_t vltime, uint32_t pltime);
|
---|
| 299 | extern ER in6_del_ifaddr (T_IN6_ADDR *addr);
|
---|
| 300 | extern T_IN6_ADDR *in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src);
|
---|
| 301 | extern bool_t in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr);
|
---|
| 302 |
|
---|
| 303 | #endif /* of #ifndef _IN6_H_ */
|
---|