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 | * ä¸è¨èä½æ¨©è
|
---|
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 317 2017-08-03 13:14:26Z 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 | #include <netinet/in4_var.h>
|
---|
86 | #include <netinet6/in6_var.h>
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * ç¬èªã®ã¨ã©ã¼ã³ã¼ã
|
---|
90 | */
|
---|
91 |
|
---|
92 | #define EV_NOPND (-97) /* ãã³ãã£ã³ã°ãã¦ããªã */
|
---|
93 |
|
---|
94 | /*
|
---|
95 | * ãããã¯ã¼ã¯ã¨ã©ã¼ã³ã¼ã
|
---|
96 | */
|
---|
97 |
|
---|
98 | #define EV_MSIZE (-98) /* ãã¼ã¿ã°ã©ã é·è¶
|
---|
99 | é */
|
---|
100 | #define EV_NURCH (-99) /* ãããã¯ã¼ã¯å°éä¸è½ */
|
---|
101 | #define EV_HDOWN (-100) /* ãã¹ããã¦ã³ */
|
---|
102 | #define EV_HURCH (-101) /* ãã¹ãå°éä¸è½ */
|
---|
103 | #define EV_CNNRF (-102) /* æ¥ç¶ä¸è½ */
|
---|
104 | #define EV_CNRST (-103) /* æ¥ç¶ãªã»ãã */
|
---|
105 | #define EV_REXMTMO (-104) /* åéã¿ã¤ã ã¢ã¦ã */
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * å
|
---|
109 | ±éã¿ã¤ãã®èµ·åå¨æã®å®ç¾©
|
---|
110 | */
|
---|
111 |
|
---|
112 | #define IN_TIMER_TMO (SYSTIM_HZ/NET_TIMER_CYCLE)
|
---|
113 |
|
---|
114 | /*
|
---|
115 | * ã«ã¼ãã£ã³ã°ã¨ã³ããªç¶æ
|
---|
116 | ãã©ã°
|
---|
117 | */
|
---|
118 |
|
---|
119 | #define IN_RTF_DEFINED UINT_C(0x01) /* å®ç¾©æ¸ã¿ */
|
---|
120 | #define IN_RTF_REDIRECT UINT_C(0x10) /* åãç´ãã«ããèªåè¨å®ããã */
|
---|
121 |
|
---|
122 | /*
|
---|
123 | * IPv4 㨠IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã
|
---|
124 | */
|
---|
125 |
|
---|
126 | #if defined(_IP6_CFG)
|
---|
127 |
|
---|
128 | #define T_IN_ADDR T_IN6_ADDR
|
---|
129 | #define T_IPEP T_IPV6EP
|
---|
130 | #define IP_ADDRANY IPV6_ADDRANY
|
---|
131 |
|
---|
132 | #elif defined(_IP4_CFG) /* of #if defined(_IP6_CFG) */
|
---|
133 |
|
---|
134 | #define T_IN_ADDR T_IN4_ADDR
|
---|
135 | #define T_IPEP T_IPV4EP
|
---|
136 | #define IP_ADDRANY IPV4_ADDRANY
|
---|
137 |
|
---|
138 | #endif /* of #if defined(_IP6_CFG) */
|
---|
139 |
|
---|
140 | #if defined(_IP6_CFG)
|
---|
141 |
|
---|
142 | #if defined(_IP4_CFG)
|
---|
143 |
|
---|
144 | #define IN_CKSUM(nbuf,proto,off,len) (GET_IP_VER(nbuf)==IPV6_VERSION \
|
---|
145 | ?in6_cksum(nbuf,proto,off,len) \
|
---|
146 | :in4_cksum(nbuf,proto,off,len))
|
---|
147 | #define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf) \
|
---|
148 | inn_is_dstaddr_accept(myaddr,nbuf)
|
---|
149 | #define IN_ARE_HDR_ADDR_EQUAL(nbuf) (GET_IP_VER(nbuf)==IPV6_VERSION \
|
---|
150 | ?IN6_ARE_ADDR_EQUAL(&GET_IP6_HDR(nbuf)->dst,&GET_IP6_HDR(nbuf)->src) \
|
---|
151 | :IN4_ARE_ADDR_EQUAL(&GET_IP4_HDR(nbuf)->dst,&GET_IP4_HDR(nbuf)->src))
|
---|
152 | #define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf) \
|
---|
153 | inn_are_net_srcaddr_equal(ipaddr,nbuf)
|
---|
154 | #define IN_COPY_TO_HOST(dst,nbuf) inn_copy_to_host(dst,nbuf)
|
---|
155 | #define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout) \
|
---|
156 | inn_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
|
---|
157 | #define IN_IS_ADDR_MULTICAST(addr) inn_is_addr_multicast(addr)
|
---|
158 | #define IN_IS_NET_ADDR_MULTICAST(nbuf) IN_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
|
---|
159 | #define IN_ADDRWITHIFP(ifp,src,dst) inn_addrwithifp(ifp,src,dst)
|
---|
160 | #define IN_IS_ADDR_ANY(addr) IN6_IS_ADDR_UNSPECIFIED(addr)
|
---|
161 |
|
---|
162 | #else /* of #if defined(_IP4_CFG) */
|
---|
163 |
|
---|
164 | #define IN_CKSUM(nbuf,proto,off,len) in6_cksum(nbuf,proto,off,len)
|
---|
165 | #define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf) \
|
---|
166 | INN6_IS_DSTADDR_ACCEPT(myaddr,nbuf)
|
---|
167 | #define IN_ARE_HDR_ADDR_EQUAL(nbuf) IN6_ARE_ADDR_EQUAL(&GET_IP6_HDR(nbuf)->dst,&GET_IP6_HDR(nbuf)->src)
|
---|
168 | #define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf) \
|
---|
169 | IN6_ARE_ADDR_EQUAL(ipaddr,&GET_IP6_HDR(nbuf)->src)
|
---|
170 | #define IN_COPY_TO_HOST(dst,nbuf) IN6_COPY_TO_HOST(dst, nbuf)
|
---|
171 | #define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout) \
|
---|
172 | in6_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
|
---|
173 | #define IN_IS_ADDR_MULTICAST(addr) IN6_IS_ADDR_MULTICAST(addr)
|
---|
174 | #define IN_IS_NET_ADDR_MULTICAST(nbuf) IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
|
---|
175 | #define IN_ADDRWITHIFP(ifp,src,dst) in6_addrwithifp(ifp,src,dst)
|
---|
176 | #define IN_IS_ADDR_ANY(addr) IN6_IS_ADDR_UNSPECIFIED(addr)
|
---|
177 |
|
---|
178 | #endif /* of #if defined(_IP4_CFG) */
|
---|
179 |
|
---|
180 | #else /* of #if defined(_IP6_CFG) */
|
---|
181 |
|
---|
182 | #if defined(_IP4_CFG)
|
---|
183 |
|
---|
184 | #define IN_CKSUM(nbuf,proto,off,len) in4_cksum(nbuf,proto,off,len)
|
---|
185 | #define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf) \
|
---|
186 | inn4_is_dstaddr_accept(myaddr,nbuf)
|
---|
187 | #define IN_ARE_HDR_ADDR_EQUAL(nbuf) IN4_ARE_ADDR_EQUAL(&GET_IP4_HDR(nbuf)->dst,&GET_IP4_HDR(nbuf)->src)
|
---|
188 | #define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf) \
|
---|
189 | (*(ipaddr)==ntohl(GET_IP4_HDR(nbuf)->src))
|
---|
190 | #define IN_COPY_TO_HOST(dst,nbuf) IN4_COPY_TO_HOST(dst, nbuf)
|
---|
191 | #define IN_GET_DATAGRAM(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout) \
|
---|
192 | in4_get_datagram(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout)
|
---|
193 | #define IN_IS_ADDR_MULTICAST(addr) IN4_IS_ADDR_MULTICAST(*(addr))
|
---|
194 | #define IN_IS_NET_ADDR_MULTICAST(nbuf) IN4_IS_ADDR_MULTICAST(ntohl(GET_IP4_HDR(nbuf)->dst))
|
---|
195 | #define IN_ADDRWITHIFP(ifp,src,dst) in4_addrwithifp(ifp,src,dst)
|
---|
196 | #define IN_IS_ADDR_ANY(addr) IN4_IS_ADDR_ANY(addr)
|
---|
197 |
|
---|
198 | #else /* of #if defined(_IP4_CFG) */
|
---|
199 |
|
---|
200 | #error "not implemented."
|
---|
201 |
|
---|
202 | #endif /* of #if defined(_IP4_CFG) */
|
---|
203 |
|
---|
204 | #endif /* of #if defined(_IP6_CFG) */
|
---|
205 |
|
---|
206 | #ifndef _MACRO_ONLY
|
---|
207 |
|
---|
208 | /*
|
---|
209 | * é¢æ°
|
---|
210 | */
|
---|
211 | extern bool_t inn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *nbuf);
|
---|
212 | extern bool_t inn_is_addr_multicast (T_IN6_ADDR *addr);
|
---|
213 | extern bool_t inn_are_net_srcaddr_equal (T_IN6_ADDR *ipaddr, T_NET_BUF *nbuf);
|
---|
214 | extern void inn_copy_to_host (T_IN6_ADDR *dst, T_NET_BUF *nbuf);
|
---|
215 | extern ER inn_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
|
---|
216 | T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
|
---|
217 | uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
|
---|
218 | extern T_IN6_ADDR *inn_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, T_IN6_ADDR *dst);
|
---|
219 |
|
---|
220 | #endif /* of #ifndef _MACRO_ONLY */
|
---|
221 |
|
---|
222 | #endif /* of #ifndef _IN_VAR_H_ */
|
---|