source: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h@ 331

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

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 10.7 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, 1989, 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 * Fundamental constants relating to ethernet.
67 *
68 * $FreeBSD: src/sys/net/ethernet.h,v 1.9.2.1 1999/08/29 16:28:13 peter Exp $
69 *
70 */
71
72#ifndef _ETHERNET_H_
73#define _ETHERNET_H_
74
75#ifdef SUPPORT_ETHER
76
77/*
78 * フィールド長
79 */
80
81#define ETHER_ADDR_LEN 6 /* Ethernet (MAC) Address */
82#define ETHER_TYPE_LEN 2 /* Type */
83#define ETHER_CRC_LEN 0/*4*/ /* CRC */
84
85/*
86 * フレーム長 (Ethernet ヘッダと CRC を含む)
87 */
88
89#define ETHER_MIN_LEN 64
90#define ETHER_MAX_LEN (IF_MTU + sizeof(T_ETHER_HDR) + ETHER_CRC_LEN)
91
92/*
93 * Ethernet ヘッダ
94 */
95
96#ifndef IF_ETHER_NIC_HDR_ALIGN
97#error IF_ETHER_NIC_HDR_ALIGN expected.
98#endif /* of #ifndef IF_ETHER_NIC_HDR_ALIGN */
99
100#if defined(__RX)
101
102#pragma pack
103typedef struct t_ether_header {
104
105#if IF_ETHER_NIC_HDR_ALIGN != 0
106
107 uint8_t align[IF_ETHER_NIC_HDR_ALIGN]; /* アライン調整 */
108
109#endif /* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
110
111 uint8_t dhost[ETHER_ADDR_LEN];
112 uint8_t shost[ETHER_ADDR_LEN];
113 uint16_t type;
114 } T_ETHER_HDR;
115#pragma packoption
116
117#elif defined(TOPPERS_S810_CLG3_85) /* of #if defined(__RX) */
118
119typedef struct t_ether_header {
120
121#if IF_ETHER_NIC_HDR_ALIGN != 0
122
123 uint8_t align[IF_ETHER_NIC_HDR_ALIGN]; /* アライン調整 */
124
125#endif /* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
126
127 uint8_t dhost[ETHER_ADDR_LEN];
128 uint8_t shost[ETHER_ADDR_LEN];
129 uint16_t type;
130 } T_ETHER_HDR;
131
132#else /* of #if defined(__RX) */
133
134typedef struct t_ether_header {
135
136#if IF_ETHER_NIC_HDR_ALIGN != 0
137
138 uint8_t align[IF_ETHER_NIC_HDR_ALIGN]; /* アライン調整 */
139
140#endif /* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
141
142 uint8_t dhost[ETHER_ADDR_LEN];
143 uint8_t shost[ETHER_ADDR_LEN];
144 uint16_t type;
145 } __attribute__((packed, aligned(2)))T_ETHER_HDR;
146
147#endif /* of #if defined(__RX) */
148
149#define GET_ETHER_HDR(nbuf) ((T_ETHER_HDR*)((nbuf)->buf))
150
151/*
152 * MAC アドレスの定義
153 */
154
155#define ETHER_MCAST_ADDR UINT_C(0x01) /* マルチキャスト・アドレス */
156#define ETHER_LOCAL_ADDR UINT_C(0x02) /* ローカル・アドレス */
157
158typedef struct t_ether_addr {
159 uint8_t lladdr[ETHER_ADDR_LEN];
160 } __attribute__((packed, aligned(2)))T_ETHER_ADDR;
161
162/*
163 * Type フィールド
164 */
165
166#define ETHER_TYPE_IP UINT_C(0x0800) /* IPv4 */
167#define ETHER_TYPE_ARP UINT_C(0x0806) /* ARP */
168#define ETHER_TYPE_IPV6 UINT_C(0x86dd) /* IPv6 */
169
170/*
171 * インタフェースの選択マクロ
172 */
173
174#define T_IF_HDR T_ETHER_HDR /* インタフェースのヘッダ */
175#define T_IF_ADDR T_ETHER_ADDR /* インタフェースのアドレス */
176#define IF_HDR_ALIGN 2 /* ヘッダのアライン単位 */
177#define IF_MTU 1500 /* インタフェースの MTU */
178#define IF_MIN_LEN ETHER_MIN_LEN /* インターフェースフレームの最短長 */
179
180#define IF_OUTPUT(o,d,g,t) ether_output(o,d,g,t) /* インタフェースの出力関数 */
181#define IF_RAW_OUTPUT(o,t) ether_raw_output(o,t) /* インタフェースの出力関数、アドレス解決無し */
182#define IF_SET_PROTO(b,p) (GET_ETHER_HDR(b)->type = htons(p))
183 /* インタフェースのプロトコル設定関数 */
184#define IF_SOFTC_TO_IFADDR(s) ((T_IF_ADDR*)(s)->ifaddr.lladdr)
185 /* ソフトウェア情報から MAC アドレスを取り出す */
186#define IF_GET_IFNET() ether_get_ifnet() /* ネットワークインタフェース構造体を返す。 */
187#define IF_TYPE IFT_ETHER /* インタフェースの型 */
188#define IF_SRAND() ether_srand() /* インタフェースの乱数初期値 */
189
190/* IPv4 関係 */
191
192#define IF_PROTO_IP ETHER_TYPE_IP /* インタフェースの IPv4 プロトコル指定 */
193#define IF_PROTO_ARP ETHER_TYPE_ARP /* インタフェースの ARP プロトコル指定 */
194
195/* IPv6 関係 */
196
197#define MAX_IF_MADDR_CNT 2 /* インタフェースのマルチキャストアドレス配列の最大サイズ */
198#define IF_MADDR_INIT { { { 0, 0, 0, 0, 0, 0 } }, { { 0, 0, 0, 0, 0, 0 } } }
199 /* インタフェースのマルチキャストアドレス配列の初期化 */
200#define IF_PROTO_IPV6 ETHER_TYPE_IPV6 /* インタフェースの IPv6 プロトコル指定 */
201#define IF_ADDMULTI(s) IF_ETHER_NIC_ADDMULTI(s)
202 /* マルチキャストアドレスの登録 */
203#define IF_IN6_NEED_CACHE(i) (true) /* 近隣探索キャッシュを使用する。 */
204#define IF_IN6_IFID(i,a) IF_ETHER_NIC_IN6_IFID(i,a)
205 /* インタフェース識別子の設定 */
206#define IF_IN6_RESOLVE_MULTICAST(i,m) \
207 ether_in6_resolve_multicast(i,m)
208 /* インタフェースのマルチキャストアドレスへの変換 */
209
210/*
211 * 前方参照
212 */
213
214#ifndef T_IFNET_DEFINED
215
216typedef struct t_ifnet T_IFNET;
217
218#define T_IFNET_DEFINED
219
220#endif /* of #ifndef T_IFNET_DEFINED */
221
222#ifndef T_IF_SOFTC_DEFINED
223
224typedef struct t_if_softc T_IF_SOFTC;
225
226#define T_IF_SOFTC_DEFINED
227
228#endif /* of #ifndef T_IF_SOFTC_DEFINED */
229
230#ifndef T_IN4_ADDR_DEFINED
231
232typedef uint32_t T_IN4_ADDR;
233
234#define T_IN4_ADDR_DEFINED
235
236#endif /* of #ifndef T_IN4_ADDR_DEFINED */
237
238#ifndef T_NET_BUF_DEFINED
239
240typedef struct t_net_buf T_NET_BUF;
241
242#define T_NET_BUF_DEFINED
243
244#endif /* of #ifndef T_NET_BUF_DEFINED */
245
246/*
247 * ネットワークインタフェースに依存しないソフトウェア情報
248 */
249
250#ifdef T_IF_ETHER_NIC_SOFTC
251
252struct t_if_softc {
253 T_IF_ADDR ifaddr; /* ネットワークインタフェースのアドレス */
254 uint16_t timer; /* 送信タイムアウト */
255 T_IF_ETHER_NIC_SOFTC *sc; /* ディバイス依存のソフトウェア情報 */
256 ID semid_txb_ready; /* 送信セマフォ */
257 ID semid_rxb_ready; /* 受信セマフォ */
258
259#ifdef _IP6_CFG
260
261 T_IF_ADDR maddrs[MAX_IF_MADDR_CNT]; /* マルチキャストアドレスリスト */
262
263#endif /* of #ifdef _IP6_CFG */
264 };
265
266#endif /* of #ifdef T_IF_ETHER_NIC_SOFTC */
267
268#define IF_FLAG_UP 0x01U
269#define IF_FLAG_LINK_UP 0x10U
270
271/*
272 * 変数
273 */
274
275#ifdef ETHER_CFG_COLLECT_ADDR
276
277T_ETHER_ADDR ether_collect_addr;
278
279#endif /* of #ifdef ETHER_CFG_COLLECT_ADDR */
280
281/*
282 * 関数
283 */
284
285#ifdef _IP6_CFG
286
287/* 前方参照 */
288
289#ifndef T_IN6_ADDR_DEFINED
290
291typedef struct t_in6_addr T_IN6_ADDR;
292
293#define T_IN6_ADDR_DEFINED
294
295#endif /* of #ifndef T_IN6_ADDR_DEFINED */
296
297extern ER ether_in6_resolve_multicast(T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr);
298
299#endif /* of #ifdef _IP6_CFG */
300
301extern T_IFNET *ether_get_ifnet (void);
302extern ER ether_output (T_NET_BUF *data, const void *dst, T_IF_ADDR *gw, TMO tmout);
303extern ER ether_raw_output (T_NET_BUF *data, TMO tmout);
304extern uint32_t ether_srand (void);
305
306/** Function prototype for netif status- or link-callback functions. */
307typedef void (*ether_status_callback_fn)(T_IFNET *ether);
308extern void ether_set_link_callback(ether_status_callback_fn link_callback);
309extern void ether_set_link_up(T_IFNET *ether);
310extern void ether_set_link_down(T_IFNET *ether);
311
312#endif /* of #ifdef SUPPORT_ETHER */
313
314#endif /* of #ifndef _ETHERNET_H_ */
Note: See TracBrowser for help on using the repository browser.