1 | /*
|
---|
2 | * TINET (UDP/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 | * 上記著作権者は,以下の (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, 1988, 1990, 1993, 1995
|
---|
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 ceproduce 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 | * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
|
---|
67 | * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.49.2.2 1999/08/29 16:29:58 peter Exp $
|
---|
68 | */
|
---|
69 |
|
---|
70 | #include <string.h>
|
---|
71 |
|
---|
72 | #ifdef TARGET_KERNEL_ASP
|
---|
73 |
|
---|
74 | #include <kernel.h>
|
---|
75 | #include <sil.h>
|
---|
76 | #include "kernel_cfg.h"
|
---|
77 |
|
---|
78 | #endif /* of #ifdef TARGET_KERNEL_ASP */
|
---|
79 |
|
---|
80 | #ifdef TARGET_KERNEL_JSP
|
---|
81 |
|
---|
82 | #include <s_services.h>
|
---|
83 | #include <t_services.h>
|
---|
84 | #include "kernel_id.h"
|
---|
85 |
|
---|
86 | #endif /* of #ifdef TARGET_KERNEL_JSP */
|
---|
87 |
|
---|
88 | #include <tinet_defs.h>
|
---|
89 | #include <tinet_config.h>
|
---|
90 |
|
---|
91 | #include <net/if.h>
|
---|
92 | #include <net/if_ppp.h>
|
---|
93 | #include <net/if_loop.h>
|
---|
94 | #include <net/ethernet.h>
|
---|
95 | #include <net/net.h>
|
---|
96 | #include <net/net_buf.h>
|
---|
97 | #include <net/net_count.h>
|
---|
98 | #include <net/ppp_ipcp.h>
|
---|
99 |
|
---|
100 | #include <netinet/in.h>
|
---|
101 | #include <netinet6/in6.h>
|
---|
102 | #include <netinet/in_var.h>
|
---|
103 | #include <netinet/in_itron.h>
|
---|
104 | #include <netinet/ip.h>
|
---|
105 | #include <netinet/ip_var.h>
|
---|
106 | #include <netinet/ip_icmp.h>
|
---|
107 | #include <netinet6/in6_var.h>
|
---|
108 | #include <netinet/ip6.h>
|
---|
109 | #include <netinet6/ip6_var.h>
|
---|
110 | #include <netinet6/nd6.h>
|
---|
111 | #include <netinet/icmp6.h>
|
---|
112 | #include <netinet/udp.h>
|
---|
113 | #include <netinet/udp_var.h>
|
---|
114 |
|
---|
115 | #ifdef SUPPORT_UDP
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * IPv4 と IPv6 の切り替えマクロ
|
---|
119 | */
|
---|
120 |
|
---|
121 | #if defined(SUPPORT_INET4)
|
---|
122 |
|
---|
123 | #define UDP_SND_DAT udp_snd_dat
|
---|
124 | #define UDP_RCV_DAT udp_rcv_dat
|
---|
125 |
|
---|
126 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
127 |
|
---|
128 | #if defined(SUPPORT_INET6)
|
---|
129 |
|
---|
130 | #define UDP_SND_DAT udp6_snd_dat
|
---|
131 | #define UDP_RCV_DAT udp6_rcv_dat
|
---|
132 |
|
---|
133 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
134 |
|
---|
135 | /*
|
---|
136 | * TINET をライブラリ化しない場合は、全ての機能を
|
---|
137 | * オブジェクトファイルに出力するため、マクロを有効にする。
|
---|
138 | */
|
---|
139 |
|
---|
140 | #ifndef UDP_CFG_LIBRARY
|
---|
141 |
|
---|
142 | #define __udp_can_snd
|
---|
143 | #define __udp_can_rcv
|
---|
144 | #define __udp_snd_dat
|
---|
145 | #define __udp_rcv_dat
|
---|
146 |
|
---|
147 | #endif /* of #ifndef UDP_CFG_LIBRARY */
|
---|
148 |
|
---|
149 | #ifdef UDP_CFG_NON_BLOCKING
|
---|
150 |
|
---|
151 | #ifdef __udp_can_snd
|
---|
152 |
|
---|
153 | /*
|
---|
154 | * udp_can_snd -- ペンディングしている送信のキャンセル
|
---|
155 | */
|
---|
156 |
|
---|
157 | ER
|
---|
158 | udp_can_snd (T_UDP_CEP *cep, ER error)
|
---|
159 | {
|
---|
160 | if (cep->snd_p_dstaddr != NULL) { /* ノンブロッキングコールでペンディング中 */
|
---|
161 | if (IS_PTR_DEFINED(cep->callback))
|
---|
162 |
|
---|
163 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
164 |
|
---|
165 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
|
---|
166 |
|
---|
167 | #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
168 |
|
---|
169 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
|
---|
170 |
|
---|
171 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
172 |
|
---|
173 | else
|
---|
174 | error = E_OBJ;
|
---|
175 | cep->snd_p_dstaddr = NULL;
|
---|
176 | }
|
---|
177 | else if (cep->snd_tskid != TA_NULL) { /* 非ノンブロッキングコールでペンディング中 */
|
---|
178 |
|
---|
179 | #ifdef UDP_CFG_EXTENTIONS
|
---|
180 |
|
---|
181 | /* 待ち中に発生したエラー情報を設定する。*/
|
---|
182 | cep->error = error;
|
---|
183 |
|
---|
184 | #endif /* of #ifdef UDP_CFG_EXTENTIONS */
|
---|
185 |
|
---|
186 | error = rel_wai(cep->snd_tskid);
|
---|
187 | cep->snd_tskid = TA_NULL;
|
---|
188 | }
|
---|
189 | else /* どちらでもないならペンディングしていない */
|
---|
190 | error = EV_NOPND;
|
---|
191 |
|
---|
192 | return error;
|
---|
193 | }
|
---|
194 |
|
---|
195 | #endif /* of #ifdef __udp_can_snd */
|
---|
196 |
|
---|
197 | #ifdef __udp_can_rcv
|
---|
198 |
|
---|
199 | /*
|
---|
200 | * udp_can_rcv -- ペンディングしている受信のキャンセル
|
---|
201 | */
|
---|
202 |
|
---|
203 | ER
|
---|
204 | udp_can_rcv (T_UDP_CEP *cep, ER error)
|
---|
205 | {
|
---|
206 | if (cep->rcv_p_dstaddr != NULL) { /* ノンブロッキングコールでペンディング中 */
|
---|
207 | if (IS_PTR_DEFINED(cep->callback))
|
---|
208 |
|
---|
209 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
210 |
|
---|
211 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)error);
|
---|
212 |
|
---|
213 | #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
214 |
|
---|
215 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&error);
|
---|
216 |
|
---|
217 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
218 |
|
---|
219 | else
|
---|
220 | error = E_OBJ;
|
---|
221 | cep->rcv_p_dstaddr = NULL;
|
---|
222 | }
|
---|
223 | else if (cep->rcv_tskid != TA_NULL) { /* 非ノンブロッキングコールでペンディング中 */
|
---|
224 |
|
---|
225 | #ifdef UDP_CFG_EXTENTIONS
|
---|
226 |
|
---|
227 | /* 待ち中に発生したエラー情報を設定する。*/
|
---|
228 | cep->error = error;
|
---|
229 |
|
---|
230 | #endif /* of #ifdef UDP_CFG_EXTENTIONS */
|
---|
231 |
|
---|
232 | error = rel_wai(cep->rcv_tskid);
|
---|
233 | cep->rcv_tskid = TA_NULL;
|
---|
234 | }
|
---|
235 | else /* どちらでもないならペンディングしていない */
|
---|
236 | error = EV_NOPND;
|
---|
237 |
|
---|
238 | return error;
|
---|
239 | }
|
---|
240 |
|
---|
241 | #endif /* of #ifdef __udp_can_rcv */
|
---|
242 |
|
---|
243 | #ifdef __udp_snd_dat
|
---|
244 |
|
---|
245 | /*
|
---|
246 | * udp_snd_dat -- パケットの送信【標準機能】
|
---|
247 | */
|
---|
248 |
|
---|
249 | ER_UINT
|
---|
250 | UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
|
---|
251 | {
|
---|
252 | T_UDP_CEP *cep;
|
---|
253 | ER error;
|
---|
254 |
|
---|
255 | /* p_dstaddr または data が NULL ならエラー */
|
---|
256 | if (p_dstaddr == NULL || data == NULL)
|
---|
257 | return E_PAR;
|
---|
258 |
|
---|
259 | /* データ長をチェックする。*/
|
---|
260 | if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
|
---|
261 | return E_PAR;
|
---|
262 |
|
---|
263 | /* UDP 通信端点 ID をチェックする。*/
|
---|
264 | if (!VALID_UDP_CEPID(cepid))
|
---|
265 | return E_ID;
|
---|
266 |
|
---|
267 | /* UDP 通信端点を得る。*/
|
---|
268 | cep = GET_UDP_CEP(cepid);
|
---|
269 |
|
---|
270 | /* UDP 通信端点をチェックする。*/
|
---|
271 | if (!VALID_UDP_CEP(cep))
|
---|
272 | return E_NOEXS;
|
---|
273 |
|
---|
274 | /*
|
---|
275 | * 自ポート番号が UDP_PORTANY なら、自動で割り当てる。
|
---|
276 | */
|
---|
277 | if (cep->myaddr.portno == UDP_PORTANY) {
|
---|
278 | if ((error = udp_alloc_auto_port(cep)) != E_OK)
|
---|
279 | return error;
|
---|
280 | }
|
---|
281 |
|
---|
282 | /*
|
---|
283 | * タイムアウトをチェックする。
|
---|
284 | */
|
---|
285 |
|
---|
286 | if (tmout == TMO_NBLK) { /* ノンブロッキングコール */
|
---|
287 |
|
---|
288 | /* 通信端点をロックする。*/
|
---|
289 | syscall(wai_sem(cep->semid_lock));
|
---|
290 |
|
---|
291 | if (cep->snd_p_dstaddr != NULL) {
|
---|
292 |
|
---|
293 | /* ノンブロッキングコールでペンディング中 */
|
---|
294 | error = E_QOVR;
|
---|
295 |
|
---|
296 | /* 通信端点をロックを解除する。*/
|
---|
297 | syscall(sig_sem(cep->semid_lock));
|
---|
298 | }
|
---|
299 | else if (cep->snd_tskid != TA_NULL) {
|
---|
300 |
|
---|
301 | /* 非ノンブロッキングコールでペンディング中 */
|
---|
302 | error = E_OBJ;
|
---|
303 |
|
---|
304 | /* 通信端点をロックを解除する。*/
|
---|
305 | syscall(sig_sem(cep->semid_lock));
|
---|
306 | }
|
---|
307 | else {
|
---|
308 |
|
---|
309 | cep->snd_p_dstaddr = p_dstaddr;
|
---|
310 | cep->snd_data = data;
|
---|
311 | cep->snd_len = len;
|
---|
312 |
|
---|
313 | /* 通信端点をロックを解除する。*/
|
---|
314 | syscall(sig_sem(cep->semid_lock));
|
---|
315 |
|
---|
316 | cep->flags |= UDP_CEP_FLG_POST_OUTPUT;
|
---|
317 | sig_sem(SEM_UDP_POST_OUTPUT);
|
---|
318 | error = E_WBLK;
|
---|
319 | }
|
---|
320 | }
|
---|
321 | else { /* 非ノンブロッキングコール */
|
---|
322 |
|
---|
323 | /* 通信端点をロックする。*/
|
---|
324 | syscall(wai_sem(cep->semid_lock));
|
---|
325 |
|
---|
326 | if (cep->snd_p_dstaddr != NULL) {
|
---|
327 |
|
---|
328 | /* ノンブロッキングコールでペンディング中 */
|
---|
329 | error = E_OBJ;
|
---|
330 |
|
---|
331 | /* 通信端点をロックを解除する。*/
|
---|
332 | syscall(sig_sem(cep->semid_lock));
|
---|
333 | }
|
---|
334 | else if (cep->snd_tskid != TA_NULL) {
|
---|
335 |
|
---|
336 | /* 非ノンブロッキングコールでペンディング中 */
|
---|
337 | error = E_QOVR;
|
---|
338 |
|
---|
339 | /* 通信端点をロックを解除する。*/
|
---|
340 | syscall(sig_sem(cep->semid_lock));
|
---|
341 | }
|
---|
342 | else {
|
---|
343 |
|
---|
344 | /* 現在のタスク識別子を記録する。*/
|
---|
345 | get_tid(&(cep->snd_tskid));
|
---|
346 |
|
---|
347 | /* 通信端点をロックを解除する。*/
|
---|
348 | syscall(sig_sem(cep->semid_lock));
|
---|
349 |
|
---|
350 | /* パケットを送信する。*/
|
---|
351 | error = udp_send_data(cep, p_dstaddr, data, len, tmout);
|
---|
352 | }
|
---|
353 | }
|
---|
354 |
|
---|
355 | return error;
|
---|
356 | }
|
---|
357 |
|
---|
358 | #endif /* of #ifdef __udp_snd_dat */
|
---|
359 |
|
---|
360 | #ifdef __udp_rcv_dat
|
---|
361 |
|
---|
362 | /*
|
---|
363 | * udp_rcv_dat -- パケットの受信【標準機能】
|
---|
364 | */
|
---|
365 |
|
---|
366 | ER_UINT
|
---|
367 | UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
|
---|
368 | {
|
---|
369 | T_NET_BUF *input;
|
---|
370 | T_UDP_CEP *cep;
|
---|
371 | T_UDP_HDR *udph;
|
---|
372 | ER_UINT error;
|
---|
373 | uint_t ulen, uhoff;
|
---|
374 |
|
---|
375 | /* p_dstaddr または data が NULL か、len < 0 ならエラー */
|
---|
376 | if (p_dstaddr == NULL || data == NULL || len < 0)
|
---|
377 | return E_PAR;
|
---|
378 |
|
---|
379 | /* UDP 通信端点 ID をチェックする。*/
|
---|
380 | if (!VALID_UDP_CEPID(cepid))
|
---|
381 | return E_ID;
|
---|
382 |
|
---|
383 | /* UDP 通信端点を得る。*/
|
---|
384 | cep = GET_UDP_CEP(cepid);
|
---|
385 |
|
---|
386 | /* UDP 通信端点をチェックする。*/
|
---|
387 | if (!VALID_UDP_CEP(cep))
|
---|
388 | return E_NOEXS;
|
---|
389 |
|
---|
390 | /*
|
---|
391 | * タイムアウトをチェックする。
|
---|
392 | */
|
---|
393 |
|
---|
394 | if (tmout == TMO_NBLK) { /* ノンブロッキングコール */
|
---|
395 |
|
---|
396 | /* 通信端点をロックする。*/
|
---|
397 | syscall(wai_sem(cep->semid_lock));
|
---|
398 |
|
---|
399 | if (cep->rcv_p_dstaddr != NULL)
|
---|
400 |
|
---|
401 | /* ノンブロッキングコールでペンディング中 */
|
---|
402 | error = E_QOVR;
|
---|
403 |
|
---|
404 | else if (cep->rcv_tskid != TA_NULL)
|
---|
405 |
|
---|
406 | /* 非ノンブロッキングコールでペンディング中 */
|
---|
407 | error = E_OBJ;
|
---|
408 | else {
|
---|
409 | cep->rcv_p_dstaddr = p_dstaddr;
|
---|
410 | cep->rcv_data = data;
|
---|
411 | cep->rcv_len = len;
|
---|
412 | error = E_WBLK;
|
---|
413 | }
|
---|
414 |
|
---|
415 | /* 通信端点をロックを解除する。*/
|
---|
416 | syscall(sig_sem(cep->semid_lock));
|
---|
417 | return error;
|
---|
418 | }
|
---|
419 | else { /* 非ノンブロッキングコール */
|
---|
420 |
|
---|
421 | /* 通信端点をロックする。*/
|
---|
422 | syscall(wai_sem(cep->semid_lock));
|
---|
423 |
|
---|
424 | if (cep->rcv_p_dstaddr != NULL) {
|
---|
425 |
|
---|
426 | /* ノンブロッキングコールでペンディング中 */
|
---|
427 | error = E_OBJ;
|
---|
428 |
|
---|
429 | /* 通信端点をロックを解除する。*/
|
---|
430 | syscall(sig_sem(cep->semid_lock));
|
---|
431 | }
|
---|
432 | else if (cep->rcv_tskid != TA_NULL) {
|
---|
433 |
|
---|
434 | /* 非ノンブロッキングコールでペンディング中 */
|
---|
435 | error = E_QOVR;
|
---|
436 |
|
---|
437 | /* 通信端点をロックを解除する。*/
|
---|
438 | syscall(sig_sem(cep->semid_lock));
|
---|
439 | }
|
---|
440 | else {
|
---|
441 |
|
---|
442 | /* 現在のタスク識別子を記録する。*/
|
---|
443 | get_tid(&(cep->rcv_tskid));
|
---|
444 |
|
---|
445 | /* 通信端点をロックを解除する。*/
|
---|
446 | syscall(sig_sem(cep->semid_lock));
|
---|
447 |
|
---|
448 | /* 入力があるまで待つ。*/
|
---|
449 | if (cep->cb_netbuf != NULL) {
|
---|
450 |
|
---|
451 | /*
|
---|
452 | * ここにくる場合は、コールバック関数の中から
|
---|
453 | * udp_rcv_dat を呼び出していることになり、
|
---|
454 | * すでに入力済みである。
|
---|
455 | */
|
---|
456 | input = cep->cb_netbuf;
|
---|
457 | cep->cb_netbuf = NULL;
|
---|
458 | }
|
---|
459 | else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
|
---|
460 | cep->rcv_tskid = TA_NULL;
|
---|
461 | return error;
|
---|
462 | }
|
---|
463 |
|
---|
464 | /* p_dstaddr を設定する。*/
|
---|
465 | uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
|
---|
466 | udph = GET_UDP_HDR(input, uhoff);
|
---|
467 | p_dstaddr->portno = ntohs(udph->sport);
|
---|
468 | IN_COPY_TO_HOST(&p_dstaddr->ipaddr, &GET_IP_HDR(input)->src);
|
---|
469 |
|
---|
470 | /* データをバッファに移す。*/
|
---|
471 | ulen = ntohs(udph->ulen);
|
---|
472 | if (ulen - UDP_HDR_SIZE > len)
|
---|
473 | error = E_BOVR;
|
---|
474 | else {
|
---|
475 | len = (int_t)(ulen - UDP_HDR_SIZE);
|
---|
476 | error = (ER_UINT)(ulen - UDP_HDR_SIZE);
|
---|
477 | }
|
---|
478 |
|
---|
479 | memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
|
---|
480 |
|
---|
481 | syscall(rel_net_buf(input));
|
---|
482 |
|
---|
483 | cep->rcv_tskid = TA_NULL;
|
---|
484 | }
|
---|
485 | return error;
|
---|
486 | }
|
---|
487 | }
|
---|
488 |
|
---|
489 | #endif /* of #ifdef __udp_rcv_dat */
|
---|
490 |
|
---|
491 | #endif /* of #ifdef UDP_CFG_NON_BLOCKING */
|
---|
492 |
|
---|
493 | #endif /* of #ifdef SUPPORT_UDP */
|
---|