1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** NetX Utility */ 16 /** */ 17 /** NetX Duo IPerf Test Program */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #ifndef NX_IPERF_H 23 #define NX_IPERF_H 24 25 /* Enable authentication. 26 #define NX_IPERF_AUTH_ENABLE 27 */ 28 29 #ifndef NX_IPERF_TCP_RX_PORT 30 #define NX_IPERF_TCP_RX_PORT 5001 31 #endif 32 33 #ifndef NX_IPERF_UDP_RX_PORT 34 #define NX_IPERF_UDP_RX_PORT 5001 35 #endif 36 37 #ifndef NX_IPERF_DESTINATION_PORT 38 #define NX_IPERF_DESTINATION_PORT 5001 39 #endif 40 41 #ifndef NX_IPERF_THREAD_PRIORITY 42 #define NX_IPERF_THREAD_PRIORITY 1 43 #endif 44 45 #ifndef ULONG64_DEFINED 46 #define ULONG64_DEFINED 47 #define ULONG64 unsigned long long 48 #endif 49 50 #define NX_IPERF_CTRL_SIGN_MASK 0x0F 51 #define NX_IPERF_CLEAN_UP_MASK 0x01 52 53 typedef struct 54 { 55 ULONG CmdID; 56 ULONG version; 57 ULONG ip; 58 ULONG ipv6[4]; 59 ULONG port; 60 UCHAR ctrl_sign; 61 UINT ErrorCode; 62 ULONG WperfPort; 63 ULONG64 PacketsTxed; 64 ULONG64 PacketsRxed; 65 ULONG64 BytesTxed; 66 ULONG64 BytesRxed; 67 ULONG64 StartTime; 68 ULONG64 RunTime; 69 ULONG64 TestTime; 70 ULONG64 ThroughPut; 71 ULONG64 PacketSize; 72 ULONG64 Rate; 73 UINT TestStatus; /* 0 means no test is running. 74 1 means Test Thread is created and is running. 75 2 means a test has finished. */ 76 ULONG64 idleTime; 77 } ctrl_info; 78 79 /*test list for wperf*/ 80 typedef struct 81 { 82 ULONG cmdID; 83 ULONG threadID; 84 } thread_list; 85 86 /* test type enum */ 87 enum testTypeList 88 { 89 UNKNOWN_TEST = 0, 90 TCP_RX_START = 1, 91 UDP_RX_START = 3, 92 TCP_TX_START = 5, 93 UDP_TX_START = 7, 94 95 UDP_RX_STOP, 96 TCP_RX_STOP, 97 UDP_TX_STOP, 98 TCP_TX_STOP 99 }; 100 101 enum errorCodeList 102 { 103 UDP_RX_STOP_ERROR = 5000, 104 UDP_RX_CREATE_ERROR, 105 UDP_TX_STOP_ERROR, 106 UDP_TX_CREATE_ERROR, 107 TCP_RX_STOP_ERROR, 108 TCP_RX_CREATE_ERROR, 109 TCP_TX_STOP_ERROR, 110 TCP_TX_CREATE_ERROR 111 }; 112 113 typedef struct 114 { 115 int udp_id; 116 ULONG tv_sec; 117 ULONG tv_usec; 118 } udp_payload; 119 120 #define htmlwrite(p, s, l) (nx_packet_data_append(p, s, l, server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER)) 121 122 #define htmlresponse "HTTP/1.0 200 \r\nContent-Type: text/html\r\n\r\n" 123 #define htmltag "<HTML>" 124 #define htmlendtag "</HTML>" 125 #define titleline "<HEAD><TITLE>NetX IPerf Demonstration</TITLE></HEAD>\r\n" 126 127 #define bodytag "<body bgcolor=\"#000000\">\r\n" 128 #define bodyendtag "</body>\r\n" 129 130 #define logo_area \ 131 "<table border=0 align=center width=90%><tr>" \ 132 "<td width=30%><img align=left src=mslogo.jpg>" \ 133 "</td><td width=33%></td><td width=33%><img align=right src=nxlogo.png></td></tr></table>" 134 135 #define hrline "<HR SIZE=6 WIDTH=\"90%\" NOSHADE COLOR=\"#FFFF00\">" 136 #define h1line1 " <H1><font face=arial color=\"#FFFFFF\">NetX IP Address: " 137 #define h1line2 "</font></H1><br>\r\n" 138 #define tabletag "<table height=50%>" 139 #define fonttag "<font face=arial color=\"#FFFFFF\" size=\"5\">" 140 #define fontcolortag "<font face=arial color=\"#FFFF00\" size=\"5\">" 141 #define fontendtag "</font>" 142 143 #define centertag "<center WIDTH=\"90%\">\r\n" 144 #define centerendtag "</center>" 145 #define outtermosttable "<table width=80% border=0 bordercolor=#ffff00 rules=cols color=#FFFF00 farme=void><tr><td width=55%>\r\n" 146 #define maintabletag "<TABLE BORDER=0 ALIGN=left WIDTH=85% ><TR><TD colspan=4>\r\n" 147 #define tableendtag "</TABLE>" 148 #define trtag "<TR>" 149 #define trendtag "</TR>" 150 #define tdtag "<TD>" 151 #define toptdtag "<TD align=center style=\"vertical-align:top;\">" 152 #define tdcolspan4tag "<TD colspan=\"4\">" 153 #define tdcolspan3tag "<TD colspan=\"3\">" 154 #define tdcolspan2tag "<TD colspan=\"2\">" 155 #define tdendtag "</TD>\r\n" 156 #define doublebr "<br><br>\r\n" 157 #define spanline "<TR><TD colspan=\"4\"><br><br></TD></TR>" 158 #define rightspanline "<TR><TD><br><br></TD></TR>" 159 #define tdcentertag "<TD align=center>" 160 161 162 #define formtag "<form action=\"/test.htm\" method=\"get\">" 163 #define formendtag "</form>" 164 165 #define UDPTXSTRING "Start UDP Transmit Test" 166 #define UDP_Tx "UDP_Tx" 167 #define udptxsubmittag1 \ 168 "<form action=\"/test.htm\" method=\"get\">\r\n" \ 169 "<TR><TD><input type=\"submit\" Value=\""UDPTXSTRING "\" style= \"background-color:#FFFF00; " \ 170 "font-size:19px; font-weight: bold\"></TD></TR>\r\n" \ 171 "<TR><TD><input type=\"hidden\" name=\"TestType\" value=\""UDP_Tx "\"></input></TD></TR>" \ 172 "<TR><TD>"fonttag "Destination IP Address:</font></TD>\r\n" \ 173 "<TD><input name=\"ip\" value=\"" 174 175 #define udptxsubmittag2 \ 176 "\"></input></TD></TR>\r\n" \ 177 "<TR><TD>"fonttag "Destination Port:</font></TD>\r\n" \ 178 "<TD><input name=\"port\" value=\"" 179 180 #define udptxsubmittag3 \ 181 "\"></input></TD></TR>\r\n" \ 182 "<TR><TD>"fonttag "Test Time(Seconds):</font></TD>\r\n" \ 183 "<TD><input name=\"test_time\" value=\"" 184 185 #define udptxsubmittag4 \ 186 "\"></input></TD></TR>\r\n" \ 187 "<TR><TD>"fonttag "Packet size:</font></TD>\r\n" \ 188 "<TD><input name=\"size\" value=\"" 189 190 #define udptxsubmittag5 \ 191 "\"></input></TD></TR>\r\n" \ 192 "</form><TR><TD colspan=\"4\"><br><br></TD></TR>\r\n" 193 194 #define UDPRXSTRING "Start UDP Receive Test" 195 #define UDP_Rx "UDP_Rx" 196 #define udprxsubmittag1 \ 197 "<form action=\"/test.htm\" method=\"get\">\r\n" \ 198 "<TR><TD><input type=\"submit\" Value=\""UDPRXSTRING "\" style= \"background-color:#FFFF00; font-size:19px; font-weight: bold\"></TD></TR>\r\n" \ 199 "<TR><TD><input type=\"hidden\" name=\"TestType\" value=\""UDP_Rx "\"></input></TD></TR>" \ 200 "<TR><TD>"fonttag "Test Time(Seconds):</font></TD>\r\n" \ 201 "<TD><input name=\"test_time\" value=\"" 202 203 #define udprxsubmittag2 \ 204 "\"></input></TD></TR></form>\r\n" \ 205 "<TR><TD colspan=\"4\"><br><br></TD></TR>\r\n" 206 207 #define TCP_Tx "TCP_Tx" 208 #define tcptxsubmittag1 \ 209 "<form action=\"/test.htm\" method=\"get\">\r\n" \ 210 "<TR><TD><input type=\"submit\" Value=\"Start TCP Transmit Test\" style= \"background-color:#FFFF00; font-size:19px; font-weight: bold\"></TD></TR>\r\n" \ 211 "<TR><TD><input type=\"hidden\" name=\"TestType\" value=\""TCP_Tx "\"></input></TD></TR>" \ 212 "<TR><TD>"fonttag "Destination IP Address:</font></TD>\r\n" \ 213 "<TD><input name=\"ip\" value=\"" 214 215 #define tcptxsubmittag2 \ 216 "\"></input></TD></TR>\r\n" \ 217 "<TR><TD>"fonttag "Destination Port:</font></TD>\r\n" \ 218 "<TD><input name=\"port\" value=\"" 219 220 #define tcptxsubmittag3 \ 221 "\"></input></TD></TR>\r\n" \ 222 "<TR><TD>"fonttag "Test Time(Seconds):</font></TD>\r\n" \ 223 "<TD><input name=\"test_time\" value=\"" 224 225 #define tcptxsubmittag4 \ 226 "\"></input></TD></TR>\r\n" \ 227 "</form><TR><TD colspan=\"4\"><br><br></TD></TR>\r\n" 228 229 #define TCP_Rx "TCP_Rx" 230 #define tcprxsubmittag1 \ 231 "<form action=\"/test.htm\" method=\"get\">\r\n" \ 232 "<TR><TD><input type=\"submit\" Value=\"Start TCP Receive Test\" style= \"background-color:#FFFF00; font-size:19px; font-weight: bold\"></TD></TR>\r\n" \ 233 "<TR><TD><input type=\"hidden\" name=\"TestType\" value=\""TCP_Rx "\"></input></TD></TR>" \ 234 "<TR><TD>"fonttag "Test Time(Seconds):</font></TD>\r\n" \ 235 "<TD><input name=\"test_time\" value=\"" 236 237 #define tcprxsubmittag2 \ 238 "\"></input></TD></TR>\r\n" \ 239 "</form>\r\n<TR><TD colspan=\"4\"><br><br></TD></TR>\r\n" 240 241 #define choosetesttag \ 242 "<TD align=center><font align=center face=arial color=\"#FFFFFF\" size=\"5\">Choose a test from the left.</font></TD>\r\n" 243 244 #endif /* NX_IPERF_H */ 245