1 | /*
|
---|
2 | * TINET (UDP/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$
|
---|
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 ceproduce 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 | * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
|
---|
79 | * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.49.2.2 1999/08/29 16:29:58 peter Exp $
|
---|
80 | */
|
---|
81 |
|
---|
82 | #ifdef __udp_can_snd_nblk
|
---|
83 |
|
---|
84 | /*
|
---|
85 | * udp_can_snd -- ãã³ãã£ã³ã°ãã¦ããéä¿¡ã®ãã£ã³ã»ã«
|
---|
86 | */
|
---|
87 |
|
---|
88 | ER
|
---|
89 | UDP_CAN_SND (T_UDP_CEP *cep, ER error)
|
---|
90 | {
|
---|
91 | if (cep->snd_p_dstaddr != NULL) { /* ãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
92 | if (IS_PTR_DEFINED(cep->callback))
|
---|
93 |
|
---|
94 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
95 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
|
---|
96 | #else
|
---|
97 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
|
---|
98 | #endif
|
---|
99 | else
|
---|
100 | error = E_OBJ;
|
---|
101 | cep->snd_p_dstaddr = NULL;
|
---|
102 | }
|
---|
103 | else if (cep->snd_tskid != TA_NULL) { /* éãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
104 |
|
---|
105 | #ifdef UDP_CFG_EXTENTIONS
|
---|
106 |
|
---|
107 | /* å¾
|
---|
108 | ã¡ä¸ã«çºçããã¨ã©ã¼æ
|
---|
109 | å ±ãè¨å®ããã*/
|
---|
110 | cep->error = error;
|
---|
111 |
|
---|
112 | #endif /* of #ifdef UDP_CFG_EXTENTIONS */
|
---|
113 |
|
---|
114 | error = rel_wai(cep->snd_tskid);
|
---|
115 | cep->snd_tskid = TA_NULL;
|
---|
116 | }
|
---|
117 | else /* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
|
---|
118 | error = EV_NOPND;
|
---|
119 |
|
---|
120 | return error;
|
---|
121 | }
|
---|
122 |
|
---|
123 | #endif /* of #ifdef __udp_can_snd_nblk */
|
---|
124 |
|
---|
125 | #ifdef __udp_can_rcv_nblk
|
---|
126 |
|
---|
127 | /*
|
---|
128 | * udp_can_rcv -- ãã³ãã£ã³ã°ãã¦ããåä¿¡ã®ãã£ã³ã»ã«
|
---|
129 | */
|
---|
130 |
|
---|
131 | ER
|
---|
132 | UDP_CAN_RCV (T_UDP_CEP *cep, ER error)
|
---|
133 | {
|
---|
134 | if (cep->rcv_p_dstaddr != NULL) { /* ãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
135 | if (IS_PTR_DEFINED(cep->callback))
|
---|
136 |
|
---|
137 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
138 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_CAN_CEP, (void*)error);
|
---|
139 | #else
|
---|
140 | (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_CAN_CEP, (void*)&error);
|
---|
141 | #endif
|
---|
142 | else
|
---|
143 | error = E_OBJ;
|
---|
144 | cep->rcv_p_dstaddr = NULL;
|
---|
145 | }
|
---|
146 | else if (cep->rcv_tskid != TA_NULL) { /* éãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
147 |
|
---|
148 | #ifdef UDP_CFG_EXTENTIONS
|
---|
149 |
|
---|
150 | /* å¾
|
---|
151 | ã¡ä¸ã«çºçããã¨ã©ã¼æ
|
---|
152 | å ±ãè¨å®ããã*/
|
---|
153 | cep->error = error;
|
---|
154 |
|
---|
155 | #endif /* of #ifdef UDP_CFG_EXTENTIONS */
|
---|
156 |
|
---|
157 | error = rel_wai(cep->rcv_tskid);
|
---|
158 | cep->rcv_tskid = TA_NULL;
|
---|
159 | }
|
---|
160 | else /* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
|
---|
161 | error = EV_NOPND;
|
---|
162 |
|
---|
163 | return error;
|
---|
164 | }
|
---|
165 |
|
---|
166 | #endif /* of #ifdef __udp_can_rcv_nblk */
|
---|
167 |
|
---|
168 | #ifdef __udp_snd_dat_nblk
|
---|
169 |
|
---|
170 | /*
|
---|
171 | * udp_snd_dat -- ãã±ããã®éä¿¡ãæ¨æºæ©è½ã
|
---|
172 | */
|
---|
173 |
|
---|
174 | ER_UINT
|
---|
175 | UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
|
---|
176 | {
|
---|
177 | T_UDP_CEP *cep;
|
---|
178 | ER error;
|
---|
179 |
|
---|
180 | /* p_dstaddr ã¾ã㯠data ã NULL ãªãã¨ã©ã¼ */
|
---|
181 | if (p_dstaddr == NULL || data == NULL)
|
---|
182 | return E_PAR;
|
---|
183 |
|
---|
184 | /* ãã¼ã¿é·ããã§ãã¯ããã*/
|
---|
185 | if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
|
---|
186 | return E_PAR;
|
---|
187 |
|
---|
188 | #if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
|
---|
189 |
|
---|
190 | /*
|
---|
191 | * API ã IPv6 㧠IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
|
---|
192 | * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
|
---|
193 | */
|
---|
194 | if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
|
---|
195 | return E_PAR;
|
---|
196 |
|
---|
197 | #endif /* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
|
---|
198 |
|
---|
199 | /* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
|
---|
200 | if (!VALID_UDP_CEPID(cepid))
|
---|
201 | return E_ID;
|
---|
202 |
|
---|
203 | /* UDP é信端ç¹ãå¾ãã*/
|
---|
204 | cep = GET_UDP_CEP(cepid);
|
---|
205 |
|
---|
206 | /* UDP é信端ç¹ããã§ãã¯ããã*/
|
---|
207 | if (!VALID_UDP_CEP(cep))
|
---|
208 | return E_NOEXS;
|
---|
209 |
|
---|
210 | /*
|
---|
211 | * èªãã¼ãçªå·ã UDP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
|
---|
212 | */
|
---|
213 | if (cep->myaddr.portno == UDP_PORTANY) {
|
---|
214 | if ((error = UDP_ALLOC_AUTO_PORT(cep)) != E_OK)
|
---|
215 | return error;
|
---|
216 | }
|
---|
217 |
|
---|
218 | /*
|
---|
219 | * ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã
|
---|
220 | */
|
---|
221 | if (tmout == TMO_NBLK) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
222 |
|
---|
223 | /* é信端ç¹ãããã¯ããã*/
|
---|
224 | syscall(wai_sem(cep->semid_lock));
|
---|
225 |
|
---|
226 | if (cep->snd_p_dstaddr != NULL) {
|
---|
227 |
|
---|
228 | /* ãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
229 | error = E_QOVR;
|
---|
230 |
|
---|
231 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
232 | syscall(sig_sem(cep->semid_lock));
|
---|
233 | }
|
---|
234 | else if (cep->snd_tskid != TA_NULL) {
|
---|
235 |
|
---|
236 | /* éãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
237 | error = E_OBJ;
|
---|
238 |
|
---|
239 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
240 | syscall(sig_sem(cep->semid_lock));
|
---|
241 | }
|
---|
242 | else {
|
---|
243 |
|
---|
244 | cep->snd_p_dstaddr = p_dstaddr;
|
---|
245 | cep->snd_data = data;
|
---|
246 | cep->snd_len = len;
|
---|
247 |
|
---|
248 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
249 | syscall(sig_sem(cep->semid_lock));
|
---|
250 |
|
---|
251 | cep->flags |= UDP_CEP_FLG_POST_OUTPUT;
|
---|
252 | sig_sem(SEM_UDP_POST_OUTPUT);
|
---|
253 | error = E_WBLK;
|
---|
254 | }
|
---|
255 | }
|
---|
256 | else { /* éãã³ããããã³ã°ã³ã¼ã« */
|
---|
257 |
|
---|
258 | /* é信端ç¹ãããã¯ããã*/
|
---|
259 | syscall(wai_sem(cep->semid_lock));
|
---|
260 |
|
---|
261 | if (cep->snd_p_dstaddr != NULL) {
|
---|
262 |
|
---|
263 | /* ãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
264 | error = E_OBJ;
|
---|
265 |
|
---|
266 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
267 | syscall(sig_sem(cep->semid_lock));
|
---|
268 | }
|
---|
269 | else if (cep->snd_tskid != TA_NULL) {
|
---|
270 |
|
---|
271 | /* éãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
272 | error = E_QOVR;
|
---|
273 |
|
---|
274 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
275 | syscall(sig_sem(cep->semid_lock));
|
---|
276 | }
|
---|
277 | else {
|
---|
278 |
|
---|
279 | /* ç¾å¨ã®ã¿ã¹ã¯èå¥åãè¨é²ããã*/
|
---|
280 | get_tid(&(cep->snd_tskid));
|
---|
281 |
|
---|
282 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
283 | syscall(sig_sem(cep->semid_lock));
|
---|
284 |
|
---|
285 | /* ãã±ãããéä¿¡ããã*/
|
---|
286 | error = UDP_SEND_DATA(cep, p_dstaddr, data, len, tmout);
|
---|
287 | }
|
---|
288 | }
|
---|
289 |
|
---|
290 | return error;
|
---|
291 | }
|
---|
292 |
|
---|
293 | #endif /* of #ifdef __udp_snd_dat_nblk */
|
---|
294 |
|
---|
295 | #ifdef __udp_rcv_dat_nblk
|
---|
296 |
|
---|
297 | /*
|
---|
298 | * udp_rcv_dat -- ãã±ããã®åä¿¡ãæ¨æºæ©è½ã
|
---|
299 | */
|
---|
300 |
|
---|
301 | ER_UINT
|
---|
302 | UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
|
---|
303 | {
|
---|
304 | T_NET_BUF *input;
|
---|
305 | T_UDP_CEP *cep;
|
---|
306 | T_UDP_HDR *udph;
|
---|
307 | ER_UINT error;
|
---|
308 | uint_t ulen, uhoff;
|
---|
309 |
|
---|
310 | /* p_dstaddr ã¾ã㯠data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
|
---|
311 | if (p_dstaddr == NULL || data == NULL || len < 0)
|
---|
312 | return E_PAR;
|
---|
313 |
|
---|
314 | /* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
|
---|
315 | if (!VALID_UDP_CEPID(cepid))
|
---|
316 | return E_ID;
|
---|
317 |
|
---|
318 | /* UDP é信端ç¹ãå¾ãã*/
|
---|
319 | cep = GET_UDP_CEP(cepid);
|
---|
320 |
|
---|
321 | /* UDP é信端ç¹ããã§ãã¯ããã*/
|
---|
322 | if (!VALID_UDP_CEP(cep))
|
---|
323 | return E_NOEXS;
|
---|
324 |
|
---|
325 | /*
|
---|
326 | * ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã
|
---|
327 | */
|
---|
328 |
|
---|
329 | if (tmout == TMO_NBLK) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
330 |
|
---|
331 | /* é信端ç¹ãããã¯ããã*/
|
---|
332 | syscall(wai_sem(cep->semid_lock));
|
---|
333 |
|
---|
334 | if (cep->rcv_p_dstaddr != NULL)
|
---|
335 |
|
---|
336 | /* ãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
337 | error = E_QOVR;
|
---|
338 |
|
---|
339 | else if (cep->rcv_tskid != TA_NULL)
|
---|
340 |
|
---|
341 | /* éãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
342 | error = E_OBJ;
|
---|
343 | else {
|
---|
344 | cep->rcv_p_dstaddr = p_dstaddr;
|
---|
345 | cep->rcv_data = data;
|
---|
346 | cep->rcv_len = len;
|
---|
347 | error = E_WBLK;
|
---|
348 | }
|
---|
349 |
|
---|
350 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
351 | syscall(sig_sem(cep->semid_lock));
|
---|
352 | return error;
|
---|
353 | }
|
---|
354 | else { /* éãã³ããããã³ã°ã³ã¼ã« */
|
---|
355 |
|
---|
356 | /* é信端ç¹ãããã¯ããã*/
|
---|
357 | syscall(wai_sem(cep->semid_lock));
|
---|
358 |
|
---|
359 | if (cep->rcv_p_dstaddr != NULL) {
|
---|
360 |
|
---|
361 | /* ãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
362 | error = E_OBJ;
|
---|
363 |
|
---|
364 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
365 | syscall(sig_sem(cep->semid_lock));
|
---|
366 | }
|
---|
367 | else if (cep->rcv_tskid != TA_NULL) {
|
---|
368 |
|
---|
369 | /* éãã³ããããã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸ */
|
---|
370 | error = E_QOVR;
|
---|
371 |
|
---|
372 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
373 | syscall(sig_sem(cep->semid_lock));
|
---|
374 | }
|
---|
375 | else {
|
---|
376 |
|
---|
377 | /* ç¾å¨ã®ã¿ã¹ã¯èå¥åãè¨é²ããã*/
|
---|
378 | get_tid(&(cep->rcv_tskid));
|
---|
379 |
|
---|
380 | /* é信端ç¹ãããã¯ã解é¤ããã*/
|
---|
381 | syscall(sig_sem(cep->semid_lock));
|
---|
382 |
|
---|
383 | /* å
|
---|
384 | ¥åãããã¾ã§å¾
|
---|
385 | ã¤ã*/
|
---|
386 | if (cep->cb_netbuf != NULL) {
|
---|
387 |
|
---|
388 | /*
|
---|
389 | * ããã«ããå ´åã¯ãã³ã¼ã«ããã¯é¢æ°ã®ä¸ãã
|
---|
390 | * udp_rcv_dat ãå¼ã³åºãã¦ãããã¨ã«ãªãã
|
---|
391 | * ãã§ã«å
|
---|
392 | ¥åæ¸ã¿ã§ããã
|
---|
393 | */
|
---|
394 | input = cep->cb_netbuf;
|
---|
395 | cep->cb_netbuf = NULL;
|
---|
396 | }
|
---|
397 | else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
|
---|
398 | cep->rcv_tskid = TA_NULL;
|
---|
399 | return error;
|
---|
400 | }
|
---|
401 |
|
---|
402 | /* p_dstaddr ãè¨å®ããã*/
|
---|
403 | uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
|
---|
404 | udph = GET_UDP_HDR(input, uhoff);
|
---|
405 | p_dstaddr->portno = ntohs(udph->sport);
|
---|
406 | IN_COPY_TO_HOST(&p_dstaddr->ipaddr, input);
|
---|
407 |
|
---|
408 | /* ãã¼ã¿ããããã¡ã«ç§»ãã*/
|
---|
409 | ulen = ntohs(udph->ulen);
|
---|
410 | if (ulen - UDP_HDR_SIZE > len)
|
---|
411 | error = E_BOVR;
|
---|
412 | else {
|
---|
413 | len = (int_t)(ulen - UDP_HDR_SIZE);
|
---|
414 | error = (ER_UINT)(ulen - UDP_HDR_SIZE);
|
---|
415 | }
|
---|
416 |
|
---|
417 | memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
|
---|
418 |
|
---|
419 | syscall(rel_net_buf(input));
|
---|
420 |
|
---|
421 | cep->rcv_tskid = TA_NULL;
|
---|
422 | }
|
---|
423 | return error;
|
---|
424 | }
|
---|
425 | }
|
---|
426 |
|
---|
427 | #endif /* of #ifdef __udp_rcv_dat_nblk */
|
---|