source: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/ip4_var.h@ 366

Last change on this file since 366 was 366, checked in by coas-nagasima, 5 years ago

バッファ構造体への変更が、すべての定義に適用されていないを修正

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 9.3 KB
Line 
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/*
35 * Copyright (c) 1982, 1986, 1993
36 * The Regents of the University of California. All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)ip_var.h 8.2 (Berkeley) 1/9/95
67 * $FreeBSD: src/sys/netinet/ip_var.h,v 1.45.2.1 1999/08/29 16:29:51 peter Exp $
68 */
69
70#ifndef _IP4_VAR_H_
71#define _IP4_VAR_H_
72
73/*
74 * IPv4 ヘッダ・ペイロードアクセスマクロ
75 */
76
77#define IF_IP4_HDR_SIZE (IF_HDR_SIZE + IP4_HDR_SIZE)
78
79#define GET_IP4_HDR(nbuf) ((T_IP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
80#define GET_IP4_SDU(nbuf) ((uint8_t*)((nbuf)->buf) + GET_IF_IP4_HDR_SIZE(nbuf))
81
82#define GET_IP4_HDR_SIZE(nbuf) ((uint8_t)IP4_VHL_HL(GET_IP4_HDR(nbuf)->vhl) << 2)
83#define GET_IP4_SDU_SIZE(nbuf) (ntohs(GET_IP4_HDR(nbuf)->len) - GET_IP4_HDR_SIZE(nbuf))
84#define GET_IF_IP4_HDR_SIZE(nbuf) (IF_HDR_SIZE + (GET_IP4_HDR_SIZE(nbuf)))
85
86#define SET_IP4_SDU_SIZE(nbuf,slen) (GET_IP4_HDR(nbuf)->len=(uint16_t)htons((slen) + IP4_HDR_SIZE))
87
88/*
89 * IP の MSS サイズのネットワークバッファ
90 */
91
92typedef struct t_net_buf_ip_mss {
93 uint16_t len; /* データの長さ */
94 uint8_t idix; /* mpfid のインデックス */
95 uint8_t flags; /* フラグ */
96#ifdef IF_ETHER_MULTI_NIC
97 uint8_t conn_pos;
98#endif
99#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
100 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
101#endif
102#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
103 uint8_t halign[4 - IF_HDR_ALIGN];
104#endif
105 uint8_t buf[IF_HDR_SIZE + IP4_MSS];
106 /* バッファ本体 */
107 } T_NET_BUF_IP_MSS;
108
109/*
110 * 65536 オクテットサイズのネットワークバッファ
111 */
112
113typedef struct t_net_buf4_65536 {
114 uint16_t len; /* データの長さ */
115 uint8_t idix; /* mpfid のインデックス */
116 uint8_t flags; /* フラグ */
117#ifdef IF_ETHER_MULTI_NIC
118 uint8_t conn_pos;
119#endif
120#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
121 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
122#endif
123#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
124 uint8_t halign[4 - IF_HDR_ALIGN];
125#endif
126 uint8_t buf[IF_IP4_HDR_SIZE + 65536];
127 /* バッファ本体 */
128#if defined(IF_PDU_HDR_PADDING)
129 uint8_t padding[IF_PDU_HDR_PADDING];
130#endif /* ヘッダの余分 */
131 } T_NET_BUF4_65536;
132
133#ifdef IP4_CFG_FRAGMENT
134
135/*
136 * 再構成キュー用 IPv4 ヘッダの定義
137 */
138
139typedef struct t_qip4_hdr {
140 uint8_t vhl; /* version << 4 | header length >> 2 */
141 /* length は 4 octets 単位 */
142 uint8_t type; /* type of services */
143 uint16_t len; /* total length */
144
145 uint16_t id; /* identification */
146 uint16_t flg_off; /* fragment flag & offset */
147
148 uint8_t ttl; /* time to live */
149 uint8_t proto; /* protocol */
150 uint16_t sum; /* checksum */
151
152 uint32_t src; /* source address */
153
154 T_NET_BUF *next; /* 次の IPv4 フラグメント */
155 } __attribute__((packed, aligned(2))) T_QIP4_HDR;
156
157#define QIP4_HDR_SIZE (sizeof(T_QIP4_HDR))
158#define IF_QIP4_HDR_SIZE (IF_HDR_SIZE + QIP4_HDR_SIZE)
159
160#define GET_QIP4_HDR(nbuf) ((T_QIP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
161#define GET_QIP4_SDU(nbuf) ((uint8_t*)(nbuf)->buf + GET_IF_QIP4_HDR_SIZE(nbuf))
162
163#define GET_QIP4_HDR_SIZE(iph) ((uint8_t)IP4_VHL_HL((iph)->vhl) << 2)
164#define GET_IF_QIP4_HDR_SIZE(nbuf) (IF_HDR_SIZE + (GET_QIP4_HDR_SIZE(GET_QIP4_HDR(nbuf))))
165
166/*
167 * データグラム再構成用ネットワークバッファ
168 */
169
170typedef struct t_net_buf4_reassm {
171 uint16_t len; /* データの長さ */
172 uint8_t idix; /* mpfid のインデックス */
173 uint8_t flags; /* フラグ */
174#ifdef IF_ETHER_MULTI_NIC
175 uint8_t conn_pos;
176#endif
177#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
178 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
179#endif
180#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
181 uint8_t align[4 - IF_HDR_ALIGN];
182#endif
183 uint8_t buf[IP4_CFG_FRAG_REASSM_SIZE];
184 /* バッファ本体 */
185 } __attribute__((packed, aligned(2))) T_NET_BUF4_REASSM;
186
187#endif /* of #ifdef IP4_CFG_FRAGMENT */
188
189/*
190 * TCP の再構成キューにおける IPv4 ヘッダの定義
191 */
192
193typedef struct t_ip4_tcp_q_hdr {
194 uint8_t vhl; /* version << 4 | header length >> 2 */
195 /* length は 4 octets 単位 */
196 uint8_t type; /* type of services */
197 uint16_t len; /* total length */
198
199 uint16_t id; /* identification */
200 uint16_t flg_off; /* fragment flag & offset */
201
202 uint8_t ttl; /* time to live */
203 uint8_t proto; /* protocol */
204 uint16_t thoff; /* TCP ヘッダのオフセット */
205
206 T_IN4_ADDR src; /* source address */
207 T_IN4_ADDR dst; /* destination address */
208 } __attribute__((packed, aligned(2))) T_IP4_TCP_Q_HDR;
209
210#ifdef SUPPORT_MIB
211
212/*
213 * SNMP の 管理情報ベース (MIB)
214 */
215
216typedef struct t_ip_stats {
217 uint32_t ipInReceives;
218 uint32_t ipInHdrErrors;
219 uint32_t ipInAddrErrors;
220/* uint32_t ipForwDatagrams;*/
221 uint32_t ipInUnknownProtos;
222/* uint32_t ipInDiscards;*/
223 uint32_t ipInDelivers;
224 uint32_t ipOutRequests;
225 uint32_t ipOutDiscards;
226/* uint32_t ipOutNoRoutes;*/
227
228#ifdef IP4_CFG_FRAGMENT
229
230 uint32_t ipReasmReqds;
231 uint32_t ipReasmOKs;
232 uint32_t ipReasmFails;
233 uint32_t ipFragOKs;
234 uint32_t ipFragFails;
235 uint32_t ipFragCreates;
236
237#else /* of #ifdef IP4_CFG_FRAGMENT */
238
239 uint32_t ipReasmReqds;
240/* uint32_t ipReasmOKs;*/
241 uint32_t ipReasmFails;
242/* uint32_t ipFragOKs;*/
243/* uint32_t ipFragFails;*/
244/* uint32_t ipFragCreates;*/
245
246#endif /* of #ifdef IP4_CFG_FRAGMENT */
247
248} T_IP_STATS;
249
250extern T_IP_STATS ip_stats;
251
252#endif /* of #ifdef SUPPORT_MIB */
253
254/*
255 * 関数
256 */
257
258extern void ip_frag_timer (void);
259extern void ip_init (void);
260extern ER ip_remove_options (T_NET_BUF *nbuf);
261extern ER ip_output (T_NET_BUF *nbuf, TMO tmout);
262extern void ip_exchg_addr (T_NET_BUF *nbuf);
263
264#endif /* of #ifndef _IP4_VAR_H_ */
Note: See TracBrowser for help on using the repository browser.