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 | * ä¸è¨èä½æ¨©è
|
---|
8 | ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
9 | * ã«ãã£ã¦å
|
---|
10 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
11 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
12 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
13 | å¸ï¼ä»¥ä¸ï¼
|
---|
14 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
15 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
16 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
17 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
18 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
19 | * ç¨ã§ããå½¢ã§åé
|
---|
20 | å¸ããå ´åã«ã¯ï¼åé
|
---|
21 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
22 | * è
|
---|
23 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
24 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
25 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
26 | * ç¨ã§ããªãå½¢ã§åé
|
---|
27 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
|
---|
28 | * (a) åé
|
---|
29 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
30 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
31 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
32 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
33 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
34 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
35 | 責ãããã¨ï¼
|
---|
36 | *
|
---|
37 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
38 | ã
|
---|
39 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
40 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
41 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
42 | *
|
---|
43 | * @(#) $Id: in_var.h 270 2017-02-09 04:03:47Z coas-nagasima $
|
---|
44 | */
|
---|
45 |
|
---|
46 | /*
|
---|
47 | * Copyright (c) 1985, 1986, 1993
|
---|
48 | * The Regents of the University of California. All rights reserved.
|
---|
49 | *
|
---|
50 | * Redistribution and use in source and binary forms, with or without
|
---|
51 | * modification, are permitted provided that the following conditions
|
---|
52 | * are met:
|
---|
53 | * 1. Redistributions of source code must retain the above copyright
|
---|
54 | * notice, this list of conditions and the following disclaimer.
|
---|
55 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
56 | * notice, this list of conditions and the following disclaimer in the
|
---|
57 | * documentation and/or other materials provided with the distribution.
|
---|
58 | * 3. All advertising materials mentioning features or use of this software
|
---|
59 | * must display the following acknowledgement:
|
---|
60 | * This product includes software developed by the University of
|
---|
61 | * California, Berkeley and its contributors.
|
---|
62 | * 4. Neither the name of the University nor the names of its contributors
|
---|
63 | * may be used to endorse or promote products derived from this software
|
---|
64 | * without specific prior written permission.
|
---|
65 | *
|
---|
66 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
67 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
68 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
69 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
70 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
71 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
72 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
73 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
74 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
75 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
76 | * SUCH DAMAGE.
|
---|
77 | *
|
---|
78 | * @(#)in_var.h 8.2 (Berkeley) 1/9/95
|
---|
79 | * $FreeBSD: src/sys/netinet/in_var.h,v 1.29.2.1 1999/08/29 16:29:38 peter Exp $
|
---|
80 | */
|
---|
81 |
|
---|
82 | #ifndef _IN_VAR_H_
|
---|
83 | #define _IN_VAR_H_
|
---|
84 |
|
---|
85 | #if defined(SUPPORT_INET6)
|
---|
86 |
|
---|
87 | #include <netinet6/in6_var.h>
|
---|
88 |
|
---|
89 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
90 |
|
---|
91 | /*
|
---|
92 | * ç¬èªã®ã¨ã©ã¼ã³ã¼ã
|
---|
93 | */
|
---|
94 |
|
---|
95 | #define EV_NOPND (-97) /* ãã³ãã£ã³ã°ãã¦ããªã */
|
---|
96 |
|
---|
97 | /*
|
---|
98 | * ãããã¯ã¼ã¯ã¨ã©ã¼ã³ã¼ã
|
---|
99 | */
|
---|
100 |
|
---|
101 | #define EV_MSIZE (-98) /* ãã¼ã¿ã°ã©ã é·è¶
|
---|
102 | é */
|
---|
103 | #define EV_NURCH (-99) /* ãããã¯ã¼ã¯å°éä¸è½ */
|
---|
104 | #define EV_HDOWN (-100) /* ãã¹ããã¦ã³ */
|
---|
105 | #define EV_HURCH (-101) /* ãã¹ãå°éä¸è½ */
|
---|
106 | #define EV_CNNRF (-102) /* æ¥ç¶ä¸è½ */
|
---|
107 | #define EV_CNRST (-103) /* æ¥ç¶ãªã»ãã */
|
---|
108 | #define EV_REXMTMO (-104) /* åéã¿ã¤ã ã¢ã¦ã */
|
---|
109 |
|
---|
110 | /*
|
---|
111 | * å
|
---|
112 | ±éã¿ã¤ãã®èµ·åå¨æã®å®ç¾©
|
---|
113 | */
|
---|
114 |
|
---|
115 | #define IN_TIMER_TMO (SYSTIM_HZ/NET_TIMER_CYCLE)
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * ã¤ã³ã¿ãã§ã¼ã¹ã¢ãã¬ã¹æ§é ä½
|
---|
119 | */
|
---|
120 |
|
---|
121 | typedef struct t_in4_ifaddr {
|
---|
122 | T_IN4_ADDR addr; /* IPv4 ã¢ãã¬ã¹ */
|
---|
123 | T_IN4_ADDR mask; /* ãµãããããã¹ã¯ */
|
---|
124 | } T_IN4_IFADDR;
|
---|
125 |
|
---|
126 | /*
|
---|
127 | * ã«ã¼ãã£ã³ã°è¡¨ã¨ã³ããªæ§é ä½
|
---|
128 | */
|
---|
129 |
|
---|
130 | typedef struct t_in4_rtentry {
|
---|
131 | T_IN4_ADDR target; /* ç®æ¨ãããã¯ã¼ã¯ã¢ãã¬ã¹ */
|
---|
132 | T_IN4_ADDR mask; /* ç®æ¨ãããã¯ã¼ã¯ã¢ãã¬ã¹ã®ãµãããããã¹ã¯ */
|
---|
133 | T_IN4_ADDR gateway; /* ã²ã¼ãã¦ã§ã¤ã® IP ã¢ãã¬ã¹ */
|
---|
134 | uint32_t expire; /* æå¹æéãåããæå» [s] */
|
---|
135 | uint8_t flags; /* ãã©ã° */
|
---|
136 | } T_IN4_RTENTRY;
|
---|
137 |
|
---|
138 | /*
|
---|
139 | * TINET 1.1 ã¨ã®äºææ§ã®ããã®å®ç¾©
|
---|
140 | */
|
---|
141 |
|
---|
142 | #ifdef NUM_ROUTE_ENTRY
|
---|
143 |
|
---|
144 | #define NUM_STATIC_ROUTE_ENTRY NUM_ROUTE_ENTRY
|
---|
145 | #define NUM_REDIRECT_ROUTE_ENTRY 0
|
---|
146 | #define T_RT_ENTRY T_IN_RTENTRY
|
---|
147 |
|
---|
148 | #else /* of #ifdef NUM_ROUTE_ENTRY */
|
---|
149 |
|
---|
150 | #define NUM_ROUTE_ENTRY \
|
---|
151 | (NUM_STATIC_ROUTE_ENTRY + NUM_REDIRECT_ROUTE_ENTRY)
|
---|
152 | /* ã«ã¼ãã£ã³ã°è¡¨ã®ã¨ã³ããªæ° */
|
---|
153 |
|
---|
154 | #endif /* of #ifdef NUM_ROUTE_ENTRY */
|
---|
155 |
|
---|
156 | /*
|
---|
157 | * ã«ã¼ãã£ã³ã°ã¨ã³ããªç¶æ
|
---|
158 | ãã©ã°
|
---|
159 | */
|
---|
160 |
|
---|
161 | #define IN_RTF_DEFINED UINT_C(0x01) /* å®ç¾©æ¸ã¿ */
|
---|
162 | #define IN_RTF_REDIRECT UINT_C(0x10) /* åãç´ãã«ããèªåè¨å®ããã */
|
---|
163 |
|
---|
164 | /*
|
---|
165 | * IPv4 㨠IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã
|
---|
166 | */
|
---|
167 |
|
---|
168 | #if defined(SUPPORT_INET4)
|
---|
169 |
|
---|
170 | #define IN_SET_HEADER(nbuf,len,dst,src,proto,ttl) \
|
---|
171 | in4_set_header(nbuf,len,dst,src,proto,ttl)
|
---|
172 | #define IN_GET_DATAGRAM(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout) \
|
---|
173 | in4_get_datagram(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout)
|
---|
174 | #define IN_CKSUM(nbuf,proto,off,len) in4_cksum(nbuf,proto,off,len)
|
---|
175 | #define IN_IS_DSTADDR_ACCEPT(myaddr,dstaddr) \
|
---|
176 | in4_is_dstaddr_accept(myaddr,dstaddr)
|
---|
177 | #define IN_IFAWITHIFP(ifp,dst) in4_ifawithifp(ifp,dst)
|
---|
178 | #define T_IN_IFADDR T_IN4_IFADDR
|
---|
179 | #define T_IN_RTENTRY T_IN4_RTENTRY
|
---|
180 |
|
---|
181 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
182 |
|
---|
183 | /*
|
---|
184 | * ã«ã¼ãã£ã³ã°è¡¨
|
---|
185 | */
|
---|
186 |
|
---|
187 | extern T_IN_RTENTRY routing_tbl[];
|
---|
188 |
|
---|
189 | /*
|
---|
190 | * åæ¹åç
|
---|
191 | §
|
---|
192 | */
|
---|
193 |
|
---|
194 | #ifndef T_NET_BUF_DEFINED
|
---|
195 | typedef struct t_net_buf T_NET_BUF;
|
---|
196 | #define T_NET_BUF_DEFINED
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | #ifndef T_IFNET_DEFINED
|
---|
200 | typedef struct t_ifnet T_IFNET;
|
---|
201 | #define T_IFNET_DEFINED
|
---|
202 | #endif
|
---|
203 |
|
---|
204 | /*
|
---|
205 | * é¢æ°
|
---|
206 | */
|
---|
207 |
|
---|
208 | extern void ip_input (T_NET_BUF *data);
|
---|
209 | extern ER in4_set_header (T_NET_BUF *nbuf, uint_t len,
|
---|
210 | T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl);
|
---|
211 | extern ER in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
|
---|
212 | T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
|
---|
213 | uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout);
|
---|
214 | extern uint16_t in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
|
---|
215 | extern T_IN4_ADDR in4_rtalloc (T_IN4_ADDR dst);
|
---|
216 | extern void in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo);
|
---|
217 | extern void in4_init (void);
|
---|
218 | extern T_IN4_IFADDR *in4_ifawithifp (T_IFNET *ifp, T_IN4_ADDR *dst);
|
---|
219 | extern T_IN_RTENTRY *in_rtnewentry (uint8_t flags, uint32_t tmo);
|
---|
220 | extern void in_rttimer (void);
|
---|
221 | extern void in_rtinit (void);
|
---|
222 | extern const T_NET_BUF**ip_get_frag_queue (void);
|
---|
223 |
|
---|
224 | /*
|
---|
225 | * in4_is_dstaddr_accept -- å®å
|
---|
226 | ã¢ãã¬ã¹ã¨ãã¦æ£ããããã§ãã¯ããã
|
---|
227 | *
|
---|
228 | * 注æ: dstaddr ã¯ã
|
---|
229 | * TINET-1.2 ãããããã¯ã¼ã¯ãã¤ããªã¼ãã
|
---|
230 | * TINET-1.1 ã¾ã§ã¯ããã¹ããã¤ããªã¼ã
|
---|
231 | */
|
---|
232 | extern bool_t in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr);
|
---|
233 |
|
---|
234 | /*
|
---|
235 | * in_cksum -- ãã§ãã¯ãµã è¨ç®é¢æ°ãIPv4ãICMPv4 ç¨
|
---|
236 | *
|
---|
237 | * 注æ: data 㯠4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
|
---|
238 | * data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
|
---|
239 | * ä¾å¤ãçºçããå¯è½æ§ãããã
|
---|
240 | * len 㯠4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
|
---|
241 | */
|
---|
242 | extern uint16_t in_cksum(void *data, uint_t len /*ãªã¯ãããåä½*/);
|
---|
243 |
|
---|
244 | /*
|
---|
245 | * in_cksum_sum -- ãã§ãã¯ãµã ã®åè¨è¨ç®é¢æ°
|
---|
246 | *
|
---|
247 | * 注æ: data 㯠4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
|
---|
248 | * data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
|
---|
249 | * ä¾å¤ãçºçããå¯è½æ§ãããã
|
---|
250 | * len 㯠4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
|
---|
251 | */
|
---|
252 | extern uint32_t in_cksum_sum (void *data, uint_t len /*ãªã¯ãããåä½*/);
|
---|
253 |
|
---|
254 | /*
|
---|
255 | * in_cksum_carry -- ãã§ãã¯ãµã ã®æ¡ä¸ãè¨ç®é¢æ°
|
---|
256 | *
|
---|
257 | * 注æ: data 㯠4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
|
---|
258 | * data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
|
---|
259 | * ä¾å¤ãçºçããå¯è½æ§ãããã
|
---|
260 | * len 㯠4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
|
---|
261 | */
|
---|
262 | extern uint32_t in_cksum_carry (uint32_t sum);
|
---|
263 |
|
---|
264 | #endif /* of #ifndef _IN_VAR_H_ */
|
---|