[313] | 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: tcp_usrreq.c 313 2017-07-23 04:50:32Z coas-nagasima $
|
---|
| 44 | */
|
---|
| 45 |
|
---|
| 46 | /*
|
---|
| 47 | * Copyright (c) 1982, 1986, 1988, 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 | * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
|
---|
| 79 | * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.40.2.3 1999/08/29 16:29:57 peter Exp $
|
---|
| 80 | */
|
---|
| 81 |
|
---|
| 82 | #include <string.h>
|
---|
| 83 |
|
---|
| 84 | #ifdef TARGET_KERNEL_ASP
|
---|
| 85 |
|
---|
| 86 | #include <kernel.h>
|
---|
| 87 | #include <sil.h>
|
---|
| 88 | #include "kernel_cfg.h"
|
---|
| 89 | #include "tinet_cfg.h"
|
---|
| 90 |
|
---|
| 91 | #endif /* of #ifdef TARGET_KERNEL_ASP */
|
---|
| 92 |
|
---|
| 93 | #ifdef TARGET_KERNEL_JSP
|
---|
| 94 |
|
---|
| 95 | #include <s_services.h>
|
---|
| 96 | #include <t_services.h>
|
---|
| 97 | #include "kernel_id.h"
|
---|
| 98 | #include "tinet_id.h"
|
---|
| 99 |
|
---|
| 100 | #endif /* of #ifdef TARGET_KERNEL_JSP */
|
---|
| 101 |
|
---|
| 102 | #include <tinet_defs.h>
|
---|
| 103 | #include <tinet_config.h>
|
---|
| 104 |
|
---|
| 105 | #include <net/if.h>
|
---|
| 106 | #include <net/if_ppp.h>
|
---|
| 107 | #include <net/if_loop.h>
|
---|
| 108 | #include <net/ethernet.h>
|
---|
| 109 | #include <net/net.h>
|
---|
| 110 | #include <net/net_endian.h>
|
---|
| 111 | #include <net/net_var.h>
|
---|
| 112 | #include <net/net_buf.h>
|
---|
| 113 | #include <net/net_timer.h>
|
---|
| 114 | #include <net/net_count.h>
|
---|
| 115 |
|
---|
| 116 | #include <netinet/in.h>
|
---|
| 117 | #include <netinet/in_var.h>
|
---|
| 118 | #include <netinet/in_itron.h>
|
---|
| 119 | #include <netinet/ip.h>
|
---|
| 120 | #include <netinet/ip_var.h>
|
---|
| 121 | #include <netinet/tcp.h>
|
---|
| 122 | #include <netinet/tcp_var.h>
|
---|
| 123 | #include <netinet/tcp_fsm.h>
|
---|
| 124 | #include <netinet/tcp_seq.h>
|
---|
| 125 | #include <netinet/tcp_timer.h>
|
---|
| 126 |
|
---|
| 127 | #include <net/if_var.h>
|
---|
| 128 |
|
---|
| 129 | #ifdef SUPPORT_TCP
|
---|
| 130 |
|
---|
| 131 | /*
|
---|
| 132 | * TINET ãã©ã¤ãã©ãªåããªãå ´åã¯ãå
|
---|
| 133 | ¨ã¦ã®æ©è½ã
|
---|
| 134 | * ãªãã¸ã§ã¯ããã¡ã¤ã«ã«åºåããããããã¯ããæå¹ã«ããã
|
---|
| 135 | */
|
---|
| 136 |
|
---|
| 137 | #ifndef TCP_CFG_LIBRARY
|
---|
| 138 |
|
---|
| 139 | #define __tcp_cre_rep
|
---|
| 140 | #define __tcp_del_rep
|
---|
| 141 | #define __tcp_cre_cep
|
---|
| 142 | #define __tcp_del_cep
|
---|
| 143 | #define __tcp_acp_cep
|
---|
| 144 | #define __tcp_con_cep
|
---|
| 145 | #define __tcp_sht_cep
|
---|
| 146 | #define __tcp_cls_cep
|
---|
| 147 | #define __tcp_snd_dat
|
---|
| 148 | #define __tcp_rcv_dat
|
---|
| 149 | #define __tcp_snd_oob
|
---|
| 150 | #define __tcp_rcv_oob
|
---|
| 151 | #define __tcp_get_buf
|
---|
| 152 | #define __tcp_snd_buf
|
---|
| 153 | #define __tcp_rcv_buf
|
---|
| 154 | #define __tcp_rel_buf
|
---|
| 155 | #define __tcp_can_cep
|
---|
| 156 | #define __tcp_set_opt
|
---|
| 157 | #define __tcp_get_opt
|
---|
| 158 |
|
---|
| 159 | #endif /* of #ifndef TCP_CFG_LIBRARY */
|
---|
| 160 |
|
---|
| 161 | /*
|
---|
| 162 | * IPv6 㨠IPv4 ã§å¼æ°ãç°ãªãé¢æ°ã®ã³ã³ãã¤ã«
|
---|
| 163 | */
|
---|
| 164 |
|
---|
| 165 | #if defined(SUPPORT_INET6)
|
---|
| 166 |
|
---|
| 167 | #define T_IPEP T_IPV6EP
|
---|
| 168 | #define TCP_ACP_CEP tcp6_acp_cep
|
---|
| 169 | #define TCP_CON_CEP tcp6_con_cep
|
---|
| 170 | #define TCP_FIND_CEP_REP tcp6_find_cep_rep
|
---|
| 171 |
|
---|
| 172 | #if defined(SUPPORT_INET4)
|
---|
| 173 |
|
---|
| 174 | #undef T_TCP_REP
|
---|
| 175 | #define T_TCP_REP T_TCP6_REP
|
---|
| 176 |
|
---|
| 177 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
| 178 |
|
---|
| 179 | #define TCP_CRE_REP tcp6_cre_rep
|
---|
| 180 | #define TCP_DEL_REP_BODY tcp6_del_rep_body
|
---|
| 181 | #define GET_TCP_REP GET_TCP6_REP
|
---|
| 182 | #define VALID_TCP_REPID VALID_TCP6_REPID
|
---|
| 183 | #define T_TCPN_CREP T_TCP6_CREP
|
---|
| 184 | #define API_PROTO API_PROTO_IPV6
|
---|
| 185 |
|
---|
| 186 | #include <netinet/tcpn_usrreq.c>
|
---|
| 187 |
|
---|
| 188 | #undef T_IPEP
|
---|
| 189 | #undef TCP_ACP_CEP
|
---|
| 190 | #undef TCP_CON_CEP
|
---|
| 191 | #undef TCP_FIND_CEP_REP
|
---|
| 192 |
|
---|
| 193 | #undef TCP_CRE_REP
|
---|
| 194 | #undef TCP_DEL_REP_BODY
|
---|
| 195 | #undef GET_TCP_REP
|
---|
| 196 | #undef VALID_TCP_REPID
|
---|
| 197 | #undef T_TCPN_CREP
|
---|
| 198 | #undef API_PROTO
|
---|
| 199 |
|
---|
| 200 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
| 201 |
|
---|
| 202 | #if defined(SUPPORT_INET4)
|
---|
| 203 |
|
---|
| 204 | #define T_IPEP T_IPV4EP
|
---|
| 205 | #define TCP_ACP_CEP tcp_acp_cep
|
---|
| 206 | #define TCP_CON_CEP tcp_con_cep
|
---|
| 207 | #define TCP_FIND_CEP_REP tcp4_find_cep_rep
|
---|
| 208 |
|
---|
| 209 | #if defined(SUPPORT_INET6)
|
---|
| 210 |
|
---|
| 211 | #undef T_TCP_REP
|
---|
| 212 | #define T_TCP_REP T_TCP4_REP
|
---|
| 213 |
|
---|
| 214 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
| 215 |
|
---|
| 216 | #define TCP_CRE_REP tcp_cre_rep
|
---|
| 217 | #define TCP_DEL_REP_BODY tcp4_del_rep_body
|
---|
| 218 | #define GET_TCP_REP GET_TCP4_REP
|
---|
| 219 | #define VALID_TCP_REPID VALID_TCP4_REPID
|
---|
| 220 | #define T_TCPN_CREP T_TCP_CREP
|
---|
| 221 | #define API_PROTO API_PROTO_IPV4
|
---|
| 222 |
|
---|
| 223 | #include <netinet/tcpn_usrreq.c>
|
---|
| 224 |
|
---|
| 225 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
| 226 |
|
---|
| 227 | #ifdef __tcp_cls_cep
|
---|
| 228 |
|
---|
| 229 | /*
|
---|
| 230 | * tcp_user_closed -- ã¦ã¼ã¶ããã®ã³ãã¯ã·ã§ã³ã®éæ¾
|
---|
| 231 | */
|
---|
| 232 |
|
---|
| 233 | T_TCP_CEP *
|
---|
| 234 | tcp_user_closed (T_TCP_CEP *cep)
|
---|
| 235 | {
|
---|
| 236 | switch (cep->fsm_state) {
|
---|
| 237 |
|
---|
| 238 | case TCP_FSM_CLOSED: /* ã¯ãã¼ãº */
|
---|
| 239 | case TCP_FSM_LISTEN: /* ååãªã¼ãã³ */
|
---|
| 240 | cep->fsm_state = TCP_FSM_CLOSED;
|
---|
| 241 | cep = tcp_close(cep);
|
---|
| 242 | break;
|
---|
| 243 |
|
---|
| 244 | case TCP_FSM_SYN_SENT: /* è½åãªã¼ãã³ãSYN éä¿¡æ¸ã¿ */
|
---|
| 245 | case TCP_FSM_SYN_RECVD: /* SYN ãåä¿¡ããSYN éä¿¡æ¸ã¿ */
|
---|
| 246 | cep->flags |= TCP_CEP_FLG_NEED_FIN;
|
---|
| 247 | break;
|
---|
| 248 |
|
---|
| 249 | case TCP_FSM_ESTABLISHED: /* ã³ãã¯ã·ã§ã³éè¨å®äº */
|
---|
| 250 | cep->fsm_state = TCP_FSM_FIN_WAIT_1;
|
---|
| 251 | break;
|
---|
| 252 |
|
---|
| 253 | case TCP_FSM_CLOSE_WAIT: /* ç¸æãã FIN åä¿¡ãAPP ã®çµäºå¾
|
---|
| 254 | ã¡ */
|
---|
| 255 | cep->fsm_state = TCP_FSM_LAST_ACK;
|
---|
| 256 | break;
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | if (cep != NULL && cep->fsm_state == TCP_FSM_FIN_WAIT_2)
|
---|
| 260 | cep->timer[TCP_TIM_2MSL] = TCP_TVAL_KEEP_COUNT * TCP_TVAL_KEEP_INTERVAL;
|
---|
| 261 | return cep;
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | /*
|
---|
| 265 | * tcp_cls_cep -- é信端ç¹ã®ã¯ãã¼ãºãæ¨æºæ©è½ã
|
---|
| 266 | */
|
---|
| 267 |
|
---|
| 268 | ER
|
---|
| 269 | tcp_cls_cep (ID cepid, TMO tmout)
|
---|
| 270 | {
|
---|
| 271 | T_TCP_CEP *cep;
|
---|
| 272 | ER error = E_OK;
|
---|
| 273 | FLGPTN flag;
|
---|
| 274 |
|
---|
| 275 | #ifndef TCP_CFG_NON_BLOCKING
|
---|
| 276 |
|
---|
| 277 | /* tmout ã TMO_NBLK ãªãã¨ã©ã¼ */
|
---|
| 278 | if (tmout == TMO_NBLK)
|
---|
| 279 | return E_PAR;
|
---|
| 280 |
|
---|
| 281 | #endif /* of #ifndef TCP_CFG_NON_BLOCKING */
|
---|
| 282 |
|
---|
| 283 | /*
|
---|
| 284 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 285 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 286 | */
|
---|
| 287 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_CLS_CEP)) != E_OK)
|
---|
| 288 | return error;
|
---|
| 289 |
|
---|
| 290 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 291 |
|
---|
| 292 | /* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
|
---|
| 293 | if (tmout == TMO_NBLK) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 294 |
|
---|
| 295 | if (!IS_PTR_DEFINED(cep->callback))
|
---|
| 296 | error = E_OBJ;
|
---|
| 297 | else if (cep->fsm_state == TCP_FSM_CLOSED) { /* ãã§ã«ã¯ãã¼ãºããã¦ããã¨ã */
|
---|
| 298 |
|
---|
| 299 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
| 300 |
|
---|
| 301 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_CLS_CEP, E_OK);
|
---|
| 302 | error = E_WBLK;
|
---|
| 303 |
|
---|
| 304 | #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
| 305 |
|
---|
| 306 | ER error = E_OK;
|
---|
| 307 |
|
---|
| 308 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_CLS_CEP, (void*)&error);
|
---|
| 309 | error = E_WBLK;
|
---|
| 310 |
|
---|
| 311 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
| 312 |
|
---|
| 313 | }
|
---|
| 314 | else {
|
---|
| 315 | /* NBLK ã®API æ©è½ã³ã¼ããè¨å®ããã*/
|
---|
| 316 | cep->rcv_nblk_tfn = TFN_TCP_CLS_CEP;
|
---|
| 317 |
|
---|
| 318 | if ((cep = tcp_user_closed(cep)) != NULL) { /* ã³ãã¯ã·ã§ã³ãåæããã*/
|
---|
| 319 | /* åæã»ã°ã¡ã³ãåºåããã¹ãããã*/
|
---|
| 320 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 321 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | /* cep ã NULL ã§æ»ã£ã¦ããå ´åã¯ã
|
---|
| 325 | * æ¢ã«ã³ãã¯ã·ã§ã³ãåæããã¦ãããã¨ãæå³ãã¦ããã
|
---|
| 326 | * ã¾ãããã®å ´åã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºããã¦ããã
|
---|
| 327 | */
|
---|
| 328 | return E_WBLK;
|
---|
| 329 | }
|
---|
| 330 | }
|
---|
| 331 | else { /* éãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 332 |
|
---|
| 333 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 334 |
|
---|
| 335 | if ((cep = tcp_user_closed(cep)) == NULL) { /* ã³ãã¯ã·ã§ã³ãåæããã*/
|
---|
| 336 |
|
---|
| 337 | /* cep ã NULL ã§æ»ã£ã¦ããå ´åã¯ã
|
---|
| 338 | * æ¢ã«ã³ãã¯ã·ã§ã³ãåæããã¦ãããã¨ãæå³ãã¦ããã
|
---|
| 339 | */
|
---|
| 340 | return error;
|
---|
| 341 | }
|
---|
| 342 | else {
|
---|
| 343 | /* åæã»ã°ã¡ã³ãåºåããã¹ãããã*/
|
---|
| 344 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 345 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 346 |
|
---|
| 347 | /* ã¤ãã³ããã©ã°ã CLOSED ã«ãªãã¾ã§å¾
|
---|
| 348 | ã¤ã*/
|
---|
| 349 | error = twai_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED, TWF_ORW, &flag, tmout);
|
---|
| 350 | if (error == E_OK && cep->error != E_OK)
|
---|
| 351 | error = cep->error;
|
---|
| 352 |
|
---|
| 353 | if (error != E_OK) {
|
---|
| 354 | if (error == E_RLWAI) {
|
---|
| 355 | /* tcp_cls_cep ããã£ã³ã»ã«ãããã¨ãã¯ãRST ãéä¿¡ããã*/
|
---|
| 356 | tcp_respond(NULL, cep, cep->rcv_nxt, cep->snd_una - 1,
|
---|
| 357 | cep->rbufsz - cep->rwbuf_count, TCP_FLG_RST);
|
---|
| 358 | }
|
---|
| 359 |
|
---|
| 360 | /* ã¿ã¤ãã¼ãåæ¢ããã*/
|
---|
| 361 | tcp_cancel_timers(cep);
|
---|
| 362 |
|
---|
| 363 | /*
|
---|
| 364 | * é信端ç¹ãããã¯ãã
|
---|
| 365 | * åä¿¡åæ§æãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã
|
---|
| 366 | */
|
---|
| 367 | syscall(wai_sem(cep->semid_lock));
|
---|
| 368 | tcp_free_reassq(cep);
|
---|
| 369 | syscall(sig_sem(cep->semid_lock));
|
---|
| 370 |
|
---|
| 371 | /* ç¶æ
|
---|
| 372 | ãæªä½¿ç¨ã«ããã*/
|
---|
| 373 | cep->fsm_state = TCP_FSM_CLOSED;
|
---|
| 374 |
|
---|
| 375 | /*
|
---|
| 376 | * 以ä¸ã«é¢ä¿ããªããã©ã°ãã¯ãªã¢ã¼ããã
|
---|
| 377 | * ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
|
---|
| 378 | * ã»åçãªé信端ç¹ã®çæã»åé¤æ©è½
|
---|
| 379 | */
|
---|
| 380 | cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
|
---|
| 381 |
|
---|
| 382 | /*
|
---|
| 383 | * é信端ç¹ãããã¯ãã
|
---|
| 384 | * éåä¿¡ã¦ã£ã³ããããã¡ãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã
|
---|
| 385 | */
|
---|
| 386 | cep->rwbuf_count = 0;
|
---|
| 387 | syscall(wai_sem(cep->semid_lock));
|
---|
| 388 | TCP_FREE_RWBUFQ(cep);
|
---|
| 389 | TCP_FREE_SWBUFQ(cep);
|
---|
| 390 | syscall(sig_sem(cep->semid_lock));
|
---|
| 391 |
|
---|
| 392 | syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
|
---|
| 393 | }
|
---|
| 394 | }
|
---|
| 395 |
|
---|
| 396 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 397 |
|
---|
| 398 | }
|
---|
| 399 |
|
---|
| 400 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 401 |
|
---|
| 402 | cep->rcv_tskid = TA_NULL;
|
---|
| 403 | cep->rcv_tfn = TFN_TCP_UNDEF;
|
---|
| 404 | return error;
|
---|
| 405 | }
|
---|
| 406 |
|
---|
| 407 | #endif /* of #ifdef __tcp_cls_cep */
|
---|
| 408 |
|
---|
| 409 | #ifdef __tcp_sht_cep
|
---|
| 410 |
|
---|
| 411 | /*
|
---|
| 412 | * tcp_sht_cep -- ãã¼ã¿éä¿¡ã®çµäºãæ¨æºæ©è½ã
|
---|
| 413 | */
|
---|
| 414 |
|
---|
| 415 | ER
|
---|
| 416 | tcp_sht_cep (ID cepid)
|
---|
| 417 | {
|
---|
| 418 | T_TCP_CEP *cep;
|
---|
| 419 | ER error = E_OK;
|
---|
| 420 |
|
---|
| 421 | /*
|
---|
| 422 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 423 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 424 | */
|
---|
| 425 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SHT_CEP)) != E_OK)
|
---|
| 426 | return error;
|
---|
| 427 |
|
---|
| 428 | /* TCP é信端ç¹ã®ã³ãã¯ã·ã§ã³ã確ç«ç¶æ
|
---|
| 429 | ã§ãªããã°ã¨ã©ã¼ */
|
---|
| 430 | if (!TCP_FSM_HAVE_ESTABLISHED(cep->fsm_state)) {
|
---|
| 431 | if ((error = cep->error) == E_OK)
|
---|
| 432 | error = E_OBJ;
|
---|
| 433 | }
|
---|
| 434 |
|
---|
| 435 | else if ((cep = tcp_user_closed(cep)) != NULL) { /* ã³ãã¯ã·ã§ã³ãåæããã*/
|
---|
| 436 |
|
---|
| 437 | /* åæã»ã°ã¡ã³ãåºåããã¹ãããã*/
|
---|
| 438 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 439 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | cep->snd_tskid = TA_NULL;
|
---|
| 443 | cep->snd_tfn = TFN_TCP_UNDEF;
|
---|
| 444 | return error;
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 | #endif /* of #ifdef __tcp_sht_cep */
|
---|
| 448 |
|
---|
| 449 | #ifdef __tcp_snd_dat
|
---|
| 450 |
|
---|
| 451 | /*
|
---|
| 452 | * tcp_snd_dat -- ãã±ããã®éä¿¡ãæ¨æºæ©è½ã
|
---|
| 453 | */
|
---|
| 454 |
|
---|
| 455 | ER_UINT
|
---|
| 456 | tcp_snd_dat (ID cepid, void *data, int_t len, TMO tmout)
|
---|
| 457 | {
|
---|
| 458 | T_TCP_CEP *cep;
|
---|
| 459 | ER_UINT error;
|
---|
| 460 |
|
---|
| 461 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 462 |
|
---|
| 463 | /* data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
|
---|
| 464 | if (data == NULL || len < 0)
|
---|
| 465 | return E_PAR;
|
---|
| 466 |
|
---|
| 467 | #else /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 468 |
|
---|
| 469 | /* data ã NULLãlen < 0 ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
|
---|
| 470 | if (data == NULL || len < 0 || tmout == TMO_NBLK)
|
---|
| 471 | return E_PAR;
|
---|
| 472 |
|
---|
| 473 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 474 |
|
---|
| 475 | /*
|
---|
| 476 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 477 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 478 | */
|
---|
| 479 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_DAT)) != E_OK)
|
---|
| 480 | return error;
|
---|
| 481 |
|
---|
| 482 | /* éä¿¡ã§ããããé信端ç¹ã®ç¶æ
|
---|
| 483 | ãè¦ãã*/
|
---|
| 484 | if ((error = tcp_can_send_more(cep, TFN_TCP_SND_DAT, tmout)) != E_OK)
|
---|
| 485 | goto err_ret;
|
---|
| 486 |
|
---|
| 487 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 488 |
|
---|
| 489 | /* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
|
---|
| 490 | if (tmout == TMO_NBLK) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 491 |
|
---|
| 492 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 493 | if (!TCP_IS_SWBUF_FULL(cep)) {
|
---|
| 494 |
|
---|
| 495 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
|
---|
| 496 | error = TCP_WRITE_SWBUF(cep, data, (uint_t)len);
|
---|
| 497 |
|
---|
| 498 | /* åºåããã¹ãããã*/
|
---|
| 499 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 500 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 501 |
|
---|
| 502 | /* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 503 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
| 504 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_DAT, (void*)error);
|
---|
| 505 | #else
|
---|
| 506 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_DAT, (void*)&error);
|
---|
| 507 | #endif
|
---|
| 508 | error = E_WBLK;
|
---|
| 509 | goto err_ret;
|
---|
| 510 | }
|
---|
| 511 | else {
|
---|
| 512 | cep->snd_data = data;
|
---|
| 513 | cep->snd_len = len;
|
---|
| 514 | cep->snd_nblk_tfn = TFN_TCP_SND_DAT;
|
---|
| 515 | TCP_ALLOC_SWBUF(cep);
|
---|
| 516 |
|
---|
| 517 | return E_WBLK;
|
---|
| 518 | }
|
---|
| 519 | }
|
---|
| 520 | else { /* éãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 521 |
|
---|
| 522 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 523 |
|
---|
| 524 | /* éä¿¡ã¦ã£ã³ããããã¡ã空ãã®ãå¾
|
---|
| 525 | ã¤ã*/
|
---|
| 526 | if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
|
---|
| 527 | goto err_ret;
|
---|
| 528 |
|
---|
| 529 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
|
---|
| 530 | if ((error = TCP_WRITE_SWBUF(cep, data, (uint_t)len)) > 0) {
|
---|
| 531 |
|
---|
| 532 | /* ãã¼ã¿ãéä¿¡ãããéä¿¡ã¦ã£ã³ããããã¡ããã«ã®ã¨ãã¯å¼·å¶çã«éä¿¡ããã*/
|
---|
| 533 | if (TCP_IS_SWBUF_FULL(cep))
|
---|
| 534 | cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
|
---|
| 535 |
|
---|
| 536 | /* åºåããã¹ãããã*/
|
---|
| 537 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 538 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 539 | }
|
---|
| 540 |
|
---|
| 541 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 542 |
|
---|
| 543 | }
|
---|
| 544 |
|
---|
| 545 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 546 |
|
---|
| 547 | err_ret:
|
---|
| 548 | cep->snd_tskid = TA_NULL;
|
---|
| 549 | cep->snd_tfn = TFN_TCP_UNDEF;
|
---|
| 550 | return error;
|
---|
| 551 | }
|
---|
| 552 |
|
---|
| 553 | #endif /* of #ifdef __tcp_snd_dat */
|
---|
| 554 |
|
---|
| 555 | #ifdef __tcp_get_buf
|
---|
| 556 |
|
---|
| 557 | /*
|
---|
| 558 | * tcp_get_buf -- éä¿¡ç¨ãããã¡ã®ç²å¾ãæ¨æºæ©è½ã
|
---|
| 559 | */
|
---|
| 560 |
|
---|
| 561 | ER_UINT
|
---|
| 562 | tcp_get_buf (ID cepid, void **p_buf, TMO tmout)
|
---|
| 563 | {
|
---|
| 564 | T_TCP_CEP *cep;
|
---|
| 565 | ER_UINT error;
|
---|
| 566 |
|
---|
| 567 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 568 |
|
---|
| 569 | /* p_buf ã NULL ãªãã¨ã©ã¼ */
|
---|
| 570 | if (p_buf == NULL)
|
---|
| 571 | return E_PAR;
|
---|
| 572 |
|
---|
| 573 | #else /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 574 |
|
---|
| 575 | /* p_buf ã NULL ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
|
---|
| 576 | if (p_buf == NULL || tmout == TMO_NBLK)
|
---|
| 577 | return E_PAR;
|
---|
| 578 |
|
---|
| 579 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 580 |
|
---|
| 581 | /*
|
---|
| 582 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 583 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 584 | */
|
---|
| 585 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_GET_BUF)) != E_OK)
|
---|
| 586 | return error;
|
---|
| 587 |
|
---|
| 588 | /* éä¿¡ã§ããããé信端ç¹ã®ç¶æ
|
---|
| 589 | ãè¦ãã*/
|
---|
| 590 | if ((error = tcp_can_send_more(cep, TFN_TCP_GET_BUF, tmout)) != E_OK)
|
---|
| 591 | goto err_ret;
|
---|
| 592 |
|
---|
| 593 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 594 |
|
---|
| 595 | /* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
|
---|
| 596 | if (tmout == TMO_NBLK) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 597 |
|
---|
| 598 | if (!TCP_IS_SWBUF_FULL(cep)) {
|
---|
| 599 |
|
---|
| 600 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 601 | error = TCP_GET_SWBUF_ADDR(cep, p_buf);
|
---|
| 602 |
|
---|
| 603 | /* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 604 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
| 605 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_GET_BUF, (void*)error);
|
---|
| 606 | #else
|
---|
| 607 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_GET_BUF, (void*)&error);
|
---|
| 608 | #endif
|
---|
| 609 | error = E_WBLK;
|
---|
| 610 | goto err_ret;
|
---|
| 611 | }
|
---|
| 612 | else {
|
---|
| 613 | cep->snd_p_buf = p_buf;
|
---|
| 614 | cep->snd_nblk_tfn = TFN_TCP_GET_BUF;
|
---|
| 615 | TCP_ALLOC_SWBUF(cep);
|
---|
| 616 | return E_WBLK;
|
---|
| 617 | }
|
---|
| 618 | }
|
---|
| 619 |
|
---|
| 620 | else { /* éãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 621 |
|
---|
| 622 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 623 |
|
---|
| 624 | /* éä¿¡ã¦ã£ã³ããããã¡ã空ãã®ãå¾
|
---|
| 625 | ã¤ã*/
|
---|
| 626 | if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
|
---|
| 627 | goto err_ret;
|
---|
| 628 |
|
---|
| 629 | /* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºã¢ãã¬ã¹ãç²å¾ããã*/
|
---|
| 630 | error = TCP_GET_SWBUF_ADDR(cep, p_buf);
|
---|
| 631 |
|
---|
| 632 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 633 |
|
---|
| 634 | }
|
---|
| 635 |
|
---|
| 636 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 637 |
|
---|
| 638 | err_ret:
|
---|
| 639 | cep->snd_tskid = TA_NULL;
|
---|
| 640 | cep->snd_tfn = TFN_TCP_UNDEF;
|
---|
| 641 | return error;
|
---|
| 642 | }
|
---|
| 643 |
|
---|
| 644 | #endif /* of #ifdef __tcp_get_buf */
|
---|
| 645 |
|
---|
| 646 | #ifdef __tcp_snd_buf
|
---|
| 647 |
|
---|
| 648 | /*
|
---|
| 649 | * tcp_snd_buf -- ãããã¡å
|
---|
| 650 | ã®ãã¼ã¿ã®éä¿¡ãæ¨æºæ©è½ã
|
---|
| 651 | */
|
---|
| 652 |
|
---|
| 653 | ER
|
---|
| 654 | tcp_snd_buf (ID cepid, int_t len)
|
---|
| 655 | {
|
---|
| 656 | T_TCP_CEP *cep;
|
---|
| 657 | ER error;
|
---|
| 658 |
|
---|
| 659 | /* éä¿¡ããé·ã len ããã§ãã¯ããã*/
|
---|
| 660 | if (len < 0)
|
---|
| 661 | return E_PAR;
|
---|
| 662 |
|
---|
| 663 | /* éä¿¡ããé·ãlen ã 0 ã§ããã°ãä½ãããªãã§æ»ãã*/
|
---|
| 664 | if (len == 0)
|
---|
| 665 | return E_OK;
|
---|
| 666 |
|
---|
| 667 | /*
|
---|
| 668 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 669 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 670 | */
|
---|
| 671 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_BUF)) != E_OK)
|
---|
| 672 | return error;
|
---|
| 673 |
|
---|
| 674 | /* éä¿¡ããé·ã len ããã§ãã¯ããã*/
|
---|
| 675 | if (len > cep->get_buf_len) {
|
---|
| 676 | error = E_OBJ;
|
---|
| 677 | goto err_ret;
|
---|
| 678 | }
|
---|
| 679 |
|
---|
| 680 | /* éä¿¡ã§ããããCEP ã® FSM ç¶æ
|
---|
| 681 | ãè¦ãã*/
|
---|
| 682 | if (!TCP_FSM_CAN_SEND_MORE(cep->fsm_state)) {
|
---|
| 683 | if ((error = cep->error) == E_OK)
|
---|
| 684 | error = E_OBJ;
|
---|
| 685 | goto err_ret;
|
---|
| 686 | }
|
---|
| 687 |
|
---|
| 688 | /* éä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿ãéä¿¡å¯è½ã«ããã*/
|
---|
| 689 | TCP_SEND_SWBUF(cep, (uint_t)len);
|
---|
| 690 |
|
---|
| 691 | /* åºåããã¹ãããã*/
|
---|
| 692 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 693 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 694 |
|
---|
| 695 | err_ret:
|
---|
| 696 | cep->snd_tskid = TA_NULL;
|
---|
| 697 | cep->snd_tfn = TFN_TCP_UNDEF;
|
---|
| 698 | return error;
|
---|
| 699 | }
|
---|
| 700 |
|
---|
| 701 | #endif /* of #ifdef __tcp_snd_buf */
|
---|
| 702 |
|
---|
| 703 | #ifdef __tcp_rcv_dat
|
---|
| 704 |
|
---|
| 705 | /*
|
---|
| 706 | * tcp_rcv_dat -- ãã±ããã®åä¿¡ãæ¨æºæ©è½ã
|
---|
| 707 | */
|
---|
| 708 |
|
---|
| 709 | ER_UINT
|
---|
| 710 | tcp_rcv_dat (ID cepid, void *data, int_t len, TMO tmout)
|
---|
| 711 | {
|
---|
| 712 | T_TCP_CEP *cep;
|
---|
| 713 | ER_UINT error;
|
---|
| 714 |
|
---|
| 715 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 716 |
|
---|
| 717 | /* data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
|
---|
| 718 | if (data == NULL || len < 0)
|
---|
| 719 | return E_PAR;
|
---|
| 720 |
|
---|
| 721 | #else /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 722 |
|
---|
| 723 | /* data ã NULLãlen < 0 ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
|
---|
| 724 | if (data == NULL || len < 0 || tmout == TMO_NBLK)
|
---|
| 725 | return E_PAR;
|
---|
| 726 |
|
---|
| 727 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 728 |
|
---|
| 729 | /*
|
---|
| 730 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 731 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 732 | */
|
---|
| 733 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_RCV_DAT)) != E_OK)
|
---|
| 734 | return error;
|
---|
| 735 |
|
---|
| 736 | /* åä¿¡ã§ããããé信端ç¹ã®ç¶æ
|
---|
| 737 | ãè¦ãã*/
|
---|
| 738 | if (tcp_can_recv_more(&error, cep, TFN_TCP_RCV_DAT, tmout) != E_OK)
|
---|
| 739 | goto err_ret;
|
---|
| 740 |
|
---|
| 741 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 742 |
|
---|
| 743 | /* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
|
---|
| 744 | if (tmout == TMO_NBLK) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 745 |
|
---|
| 746 | /* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 747 | if (cep->rwbuf_count > 0) {
|
---|
| 748 |
|
---|
| 749 | /* åä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãåãåºãã*/
|
---|
| 750 | len = TCP_READ_RWBUF(cep, data, (uint_t)len);
|
---|
| 751 |
|
---|
| 752 | /* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 753 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
| 754 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_DAT, (void*)(uint32_t)len);
|
---|
| 755 | #else
|
---|
| 756 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_DAT, (void*)&len);
|
---|
| 757 | #endif
|
---|
| 758 | error = E_WBLK;
|
---|
| 759 | goto err_ret;
|
---|
| 760 | }
|
---|
| 761 | else {
|
---|
| 762 | cep->rcv_data = data;
|
---|
| 763 | cep->rcv_len = len;
|
---|
| 764 | cep->rcv_nblk_tfn = TFN_TCP_RCV_DAT;
|
---|
| 765 | return E_WBLK;
|
---|
| 766 | }
|
---|
| 767 | }
|
---|
| 768 | else { /* éãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 769 |
|
---|
| 770 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 771 |
|
---|
| 772 | /* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ããªããã°ãå
|
---|
| 773 | ¥åãããã¾ã§å¾
|
---|
| 774 | ã¤ã*/
|
---|
| 775 | if ((error = tcp_wait_rwbuf(cep, tmout)) != E_OK)
|
---|
| 776 | goto err_ret;
|
---|
| 777 |
|
---|
| 778 | /* åä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãåãåºãã*/
|
---|
| 779 | error = TCP_READ_RWBUF(cep, data, (uint_t)len);
|
---|
| 780 |
|
---|
| 781 | /* ç¸æã«ã¦ã£ã³ãã¦ãµã¤ãºãå¤ãã£ããã¨ãç¥ãããããåºåããã¹ãããã*/
|
---|
| 782 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 783 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 784 |
|
---|
| 785 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 786 |
|
---|
| 787 | }
|
---|
| 788 |
|
---|
| 789 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 790 |
|
---|
| 791 | err_ret:
|
---|
| 792 | cep->rcv_tskid = TA_NULL;
|
---|
| 793 | cep->rcv_tfn = TFN_TCP_UNDEF;
|
---|
| 794 | return error;
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | #endif /* of #ifdef __tcp_rcv_dat */
|
---|
| 798 |
|
---|
| 799 | #ifdef __tcp_rcv_buf
|
---|
| 800 |
|
---|
| 801 | /*
|
---|
| 802 | * tcp_rcv_buf -- åä¿¡ãããã¼ã¿ã®å
|
---|
| 803 | ¥ã£ããããã¡ã®ç²å¾ãæ¨æºæ©è½ã
|
---|
| 804 | */
|
---|
| 805 |
|
---|
| 806 | ER_UINT
|
---|
| 807 | tcp_rcv_buf (ID cepid, void **p_buf, TMO tmout)
|
---|
| 808 | {
|
---|
| 809 | T_TCP_CEP *cep;
|
---|
| 810 | ER_UINT error;
|
---|
| 811 |
|
---|
| 812 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 813 |
|
---|
| 814 | /* p_buf ã NULL ãªãã¨ã©ã¼ */
|
---|
| 815 | if (p_buf == NULL)
|
---|
| 816 | return E_PAR;
|
---|
| 817 |
|
---|
| 818 | #else /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 819 |
|
---|
| 820 | /* p_buf ã NULL ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
|
---|
| 821 | if (p_buf == NULL || tmout == TMO_NBLK)
|
---|
| 822 | return E_PAR;
|
---|
| 823 |
|
---|
| 824 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 825 |
|
---|
| 826 | /*
|
---|
| 827 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 828 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 829 | */
|
---|
| 830 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_RCV_BUF)) != E_OK)
|
---|
| 831 | return error;
|
---|
| 832 |
|
---|
| 833 | /* åä¿¡ã§ããããé信端ç¹ã®ç¶æ
|
---|
| 834 | ãè¦ãã*/
|
---|
| 835 | if (tcp_can_recv_more(&error, cep, TFN_TCP_RCV_DAT, tmout) != E_OK)
|
---|
| 836 | goto err_ret;
|
---|
| 837 |
|
---|
| 838 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 839 |
|
---|
| 840 | /* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
|
---|
| 841 | if (tmout == TMO_NBLK) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 842 |
|
---|
| 843 | /* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 844 | if (cep->rwbuf_count > 0) {
|
---|
| 845 |
|
---|
| 846 | /* åä¿¡ã¦ã£ã³ããããã¡ã®ç©ºã¢ãã¬ã¹ãç²å¾ããã*/
|
---|
| 847 | error = TCP_GET_RWBUF_ADDR(cep, p_buf);
|
---|
| 848 |
|
---|
| 849 | /* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 850 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
| 851 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_BUF, (void*)error);
|
---|
| 852 | #else
|
---|
| 853 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_BUF, (void*)&error);
|
---|
| 854 | #endif
|
---|
| 855 | error = E_WBLK;
|
---|
| 856 | goto err_ret;
|
---|
| 857 | }
|
---|
| 858 | else {
|
---|
| 859 | cep->rcv_p_buf = p_buf;
|
---|
| 860 | cep->rcv_nblk_tfn = TFN_TCP_RCV_BUF;
|
---|
| 861 | return E_WBLK;
|
---|
| 862 | }
|
---|
| 863 | }
|
---|
| 864 | else { /* éãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 865 |
|
---|
| 866 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 867 |
|
---|
| 868 | /* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ããªããã°ãå
|
---|
| 869 | ¥åãããã¾ã§å¾
|
---|
| 870 | ã¤ã*/
|
---|
| 871 | if ((error = tcp_wait_rwbuf(cep, tmout)) != E_OK) {
|
---|
| 872 | cep->rwbuf_count = 0;
|
---|
| 873 | goto err_ret;
|
---|
| 874 | }
|
---|
| 875 |
|
---|
| 876 | /* åä¿¡ã¦ã£ã³ããããã¡ã®ã¢ãã¬ã¹ãç²å¾ããã*/
|
---|
| 877 | error = TCP_GET_RWBUF_ADDR(cep, p_buf);
|
---|
| 878 |
|
---|
| 879 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 880 |
|
---|
| 881 | }
|
---|
| 882 |
|
---|
| 883 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 884 |
|
---|
| 885 | err_ret:
|
---|
| 886 | cep->rcv_tskid = TA_NULL;
|
---|
| 887 | cep->rcv_tfn = TFN_TCP_UNDEF;
|
---|
| 888 | return error;
|
---|
| 889 | }
|
---|
| 890 |
|
---|
| 891 | #endif /* of #ifdef __tcp_rcv_buf */
|
---|
| 892 |
|
---|
| 893 | #ifdef __tcp_rel_buf
|
---|
| 894 |
|
---|
| 895 | /*
|
---|
| 896 | * tcp_rel_buf -- åä¿¡ç¨ãããã¡ã®è§£æ¾ãæ¨æºæ©è½ã
|
---|
| 897 | */
|
---|
| 898 |
|
---|
| 899 | ER
|
---|
| 900 | tcp_rel_buf (ID cepid, int_t len)
|
---|
| 901 | {
|
---|
| 902 | T_TCP_CEP *cep;
|
---|
| 903 | ER error;
|
---|
| 904 |
|
---|
| 905 | /* 解æ¾ããé·ã len ããã§ãã¯ããã*/
|
---|
| 906 | if (len < 0)
|
---|
| 907 | return E_PAR;
|
---|
| 908 |
|
---|
| 909 | /*
|
---|
| 910 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 911 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 912 | */
|
---|
| 913 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_REL_BUF)) != E_OK)
|
---|
| 914 | return error;
|
---|
| 915 |
|
---|
| 916 | /* 解æ¾ããé·ã len ããã§ãã¯ããã*/
|
---|
| 917 | if (len > cep->rcv_buf_len) {
|
---|
| 918 | error = E_OBJ;
|
---|
| 919 | goto err_ret;
|
---|
| 920 | }
|
---|
| 921 |
|
---|
| 922 | /* é信端ç¹ãããã¯ããã*/
|
---|
| 923 | syscall(wai_sem(cep->semid_lock));
|
---|
| 924 |
|
---|
| 925 | /* åä¿¡ã¦ã£ã³ããããã¡ããåä¿¡ãããªã¯ããããåé¤ããã*/
|
---|
| 926 | TCP_DROP_RWBUF(cep, (uint_t)len);
|
---|
| 927 |
|
---|
| 928 | /* tcp_rcv_buf ã®å²å½ã¦é·ããªã»ããããã*/
|
---|
| 929 | cep->rcv_buf_len = 0;
|
---|
| 930 |
|
---|
| 931 | /* é信端ç¹ã®ããã¯ã解é¤ããã*/
|
---|
| 932 | syscall(sig_sem(cep->semid_lock));
|
---|
| 933 |
|
---|
| 934 | /* ç¸æã«ã¦ã£ã³ãã¦ãµã¤ãºãå¤ãã£ããã¨ãç¥ãããããåºåããã¹ãããã*/
|
---|
| 935 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 936 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 937 |
|
---|
| 938 | err_ret:
|
---|
| 939 | cep->rcv_tskid = TA_NULL;
|
---|
| 940 | cep->rcv_tfn = TFN_TCP_UNDEF;
|
---|
| 941 | return error;
|
---|
| 942 | }
|
---|
| 943 |
|
---|
| 944 | #endif /* of #ifdef __tcp_rel_buf */
|
---|
| 945 |
|
---|
| 946 | #ifdef __tcp_can_cep
|
---|
| 947 |
|
---|
| 948 | /*
|
---|
| 949 | * tcp_can_snd -- ãã³ãã£ã³ã°ãã¦ããéä¿¡ã®ãã£ã³ã»ã«
|
---|
| 950 | */
|
---|
| 951 |
|
---|
| 952 | static ER
|
---|
| 953 | tcp_can_snd (T_TCP_CEP *cep, FN fncd)
|
---|
| 954 | {
|
---|
| 955 | ER error = E_OK;
|
---|
| 956 |
|
---|
| 957 | /* é信端ç¹ãããã¯ããã*/
|
---|
| 958 | syscall(wai_sem(cep->semid_lock));
|
---|
| 959 |
|
---|
| 960 | /*
|
---|
| 961 | * snd_tskid ã TA_NULL ãªãã
|
---|
| 962 | * ãã³ãã£ã³ã°ãã¦ããªãã®ã§ã¨ã©ã¼
|
---|
| 963 | */
|
---|
| 964 | if (cep->snd_tskid == TA_NULL)
|
---|
| 965 | error = EV_NOPND;
|
---|
| 966 |
|
---|
| 967 | /* ãã³ãã£ã³ã°ä¸ã® API æ©è½ã³ã¼ãã¨ä¸è´ããªããã°ã¨ã©ã¼ */
|
---|
| 968 | else if (fncd != TFN_TCP_ALL && fncd != cep->snd_tfn)
|
---|
| 969 | error = E_OBJ;
|
---|
| 970 |
|
---|
| 971 | /* å¦çããã£ã³ã»ã«ããã*/
|
---|
| 972 | else {
|
---|
| 973 |
|
---|
| 974 | /* åä¿¡åæ§æãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã*/
|
---|
| 975 | tcp_free_reassq(cep);
|
---|
| 976 |
|
---|
| 977 | /* åä¿¡ã¦ã£ã³ããããã¡ãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã*/
|
---|
| 978 | cep->rwbuf_count = 0;
|
---|
| 979 | TCP_FREE_RWBUFQ(cep);
|
---|
| 980 |
|
---|
| 981 | /* éä¿¡ã¦ã£ã³ããããã¡ãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã*/
|
---|
| 982 | TCP_FREE_SWBUFQ(cep);
|
---|
| 983 |
|
---|
| 984 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 985 |
|
---|
| 986 | if (cep->snd_nblk_tfn != TFN_TCP_UNDEF) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 987 |
|
---|
| 988 | switch (cep->snd_nblk_tfn) {
|
---|
| 989 |
|
---|
| 990 | case TFN_TCP_CON_CEP:
|
---|
| 991 | /*
|
---|
| 992 | * é信端ç¹ããåä»å£ã解æ¾ãã
|
---|
| 993 | * ã¤ãã³ããã©ã°ãã¯ãã¼ãºã«è¨å®ããã
|
---|
| 994 | */
|
---|
| 995 | cep->rep = NULL;
|
---|
| 996 |
|
---|
| 997 | #if defined(_IP6_CFG) && defined(_IP4_CFG)
|
---|
| 998 | cep->rep4 = NULL;
|
---|
| 999 | #endif
|
---|
| 1000 |
|
---|
| 1001 | cep->fsm_state = TCP_FSM_CLOSED;
|
---|
| 1002 | syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
|
---|
| 1003 | break;
|
---|
| 1004 |
|
---|
| 1005 | case TFN_TCP_SND_DAT:
|
---|
| 1006 | case TFN_TCP_GET_BUF:
|
---|
| 1007 | case TFN_TCP_SND_OOB:
|
---|
| 1008 | break;
|
---|
| 1009 | }
|
---|
| 1010 |
|
---|
| 1011 | if (IS_PTR_DEFINED(cep->callback)) {
|
---|
| 1012 |
|
---|
| 1013 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
| 1014 |
|
---|
| 1015 | (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)E_RLWAI);
|
---|
| 1016 |
|
---|
| 1017 | #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
| 1018 |
|
---|
| 1019 | ER error = E_RLWAI;
|
---|
| 1020 |
|
---|
| 1021 | (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
|
---|
| 1022 |
|
---|
| 1023 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
| 1024 |
|
---|
| 1025 | }
|
---|
| 1026 | else
|
---|
| 1027 | error = E_OBJ;
|
---|
| 1028 | cep->snd_nblk_tfn = TFN_TCP_UNDEF;
|
---|
| 1029 | }
|
---|
| 1030 | else
|
---|
| 1031 |
|
---|
| 1032 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 1033 |
|
---|
| 1034 | error = rel_wai(cep->snd_tskid);
|
---|
| 1035 |
|
---|
| 1036 | cep->snd_tskid = TA_NULL;
|
---|
| 1037 | cep->snd_tfn = TFN_TCP_UNDEF;
|
---|
| 1038 | }
|
---|
| 1039 |
|
---|
| 1040 | /* é信端ç¹ã®ããã¯ã解é¤ããã*/
|
---|
| 1041 | syscall(sig_sem(cep->semid_lock));
|
---|
| 1042 |
|
---|
| 1043 | return error;
|
---|
| 1044 | }
|
---|
| 1045 |
|
---|
| 1046 | /*
|
---|
| 1047 | * tcp_can_rcv -- ãã³ãã£ã³ã°ãã¦ããåä¿¡ã®ãã£ã³ã»ã«
|
---|
| 1048 | */
|
---|
| 1049 |
|
---|
| 1050 | static ER
|
---|
| 1051 | tcp_can_rcv (T_TCP_CEP *cep, FN fncd)
|
---|
| 1052 | {
|
---|
| 1053 | ER error = E_OK;
|
---|
| 1054 |
|
---|
| 1055 | /* é信端ç¹ãããã¯ããã*/
|
---|
| 1056 | syscall(wai_sem(cep->semid_lock));
|
---|
| 1057 |
|
---|
| 1058 | /*
|
---|
| 1059 | * rcv_tskid ã TA_NULL ãªãã
|
---|
| 1060 | * ãã³ãã£ã³ã°ãã¦ããªãã®ã§ã¨ã©ã¼
|
---|
| 1061 | */
|
---|
| 1062 | if (cep->rcv_tskid == TA_NULL)
|
---|
| 1063 | error = EV_NOPND;
|
---|
| 1064 |
|
---|
| 1065 | /* ãã³ãã£ã³ã°ä¸ã® API æ©è½ã³ã¼ãã¨ä¸è´ããªããã°ã¨ã©ã¼ */
|
---|
| 1066 | else if (fncd != TFN_TCP_ALL && fncd != cep->rcv_tfn)
|
---|
| 1067 | error = E_OBJ;
|
---|
| 1068 |
|
---|
| 1069 | /* å¦çããã£ã³ã»ã«ããã*/
|
---|
| 1070 | else {
|
---|
| 1071 |
|
---|
| 1072 | /* åä¿¡åæ§æãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã*/
|
---|
| 1073 | tcp_free_reassq(cep);
|
---|
| 1074 |
|
---|
| 1075 | /* åä¿¡ã¦ã£ã³ããããã¡ãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã*/
|
---|
| 1076 | cep->rwbuf_count = 0;
|
---|
| 1077 | TCP_FREE_RWBUFQ(cep);
|
---|
| 1078 |
|
---|
| 1079 | /* éä¿¡ã¦ã£ã³ããããã¡ãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã*/
|
---|
| 1080 | TCP_FREE_SWBUFQ(cep);
|
---|
| 1081 |
|
---|
| 1082 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 1083 |
|
---|
| 1084 | if (cep->rcv_nblk_tfn != TFN_TCP_UNDEF) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 1085 |
|
---|
| 1086 | switch (cep->rcv_nblk_tfn) {
|
---|
| 1087 |
|
---|
| 1088 | case TFN_TCP_ACP_CEP:
|
---|
| 1089 | /*
|
---|
| 1090 | * é信端ç¹ããåä»å£ã解æ¾ãã
|
---|
| 1091 | * ã¤ãã³ããã©ã°ãã¯ãã¼ãºã«è¨å®ããã
|
---|
| 1092 | */
|
---|
| 1093 | cep->rep = NULL;
|
---|
| 1094 |
|
---|
| 1095 | #if defined(_IP6_CFG) && defined(_IP4_CFG)
|
---|
| 1096 | cep->rep4 = NULL;
|
---|
| 1097 | #endif
|
---|
| 1098 |
|
---|
| 1099 | cep->fsm_state = TCP_FSM_CLOSED;
|
---|
| 1100 | syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
|
---|
| 1101 | break;
|
---|
| 1102 |
|
---|
| 1103 | case TFN_TCP_RCV_DAT:
|
---|
| 1104 | case TFN_TCP_RCV_BUF:
|
---|
| 1105 | break;
|
---|
| 1106 |
|
---|
| 1107 | case TFN_TCP_CLS_CEP:
|
---|
| 1108 | cep->fsm_state = TCP_FSM_CLOSED;
|
---|
| 1109 | tcp_respond(NULL, cep, cep->rcv_nxt, cep->snd_una - 1,
|
---|
| 1110 | cep->rbufsz - cep->rwbuf_count, TCP_FLG_RST);
|
---|
| 1111 | syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
|
---|
| 1112 | break;
|
---|
| 1113 | }
|
---|
| 1114 |
|
---|
| 1115 | if (IS_PTR_DEFINED(cep->callback)) {
|
---|
| 1116 |
|
---|
| 1117 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
| 1118 |
|
---|
| 1119 | (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_RLWAI);
|
---|
| 1120 |
|
---|
| 1121 | #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
| 1122 |
|
---|
| 1123 | ER error = E_RLWAI;
|
---|
| 1124 |
|
---|
| 1125 | (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&error);
|
---|
| 1126 |
|
---|
| 1127 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
|
---|
| 1128 |
|
---|
| 1129 | }
|
---|
| 1130 | else
|
---|
| 1131 | error = E_OBJ;
|
---|
| 1132 | cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
|
---|
| 1133 | }
|
---|
| 1134 | else
|
---|
| 1135 |
|
---|
| 1136 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 1137 |
|
---|
| 1138 | error = rel_wai(cep->rcv_tskid);
|
---|
| 1139 |
|
---|
| 1140 | cep->rcv_tskid = TA_NULL;
|
---|
| 1141 | cep->rcv_tfn = TFN_TCP_UNDEF;
|
---|
| 1142 | }
|
---|
| 1143 |
|
---|
| 1144 | /* é信端ç¹ã®ããã¯ã解é¤ããã*/
|
---|
| 1145 | syscall(sig_sem(cep->semid_lock));
|
---|
| 1146 |
|
---|
| 1147 | return error;
|
---|
| 1148 | }
|
---|
| 1149 |
|
---|
| 1150 | /*
|
---|
| 1151 | * tcp_can_cep -- ãã³ãã£ã³ã°ãã¦ããå¦çã®ãã£ã³ã»ã«ãæ¨æºæ©è½ã
|
---|
| 1152 | */
|
---|
| 1153 |
|
---|
| 1154 | ER
|
---|
| 1155 | tcp_can_cep (ID cepid, FN fncd)
|
---|
| 1156 | {
|
---|
| 1157 | T_TCP_CEP *cep;
|
---|
| 1158 | ER error = E_OK, snd_err, rcv_err;
|
---|
| 1159 |
|
---|
| 1160 | /* API æ©è½ã³ã¼ãããã§ãã¯ããã*/
|
---|
| 1161 | if (!VALID_TFN_TCP_CAN(fncd))
|
---|
| 1162 | return E_PAR;
|
---|
| 1163 |
|
---|
| 1164 | /* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
|
---|
| 1165 | if (!VALID_TCP_CEPID(cepid))
|
---|
| 1166 | return E_ID;
|
---|
| 1167 |
|
---|
| 1168 | /* TCP é信端ç¹ãå¾ãã*/
|
---|
| 1169 | cep = GET_TCP_CEP(cepid);
|
---|
| 1170 |
|
---|
| 1171 | /* TCP é信端ç¹ããã§ãã¯ããã*/
|
---|
| 1172 | if (!VALID_TCP_CEP(cep))
|
---|
| 1173 | return E_NOEXS;
|
---|
| 1174 |
|
---|
| 1175 | if (fncd == TFN_TCP_ALL) { /* TFN_TCP_ALL ã®å¦ç */
|
---|
| 1176 | snd_err = tcp_can_snd(cep, fncd);
|
---|
| 1177 | rcv_err = tcp_can_rcv(cep, fncd);
|
---|
| 1178 |
|
---|
| 1179 | /*
|
---|
| 1180 | * snd_err 㨠rcv_err ã®ã©ã¡ãã EV_NOPND
|
---|
| 1181 | * ãªãããã³ãã£ã³ã°ãã¦ããªãã®ã§ã¨ã©ã¼
|
---|
| 1182 | */
|
---|
| 1183 | if (snd_err == EV_NOPND && rcv_err == EV_NOPND)
|
---|
| 1184 | error = E_OBJ;
|
---|
| 1185 | else {
|
---|
| 1186 | if (snd_err == EV_NOPND)
|
---|
| 1187 | snd_err = E_OK;
|
---|
| 1188 | if (rcv_err == EV_NOPND)
|
---|
| 1189 | rcv_err = E_OK;
|
---|
| 1190 |
|
---|
| 1191 | if (snd_err != E_OK)
|
---|
| 1192 | error = snd_err;
|
---|
| 1193 | else if (rcv_err != E_OK)
|
---|
| 1194 | error = rcv_err;
|
---|
| 1195 | }
|
---|
| 1196 | }
|
---|
| 1197 |
|
---|
| 1198 | else if (IS_TFN_TCP_RCV(fncd)) { /* åä¿¡å¦çã®ãã£ã³ã»ã« */
|
---|
| 1199 | if ((error = tcp_can_rcv(cep, fncd)) == EV_NOPND)
|
---|
| 1200 | error = E_OBJ;
|
---|
| 1201 | }
|
---|
| 1202 |
|
---|
| 1203 | else { /* éä¿¡å¦çã®ãã£ã³ã»ã« */
|
---|
| 1204 | if ((error = tcp_can_snd(cep, fncd)) == EV_NOPND)
|
---|
| 1205 | error = E_OBJ;
|
---|
| 1206 | }
|
---|
| 1207 |
|
---|
| 1208 | return error;
|
---|
| 1209 | }
|
---|
| 1210 |
|
---|
| 1211 | #endif /* of #ifdef __tcp_can_cep */
|
---|
| 1212 |
|
---|
| 1213 | #ifdef TCP_CFG_EXTENTIONS
|
---|
| 1214 |
|
---|
| 1215 | #ifdef __tcp_cre_cep
|
---|
| 1216 |
|
---|
| 1217 | /*
|
---|
| 1218 | * tcp_cre_cep -- TCP é信端ç¹ã®çæãæ¡å¼µæ©è½ã
|
---|
| 1219 | */
|
---|
| 1220 |
|
---|
| 1221 | ER
|
---|
| 1222 | tcp_cre_cep (ID cepid, T_TCP_CCEP *pk_ccep)
|
---|
| 1223 | {
|
---|
| 1224 | T_TCP_CEP *cep;
|
---|
| 1225 | ER error;
|
---|
| 1226 |
|
---|
| 1227 | /* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
|
---|
| 1228 | if (!VALID_TCP_CEPID(cepid))
|
---|
| 1229 | return E_ID;
|
---|
| 1230 |
|
---|
| 1231 | /* pk_ccep ã NULL ãªãã¨ã©ã¼ */
|
---|
| 1232 | if (pk_ccep == NULL)
|
---|
| 1233 | return E_PAR;
|
---|
| 1234 |
|
---|
| 1235 | /* TCP é信端ç¹ãå¾ãã*/
|
---|
| 1236 | cep = GET_TCP_CEP(cepid);
|
---|
| 1237 |
|
---|
| 1238 | /* TCP é信端ç¹ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
|
---|
| 1239 | if (!DYNAMIC_TCP_CEP(cep))
|
---|
| 1240 | return E_ID;
|
---|
| 1241 |
|
---|
| 1242 | /* é信端ç¹ãããã¯ããã*/
|
---|
| 1243 | syscall(wai_sem(cep->semid_lock));
|
---|
| 1244 |
|
---|
| 1245 | /*
|
---|
| 1246 | * TCP é信端ç¹ããã§ãã¯ãããçææ¸ã¿ã§ããã°ã¨ã©ã¼
|
---|
| 1247 | */
|
---|
| 1248 | if (VALID_TCP_CEP(cep))
|
---|
| 1249 | error = E_OBJ;
|
---|
| 1250 | else {
|
---|
| 1251 |
|
---|
| 1252 | /* TCP é信端ç¹çææ
|
---|
| 1253 | å ±ãã³ãã¼ããã*/
|
---|
| 1254 | cep->cepatr = pk_ccep->cepatr; /* é信端ç¹å±æ§ */
|
---|
| 1255 | cep->sbuf = pk_ccep->sbuf; /* éä¿¡ç¨ã¦ã£ã³ããããã¡ */
|
---|
| 1256 | cep->sbufsz = pk_ccep->sbufsz; /* éä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº */
|
---|
| 1257 | cep->rbuf = pk_ccep->rbuf; /* åä¿¡ç¨ã¦ã£ã³ããããã¡ */
|
---|
| 1258 | cep->rbufsz = pk_ccep->rbufsz; /* åä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº */
|
---|
| 1259 | cep->callback = (void*)pk_ccep->callback; /* ã³ã¼ã«ãã㯠*/
|
---|
| 1260 |
|
---|
| 1261 | /* TCP é信端ç¹ãçææ¸ã¿ã«ããã*/
|
---|
| 1262 | cep->flags |= TCP_CEP_FLG_VALID;
|
---|
| 1263 | error = E_OK;
|
---|
| 1264 | }
|
---|
| 1265 |
|
---|
| 1266 | /* é信端ç¹ã®ããã¯ã解é¤ããã*/
|
---|
| 1267 | syscall(sig_sem(cep->semid_lock));
|
---|
| 1268 |
|
---|
| 1269 | return error;
|
---|
| 1270 | }
|
---|
| 1271 |
|
---|
| 1272 | #endif /* of #ifdef __tcp_cre_cep */
|
---|
| 1273 |
|
---|
| 1274 | /*
|
---|
| 1275 | * tcp_del_cep -- TCP é信端ç¹ã®åé¤ãæ¡å¼µæ©è½ã
|
---|
| 1276 | */
|
---|
| 1277 |
|
---|
| 1278 | #ifdef __tcp_del_cep
|
---|
| 1279 |
|
---|
| 1280 | ER
|
---|
| 1281 | tcp_del_cep (ID cepid)
|
---|
| 1282 | {
|
---|
| 1283 | T_TCP_CEP *cep;
|
---|
| 1284 | ER error;
|
---|
| 1285 |
|
---|
| 1286 | /* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
|
---|
| 1287 | if (!VALID_TCP_CEPID(cepid))
|
---|
| 1288 | return E_ID;
|
---|
| 1289 |
|
---|
| 1290 | /* TCP é信端ç¹ãå¾ãã*/
|
---|
| 1291 | cep = GET_TCP_CEP(cepid);
|
---|
| 1292 |
|
---|
| 1293 | /* TCP é信端ç¹ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
|
---|
| 1294 | if (!DYNAMIC_TCP_CEP(cep))
|
---|
| 1295 | return E_ID;
|
---|
| 1296 |
|
---|
| 1297 | /* é信端ç¹ãããã¯ããã*/
|
---|
| 1298 | syscall(wai_sem(cep->semid_lock));
|
---|
| 1299 |
|
---|
| 1300 | /*
|
---|
| 1301 | * TCP é信端ç¹ããã§ãã¯ããã以ä¸ã®å ´åã¯ã¨ã©ã¼
|
---|
| 1302 | * ã»æªçæã
|
---|
| 1303 | * ã»ä½¿ç¨ä¸ã
|
---|
| 1304 | */
|
---|
| 1305 | if (!VALID_TCP_CEP(cep))
|
---|
| 1306 | error = E_NOEXS;
|
---|
| 1307 | else if (cep->fsm_state != TCP_FSM_CLOSED)
|
---|
| 1308 | error = E_OBJ;
|
---|
| 1309 | else {
|
---|
| 1310 |
|
---|
| 1311 | /* TCP é信端ç¹ãæªçæã«ããã*/
|
---|
| 1312 | cep->flags &= ~TCP_CEP_FLG_VALID;
|
---|
| 1313 | error = E_OK;
|
---|
| 1314 | }
|
---|
| 1315 |
|
---|
| 1316 | /* é信端ç¹ã®ããã¯ã解é¤ããã*/
|
---|
| 1317 | syscall(sig_sem(cep->semid_lock));
|
---|
| 1318 |
|
---|
| 1319 | return error;
|
---|
| 1320 | }
|
---|
| 1321 |
|
---|
| 1322 | #endif /* of #ifdef __tcp_del_cep */
|
---|
| 1323 |
|
---|
| 1324 | #ifdef __tcp_snd_oob
|
---|
| 1325 |
|
---|
| 1326 | /*
|
---|
| 1327 | * tcp_snd_oob -- ç·æ¥ãã¼ã¿ã®éä¿¡ãæ¡å¼µæ©è½ã
|
---|
| 1328 | */
|
---|
| 1329 |
|
---|
| 1330 | ER_UINT
|
---|
| 1331 | tcp_snd_oob (ID cepid, void *data, int_t len, TMO tmout)
|
---|
| 1332 | {
|
---|
| 1333 | T_TCP_CEP *cep;
|
---|
| 1334 | ER_UINT error;
|
---|
| 1335 |
|
---|
| 1336 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 1337 |
|
---|
| 1338 | /* data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
|
---|
| 1339 | if (data == NULL || len < 0)
|
---|
| 1340 | return E_PAR;
|
---|
| 1341 |
|
---|
| 1342 | #else /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 1343 |
|
---|
| 1344 | /* data ã NULLãlen < 0 ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
|
---|
| 1345 | if (data == NULL || len < 0 || tmout == TMO_NBLK)
|
---|
| 1346 | return E_PAR;
|
---|
| 1347 |
|
---|
| 1348 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 1349 |
|
---|
| 1350 | /*
|
---|
| 1351 | * CEP ãããã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯èå¥åãè¨é²ããã
|
---|
| 1352 | * ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸ãªã®ã§ã¨ã©ã¼
|
---|
| 1353 | */
|
---|
| 1354 | if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_OOB)) != E_OK)
|
---|
| 1355 | return error;
|
---|
| 1356 |
|
---|
| 1357 | /* éä¿¡ã§ããããé信端ç¹ã®ç¶æ
|
---|
| 1358 | ãè¦ãã*/
|
---|
| 1359 | if ((error = tcp_can_send_more(cep, TFN_TCP_SND_OOB, tmout)) != E_OK)
|
---|
| 1360 | goto err_ret;
|
---|
| 1361 |
|
---|
| 1362 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 1363 |
|
---|
| 1364 | /* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
|
---|
| 1365 | if (tmout == TMO_NBLK) { /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 1366 |
|
---|
| 1367 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 1368 | if (!TCP_IS_SWBUF_FULL(cep)) {
|
---|
| 1369 |
|
---|
| 1370 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
|
---|
| 1371 | error = TCP_WRITE_SWBUF(cep, data, (uint_t)len);
|
---|
| 1372 |
|
---|
| 1373 | /* éä¿¡ç·æ¥ãã¤ã³ã¿ãè¨å®ããã*/
|
---|
| 1374 | cep->snd_up = cep->snd_una + cep->swbuf_count;
|
---|
| 1375 |
|
---|
| 1376 | /* åºåããã¹ãããã*/
|
---|
| 1377 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 1378 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 1379 |
|
---|
| 1380 | /* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
| 1381 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
| 1382 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)error);
|
---|
| 1383 | #else
|
---|
| 1384 | (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)&error);
|
---|
| 1385 | #endif
|
---|
| 1386 | error = E_WBLK;
|
---|
| 1387 | goto err_ret;
|
---|
| 1388 | }
|
---|
| 1389 | else {
|
---|
| 1390 | cep->snd_data = data;
|
---|
| 1391 | cep->snd_len = len;
|
---|
| 1392 | cep->snd_nblk_tfn = TFN_TCP_SND_OOB;
|
---|
| 1393 | TCP_ALLOC_SWBUF(cep);
|
---|
| 1394 |
|
---|
| 1395 | return E_WBLK;
|
---|
| 1396 | }
|
---|
| 1397 | }
|
---|
| 1398 | else { /* éãã³ããããã³ã°ã³ã¼ã« */
|
---|
| 1399 |
|
---|
| 1400 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 1401 |
|
---|
| 1402 | /* éä¿¡ã¦ã£ã³ããããã¡ã空ãã®ãå¾
|
---|
| 1403 | ã¤ã*/
|
---|
| 1404 | if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
|
---|
| 1405 | goto err_ret;
|
---|
| 1406 |
|
---|
| 1407 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
|
---|
| 1408 | if ((error = TCP_WRITE_SWBUF(cep, data, (uint_t)len)) > 0) {
|
---|
| 1409 |
|
---|
| 1410 | /* éä¿¡ç·æ¥ãã¤ã³ã¿ãè¨å®ããã*/
|
---|
| 1411 | cep->snd_up = cep->snd_una + cep->swbuf_count;
|
---|
| 1412 |
|
---|
| 1413 | /* ãã¼ã¿ãéä¿¡ãããéä¿¡ã¦ã£ã³ããããã¡ããã«ã®ã¨ãã¯å¼·å¶çã«éä¿¡ããã*/
|
---|
| 1414 | if (TCP_IS_SWBUF_FULL(cep))
|
---|
| 1415 | cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
|
---|
| 1416 |
|
---|
| 1417 | /* åºåããã¹ãããã*/
|
---|
| 1418 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
| 1419 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
| 1420 | }
|
---|
| 1421 |
|
---|
| 1422 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
| 1423 |
|
---|
| 1424 | }
|
---|
| 1425 |
|
---|
| 1426 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
| 1427 |
|
---|
| 1428 | err_ret:
|
---|
| 1429 | cep->snd_tskid = TA_NULL;
|
---|
| 1430 | cep->snd_tfn = TFN_TCP_UNDEF;
|
---|
| 1431 | return error;
|
---|
| 1432 | }
|
---|
| 1433 |
|
---|
| 1434 | #endif /* of #ifdef __tcp_snd_oob */
|
---|
| 1435 |
|
---|
| 1436 | #ifdef __tcp_rcv_oob
|
---|
| 1437 |
|
---|
| 1438 | /*
|
---|
| 1439 | * tcp_rcv_oob -- ç·æ¥ãã¼ã¿ã®åä¿¡ãæ¡å¼µæ©è½ã
|
---|
| 1440 | *
|
---|
| 1441 | * 注æ: éä¿¡å´ãè¤æ°ãªã¯ãããã®ãã¼ã¿ãéä¿¡ãã¦ãã
|
---|
| 1442 | * ç·æ¥ãã¤ã³ã¿ãæã 1 ãªã¯ãããã®ãã¼ã¿ã®ã¿åä¿¡ããã
|
---|
| 1443 | */
|
---|
| 1444 |
|
---|
| 1445 | ER_UINT
|
---|
| 1446 | tcp_rcv_oob (ID cepid, void *data, int_t len)
|
---|
| 1447 | {
|
---|
| 1448 | T_TCP_CEP *cep;
|
---|
| 1449 | uint8_t *urg;
|
---|
| 1450 |
|
---|
| 1451 | /* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
|
---|
| 1452 | if (!VALID_TCP_CEPID(cepid))
|
---|
| 1453 | return E_ID;
|
---|
| 1454 |
|
---|
| 1455 | /* data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
|
---|
| 1456 | if (data == NULL || len < 0)
|
---|
| 1457 | return E_PAR;
|
---|
| 1458 |
|
---|
| 1459 | /* TCP é信端ç¹ãå¾ãã*/
|
---|
| 1460 | cep = GET_TCP_CEP(cepid);
|
---|
| 1461 |
|
---|
| 1462 | /* åä¿¡ã§ããããé信端ç¹ã®ç¶æ
|
---|
| 1463 | ãè¦ãã*/
|
---|
| 1464 | /* åä¿¡ã§ããããfsm_state ãè¦ãã*/
|
---|
| 1465 | if (!TCP_FSM_CAN_RECV_MORE(cep->fsm_state))
|
---|
| 1466 | return E_OBJ;
|
---|
| 1467 |
|
---|
| 1468 | /*
|
---|
| 1469 | * ç·æ¥ãã¼ã¿å
|
---|
| 1470 | ¥ãã®ã»ã°ã¡ã³ãã® TCP ãããã
|
---|
| 1471 | * è¨å®ããã¦ããªããã°ãç·æ¥ãã¼ã¿ãåä¿¡ãã¦ããªãã
|
---|
| 1472 | */
|
---|
| 1473 | if (cep->urg_tcph == NULL)
|
---|
| 1474 | return E_OBJ;
|
---|
| 1475 |
|
---|
| 1476 | /* len == 0 ãªããããã¡ãªã¼ãã¼ããã¼ */
|
---|
| 1477 | if (len == 0)
|
---|
| 1478 | return E_BOVR;
|
---|
| 1479 |
|
---|
| 1480 | /* ç·æ¥ãã¤ã³ã¿ãæã 1 ãªã¯ãããã®ãã¼ã¿ãèªã¿åãã*/
|
---|
| 1481 | urg = (uint8_t*)cep->urg_tcph + TCP_DATA_OFF(cep->urg_tcph->doff) + cep->urg_tcph->urp + TCP_CFG_URG_OFFSET;
|
---|
| 1482 | *(uint8_t*)data = *urg;
|
---|
| 1483 |
|
---|
| 1484 | /* èªã¿åã£ããã¼ã¿ããå¾ãã® SDU ãåã«è©°ããã*/
|
---|
| 1485 | memcpy(urg, urg + 1, cep->urg_tcph->sum - (cep->urg_tcph->urp + TCP_CFG_URG_OFFSET) - 1);
|
---|
| 1486 |
|
---|
| 1487 | /* tcp_rcv_oob() ãå¼åºããããã¨ç¥ãããããã«ãNULL ãè¨å®ããã*/
|
---|
| 1488 | cep->urg_tcph = NULL;
|
---|
| 1489 |
|
---|
| 1490 | return 1;
|
---|
| 1491 | }
|
---|
| 1492 |
|
---|
| 1493 | #endif /* of #ifdef __tcp_rcv_oob */
|
---|
| 1494 |
|
---|
| 1495 | #endif /* of #ifdef TCP_CFG_EXTENTIONS */
|
---|
| 1496 |
|
---|
| 1497 | #ifdef TCP_CFG_EXTENTIONS
|
---|
| 1498 |
|
---|
| 1499 | #ifdef __tcp_del_rep
|
---|
| 1500 |
|
---|
| 1501 | /*
|
---|
| 1502 | * tcp_del_rep -- TCP åä»å£ã®åé¤ãæ¡å¼µæ©è½ã
|
---|
| 1503 | */
|
---|
| 1504 |
|
---|
| 1505 | #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0
|
---|
| 1506 |
|
---|
| 1507 | #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0
|
---|
| 1508 |
|
---|
| 1509 | ER
|
---|
| 1510 | tcp_del_rep (ID repid)
|
---|
| 1511 | {
|
---|
| 1512 |
|
---|
| 1513 | /*
|
---|
| 1514 | * TCP åä»å£ ID ããã§ãã¯ããã
|
---|
| 1515 | * IPv6 ç¨ TCP åä»å£ã§ããã°ã
|
---|
| 1516 | * IPv6 ç¨ã®ãTCP åä»å£ã®åé¤é¢æ°ï¼æ¬ä½ï¼ããå¼åºãã
|
---|
| 1517 | */
|
---|
| 1518 | //NET_DEBUG_TCP3("tcp_del_rep1[r=%d,n=%d,x=%d]\n",
|
---|
| 1519 | // repid, TMIN_TCP6_REPID, tmax_tcp6_repid);
|
---|
| 1520 | //NET_DEBUG_TCP3("tcp_del_rep2[r=%d,n=%d,x=%d]\n",
|
---|
| 1521 | // repid, TMIN_TCP4_REPID, tmax_tcp4_repid);
|
---|
| 1522 | if (VALID_TCP6_REPID(repid))
|
---|
| 1523 | return tcp6_del_rep_body(repid);
|
---|
| 1524 |
|
---|
| 1525 | /*
|
---|
| 1526 | * TCP åä»å£ ID ããã§ãã¯ããã
|
---|
| 1527 | * IPv4 ç¨ TCP åä»å£ã§ããã°ã
|
---|
| 1528 | * IPv4 ç¨ã®ãTCP åä»å£ã®åé¤é¢æ°ï¼æ¬ä½ï¼ããå¼åºãã
|
---|
| 1529 | */
|
---|
| 1530 | else if (VALID_TCP4_REPID(repid))
|
---|
| 1531 | return tcp4_del_rep_body(repid);
|
---|
| 1532 | else
|
---|
| 1533 | return E_ID;
|
---|
| 1534 |
|
---|
| 1535 | }
|
---|
| 1536 |
|
---|
| 1537 | #else /* of #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0 */
|
---|
| 1538 |
|
---|
| 1539 | ER
|
---|
| 1540 | tcp_del_rep (ID repid)
|
---|
| 1541 | {
|
---|
| 1542 |
|
---|
| 1543 | /* TCP åä»å£ ID ããã§ãã¯ããã*/
|
---|
| 1544 | if (VALID_TCP6_REPID(repid))
|
---|
| 1545 | return tcp6_del_rep_body(repid);
|
---|
| 1546 | else
|
---|
| 1547 | return E_ID;
|
---|
| 1548 |
|
---|
| 1549 | }
|
---|
| 1550 |
|
---|
| 1551 | #endif /* of #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0 */
|
---|
| 1552 |
|
---|
| 1553 | #else /* of #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0 */
|
---|
| 1554 |
|
---|
| 1555 | ER
|
---|
| 1556 | tcp_del_rep (ID repid)
|
---|
| 1557 | {
|
---|
| 1558 |
|
---|
| 1559 | /* TCP åä»å£ ID ããã§ãã¯ããã*/
|
---|
| 1560 | if (VALID_TCP4_REPID(repid))
|
---|
| 1561 | return tcp4_del_rep_body(repid);
|
---|
| 1562 | else
|
---|
| 1563 | return E_ID;
|
---|
| 1564 |
|
---|
| 1565 | }
|
---|
| 1566 |
|
---|
| 1567 | #endif /* of #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0 */
|
---|
| 1568 |
|
---|
| 1569 | #endif /* of #ifdef __tcp_del_rep */
|
---|
| 1570 |
|
---|
| 1571 | /*
|
---|
| 1572 | * tcp_set_opt -- TCP é信端ç¹ãªãã·ã§ã³ã®è¨å®ãæ¡å¼µæ©è½ã
|
---|
| 1573 | *
|
---|
| 1574 | * 注æ: è¨å®å¯è½ãª TCP é信端ç¹ãªãã·ã§ã³ã¯ç¡ããããE_PAR ãè¿ãããã
|
---|
| 1575 | */
|
---|
| 1576 |
|
---|
| 1577 | #ifdef __tcp_set_opt
|
---|
| 1578 |
|
---|
| 1579 | ER
|
---|
| 1580 | tcp_set_opt (ID cepid, int_t optname, void *optval, int_t optlen)
|
---|
| 1581 | {
|
---|
| 1582 | T_TCP_CEP *cep;
|
---|
| 1583 |
|
---|
| 1584 | /* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
|
---|
| 1585 | if (!VALID_TCP_CEPID(cepid))
|
---|
| 1586 | return E_ID;
|
---|
| 1587 |
|
---|
| 1588 | /* TCP é信端ç¹ãå¾ãã*/
|
---|
| 1589 | cep = GET_TCP_CEP(cepid);
|
---|
| 1590 |
|
---|
| 1591 | /* TCP é信端ç¹ããã§ãã¯ããã*/
|
---|
| 1592 | if (!VALID_TCP_CEP(cep))
|
---|
| 1593 | return E_NOEXS;
|
---|
| 1594 |
|
---|
| 1595 | return E_PAR;
|
---|
| 1596 | }
|
---|
| 1597 |
|
---|
| 1598 | #endif /* of #ifdef __tcp_set_opt */
|
---|
| 1599 |
|
---|
| 1600 | /*
|
---|
| 1601 | * tcp_get_opt -- TCP é信端ç¹ãªãã·ã§ã³ã®è¨å®ãæ¡å¼µæ©è½ã
|
---|
| 1602 | *
|
---|
| 1603 | * 注æ: è¨å®å¯è½ãª TCP é信端ç¹ãªãã·ã§ã³ã¯ç¡ããããE_PAR ãè¿ãããã
|
---|
| 1604 | */
|
---|
| 1605 |
|
---|
| 1606 | #ifdef __tcp_get_opt
|
---|
| 1607 |
|
---|
| 1608 | ER
|
---|
| 1609 | tcp_get_opt (ID cepid, int_t optname, void *optval, int_t optlen)
|
---|
| 1610 | {
|
---|
| 1611 | T_TCP_CEP *cep;
|
---|
| 1612 |
|
---|
| 1613 | /* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
|
---|
| 1614 | if (!VALID_TCP_CEPID(cepid))
|
---|
| 1615 | return E_ID;
|
---|
| 1616 |
|
---|
| 1617 | /* TCP é信端ç¹ãå¾ãã*/
|
---|
| 1618 | cep = GET_TCP_CEP(cepid);
|
---|
| 1619 |
|
---|
| 1620 | /* TCP é信端ç¹ããã§ãã¯ããã*/
|
---|
| 1621 | if (!VALID_TCP_CEP(cep))
|
---|
| 1622 | return E_NOEXS;
|
---|
| 1623 |
|
---|
| 1624 | return E_PAR;
|
---|
| 1625 | }
|
---|
| 1626 |
|
---|
| 1627 | #endif /* of #ifdef __tcp_get_opt */
|
---|
| 1628 |
|
---|
| 1629 | #endif /* of #ifdef TCP_CFG_EXTENTIONS */
|
---|
| 1630 |
|
---|
| 1631 | #endif /* of #ifdef SUPPORT_TCP */
|
---|