source: asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netinet/in4.h@ 337

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

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 7.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, 1990, 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 * @(#)in.h 8.3 (Berkeley) 1/3/94
67 * $FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp $
68 */
69
70#ifndef _IN4_H_
71#define _IN4_H_
72
73/*
74 * IPv4 アドレス
75 */
76
77/* 前方参照 */
78
79#ifndef T_IN4_ADDR_DEFINED
80
81typedef uint32_t T_IN4_ADDR;
82
83#define T_IN4_ADDR_DEFINED
84
85#endif /* of #ifndef T_IN4_ADDR_DEFINED */
86
87/*
88 * ITRON TCP/IPv4 アドレス/ポート番号の定義
89 */
90
91typedef struct t_ipv4ep {
92 uint32_t ipaddr; /* IPv4 アドレス */
93 uint16_t portno; /* ポート番号 */
94 } T_IPV4EP;
95
96#define T_IPV4EP_DEFINED
97
98/*
99 * アドレスの長さ
100 */
101
102#define IPV4_ADDR_LEN 4
103
104/*
105 * IPv4 アドレスの定義
106 */
107
108#define IPV4_ADDRANY ULONG_C(0x00000000) /* ITRON TCP/IP 標準 */
109#define IPV4_ADDRBROADCAST ULONG_C(0xffffffff)
110
111#define IPV4_ADDR_LOOPBACK ULONG_C(0x7f000001)
112#define IPV4_ADDR_LOOPBACK_MASK IPV4_CLASS_A_MASK
113#define IPV4_ADDR_BROADCAST ULONG_C(0xffffffff)
114
115#define IPV4_CLASS_A(i) (((i) & ULONG_C(0x80000000)) == 0)
116#define IPV4_CLASS_A_NET ULONG_C(0xff000000)
117#define IPV4_CLASS_A_MASK ULONG_C(0xff000000)
118#define IPV4_CLASS_A_HOST ULONG_C(0x00ffffff)
119
120#define IPV4_CLASS_B(i) (((i) & ULONG_C(0xc0000000)) == ULONG_C(0x80000000))
121#define IPV4_CLASS_B_NET ULONG_C(0xffff0000)
122#define IPV4_CLASS_B_MASK ULONG_C(0xffff0000)
123#define IPV4_CLASS_B_HOST ULONG_C(0x0000ffff)
124
125#define IPV4_CLASS_C(i) (((i) & ULONG_C(0xe0000000)) == ULONG_C(0xc0000000))
126#define IPV4_CLASS_C_NET ULONG_C(0xffffff00)
127#define IPV4_CLASS_C_MASK ULONG_C(0xffffff00)
128#define IPV4_CLASS_C_HOST ULONG_C(0x000000ff)
129
130#define IPV4_CLASS_D(i) (((i) & ULONG_C(0xf0000000)) == ULONG_C(0xe0000000))
131
132#define IN4_IS_ADDR_MULTICAST(i) IPV4_CLASS_D(i)
133
134#define MAKE_IPV4_LOCAL_BROADCAST(i) (IPV4_CLASS_A(i)?((i)|IPV4_CLASS_A_HOST):\
135 IPV4_CLASS_B(i)?((i)|IPV4_CLASS_B_HOST):\
136 IPV4_CLASS_C(i)?((i)|IPV4_CLASS_C_HOST):\
137 IPV4_ADDR_BROADCAST)
138
139#define MAKE_IPV4_LOCAL_MASK(i) (IPV4_CLASS_A(i)?IPV4_CLASS_A_MASK:\
140 IPV4_CLASS_B(i)?IPV4_CLASS_B_MASK:\
141 IPV4_CLASS_C(i)?IPV4_CLASS_C_MASK:\
142 IPV4_ADDRANY)
143
144#define MAKE_IPV4_ADDR(a,b,c,d) ((T_IN4_ADDR)(((uint32_t)(a)<<24)|((uint32_t)(b)<<16)|((uint32_t)(c)<<8)|(d)))
145
146/*
147 * 関数シミュレーションマクロ
148 */
149
150#define IN4_ARE_ADDR_EQUAL(dst,src) (*(dst)==*(src))
151#define IN4_IS_ADDR_ANY(addr) (*(addr)==IPV4_ADDRANY)
152#define IN4_IS_ADDR_BROADCAST(addr) (*(addr)==IPV4_ADDRBROADCAST)
153#define ip2str(buf,p_ipaddr) (ipv42str(buf,p_ipaddr))
154
155/*
156 * 動的生成用 TCP 通信端点
157 */
158
159typedef struct t_tcp_ccep {
160 /* 標準 */
161 ATR cepatr; /* 通信端点属性 */
162 void *sbuf; /* 送信用ウィンドバッファ */
163 int_t sbufsz; /* 送信用ウィンドバッファサイズ */
164 void *rbuf; /* 受信用ウィンドバッファ */
165 int_t rbufsz; /* 受信用ウィンドバッファサイズ */
166 FP callback; /* コールバック */
167 /* 実装依存 */
168 } T_TCP_CCEP;
169
170/*
171 * 動的生成用 TCP 受付口
172 */
173
174typedef struct t_tcp_crep {
175 /* 標準 */
176 ATR repatr; /* 受付口属性 */
177 T_IPV4EP myaddr; /* 自分のアドレス */
178 /* 実装依存 */
179 } T_TCP_CREP;
180
181/*
182 * 動的生成用 UDP 通信端点
183 */
184
185typedef struct t_udp_ccep {
186 /* 標準 */
187 ATR cepatr; /* UDP 通信端点属性 */
188 T_IPV4EP myaddr; /* 自分のアドレス */
189 FP callback; /* コールバック関数 */
190 /* 実装依存 */
191 } T_UDP_CCEP;
192
193/*
194 * TINET 独自 API
195 */
196
197extern char *ipv42str (char *buf, const T_IN4_ADDR *p_ipaddr);
198extern uint_t in4_get_maxnum_ifaddr (void);
199extern const T_IN4_ADDR *in4_get_ifaddr (int_t index);
200extern ER in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask);
201extern ER in4_add_route (int_t index, T_IN4_ADDR target,
202 T_IN4_ADDR mask, T_IN4_ADDR gateway);
203
204#endif /* of #ifndef _IN4_H_ */
Note: See TracBrowser for help on using the repository browser.