- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.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 * … … 58 58 #endif /* of #ifdef TARGET_KERNEL_JSP */ 59 59 60 #include <tinet_defs.h>61 #include <tinet_config.h>62 63 #include <net/if.h>64 #include <net/if_ppp.h>65 #include <net/if_loop.h>66 #include <net/ethernet.h>67 #include <net/net.h>68 #include <net/net_timer.h>69 70 60 #include <netinet/in.h> 71 61 #include <netinet/in_itron.h> 72 #include <netinet/ip.h>73 #include <netinet/ip6.h>74 #include <netinet/tcp.h>75 62 76 63 #include <netapp/netapp.h> 77 64 #include <netapp/netapp_var.h> 78 #include <netapp/ discard.h>65 #include <netapp/tcp_discard_srv.h> 79 66 80 67 #ifdef USE_TCP_DISCARD_SRV … … 121 108 122 109 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) { 123 syslog(LOG_NOTICE, "[TDS :%02dACP] accept error: %s", cepid, itron_strerror(error));110 syslog(LOG_NOTICE, "[TDSn:%02u ACP] accept error: %s", cepid, itron_strerror(error)); 124 111 return error; 125 112 } 126 113 127 114 #ifdef USE_TCP_EXTENTIONS 128 if ((error = free_tcp_rep(repid, true)) != E_OK) {129 syslog(LOG_NOTICE, "[TDS :%02dDEL] REP delete error: %s", cepid, itron_strerror(error));115 if ((error = FREE_TCP_REP(repid, true)) != E_OK) { 116 syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error)); 130 117 return error; 131 118 } … … 134 121 count = total = 0; 135 122 get_tim(&time); 136 syslog(LOG_NOTICE, "[TDS :%02d RCV] connected: %6ld, from: %s.%d",123 syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d", 137 124 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 138 125 while ((rlen = tcp_rcv_buf(cepid, (void*)&buf, TMO_FEVR)) > 0) { … … 140 127 141 128 #ifdef SHOW_RCV_RANGE 142 syslog(LOG_NOTICE, "[TDS :%02d RCV] count: %4d, len: %4d, data: %02x -> %02x",129 syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x", 143 130 cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1)); 144 131 #endif /* of #ifdef SHOW_RCV_RANGE */ … … 150 137 151 138 if ((error = tcp_rel_buf(cepid, rlen)) != E_OK) { 152 syslog(LOG_NOTICE, "[TDS :%02dRCV] rel buf error: %s",139 syslog(LOG_NOTICE, "[TDSn:%02u RCV] rel buf error: %s", 153 140 cepid, itron_strerror(error)); 154 141 rlen = 0; … … 159 146 160 147 if (rlen != 0) 161 syslog(LOG_NOTICE, "[TDS :%02dRCV] recv buf error: %s", cepid, itron_strerror(rlen));148 syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv buf error: %s", cepid, itron_strerror(rlen)); 162 149 163 150 if ((error = tcp_sht_cep(cepid)) != E_OK) 164 syslog(LOG_NOTICE, "[TDS :%02dRCV] shutdown error: %s", cepid, itron_strerror(error));151 syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error)); 165 152 166 153 if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK) 167 syslog(LOG_NOTICE, "[TDS :%02dRCV] close error: %s", cepid, itron_strerror(error));154 syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error)); 168 155 169 156 get_tim(&time); 170 syslog(LOG_NOTICE, "[TDS :%02d RCV] finished: %6ld, rcv: %4d, len: %ld",157 syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu", 171 158 cepid, time / SYSTIM_HZ, count, total); 172 159 … … 190 177 191 178 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) { 192 syslog(LOG_NOTICE, "[TDS :%02dRCV] accept error: %s", cepid, itron_strerror(error));179 syslog(LOG_NOTICE, "[TDSn:%02u RCV] accept error: %s", cepid, itron_strerror(error)); 193 180 return error; 194 181 } 195 182 196 183 #ifdef USE_TCP_EXTENTIONS 197 if ((error = free_tcp_rep(repid, true)) != E_OK) {198 syslog(LOG_NOTICE, "[TDS :%02dDEL] REP delete error: %s", cepid, itron_strerror(error));184 if ((error = FREE_TCP_REP(repid, true)) != E_OK) { 185 syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error)); 199 186 return error; 200 187 } … … 203 190 count = total = 0; 204 191 get_tim(&time); 205 syslog(LOG_NOTICE, "[TDS :%02d RCV] connected: %6ld, from: %s.%d",192 syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d", 206 193 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 207 194 while ((rlen = tcp_rcv_dat(cepid, buf, BUF_SIZE - 1, TMO_FEVR)) > 0) { … … 209 196 210 197 #ifdef SHOW_RCV_RANGE 211 syslog(LOG_NOTICE, "[TDS :%02d RCV] count: %4d, len: %4d, data: %02x -> %02x",198 syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x", 212 199 cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1)); 213 200 #endif /* of #ifdef SHOW_RCV_RANGE */ … … 216 203 } 217 204 if (rlen != 0) 218 syslog(LOG_NOTICE, "[TDS :%02dRCV] recv error: %s", cepid, itron_strerror(rlen));205 syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv error: %s", cepid, itron_strerror(rlen)); 219 206 220 207 if ((error = tcp_sht_cep(cepid)) != E_OK) 221 syslog(LOG_NOTICE, "[TDS :%02dRCV] shutdown error: %s", cepid, itron_strerror(error));208 syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error)); 222 209 223 210 if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK) 224 syslog(LOG_NOTICE, "[TDS :%02dRCV] close error: %s", cepid, itron_strerror(error));211 syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error)); 225 212 226 213 get_tim(&time); 227 syslog(LOG_NOTICE, "[TDS :%02d RCV] finished: %6ld, rcv: %4d, len: %ld",214 syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu", 228 215 cepid, time / SYSTIM_HZ, count, total); 229 216 … … 243 230 { 244 231 ID tskid; 245 T_TCP _CREP crep;232 T_TCPN_CREP crep; 246 233 247 234 get_tid(&tskid); … … 250 237 crep.myaddr.portno = UINT_C(9); 251 238 239 #if defined(SUPPORT_INET6) 240 241 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 242 243 #else /* #if defined(SUPPORT_INET6) */ 244 252 245 #if defined(SUPPORT_INET4) 253 246 crep.myaddr.ipaddr = IPV4_ADDRANY; 254 247 #endif 255 248 256 #if defined(SUPPORT_INET6) 257 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 258 #endif 259 260 return alloc_tcp_rep(repid, tskid, &crep); 249 #endif /* #if defined(SUPPORT_INET6) */ 250 251 return ALLOC_TCP_REP(repid, tskid, &crep); 261 252 } 262 253 … … 285 276 #endif 286 277 287 return alloc_tcp_cep(cepid, tskid, &ccep);278 return ALLOC_TCP_CEP(cepid, tskid, &ccep); 288 279 } 289 280 … … 299 290 300 291 syscall(get_tid(&tskid)); 301 syslog(LOG_NOTICE, "[TCP ECHO SRV:%d] started.", tskid); 292 293 #if defined(SUPPORT_INET6) 294 #if defined(SUPPORT_INET4) 295 syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d] started.", tskid); 296 #else 297 syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d] started.", tskid); 298 #endif 299 #else 300 syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d] started.", tskid); 301 #endif 302 302 303 while (true) { 303 304 304 305 syscall(slp_tsk()); 305 306 if ((error = get_tcp_cep (&cepid)) != E_OK) { 306 syslog(LOG_NOTICE, "[TDS :00 EXT] CEP create error: %s", itron_strerror(error));307 syslog(LOG_NOTICE, "[TDSn:00 EXT] CEP create error: %s", itron_strerror(error)); 307 308 continue; 308 309 } … … 311 312 312 313 if ((error = get_tcp_rep (&repid)) != E_OK) { 313 syslog(LOG_NOTICE, "[TDS :00 EXT] REP create error: %s", itron_strerror(error));314 syslog(LOG_NOTICE, "[TDSn:00 EXT] REP create error: %s", itron_strerror(error)); 314 315 break; 315 316 } 316 317 else if ((error = tcp_discard_srv(cepid, repid)) != E_OK) { 317 error = free_tcp_rep(repid, error != E_DLT);318 error = FREE_TCP_REP(repid, error != E_DLT); 318 319 break; 319 320 } 320 321 } 321 322 322 if ((error = free_tcp_cep(cepid)) != E_OK)323 syslog(LOG_NOTICE, "[TDS :%02dEXT] CEP delete error: %s", cepid, itron_strerror(error));323 if ((error = FREE_TCP_CEP(cepid)) != E_OK) 324 syslog(LOG_NOTICE, "[TDSn:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error)); 324 325 325 326 } … … 334 335 335 336 get_tid(&tskid); 336 syslog(LOG_NOTICE, "[TCP DISCARD SRV:%d,%d] started.", tskid, (ID)exinf); 337 338 #if defined(SUPPORT_INET6) 339 #if defined(SUPPORT_INET4) 340 syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d,%d] started.", tskid, (ID)exinf); 341 #else 342 syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf); 343 #endif 344 #else 345 syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf); 346 #endif 347 337 348 while (true) { 338 349 while (tcp_discard_srv((ID)exinf, TCP_DISCARD_SRV_REPID) == E_OK)
Note:
See TracChangeset
for help on using the changeset viewer.