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: udp_input.c 270 2017-02-09 04:03:47Z coas-nagasima $
|
---|
44 | */
|
---|
45 |
|
---|
46 | /*
|
---|
47 | * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
|
---|
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 |
|
---|
79 | #include <string.h>
|
---|
80 |
|
---|
81 | #ifdef TARGET_KERNEL_ASP
|
---|
82 |
|
---|
83 | #include <kernel.h>
|
---|
84 | #include <sil.h>
|
---|
85 | #include <t_syslog.h>
|
---|
86 |
|
---|
87 | #endif /* of #ifdef TARGET_KERNEL_ASP */
|
---|
88 |
|
---|
89 | #ifdef TARGET_KERNEL_JSP
|
---|
90 |
|
---|
91 | #include <s_services.h>
|
---|
92 | #include <t_services.h>
|
---|
93 | #include "kernel_id.h"
|
---|
94 |
|
---|
95 | #endif /* of #ifdef TARGET_KERNEL_JSP */
|
---|
96 |
|
---|
97 | #include <tinet_defs.h>
|
---|
98 | #include <tinet_config.h>
|
---|
99 |
|
---|
100 | #include <net/if.h>
|
---|
101 | #include <net/if_loop.h>
|
---|
102 | #include <net/if_ppp.h>
|
---|
103 | #include <net/ethernet.h>
|
---|
104 | #include <net/ppp_ipcp.h>
|
---|
105 | #include <net/net.h>
|
---|
106 | #include <net/net_buf.h>
|
---|
107 | #include <net/net_count.h>
|
---|
108 |
|
---|
109 | #include <netinet/in.h>
|
---|
110 | #include <netinet/in_var.h>
|
---|
111 | #include <netinet6/in6.h>
|
---|
112 | #include <netinet6/in6_var.h>
|
---|
113 | #include <netinet/in_itron.h>
|
---|
114 | #include <netinet/ip.h>
|
---|
115 | #include <netinet/ip_var.h>
|
---|
116 | #include <netinet/ip6.h>
|
---|
117 | #include <netinet6/ip6_var.h>
|
---|
118 | #include <netinet/ip_icmp.h>
|
---|
119 | #include <netinet/icmp6.h>
|
---|
120 |
|
---|
121 | #include <netinet/udp.h>
|
---|
122 | #include <netinet/udp_var.h>
|
---|
123 |
|
---|
124 | #include <net/if_var.h>
|
---|
125 |
|
---|
126 | #ifdef SUPPORT_UDP
|
---|
127 |
|
---|
128 | #ifdef SUPPORT_MIB
|
---|
129 |
|
---|
130 | /*
|
---|
131 | * SNMP 㮠管çæ
|
---|
132 | å ±ãã¼ã¹ (MIB)
|
---|
133 | */
|
---|
134 |
|
---|
135 | T_UDP_STATS udp_stats;
|
---|
136 |
|
---|
137 | #endif /* of #ifdef SUPPORT_MIB */
|
---|
138 |
|
---|
139 | #if defined(SUPPORT_INET4)
|
---|
140 |
|
---|
141 | #ifdef DHCP_CFG
|
---|
142 |
|
---|
143 | /*
|
---|
144 | * udp_dstaddr_accept -- UDP ã®ãã¦å
|
---|
145 | ã¢ãã¬ã¹ãæ£ããããã§ãã¯ããã
|
---|
146 | *
|
---|
147 | * DHCP_CFG ãå®ç¾©ããã¦ããã¨ãã¯ã以ä¸ã®ãã¼ã¿ã°ã©ã ãåä¿¡ããã
|
---|
148 | *
|
---|
149 | * ã»ãã¦å
|
---|
150 | ã¢ãã¬ã¹ãããã¼ããã£ã¹ã
|
---|
151 | * ã»ãã¼ã«ã«ã¢ãã¬ã¹ãæªå®ç¾©
|
---|
152 | */
|
---|
153 |
|
---|
154 | static bool_t
|
---|
155 | udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
|
---|
156 | {
|
---|
157 | T_IFNET *ifp = IF_GET_IFNET();
|
---|
158 |
|
---|
159 | if (ifp->in_ifaddr.addr == IPV4_ADDRANY ||
|
---|
160 | ntohl(*dstaddr) == IPV4_ADDR_BROADCAST ||
|
---|
161 | ntohl(*dstaddr) == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask))
|
---|
162 | return true;
|
---|
163 | else
|
---|
164 | return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
|
---|
165 | }
|
---|
166 |
|
---|
167 | #elif defined(ETHER_CFG_MULTICAST)
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * udp_dstaddr_accept -- UDP ã®ãã¦å
|
---|
171 | ã¢ãã¬ã¹ãæ£ããããã§ãã¯ããã
|
---|
172 | *
|
---|
173 | * 以ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
|
---|
174 | *
|
---|
175 | * ã»ãã¦å
|
---|
176 | ã¢ãã¬ã¹ãããã¼ããã£ã¹ã
|
---|
177 | */
|
---|
178 |
|
---|
179 | static bool_t
|
---|
180 | udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
|
---|
181 | {
|
---|
182 | T_IFNET *ifp = IF_GET_IFNET();
|
---|
183 | T_IN4_ADDR dst = ntohl(*dstaddr);
|
---|
184 |
|
---|
185 | if (dst == IPV4_ADDR_BROADCAST ||
|
---|
186 | dst == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask) ||
|
---|
187 | IN4_IS_ADDR_MULTICAST(dst))
|
---|
188 | return true;
|
---|
189 | else
|
---|
190 | return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
|
---|
191 | }
|
---|
192 |
|
---|
193 | #else /* of #ifdef DHCP_CFG */
|
---|
194 |
|
---|
195 | /*
|
---|
196 | * udp_dstaddr_accept -- UDP ã®ãã¦å
|
---|
197 | ã¢ãã¬ã¹ãæ£ããããã§ãã¯ããã
|
---|
198 | *
|
---|
199 | * 以ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
|
---|
200 | *
|
---|
201 | * ã»ãã¦å
|
---|
202 | ã¢ãã¬ã¹ãããã¼ããã£ã¹ã
|
---|
203 | */
|
---|
204 |
|
---|
205 | static bool_t
|
---|
206 | udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
|
---|
207 | {
|
---|
208 | T_IFNET *ifp = IF_GET_IFNET();
|
---|
209 |
|
---|
210 | if (ntohl(*dstaddr) == IPV4_ADDR_BROADCAST ||
|
---|
211 | ntohl(*dstaddr) == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask))
|
---|
212 | return true;
|
---|
213 | else
|
---|
214 | return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
|
---|
215 | }
|
---|
216 |
|
---|
217 | #endif /* of #ifdef DHCP_CFG */
|
---|
218 |
|
---|
219 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
220 |
|
---|
221 | #if defined(SUPPORT_INET6)
|
---|
222 |
|
---|
223 | /*
|
---|
224 | * udp_dstaddr_accept -- UDP ã®ãã¦å
|
---|
225 | ã¢ãã¬ã¹ãæ£ããããã§ãã¯ããã
|
---|
226 | *
|
---|
227 | * 以ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
|
---|
228 | *
|
---|
229 | * ã»ãã¦å
|
---|
230 | ã¢ãã¬ã¹ããã«ããã£ã¹ã
|
---|
231 | */
|
---|
232 |
|
---|
233 | static bool_t
|
---|
234 | udp_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr)
|
---|
235 | {
|
---|
236 | if (IN6_IS_ADDR_MULTICAST(dstaddr))
|
---|
237 | return true;
|
---|
238 | else
|
---|
239 | return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
|
---|
240 | }
|
---|
241 |
|
---|
242 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
243 |
|
---|
244 | /*
|
---|
245 | * udp_input -- UDP ã®å
|
---|
246 | ¥åé¢æ°
|
---|
247 | */
|
---|
248 |
|
---|
249 | uint_t
|
---|
250 | udp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
|
---|
251 | {
|
---|
252 | T_NET_BUF *input = *inputp;
|
---|
253 | T_UDP_CEP *cep;
|
---|
254 | T_UDP_HDR *udph;
|
---|
255 | T_IP_HDR *iph;
|
---|
256 | int_t ix;
|
---|
257 | uint_t len, hlen, ulen;
|
---|
258 |
|
---|
259 | hlen = (uint_t)GET_IF_IP_HDR_SIZE(input);
|
---|
260 |
|
---|
261 | NET_COUNT_UDP(net_count_udp.in_octets, input->len - hlen);
|
---|
262 | NET_COUNT_UDP(net_count_udp.in_packets, 1);
|
---|
263 | NET_COUNT_MIB(udp_stats.udpInDatagrams, 1);
|
---|
264 |
|
---|
265 | /* ãããé·ããã§ãã¯ããã*/
|
---|
266 | if (input->len < hlen + UDP_HDR_SIZE)
|
---|
267 | goto buf_rel;
|
---|
268 |
|
---|
269 | udph = (T_UDP_HDR *)(input->buf + *offp);
|
---|
270 |
|
---|
271 | /* ãã¼ã¿ã°ã©ã é·ããã§ãã¯ãã */
|
---|
272 | ulen = ntohs(udph->ulen);
|
---|
273 | if (ulen != input->len - hlen)
|
---|
274 | goto buf_rel;
|
---|
275 |
|
---|
276 | /* å®å
|
---|
277 | ãã¼ãã 0 ã®ãã¼ã¿ã°ã©ã ã¯ç ´æ£ãããRFC768 */
|
---|
278 | if (udph->dport == 0)
|
---|
279 | goto buf_rel;
|
---|
280 |
|
---|
281 | #ifdef UDP_CFG_IN_CHECKSUM
|
---|
282 |
|
---|
283 | /* ãã§ãã¯ãµã ããã§ãã¯ãã */
|
---|
284 | if (udph->sum && IN_CKSUM(input, IPPROTO_UDP, *offp, ulen) != 0)
|
---|
285 | goto buf_rel;
|
---|
286 |
|
---|
287 | #endif /* of #ifdef UDP_CFG_IN_CHECKSUM */
|
---|
288 |
|
---|
289 | iph = GET_IP_HDR(input);
|
---|
290 |
|
---|
291 | /* å®å
|
---|
292 | ã¢ãã¬ã¹ã¨ãã¼ãããã§ãã¯ãã */
|
---|
293 | for (ix = tmax_udp_ccepid; ix -- > 0; ) {
|
---|
294 | cep = &udp_cep[ix];
|
---|
295 | if (VALID_UDP_CEP(cep) &&
|
---|
296 | udp_is_dstaddr_accept(&cep->myaddr.ipaddr, &iph->dst) &&
|
---|
297 | ntohs(udph->dport) == cep->myaddr.portno) {
|
---|
298 | len = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
|
---|
299 |
|
---|
300 | if (cep->rcv_tskid != TA_NULL) { /* éãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
301 | if (psnd_dtq(cep->rcvqid, (intptr_t)input) != E_OK)
|
---|
302 | goto buf_rel;
|
---|
303 | }
|
---|
304 |
|
---|
305 | #ifdef UDP_CFG_NON_BLOCKING
|
---|
306 |
|
---|
307 | else if (cep->rcv_p_dstaddr != NULL) { /* ãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
308 |
|
---|
309 | /* p_dstaddr ãè¨å®ããã*/
|
---|
310 | cep->rcv_p_dstaddr->portno = ntohs(udph->sport);
|
---|
311 | IN_COPY_TO_HOST(&cep->rcv_p_dstaddr->ipaddr, &GET_IP_HDR(input)->src);
|
---|
312 |
|
---|
313 | /* ãã¼ã¿ããããã¡ã«ç§»ãã*/
|
---|
314 | memcpy(cep->rcv_data, GET_UDP_SDU(input, *offp),
|
---|
315 | (size_t)(len < cep->rcv_len ? len : cep->rcv_len));
|
---|
316 | syscall(rel_net_buf(input));
|
---|
317 |
|
---|
318 | if (IS_PTR_DEFINED(cep->callback))
|
---|
319 |
|
---|
320 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
321 |
|
---|
322 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)len);
|
---|
323 |
|
---|
324 | #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
325 |
|
---|
326 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&len);
|
---|
327 |
|
---|
328 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
329 |
|
---|
330 | else
|
---|
331 | syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
|
---|
332 | cep->rcv_p_dstaddr = NULL;
|
---|
333 | }
|
---|
334 |
|
---|
335 | #endif /* of #ifdef UDP_CFG_NON_BLOCKING */
|
---|
336 |
|
---|
337 | else if (IS_PTR_DEFINED(cep->callback)) {
|
---|
338 |
|
---|
339 | /* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
340 | cep->cb_netbuf = input;
|
---|
341 |
|
---|
342 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
343 |
|
---|
344 | (*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)len);
|
---|
345 |
|
---|
346 | #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
347 |
|
---|
348 | (*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&len);
|
---|
349 |
|
---|
350 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
351 |
|
---|
352 | /*
|
---|
353 | * ãããã¯ã¼ã¯ãããã¡ããã®ã¾ã¾ã§ããã°ãã³ã¼ã«ããã¯é¢æ°å
|
---|
354 | ã§
|
---|
355 | * ãã¼ã¿ãèªã¿åºããªãã£ããã¨ã«ãªãã®ã§ãæ¨ã¦ãã
|
---|
356 | */
|
---|
357 | if (cep->cb_netbuf != NULL)
|
---|
358 | syscall(rel_net_buf(cep->cb_netbuf));
|
---|
359 | }
|
---|
360 | else
|
---|
361 | goto buf_rel;
|
---|
362 |
|
---|
363 | return IPPROTO_DONE;
|
---|
364 | }
|
---|
365 | }
|
---|
366 |
|
---|
367 | NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
|
---|
368 |
|
---|
369 | #if defined(SUPPORT_INET4)
|
---|
370 |
|
---|
371 | /* ãã¼ã«ã« IP ã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã®ã¿ ICMP ã¨ã©ã¼ãéç¥ããã*/
|
---|
372 | if (ntohl(iph->dst) == IF_GET_IFNET()->in_ifaddr.addr) {
|
---|
373 | syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
|
---|
374 |
|
---|
375 | icmp_error(ICMP4_UNREACH_PORT, input);
|
---|
376 | /* icmp_error ã§ã¯ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããªãã®ã§ä¸ã¸æããã*/
|
---|
377 | }
|
---|
378 |
|
---|
379 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
380 |
|
---|
381 | #if defined(SUPPORT_INET6)
|
---|
382 |
|
---|
383 | /* ãã«ããã£ã¹ãã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã 㯠ICMP ã¨ã©ã¼ãéç¥ããªãã*/
|
---|
384 | if (!IN6_IS_ADDR_MULTICAST(&iph->dst)) {
|
---|
385 | syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
|
---|
386 |
|
---|
387 | /* icmp6_error ã§ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããã*/
|
---|
388 | icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
|
---|
389 |
|
---|
390 | NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
|
---|
391 | NET_COUNT_MIB(udp_stats.udpInErrors, 1);
|
---|
392 | return IPPROTO_DONE;
|
---|
393 | }
|
---|
394 |
|
---|
395 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
396 |
|
---|
397 | buf_rel:
|
---|
398 | NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
|
---|
399 | NET_COUNT_MIB(udp_stats.udpInErrors, 1);
|
---|
400 | syscall(rel_net_buf(input));
|
---|
401 | return IPPROTO_DONE;
|
---|
402 | }
|
---|
403 |
|
---|
404 | #endif /* of #ifdef SUPPORT_UDP */
|
---|