[270] | 1 | /*
|
---|
| 2 | * TINET (TCP/IP Protocol Stack)
|
---|
| 3 | *
|
---|
[331] | 4 | * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
|
---|
[270] | 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/ip6_var.h,v 1.10 2002/10/16 01:54:45 sam Exp $ */
|
---|
| 35 | /* $KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 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, 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 | * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
|
---|
| 99 | */
|
---|
| 100 |
|
---|
| 101 | #ifndef _IP6_VAR_H_
|
---|
| 102 | #define _IP6_VAR_H_
|
---|
| 103 |
|
---|
| 104 | /*
|
---|
| 105 | * IPv6 ヘッダ・ペイロードアクセスマクロ
|
---|
| 106 | */
|
---|
| 107 |
|
---|
| 108 | #define IF_IP6_HDR_SIZE (IF_HDR_SIZE + IP6_HDR_SIZE)
|
---|
| 109 |
|
---|
| 110 | #define GET_IP6_HDR(nbuf) ((T_IP6_HDR*)((nbuf)->buf + IF_HDR_SIZE))
|
---|
| 111 | #define GET_IP6_SDU(nbuf) ((uint8_t*)((nbuf)->buf) + GET_IF_IP6_HDR_SIZE(nbuf))
|
---|
| 112 | #define GET_IP6_NEXT_HDR(nbuf) ((uint8_t*)((nbuf)->buf) + IF_IP6_HDR_SIZE)
|
---|
| 113 |
|
---|
[331] | 114 | #define GET_IP6_HDR_SIZE(nbuf) (get_ip6_hdr_size(nbuf))
|
---|
| 115 | #define GET_IP6_SDU_SIZE(nbuf) (ntohs(GET_IP6_HDR(nbuf)->plen))
|
---|
| 116 | #define GET_IF_IP6_HDR_SIZE(nbuf) (IF_HDR_SIZE + (GET_IP6_HDR_SIZE(nbuf)))
|
---|
[270] | 117 |
|
---|
[331] | 118 | #define SET_IP6_CF(nbuf,cf) (GET_IP6_HDR(nbuf)->vcf=htonl(IP6_MAKE_VCF(IP6_VCF_V(ntohl(GET_IP6_HDR(nbuf)->vcf)),cf)))
|
---|
| 119 | #define SET_IP6_SDU_SIZE(nbuf,slen) (GET_IP6_HDR(nbuf)->plen=htons(slen))
|
---|
[270] | 120 |
|
---|
| 121 | /* ip6_output のフラグ */
|
---|
| 122 |
|
---|
| 123 | #define IPV6_OUT_FLG_DAD 0x0100 /* 重複アドレス検出 */
|
---|
| 124 | #define IPV6_OUT_FLG_HOP_LIMIT 0x0200 /* ホップリミット指定 */
|
---|
| 125 |
|
---|
| 126 | /* ホップリミットフラグが付く時、ホップリミット値を操作するマクロ */
|
---|
| 127 |
|
---|
| 128 | #define IPV6_OUT_GET_HOP_LIMIT(f) ((f)&0x00ff)
|
---|
| 129 | #define IPV6_OUT_SET_HOP_LIMIT(f,l) ((f)|(l))
|
---|
| 130 |
|
---|
| 131 | /*
|
---|
| 132 | * ip6_unknown_opt -- 未知のオプションの処理
|
---|
| 133 | *
|
---|
| 134 | * 戻り値:
|
---|
| 135 | *
|
---|
| 136 | * 0 以上 正常、オプション長。
|
---|
| 137 | * IP6_OPT_RET_ERR (-1) エラー、呼出側でネットワークバッファを開放する。
|
---|
| 138 | * IP6_OPT_RET_REL (-2) エラー、ネットワークバッファは開放されている。
|
---|
| 139 | */
|
---|
| 140 |
|
---|
| 141 | #define IP6_OPT_RET_ERR (-1)
|
---|
| 142 | #define IP6_OPT_RET_REL (-2)
|
---|
| 143 |
|
---|
| 144 | /*
|
---|
[331] | 145 | * IPv6 の MMTU サイズのネットワークバッファ
|
---|
[270] | 146 | */
|
---|
| 147 |
|
---|
[331] | 148 | #if defined(IF_HDR_SIZE)
|
---|
[270] | 149 |
|
---|
| 150 | typedef struct t_net_buf_ipv6_mmtu {
|
---|
| 151 | uint16_t len; /* データの長さ */
|
---|
| 152 | uint8_t idix; /* mpfid のインデックス */
|
---|
| 153 | uint8_t unit; /* インタフェース番号 */
|
---|
[429] | 154 | #ifdef IF_ETHER_MULTI_NIC
|
---|
| 155 | uint8_t conn_pos;
|
---|
| 156 | #endif
|
---|
[270] | 157 | #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
|
---|
| 158 | uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
|
---|
| 159 | #endif
|
---|
| 160 | #if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
|
---|
| 161 | uint8_t halign[4 - IF_HDR_ALIGN];
|
---|
| 162 | #endif
|
---|
| 163 | uint8_t buf[IF_HDR_SIZE + IPV6_MMTU];
|
---|
| 164 | /* バッファ本体 */
|
---|
| 165 | } T_NET_BUF_IPV6_MMTU;
|
---|
| 166 |
|
---|
[331] | 167 | #endif /* of #if defined(IF_HDR_SIZE) */
|
---|
| 168 |
|
---|
[270] | 169 | /*
|
---|
| 170 | * 65536 オクテットサイズのネットワークバッファ
|
---|
| 171 | */
|
---|
| 172 |
|
---|
| 173 | typedef struct t_net_buf6_65536 {
|
---|
| 174 | uint16_t len; /* データの長さ */
|
---|
| 175 | uint8_t idix; /* mpfid のインデックス */
|
---|
| 176 | uint8_t flags; /* フラグ */
|
---|
[429] | 177 | #ifdef IF_ETHER_MULTI_NIC
|
---|
| 178 | uint8_t conn_pos;
|
---|
| 179 | #endif
|
---|
[270] | 180 | #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
|
---|
| 181 | uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
|
---|
| 182 | #endif
|
---|
| 183 | #if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
|
---|
| 184 | uint8_t halign[4 - IF_HDR_ALIGN];
|
---|
| 185 | #endif
|
---|
| 186 | uint8_t buf[IF_IP6_HDR_SIZE + 65536];
|
---|
| 187 | /* バッファ本体 */
|
---|
| 188 | #if defined(IF_PDU_HDR_PADDING)
|
---|
| 189 | uint8_t padding[IF_PDU_HDR_PADDING];
|
---|
| 190 | #endif /* ヘッダの余分 */
|
---|
| 191 | } T_NET_BUF6_65536;
|
---|
| 192 |
|
---|
| 193 | #ifdef IP6_CFG_FRAGMENT
|
---|
| 194 |
|
---|
| 195 | /*
|
---|
| 196 | * 再構成キュー用 IPv6 ヘッダの定義
|
---|
| 197 | */
|
---|
| 198 |
|
---|
| 199 | typedef struct t_qip6_hdr {
|
---|
| 200 | uint32_t vcf; /* Version: 4 bit */
|
---|
| 201 | /* Traffic Class: 8 bit */
|
---|
| 202 | /* Flow Label: 20 bit */
|
---|
| 203 | uint16_t plen; /* Payload Length */
|
---|
| 204 | uint8_t next; /* Next Header */
|
---|
| 205 | uint8_t hlim; /* Hop Limit */
|
---|
| 206 | T_IN6_ADDR src; /* Source Address */
|
---|
| 207 | T_NET_BUF *next_frag; /* 次の IPv6 フラグメント */
|
---|
| 208 | uint16_t foff; /* 断片ヘッダのオフセット */
|
---|
| 209 | uint16_t flen; /* 断片長 */
|
---|
| 210 | uint16_t ftim; /* 再構成タイムアウト */
|
---|
| 211 | uint16_t dummy1;
|
---|
| 212 | uint8_t dummy2[sizeof(T_IN6_ADDR) - (sizeof(T_NET_BUF*) + sizeof(uint16_t) * 4)];
|
---|
| 213 | } __attribute__((packed, aligned(2)))T_QIP6_HDR;
|
---|
| 214 |
|
---|
| 215 | #define QIP6_HDR_SIZE (sizeof(T_QIP6_HDR))
|
---|
| 216 | #define IF_QIP6_HDR_SIZE (IF_HDR_SIZE + QIP6_HDR_SIZE)
|
---|
| 217 |
|
---|
| 218 | #define GET_QIP6_HDR(nbuf) ((T_QIP6_HDR*)((nbuf)->buf + IF_HDR_SIZE))
|
---|
| 219 | #define GET_QIP6_SDU(nbuf) ((uint8_t*)(nbuf)->buf + GET_IF_QIP6_HDR_SIZE(nbuf))
|
---|
| 220 |
|
---|
| 221 | #define GET_QIP6_HDR_SIZE(iph) ((uint8_t)IP6_VHL_HL((iph)->vhl) << 2)
|
---|
| 222 | #define GET_IF_QIP6_HDR_SIZE(nbuf) (IF_HDR_SIZE + (GET_QIP6_HDR_SIZE(GET_QIP6_HDR(nbuf))))
|
---|
| 223 |
|
---|
| 224 | /*
|
---|
| 225 | * データグラム再構成用ネットワークバッファ
|
---|
| 226 | */
|
---|
| 227 |
|
---|
| 228 | typedef struct t_net_buf6_reassm {
|
---|
| 229 | uint16_t len; /* データの長さ */
|
---|
| 230 | uint8_t idix; /* mpfid のインデックス */
|
---|
| 231 | uint8_t flags; /* フラグ */
|
---|
[429] | 232 | #ifdef IF_ETHER_MULTI_NIC
|
---|
| 233 | uint8_t conn_pos;
|
---|
| 234 | #endif
|
---|
[270] | 235 | #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
|
---|
| 236 | uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
|
---|
| 237 | #endif
|
---|
| 238 | #if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
|
---|
| 239 | uint8_t align[4 - IF_HDR_ALIGN];
|
---|
| 240 | #endif
|
---|
| 241 | uint8_t buf[IP6_CFG_FRAG_REASSM_SIZE];
|
---|
| 242 | /* バッファ本体 */
|
---|
| 243 | } T_NET_BUF6_REASSM;
|
---|
| 244 |
|
---|
| 245 | #endif /* of #ifdef IP6_CFG_FRAGMENT */
|
---|
| 246 |
|
---|
| 247 | /*
|
---|
| 248 | * TCP の再構成キューにおける IPv6 ヘッダの定義
|
---|
| 249 | */
|
---|
| 250 |
|
---|
[331] | 251 | typedef struct t_ip6_tcp_q_hdr {
|
---|
[270] | 252 | uint8_t vc; /* Version: 4 bit */
|
---|
| 253 | uint8_t cf; /* Traffic Class: 8 bit */
|
---|
| 254 | /* Flow Label: 4 bit (20 bit) */
|
---|
| 255 | uint16_t thoff; /* TCP ヘッダのオフセット */
|
---|
| 256 | uint16_t plen; /* Payload Length */
|
---|
| 257 | uint8_t next; /* Next Header */
|
---|
| 258 | uint8_t hlim; /* Hop Limit */
|
---|
| 259 | T_IN6_ADDR src; /* Source Address */
|
---|
| 260 | T_IN6_ADDR dst; /* Destination Address */
|
---|
[331] | 261 | } __attribute__((packed, aligned(2))) T_IP6_TCP_Q_HDR;
|
---|
[270] | 262 |
|
---|
| 263 | #ifdef SUPPORT_MIB
|
---|
| 264 |
|
---|
| 265 | /*
|
---|
| 266 | * SNMP の 管理情報ベース (MIB)
|
---|
| 267 | */
|
---|
| 268 |
|
---|
| 269 | typedef struct t_in6_ifstat {
|
---|
| 270 | uint32_t ipv6IfStatsInReceives;
|
---|
| 271 | uint32_t ipv6IfStatsInHdrErrors;
|
---|
| 272 | /* uint32_t ipv6IfStatsInTooBigErrors;*/
|
---|
| 273 | /* uint32_t ipv6IfStatsInNoRoutes;*/
|
---|
| 274 | uint32_t ipv6IfStatsInAddrErrors;
|
---|
| 275 | uint32_t ipv6IfStatsInUnknownProtos;
|
---|
| 276 | uint32_t ipv6IfStatsInTruncatedPkts;
|
---|
| 277 | /* uint32_t ipv6IfStatsInDiscards;*/
|
---|
| 278 | /* uint32_t ipv6IfStatsInDelivers;*/
|
---|
| 279 | /* uint32_t ipv6IfStatsOutForwDatagrams;*/
|
---|
| 280 | uint32_t ipv6IfStatsOutRequests;
|
---|
| 281 | uint32_t ipv6IfStatsOutDiscards;
|
---|
| 282 | uint32_t ipv6IfStatsOutFragOKs;
|
---|
| 283 | uint32_t ipv6IfStatsOutFragFails;
|
---|
| 284 | uint32_t ipv6IfStatsOutFragCreates;
|
---|
| 285 | uint32_t ipv6IfStatsReasmReqds;
|
---|
| 286 | uint32_t ipv6IfStatsReasmOKs;
|
---|
| 287 | uint32_t ipv6IfStatsReasmFails;
|
---|
| 288 | uint32_t ipv6IfStatsInMcastPkts;
|
---|
| 289 | uint32_t ipv6IfStatsOutMcastPkts;
|
---|
| 290 | } T_IN6_IFSTAT;
|
---|
| 291 |
|
---|
| 292 | extern T_IN6_IFSTAT in6_ifstat;
|
---|
| 293 |
|
---|
| 294 | #endif /* of #ifdef SUPPORT_MIB */
|
---|
| 295 |
|
---|
| 296 | /*
|
---|
[331] | 297 | * 変数
|
---|
| 298 | */
|
---|
| 299 |
|
---|
| 300 | extern uint8_t ip6_defhlim;
|
---|
| 301 |
|
---|
| 302 | /*
|
---|
[270] | 303 | * 関数
|
---|
| 304 | */
|
---|
| 305 |
|
---|
| 306 | extern ER ip6_output (T_NET_BUF *output, uint16_t flags, TMO tmout);
|
---|
| 307 | extern void ip6_init (void);
|
---|
| 308 | extern uint8_t *ip6_get_prev_hdr (T_NET_BUF *nbuf, uint_t off);
|
---|
[331] | 309 | extern uint_t get_ip6_hdr_size (T_NET_BUF *nbuf);
|
---|
[270] | 310 | extern ER_UINT ip6_nexthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
|
---|
| 311 | extern ER_UINT ip6_lasthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
|
---|
| 312 | extern ER_UINT ip6_unknown_opt (T_NET_BUF *input, uint8_t *opt);
|
---|
| 313 | extern uint_t dest6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
|
---|
| 314 | extern uint_t route6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
|
---|
| 315 | extern uint_t frag6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
|
---|
| 316 | extern void frag6_timer (void);
|
---|
| 317 | extern ER ip6_remove_exthdrs (T_NET_BUF *nbuf);
|
---|
| 318 |
|
---|
| 319 | #endif /* of #ifndef _IP6_VAR_H_ */
|
---|