Changeset 331 for EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_output.c
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_output.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 93 93 #include <net/ethernet.h> 94 94 #include <net/net.h> 95 #include <net/net_endian.h> 96 #include <net/net_var.h> 95 97 #include <net/net_buf.h> 96 98 #include <net/net_timer.h> … … 98 100 99 101 #include <netinet/in.h> 100 #include <netinet6/in6.h>101 102 #include <netinet/in_var.h> 102 103 #include <netinet/in_itron.h> 103 104 #include <netinet/ip.h> 104 105 #include <netinet/ip_var.h> 105 #include <netinet6/in6_var.h>106 #include <netinet/ip6.h>107 #include <netinet6/ip6_var.h>108 106 #include <netinet/tcp.h> 109 #include <netinet/tcp_timer.h>110 107 #include <netinet/tcp_var.h> 111 108 #include <netinet/tcp_fsm.h> 112 109 #include <netinet/tcp_seq.h> 110 #include <netinet/tcp_timer.h> 113 111 114 112 #ifdef SUPPORT_TCP … … 150 148 T_NET_BUF *output; 151 149 T_TCP_HDR *tcph; 152 uint_t optlen ;150 uint_t optlen, hdr_offset; 153 151 ER error; 154 152 … … 210 208 */ 211 209 len = 0; 212 if ((error = tcp _get_segment(&output, cep, optlen,213 len, (uint_t) (net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),210 if ((error = tcpn_get_segment(&output, cep, optlen, 211 len, (uint_t)net_buf_max_siz(), 214 212 NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) { 215 213 if (cep->timer[TCP_TIM_REXMT] == 0) … … 222 220 223 221 if (IS_PTR_DEFINED(cep->sbuf)) { 224 if ((error = tcp _get_segment(&output, cep, optlen,225 len, (uint_t) (net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),222 if ((error = tcpn_get_segment(&output, cep, optlen, 223 len, (uint_t)net_buf_max_siz(), 226 224 NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) { 227 225 if (cep->timer[TCP_TIM_REXMT] == 0) … … 247 245 */ 248 246 len = 0; 249 if ((error = tcp _get_segment(&output, cep, optlen,250 len, (uint_t) (net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),247 if ((error = tcpn_get_segment(&output, cep, optlen, 248 len, (uint_t)net_buf_max_siz(), 251 249 NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) { 252 250 if (cep->timer[TCP_TIM_REXMT] == 0) … … 258 256 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */ 259 257 260 if ((error = tcp _get_segment(&output, cep, optlen,261 len, (uint_t) (net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),258 if ((error = tcpn_get_segment(&output, cep, optlen, 259 len, (uint_t)net_buf_max_siz(), 262 260 NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) { 263 261 if (cep->timer[TCP_TIM_REXMT] == 0) … … 272 270 * 本実装では、最大セグメントサイズのみ設定する。 273 271 */ 272 hdr_offset = IF_IP_TCP_HDR_OFFSET(output); 274 273 if (flags & TCP_FLG_SYN) { 275 274 cep->snd_nxt = cep->iss; … … 277 276 #ifdef TCP_CFG_OPT_MSS 278 277 279 optp = GET_TCP_OPT(output, IF_IP_TCP_HDR_OFFSET);278 optp = GET_TCP_OPT(output, hdr_offset); 280 279 *optp ++ = TCP_OPT_MAXSEG; 281 280 *optp ++ = TCP_OPT_LEN_MAXSEG; … … 324 323 } 325 324 326 tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET);325 tcph = GET_TCP_HDR(output, hdr_offset); 327 326 328 327 /* … … 379 378 */ 380 379 tcph->sum = 0; 381 tcph->sum = IN_CKSUM(output, IPPROTO_TCP, (uint_t)GET_TCP_HDR_OFFSET(output), 382 GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET) + len); 380 tcph->sum = IN_CKSUM(output, IPPROTO_TCP, hdr_offset, GET_TCP_HDR_SIZE(output, hdr_offset) + len); 383 381 384 382 /* ネットワークバッファ長を調整する。*/ 385 output->len = (uint16_t)(GET_IF_IP_TCP_HDR_SIZE 2(output, IF_IP_TCP_HDR_OFFSET) + len);383 output->len = (uint16_t)(GET_IF_IP_TCP_HDR_SIZE(output, hdr_offset) + len); 386 384 387 385 /* … … 490 488 * ・動的な通信端点の生成・削除機能 491 489 */ 492 cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK | 493 TCP_CEP_FLG_DYNAMIC | TCP_CEP_FLG_VALID); 490 cep->flags &= TCP_CEP_FLG_NOT_CLEAR; 494 491 495 492 return error; … … 864 861 #endif /* of #ifdef TCP_CFG_NON_BLOCKING */ 865 862 866 if ((error = tcp _get_segment(&cep->swbufq, cep, 0,867 (uint_t) 868 (uint_t) (TCP_CFG_SWBUF_CSAVE_MAX_SIZE - IF_IP_TCP_HDR_SIZE),863 if ((error = tcpn_get_segment(&cep->swbufq, cep, 0, 864 (uint_t)TCP_CFG_SWBUF_CSAVE_MIN_SIZE, 865 (uint_t)TCP_CFG_SWBUF_CSAVE_MAX_SIZE, 869 866 (ATR)(NBA_SEARCH_DESCENT | 870 867 NBA_RESERVE_TCP | … … 888 885 len = TCP_GET_SWBUF_ADDR(cep, cep->snd_p_buf); 889 886 887 /* コールバック関数を呼び出す。*/ 890 888 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 891 892 /* コールバック関数を呼び出す。*/893 889 (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len); 894 895 #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */ 896 897 /* コールバック関数を呼び出す。*/ 890 #else 898 891 (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len); 899 900 #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */ 892 #endif 901 893 902 894 … … 924 916 /* フラグを、送信可能に設定し、強制的に送信する。*/ 925 917 cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR | TCP_CEP_FLG_POST_OUTPUT; 918 919 /* コールバック関数を呼び出す。*/ 926 920 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 927 928 /* コールバック関数を呼び出す。*/929 921 (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len); 930 931 #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */ 932 933 /* コールバック関数を呼び出す。*/ 922 #else 934 923 (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len); 935 936 #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */ 924 #endif 937 925 938 926 … … 999 987 tcp_init(); 1000 988 1001 #ifdef SUPPORT_INET6989 #ifdef _IP6_CFG 1002 990 1003 991 /* IPv6 のステートレス・アドレス自動設定を実行する。*/ 1004 992 in6_if_up(IF_GET_IFNET()); 1005 993 1006 #endif /* of #ifdef SUPPORT_INET6*/994 #endif /* of #ifdef _IP6_CFG */ 1007 995 1008 996 while (true) { … … 1083 1071 1084 1072 if (IS_PTR_DEFINED(cep->callback)) 1085 1086 1073 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 1087 1088 1074 (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)error); 1089 1090 #else /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */ 1091 1075 #else 1092 1076 (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error); 1093 1094 #endif /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */ 1095 1077 #endif 1096 1078 else 1097 1079 syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
Note:
See TracChangeset
for help on using the changeset viewer.