source: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h@ 321

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

文字コードを設定

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 7.4 KB
Line 
1/*
2 * TINET (TCP/IP Protocol Stack)
3 *
4 * Copyright (C) 2001-2009 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#ifndef _NET_BUF_H_
35#define _NET_BUF_H_
36
37/*
38 * ネットワークバッファ
39 *
40 * 4 オクテットでアラインする必要のあるプロセッサを考慮して、
41 * IF ヘッダサイズが 4 オクテット境界でないの場合、
42 * IP ヘッダ以降を 4 オクテット境界に調整する。
43 */
44
45#ifndef CPU_NET_ALIGN
46#error "CPU_NET_ALIGN expected."
47#endif
48
49/*
50 * テンプレート
51 */
52
53struct t_net_buf {
54 uint16_t len; /* データの長さ */
55 uint8_t idix; /* mpfid のインデックス */
56 uint8_t flags; /* フラグ */
57#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
58 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
59#endif
60#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
61 uint8_t halign[4 - IF_HDR_ALIGN];
62#endif
63 uint8_t buf[4]; /* バッファ本体 */
64 };
65
66#ifndef T_NET_BUF_DEFINED
67
68typedef struct t_net_buf T_NET_BUF;
69
70#define T_NET_BUF_DEFINED
71
72#endif /* of #ifndef T_NET_BUF_DEFINED */
73/*
74 * 64 オクテット
75 */
76
77typedef struct t_net_buf_64 {
78 uint16_t len; /* データの長さ */
79 uint8_t idix; /* mpfid のインデックス */
80 uint8_t flags; /* フラグ */
81#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
82 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
83#endif
84#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
85 uint8_t halign[4 - IF_HDR_ALIGN];
86#endif
87 uint8_t buf[64]; /* バッファ本体 */
88 } T_NET_BUF_64;
89
90/*
91 * 128 オクテット
92 */
93
94typedef struct t_net_buf_128 {
95 uint16_t len; /* データの長さ */
96 uint8_t idix; /* mpfid のインデックス */
97 uint8_t flags; /* フラグ */
98#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
99 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
100#endif
101#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
102 uint8_t halign[4 - IF_HDR_ALIGN];
103#endif
104 uint8_t buf[128]; /* バッファ本体 */
105 } T_NET_BUF_128;
106
107/*
108 * 256 オクテット
109 */
110
111typedef struct t_net_buf_256 {
112 uint16_t len; /* データの長さ */
113 uint8_t idix; /* mpfid のインデックス */
114 uint8_t flags; /* フラグ */
115#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
116 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
117#endif
118#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
119 uint8_t halign[4 - IF_HDR_ALIGN];
120#endif
121 uint8_t buf[256]; /* バッファ本体 */
122 } T_NET_BUF_256;
123
124/*
125 * 512 オクテット
126 */
127
128typedef struct t_net_buf_512 {
129 uint16_t len; /* データの長さ */
130 uint8_t idix; /* mpfid のインデックス */
131 uint8_t flags; /* フラグ */
132#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
133 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
134#endif
135#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
136 uint8_t halign[4 - IF_HDR_ALIGN];
137#endif
138 uint8_t buf[512];/* バッファ本体 */
139 } T_NET_BUF_512;
140
141/*
142 * 1024 オクテット
143 */
144
145typedef struct t_net_buf_1024 {
146 uint16_t len; /* データの長さ */
147 uint8_t idix; /* mpfid のインデックス */
148 uint8_t flags; /* フラグ */
149#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
150 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
151#endif
152#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
153 uint8_t halign[4 - IF_HDR_ALIGN];
154#endif
155 uint8_t buf[1024]; /* バッファ本体 */
156 } T_NET_BUF_1024;
157
158/*
159 * ネットワークインタフェースの最大 PDU サイズ
160 */
161
162typedef struct t_net_buf_if_pdu {
163 uint16_t len; /* データの長さ */
164 uint8_t idix; /* mpfid のインデックス */
165 uint8_t flags; /* フラグ */
166#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
167 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
168#endif
169#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
170 uint8_t halign[4 - IF_HDR_ALIGN];
171#endif
172 uint8_t buf[IF_PDU_SIZE];
173 /* バッファ本体 */
174#if defined(IF_PDU_HDR_PADDING)
175 uint8_t padding[IF_PDU_HDR_PADDING];
176#endif /* ヘッダの余分 */
177 } T_NET_BUF_IF_PDU;
178
179/*
180 * ネットワークバッファ表
181 */
182
183typedef struct t_net_buf_entry {
184
185 uint16_t index;
186 uint_t size;
187
188#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
189
190 ulong_t prepares;
191 ulong_t requests;
192 ulong_t allocs;
193 ulong_t errors;
194
195#endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
196
197 } T_NET_BUF_ENTRY;
198
199/*
200 * ネットワークバッファ・フラグ
201 */
202
203/*
204 * ネットワークインタフェース出力後にネットワークバッファを開放しない。
205 * 注意: 出力後にこのフラグはクリアされる。
206 */
207#define NB_FLG_NOREL_IFOUT UINT_C(0x80)
208
209/*
210 * ESP 用フラグ
211 */
212#define NB_FLG_DECRYPED UINT_C(0x40)
213
214/*
215 * ネットワークバッファ獲得属性
216 */
217
218/* 探索属性 */
219
220#define NBA_SEARCH_ASCENT UINT_C(0x1000) /* 大きなサイズの方向に探索する。 */
221#define NBA_SEARCH_DESCENT UINT_C(0x2000) /* 小さなサイズの方向に探索する。 */
222#define NBA_RESERVE_TCP UINT_C(0x4000) /* TCP 用にネットワークバッファを予約する。*/
223#define NBA_ID_MASK UINT_C(0x0fff) /* 通信端点 ID を渡す場合のマスク値 */
224
225/*
226 * 関数シミュレーションマクロ
227 */
228
229#define get_net_buf(b,l) tget_net_buf((b),(l),TMO_FEVR)
230
231/*
232 * 関数
233 */
234
235extern ER tget_net_buf_ex (T_NET_BUF **blk, uint_t minlen, uint_t maxlen, ATR nbatr, TMO tmout);
236extern ER tget_net_buf (T_NET_BUF **blk, uint_t len, TMO tmout);
237extern ER rel_net_buf (T_NET_BUF *blk);
238extern ER rus_net_buf (T_NET_BUF *blk);
239extern ER_UINT net_buf_siz (T_NET_BUF *blk);
240extern uint_t net_buf_max_siz (void);
241extern const T_NET_BUF_ENTRY *nbuf_get_tbl (void);
242extern uint_t nbuf_get_tbl_size (void);
243
244#endif /* of #ifndef _NET_BUF_H_ */
Note: See TracBrowser for help on using the repository browser.