Changes in uspace/app/nettest1/nettest1.c [d9e2e0e:3d459fc] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nettest1/nettest1.c
rd9e2e0e r3d459fc 28 28 29 29 /** @addtogroup nettest 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Networking test 1 application - sockets. 35 */ 34 * Networking test 1 application - sockets. 35 */ 36 37 #include "nettest.h" 38 #include "print_error.h" 36 39 37 40 #include <malloc.h> … … 49 52 #include <net/socket_parse.h> 50 53 51 #include "nettest.h" 52 #include "print_error.h" 53 54 /** Echo module name. 55 */ 54 /** Echo module name. */ 56 55 #define NAME "Nettest1" 57 56 58 /** Packet data pattern. 59 */ 57 /** Packet data pattern. */ 60 58 #define NETTEST1_TEXT "Networking test 1 - sockets" 61 59 62 /** Module entry point. 63 * Starts testing. 64 * @param[in] argc The number of command line parameters. 65 * @param[in] argv The command line parameters. 66 * @returns EOK on success. 67 */ 68 int main(int argc, char * argv[]); 69 70 /** Prints the application help. 71 */ 72 void nettest1_print_help(void); 73 74 /** Refreshes the data. 75 * Fills the data block with the NETTEST1_TEXT pattern. 76 * @param[out] data The data block. 77 * @param[in] size The data block size in bytes. 78 */ 79 void nettest1_refresh_data(char * data, size_t size); 80 81 int main(int argc, char * argv[]){ 82 ERROR_DECLARE; 83 84 size_t size = 27; 85 int verbose = 0; 86 sock_type_t type = SOCK_DGRAM; 87 int sockets = 10; 88 int messages = 10; 89 int family = PF_INET; 90 uint16_t port = 7; 91 92 socklen_t max_length = sizeof(struct sockaddr_in6); 93 uint8_t address_data[max_length]; 94 struct sockaddr * address = (struct sockaddr *) address_data; 95 struct sockaddr_in * address_in = (struct sockaddr_in *) address; 96 struct sockaddr_in6 * address_in6 = (struct sockaddr_in6 *) address; 97 socklen_t addrlen; 98 // char address_string[INET6_ADDRSTRLEN]; 99 uint8_t * address_start; 100 101 int * socket_ids; 102 char * data; 103 int value; 104 int index; 105 struct timeval time_before; 106 struct timeval time_after; 107 108 // parse the command line arguments 109 // stop before the last argument if it does not start with the minus sign ('-') 110 for(index = 1; (index < argc - 1) || ((index == argc - 1) && (argv[index][0] == '-')); ++ index){ 111 // options should start with the minus sign ('-') 112 if(argv[index][0] == '-'){ 113 switch(argv[index][1]){ 114 // short options with only one letter 115 case 'f': 116 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &family, 0, socket_parse_protocol_family)); 117 break; 118 case 'h': 119 nettest1_print_help(); 120 return EOK; 121 break; 122 case 'm': 123 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &messages, 0)); 124 break; 125 case 'n': 126 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &sockets, 0)); 127 break; 128 case 'p': 129 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 0)); 130 port = (uint16_t) value; 131 break; 132 case 's': 133 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 0)); 134 size = (value >= 0) ? (size_t) value : 0; 135 break; 136 case 't': 137 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &value, 0, socket_parse_socket_type)); 138 type = (sock_type_t) value; 139 break; 140 case 'v': 141 verbose = 1; 142 break; 143 // long options with the double minus sign ('-') 144 case '-': 145 if(str_lcmp(argv[index] + 2, "family=", 7) == 0){ 146 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &family, 9, socket_parse_protocol_family)); 147 }else if(str_lcmp(argv[index] + 2, "help", 5) == 0){ 148 nettest1_print_help(); 149 return EOK; 150 }else if(str_lcmp(argv[index] + 2, "messages=", 6) == 0){ 151 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &messages, 8)); 152 }else if(str_lcmp(argv[index] + 2, "sockets=", 6) == 0){ 153 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &sockets, 8)); 154 }else if(str_lcmp(argv[index] + 2, "port=", 5) == 0){ 155 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 7)); 156 port = (uint16_t) value; 157 }else if(str_lcmp(argv[index] + 2, "type=", 5) == 0){ 158 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &value, 7, socket_parse_socket_type)); 159 type = (sock_type_t) value; 160 }else if(str_lcmp(argv[index] + 2, "verbose", 8) == 0){ 161 verbose = 1; 162 }else{ 163 nettest1_print_help(); 164 return EINVAL; 165 } 166 break; 167 default: 168 nettest1_print_help(); 169 return EINVAL; 170 } 171 }else{ 172 nettest1_print_help(); 173 return EINVAL; 174 } 175 } 176 177 // if not before the last argument containing the address 178 if(index >= argc){ 179 printf("Command line error: missing address\n"); 180 nettest1_print_help(); 181 return EINVAL; 182 } 183 184 // prepare the address buffer 185 bzero(address_data, max_length); 186 switch(family){ 187 case PF_INET: 188 address_in->sin_family = AF_INET; 189 address_in->sin_port = htons(port); 190 address_start = (uint8_t *) &address_in->sin_addr.s_addr; 191 addrlen = sizeof(struct sockaddr_in); 192 break; 193 case PF_INET6: 194 address_in6->sin6_family = AF_INET6; 195 address_in6->sin6_port = htons(port); 196 address_start = (uint8_t *) &address_in6->sin6_addr.s6_addr; 197 addrlen = sizeof(struct sockaddr_in6); 198 break; 199 default: 200 fprintf(stderr, "Address family is not supported\n"); 201 return EAFNOSUPPORT; 202 } 203 204 // parse the last argument which should contain the address 205 if(ERROR_OCCURRED(inet_pton(family, argv[argc - 1], address_start))){ 206 fprintf(stderr, "Address parse error %d\n", ERROR_CODE); 207 return ERROR_CODE; 208 } 209 210 // check the buffer size 211 if(size <= 0){ 212 fprintf(stderr, "Data buffer size too small (%d). Using 1024 bytes instead.\n", size); 213 size = 1024; 214 } 215 216 // prepare the buffer 217 // size plus the terminating null (\0) 218 data = (char *) malloc(size + 1); 219 if(! data){ 220 fprintf(stderr, "Failed to allocate data buffer.\n"); 221 return ENOMEM; 222 } 223 nettest1_refresh_data(data, size); 224 225 // check the socket count 226 if(sockets <= 0){ 227 fprintf(stderr, "Socket count too small (%d). Using 2 instead.\n", sockets); 228 sockets = 2; 229 } 230 231 // prepare the socket buffer 232 // count plus the terminating null (\0) 233 socket_ids = (int *) malloc(sizeof(int) * (sockets + 1)); 234 if(! socket_ids){ 235 fprintf(stderr, "Failed to allocate receive buffer.\n"); 236 return ENOMEM; 237 } 238 socket_ids[sockets] = NULL; 239 240 if(verbose){ 241 printf("Starting tests\n"); 242 } 243 244 if(verbose){ 245 printf("1 socket, 1 message\n"); 246 } 247 248 if(ERROR_OCCURRED(gettimeofday(&time_before, NULL))){ 249 fprintf(stderr, "Get time of day error %d\n", ERROR_CODE); 250 return ERROR_CODE; 251 } 252 253 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 254 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 255 if(verbose){ 256 printf("\tOK\n"); 257 } 258 259 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 260 if(type == SOCK_STREAM){ 261 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, 1, address, addrlen)); 262 } 263 ERROR_PROPAGATE(sockets_sendto_recvfrom(verbose, socket_ids, 1, address, &addrlen, data, size, 1)); 264 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 265 if(verbose){ 266 printf("\tOK\n"); 267 } 268 269 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 270 if(type == SOCK_STREAM){ 271 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, 1, address, addrlen)); 272 } 273 ERROR_PROPAGATE(sockets_sendto(verbose, socket_ids, 1, address, addrlen, data, size, 1)); 274 ERROR_PROPAGATE(sockets_recvfrom(verbose, socket_ids, 1, address, &addrlen, data, size, 1)); 275 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 276 if(verbose){ 277 printf("\tOK\n"); 278 } 279 280 if(verbose){ 281 printf("1 socket, %d messages\n", messages); 282 } 283 284 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 285 if(type == SOCK_STREAM){ 286 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, 1, address, addrlen)); 287 } 288 ERROR_PROPAGATE(sockets_sendto_recvfrom(verbose, socket_ids, 1, address, &addrlen, data, size, messages)); 289 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 290 if(verbose){ 291 printf("\tOK\n"); 292 } 293 294 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 295 if(type == SOCK_STREAM){ 296 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, 1, address, addrlen)); 297 } 298 ERROR_PROPAGATE(sockets_sendto(verbose, socket_ids, 1, address, addrlen, data, size, messages)); 299 ERROR_PROPAGATE(sockets_recvfrom(verbose, socket_ids, 1, address, &addrlen, data, size, messages)); 300 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 301 if(verbose){ 302 printf("\tOK\n"); 303 } 304 305 if(verbose){ 306 printf("%d sockets, 1 message\n", sockets); 307 } 308 309 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 310 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 311 if(verbose){ 312 printf("\tOK\n"); 313 } 314 315 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 316 if(type == SOCK_STREAM){ 317 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, sockets, address, addrlen)); 318 } 319 ERROR_PROPAGATE(sockets_sendto_recvfrom(verbose, socket_ids, sockets, address, &addrlen, data, size, 1)); 320 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 321 if(verbose){ 322 printf("\tOK\n"); 323 } 324 325 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 326 if(type == SOCK_STREAM){ 327 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, sockets, address, addrlen)); 328 } 329 ERROR_PROPAGATE(sockets_sendto(verbose, socket_ids, sockets, address, addrlen, data, size, 1)); 330 ERROR_PROPAGATE(sockets_recvfrom(verbose, socket_ids, sockets, address, &addrlen, data, size, 1)); 331 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 332 if(verbose){ 333 printf("\tOK\n"); 334 } 335 336 if(verbose){ 337 printf("%d sockets, %d messages\n", sockets, messages); 338 } 339 340 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 341 if(type == SOCK_STREAM){ 342 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, sockets, address, addrlen)); 343 } 344 ERROR_PROPAGATE(sockets_sendto_recvfrom(verbose, socket_ids, sockets, address, &addrlen, data, size, messages)); 345 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 346 if(verbose){ 347 printf("\tOK\n"); 348 } 349 350 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 351 if(type == SOCK_STREAM){ 352 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, sockets, address, addrlen)); 353 } 354 ERROR_PROPAGATE(sockets_sendto(verbose, socket_ids, sockets, address, addrlen, data, size, messages)); 355 ERROR_PROPAGATE(sockets_recvfrom(verbose, socket_ids, sockets, address, &addrlen, data, size, messages)); 356 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 357 358 if(ERROR_OCCURRED(gettimeofday(&time_after, NULL))){ 359 fprintf(stderr, "Get time of day error %d\n", ERROR_CODE); 360 return ERROR_CODE; 361 } 362 363 if(verbose){ 364 printf("\tOK\n"); 365 } 366 367 printf("Tested in %d microseconds\n", tv_sub(&time_after, &time_before)); 368 369 if(verbose){ 370 printf("Exiting\n"); 371 } 372 373 return EOK; 374 } 375 376 void nettest1_print_help(void){ 60 static void nettest1_print_help(void) 61 { 377 62 printf( 378 63 "Network Networking test 1 aplication - sockets\n" \ … … 402 87 } 403 88 404 void nettest1_refresh_data(char * data, size_t size){ 89 /** Refreshes the data. 90 * 91 * Fills the data block with the NETTEST1_TEXT pattern. 92 * 93 * @param[out] data The data block. 94 * @param[in] size The data block size in bytes. 95 */ 96 static void nettest1_refresh_data(char *data, size_t size) 97 { 405 98 size_t length; 406 99 407 100 // fill the data 408 101 length = 0; 409 while (size > length + sizeof(NETTEST1_TEXT) - 1){102 while (size > length + sizeof(NETTEST1_TEXT) - 1) { 410 103 memcpy(data + length, NETTEST1_TEXT, sizeof(NETTEST1_TEXT) - 1); 411 104 length += sizeof(NETTEST1_TEXT) - 1; … … 415 108 } 416 109 110 111 int main(int argc, char *argv[]) 112 { 113 ERROR_DECLARE; 114 115 size_t size = 27; 116 int verbose = 0; 117 sock_type_t type = SOCK_DGRAM; 118 int sockets = 10; 119 int messages = 10; 120 int family = PF_INET; 121 uint16_t port = 7; 122 123 socklen_t max_length = sizeof(struct sockaddr_in6); 124 uint8_t address_data[max_length]; 125 struct sockaddr *address = (struct sockaddr *) address_data; 126 struct sockaddr_in *address_in = (struct sockaddr_in *) address; 127 struct sockaddr_in6 *address_in6 = (struct sockaddr_in6 *) address; 128 socklen_t addrlen; 129 uint8_t *address_start; 130 131 int *socket_ids; 132 char *data; 133 int value; 134 int index; 135 struct timeval time_before; 136 struct timeval time_after; 137 138 // parse the command line arguments 139 // stop before the last argument if it does not start with the minus sign ('-') 140 for (index = 1; (index < argc - 1) || ((index == argc - 1) && (argv[index][0] == '-')); index++) { 141 // options should start with the minus sign ('-') 142 if (argv[index][0] == '-') { 143 switch (argv[index][1]) { 144 // short options with only one letter 145 case 'f': 146 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &family, 0, socket_parse_protocol_family)); 147 break; 148 case 'h': 149 nettest1_print_help(); 150 return EOK; 151 break; 152 case 'm': 153 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &messages, 0)); 154 break; 155 case 'n': 156 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &sockets, 0)); 157 break; 158 case 'p': 159 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 0)); 160 port = (uint16_t) value; 161 break; 162 case 's': 163 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 0)); 164 size = (value >= 0) ? (size_t) value : 0; 165 break; 166 case 't': 167 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &value, 0, socket_parse_socket_type)); 168 type = (sock_type_t) value; 169 break; 170 case 'v': 171 verbose = 1; 172 break; 173 // long options with the double minus sign ('-') 174 case '-': 175 if (str_lcmp(argv[index] + 2, "family=", 7) == 0) { 176 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &family, 9, socket_parse_protocol_family)); 177 } else if (str_lcmp(argv[index] + 2, "help", 5) == 0) { 178 nettest1_print_help(); 179 return EOK; 180 } else if (str_lcmp(argv[index] + 2, "messages=", 6) == 0) { 181 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &messages, 8)); 182 } else if (str_lcmp(argv[index] + 2, "sockets=", 6) == 0) { 183 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &sockets, 8)); 184 } else if (str_lcmp(argv[index] + 2, "port=", 5) == 0) { 185 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 7)); 186 port = (uint16_t) value; 187 } else if (str_lcmp(argv[index] + 2, "type=", 5) == 0) { 188 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &value, 7, socket_parse_socket_type)); 189 type = (sock_type_t) value; 190 } else if (str_lcmp(argv[index] + 2, "verbose", 8) == 0) { 191 verbose = 1; 192 } else { 193 nettest1_print_help(); 194 return EINVAL; 195 } 196 break; 197 default: 198 nettest1_print_help(); 199 return EINVAL; 200 } 201 } else { 202 nettest1_print_help(); 203 return EINVAL; 204 } 205 } 206 207 // if not before the last argument containing the address 208 if (index >= argc) { 209 printf("Command line error: missing address\n"); 210 nettest1_print_help(); 211 return EINVAL; 212 } 213 214 // prepare the address buffer 215 bzero(address_data, max_length); 216 switch (family) { 217 case PF_INET: 218 address_in->sin_family = AF_INET; 219 address_in->sin_port = htons(port); 220 address_start = (uint8_t *) &address_in->sin_addr.s_addr; 221 addrlen = sizeof(struct sockaddr_in); 222 break; 223 case PF_INET6: 224 address_in6->sin6_family = AF_INET6; 225 address_in6->sin6_port = htons(port); 226 address_start = (uint8_t *) &address_in6->sin6_addr.s6_addr; 227 addrlen = sizeof(struct sockaddr_in6); 228 break; 229 default: 230 fprintf(stderr, "Address family is not supported\n"); 231 return EAFNOSUPPORT; 232 } 233 234 // parse the last argument which should contain the address 235 if (ERROR_OCCURRED(inet_pton(family, argv[argc - 1], address_start))) { 236 fprintf(stderr, "Address parse error %d\n", ERROR_CODE); 237 return ERROR_CODE; 238 } 239 240 // check the buffer size 241 if (size <= 0) { 242 fprintf(stderr, "Data buffer size too small (%d). Using 1024 bytes instead.\n", size); 243 size = 1024; 244 } 245 246 // prepare the buffer 247 // size plus the terminating null (\0) 248 data = (char *) malloc(size + 1); 249 if (!data) { 250 fprintf(stderr, "Failed to allocate data buffer.\n"); 251 return ENOMEM; 252 } 253 nettest1_refresh_data(data, size); 254 255 // check the socket count 256 if (sockets <= 0) { 257 fprintf(stderr, "Socket count too small (%d). Using 2 instead.\n", sockets); 258 sockets = 2; 259 } 260 261 // prepare the socket buffer 262 // count plus the terminating null (\0) 263 socket_ids = (int *) malloc(sizeof(int) * (sockets + 1)); 264 if (!socket_ids) { 265 fprintf(stderr, "Failed to allocate receive buffer.\n"); 266 return ENOMEM; 267 } 268 socket_ids[sockets] = NULL; 269 270 if (verbose) 271 printf("Starting tests\n"); 272 273 if (verbose) 274 printf("1 socket, 1 message\n"); 275 276 if (ERROR_OCCURRED(gettimeofday(&time_before, NULL))) { 277 fprintf(stderr, "Get time of day error %d\n", ERROR_CODE); 278 return ERROR_CODE; 279 } 280 281 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 282 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 283 if (verbose) 284 printf("\tOK\n"); 285 286 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 287 if (type == SOCK_STREAM) 288 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, 1, address, addrlen)); 289 ERROR_PROPAGATE(sockets_sendto_recvfrom(verbose, socket_ids, 1, address, &addrlen, data, size, 1)); 290 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 291 if (verbose) 292 printf("\tOK\n"); 293 294 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 295 if (type == SOCK_STREAM) 296 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, 1, address, addrlen)); 297 ERROR_PROPAGATE(sockets_sendto(verbose, socket_ids, 1, address, addrlen, data, size, 1)); 298 ERROR_PROPAGATE(sockets_recvfrom(verbose, socket_ids, 1, address, &addrlen, data, size, 1)); 299 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 300 if (verbose) 301 printf("\tOK\n"); 302 303 if (verbose) 304 printf("1 socket, %d messages\n", messages); 305 306 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 307 if (type == SOCK_STREAM) 308 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, 1, address, addrlen)); 309 ERROR_PROPAGATE(sockets_sendto_recvfrom(verbose, socket_ids, 1, address, &addrlen, data, size, messages)); 310 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 311 if (verbose) 312 printf("\tOK\n"); 313 314 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, 1, family, type)); 315 if (type == SOCK_STREAM) 316 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, 1, address, addrlen)); 317 ERROR_PROPAGATE(sockets_sendto(verbose, socket_ids, 1, address, addrlen, data, size, messages)); 318 ERROR_PROPAGATE(sockets_recvfrom(verbose, socket_ids, 1, address, &addrlen, data, size, messages)); 319 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, 1)); 320 if (verbose) 321 printf("\tOK\n"); 322 323 if (verbose) 324 printf("%d sockets, 1 message\n", sockets); 325 326 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 327 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 328 if (verbose) 329 printf("\tOK\n"); 330 331 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 332 if (type == SOCK_STREAM) 333 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, sockets, address, addrlen)); 334 ERROR_PROPAGATE(sockets_sendto_recvfrom(verbose, socket_ids, sockets, address, &addrlen, data, size, 1)); 335 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 336 if (verbose) 337 printf("\tOK\n"); 338 339 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 340 if (type == SOCK_STREAM) 341 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, sockets, address, addrlen)); 342 ERROR_PROPAGATE(sockets_sendto(verbose, socket_ids, sockets, address, addrlen, data, size, 1)); 343 ERROR_PROPAGATE(sockets_recvfrom(verbose, socket_ids, sockets, address, &addrlen, data, size, 1)); 344 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 345 if (verbose) 346 printf("\tOK\n"); 347 348 if (verbose) 349 printf("%d sockets, %d messages\n", sockets, messages); 350 351 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 352 if (type == SOCK_STREAM) 353 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, sockets, address, addrlen)); 354 ERROR_PROPAGATE(sockets_sendto_recvfrom(verbose, socket_ids, sockets, address, &addrlen, data, size, messages)); 355 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 356 if (verbose) 357 printf("\tOK\n"); 358 359 ERROR_PROPAGATE(sockets_create(verbose, socket_ids, sockets, family, type)); 360 if (type == SOCK_STREAM) 361 ERROR_PROPAGATE(sockets_connect(verbose, socket_ids, sockets, address, addrlen)); 362 ERROR_PROPAGATE(sockets_sendto(verbose, socket_ids, sockets, address, addrlen, data, size, messages)); 363 ERROR_PROPAGATE(sockets_recvfrom(verbose, socket_ids, sockets, address, &addrlen, data, size, messages)); 364 ERROR_PROPAGATE(sockets_close(verbose, socket_ids, sockets)); 365 366 if (ERROR_OCCURRED(gettimeofday(&time_after, NULL))) { 367 fprintf(stderr, "Get time of day error %d\n", ERROR_CODE); 368 return ERROR_CODE; 369 } 370 371 if (verbose) 372 printf("\tOK\n"); 373 374 printf("Tested in %d microseconds\n", tv_sub(&time_after, &time_before)); 375 376 if (verbose) 377 printf("Exiting\n"); 378 379 return EOK; 380 } 381 382 417 383 /** @} 418 384 */
Note:
See TracChangeset
for help on using the changeset viewer.