- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.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 * … … 56 56 #endif /* of #ifdef TARGET_KERNEL_JSP */ 57 57 58 #include <tinet_defs.h>59 #include <tinet_config.h>60 61 #include <net/if.h>62 #include <net/if_ppp.h>63 #include <net/if_loop.h>64 #include <net/ethernet.h>65 #include <net/net.h>66 #include <net/net_var.h>67 #include <net/net_timer.h>68 69 58 #include <netinet/in.h> 59 #include <netinet/in_itron.h> 70 60 #include <netinet/ip.h> 71 #include <netinet/ip6.h>72 61 #include <netinet/udp.h> 73 #include <netinet/udp_var.h>74 #include <netinet/in_itron.h>75 62 76 63 #include <netapp/netapp.h> 77 64 #include <netapp/netapp_var.h> 78 #include <netapp/ discard.h>65 #include <netapp/udp_discard_cli.h> 79 66 80 67 #ifdef USE_UDP_DISCARD_CLI … … 90 77 #define PAT_BEGIN ' ' 91 78 #define PAT_END '~' 79 80 #if defined(SUPPORT_INET6) 81 #define API_PROTO '6' 82 #else 83 #define API_PROTO '4' 84 #endif 92 85 93 86 /* … … 104 97 send_udp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno) 105 98 { 106 static char smsg[IF_MTU - IP_UDP_HDR_SIZE]; 99 #if defined(SUPPORT_INET6) 100 static char smsg[IPV6_MMTU - (IP6_HDR_SIZE + UDP_HDR_SIZE)]; 101 #else 102 static char smsg[IP4_MSS - (IP4_HDR_SIZE + UDP_HDR_SIZE)]; 103 #endif 107 104 108 105 T_IPEP dst; … … 117 114 118 115 p = smsg; 119 for (slen = IF_MTU - IP_UDP_HDR_SIZE; slen > 0; )116 for (slen = sizeof(smsg); slen > 0; ) 120 117 for (pat = PAT_BEGIN; slen > 0 && pat <= PAT_END; pat ++, slen --) 121 118 *p ++ = pat; 122 119 123 120 get_tim(&time); 124 syslog(LOG_NOTICE, "[UDC :%02d SND] sending: %6ld, to: %s.%d",125 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);121 syslog(LOG_NOTICE, "[UDC%c:%02u SND] send: %7lu, to: %s.%d", 122 API_PROTO, cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 126 123 127 124 scount = total = 0; 128 125 udp_discard_cli_valid = true; 129 for (slen = IF_MTU - IP_UDP_HDR_SIZE; udp_discard_cli_valid && slen > 0; slen --) {126 for (slen = sizeof(smsg); udp_discard_cli_valid && slen > 0; slen --) { 130 127 scount ++; 131 128 if ((len = UDP_SND_DAT(cepid, &dst, smsg, slen, TMO_FEVR)) < 0) { 132 syslog(LOG_NOTICE, "[UDC :%02d SND] send error: %s", cepid, itron_strerror(len));129 syslog(LOG_NOTICE, "[UDC%c:%02u SND] error: %s", API_PROTO, cepid, itron_strerror(len)); 133 130 return len; 134 131 } 135 132 else 136 syslog(LOG_NOTICE, "[UDC :%02d SND] send: %4d, %4d", cepid, scount, slen);133 syslog(LOG_NOTICE, "[UDC%c:%02u SND] send: %7lu, %4u", API_PROTO, cepid, scount, slen); 137 134 total += len; 138 dly_tsk(10 * SYSTIM_HZ + net _rand() % (10 * SYSTIM_HZ));135 dly_tsk(10 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ)); 139 136 } 140 137 141 138 get_tim(&time); 142 syslog(LOG_NOTICE, "[UDC :%02d SND] finished: %6ld, snd: %4d, len: %ld",143 cepid, time / SYSTIM_HZ, scount, total);139 syslog(LOG_NOTICE, "[UDC%c:%02u SND] finsh: %7lu, snd: %4u, len: %ld", 140 API_PROTO, cepid, time / SYSTIM_HZ, scount, total); 144 141 return E_OK; 145 142 } … … 158 155 int_t no; 159 156 uint16_t portno; 157 char apip; 160 158 161 159 #ifdef USE_UDP_EXTENTIONS 162 160 161 #if defined(SUPPORT_INET6) 162 T_UDP6_CCEP ccep; 163 #else 163 164 T_UDP_CCEP ccep; 165 #endif 164 166 165 167 #endif /* of #ifdef USE_UDP_EXTENTIONS */ 168 169 #if defined(SUPPORT_INET6) 170 apip = API_PROTO_IPV6; 171 #else 172 apip = API_PROTO_IPV4; 173 #endif 166 174 167 175 get_tid(&tskid); … … 171 179 line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line))); /* IP Address */ 172 180 181 if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) { 182 syslog(LOG_NOTICE, "[UDC%c:%02u TSK] unknown host.", (ID)exinf); 183 continue; 184 } 185 173 186 if ('0' <= *line && *line <= '9') { /* Port No */ 174 187 line = get_int(&no, line); … … 186 199 ccep.myaddr.portno = UDP_PORTANY; 187 200 201 #if defined(SUPPORT_INET6) 202 203 memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 204 205 #else /* #if defined(SUPPORT_INET6) */ 206 188 207 #if defined(SUPPORT_INET4) 189 208 ccep.myaddr.ipaddr = IPV4_ADDRANY; 190 209 #endif 191 210 192 #if defined(SUPPORT_INET6) 193 memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 194 #endif 195 196 if ((error = alloc_udp_cep(&cepid, tskid, &ccep)) != E_OK) { 197 syslog(LOG_NOTICE, "[UDC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error)); 211 #endif /* #if defined(SUPPORT_INET6) */ 212 213 if ((error = ALLOC_UDP_CEP(&cepid, tskid, &ccep)) != E_OK) { 214 syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP create error: %s", API_PROTO, cepid, itron_strerror(error)); 198 215 continue; 199 216 } … … 206 223 207 224 if ((error = send_udp_discard(cepid, &addr, portno)) != E_OK) 208 syslog(LOG_NOTICE, "[UDC :%02d TSK] error: %s", cepid, itron_strerror(error));225 syslog(LOG_NOTICE, "[UDC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error)); 209 226 210 227 #ifdef USE_UDP_EXTENTIONS 211 228 212 if ((error = free_udp_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)213 syslog(LOG_NOTICE, "[UDC :%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));229 if ((error = FREE_UDP_CEP(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK) 230 syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP delete error: %s", API_PROTO, cepid, itron_strerror(error)); 214 231 215 232 #endif /* of #ifdef USE_UDP_EXTENTIONS */
Note:
See TracChangeset
for help on using the changeset viewer.