Lines Matching full:sh

84 static void print_number(const struct shell *sh, uint32_t value,  in print_number()  argument
102 shell_fprintf(sh, SHELL_NORMAL, "%u.%s%u %s", radix, in print_number()
105 shell_fprintf(sh, SHELL_NORMAL, "%u %s", value, *unit); in print_number()
109 static void print_number_64(const struct shell *sh, uint64_t value, in print_number_64() argument
128 shell_fprintf(sh, SHELL_NORMAL, "%llu.%s%u %s", radix, in print_number_64()
131 shell_fprintf(sh, SHELL_NORMAL, "%llu %s", value, *unit); in print_number_64()
155 static int parse_ipv6_addr(const struct shell *sh, char *host, char *port, in parse_ipv6_addr() argument
171 shell_fprintf(sh, SHELL_WARNING, in parse_ipv6_addr()
179 static int parse_ipv4_addr(const struct shell *sh, char *host, char *port, in parse_ipv4_addr() argument
195 shell_fprintf(sh, SHELL_WARNING, in parse_ipv4_addr()
203 static int zperf_bind_host(const struct shell *sh, in zperf_bind_host() argument
224 shell_fprintf(sh, SHELL_WARNING, in zperf_bind_host()
236 static int cmd_setip(const struct shell *sh, size_t argc, char *argv[]) in cmd_setip() argument
242 shell_help(sh); in cmd_setip()
248 shell_fprintf(sh, SHELL_WARNING, in cmd_setip()
253 shell_fprintf(sh, SHELL_NORMAL, in cmd_setip()
260 shell_help(sh); in cmd_setip()
265 shell_fprintf(sh, SHELL_WARNING, in cmd_setip()
270 shell_fprintf(sh, SHELL_NORMAL, in cmd_setip()
278 shell_help(sh); in cmd_setip()
284 shell_fprintf(sh, SHELL_WARNING, in cmd_setip()
289 shell_fprintf(sh, SHELL_NORMAL, in cmd_setip()
294 shell_help(sh); in cmd_setip()
300 shell_fprintf(sh, SHELL_WARNING, in cmd_setip()
305 shell_fprintf(sh, SHELL_NORMAL, in cmd_setip()
318 const struct shell *sh = user_data; in udp_session_cb() local
322 shell_fprintf(sh, SHELL_NORMAL, "New session started.\n"); in udp_session_cb()
337 shell_fprintf(sh, SHELL_NORMAL, "End of session!\n"); in udp_session_cb()
339 shell_fprintf(sh, SHELL_NORMAL, " duration:\t\t"); in udp_session_cb()
340 print_number_64(sh, result->time_in_us, TIME_US, TIME_US_UNIT); in udp_session_cb()
341 shell_fprintf(sh, SHELL_NORMAL, "\n"); in udp_session_cb()
343 shell_fprintf(sh, SHELL_NORMAL, " received packets:\t%u\n", in udp_session_cb()
345 shell_fprintf(sh, SHELL_NORMAL, " nb packets lost:\t%u\n", in udp_session_cb()
347 shell_fprintf(sh, SHELL_NORMAL, " nb packets outorder:\t%u\n", in udp_session_cb()
350 shell_fprintf(sh, SHELL_NORMAL, " jitter:\t\t\t"); in udp_session_cb()
351 print_number(sh, result->jitter_in_us, TIME_US, TIME_US_UNIT); in udp_session_cb()
352 shell_fprintf(sh, SHELL_NORMAL, "\n"); in udp_session_cb()
354 shell_fprintf(sh, SHELL_NORMAL, " rate:\t\t\t"); in udp_session_cb()
355 print_number(sh, rate_in_kbps, KBPS, KBPS_UNIT); in udp_session_cb()
356 shell_fprintf(sh, SHELL_NORMAL, "\n"); in udp_session_cb()
362 shell_fprintf(sh, SHELL_ERROR, "UDP session error.\n"); in udp_session_cb()
377 static int shell_cmd_download(const struct shell *sh, size_t argc, in shell_cmd_download() argument
397 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_download()
408 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_download()
417 static int cmd_udp_download_stop(const struct shell *sh, size_t argc, in cmd_udp_download_stop() argument
424 shell_fprintf(sh, SHELL_WARNING, "UDP server not running!\n"); in cmd_udp_download_stop()
428 shell_fprintf(sh, SHELL_NORMAL, "UDP server stopped\n"); in cmd_udp_download_stop()
433 static int cmd_udp_download(const struct shell *sh, size_t argc, in cmd_udp_download() argument
441 start = shell_cmd_download(sh, argc, argv, &param); in cmd_udp_download()
443 shell_fprintf(sh, SHELL_WARNING, in cmd_udp_download()
448 ret = zperf_bind_host(sh, argc - start, &argv[start], &param); in cmd_udp_download()
450 shell_fprintf(sh, SHELL_WARNING, in cmd_udp_download()
452 shell_help(sh); in cmd_udp_download()
456 ret = zperf_udp_download(&param, udp_session_cb, (void *)sh); in cmd_udp_download()
458 shell_fprintf(sh, SHELL_WARNING, in cmd_udp_download()
462 shell_fprintf(sh, SHELL_ERROR, in cmd_udp_download()
469 shell_fprintf(sh, SHELL_NORMAL, in cmd_udp_download()
478 static void shell_udp_upload_print_stats(const struct shell *sh, in shell_udp_upload_print_stats() argument
484 shell_fprintf(sh, SHELL_NORMAL, "-\nUpload completed!\n"); in shell_udp_upload_print_stats()
505 shell_fprintf(sh, SHELL_ERROR, in shell_udp_upload_print_stats()
509 shell_fprintf(sh, SHELL_NORMAL, in shell_udp_upload_print_stats()
511 shell_fprintf(sh, SHELL_NORMAL, "Duration:\t\t"); in shell_udp_upload_print_stats()
512 print_number_64(sh, results->time_in_us, TIME_US, in shell_udp_upload_print_stats()
514 shell_fprintf(sh, SHELL_NORMAL, "\t("); in shell_udp_upload_print_stats()
515 print_number_64(sh, results->client_time_in_us, TIME_US, in shell_udp_upload_print_stats()
517 shell_fprintf(sh, SHELL_NORMAL, ")\n"); in shell_udp_upload_print_stats()
519 shell_fprintf(sh, SHELL_NORMAL, "Num packets:\t\t%u\t(%u)\n", in shell_udp_upload_print_stats()
523 shell_fprintf(sh, SHELL_NORMAL, in shell_udp_upload_print_stats()
526 shell_fprintf(sh, SHELL_NORMAL, "Num packets lost:\t%u\n", in shell_udp_upload_print_stats()
529 shell_fprintf(sh, SHELL_NORMAL, "Jitter:\t\t\t"); in shell_udp_upload_print_stats()
530 print_number(sh, results->jitter_in_us, TIME_US, in shell_udp_upload_print_stats()
532 shell_fprintf(sh, SHELL_NORMAL, "\n"); in shell_udp_upload_print_stats()
534 shell_fprintf(sh, SHELL_NORMAL, "Rate:\t\t\t"); in shell_udp_upload_print_stats()
535 print_number(sh, rate_in_kbps, KBPS, KBPS_UNIT); in shell_udp_upload_print_stats()
536 shell_fprintf(sh, SHELL_NORMAL, "\t("); in shell_udp_upload_print_stats()
537 print_number(sh, client_rate_in_kbps, KBPS, KBPS_UNIT); in shell_udp_upload_print_stats()
538 shell_fprintf(sh, SHELL_NORMAL, ")\n"); in shell_udp_upload_print_stats()
542 static void shell_tcp_upload_print_stats(const struct shell *sh, in shell_tcp_upload_print_stats() argument
548 shell_fprintf(sh, SHELL_NORMAL, "-\nUpload completed!\n"); in shell_tcp_upload_print_stats()
560 shell_fprintf(sh, SHELL_NORMAL, "Duration:\t"); in shell_tcp_upload_print_stats()
561 print_number_64(sh, results->client_time_in_us, in shell_tcp_upload_print_stats()
563 shell_fprintf(sh, SHELL_NORMAL, "\n"); in shell_tcp_upload_print_stats()
564 shell_fprintf(sh, SHELL_NORMAL, "Num packets:\t%u\n", in shell_tcp_upload_print_stats()
566 shell_fprintf(sh, SHELL_NORMAL, in shell_tcp_upload_print_stats()
569 shell_fprintf(sh, SHELL_NORMAL, "Rate:\t\t"); in shell_tcp_upload_print_stats()
570 print_number(sh, client_rate_in_kbps, KBPS, KBPS_UNIT); in shell_tcp_upload_print_stats()
571 shell_fprintf(sh, SHELL_NORMAL, "\n"); in shell_tcp_upload_print_stats()
575 static void shell_tcp_upload_print_periodic(const struct shell *sh, in shell_tcp_upload_print_periodic() argument
591 shell_fprintf(sh, SHELL_NORMAL, "Duration: "); in shell_tcp_upload_print_periodic()
592 print_number_64(sh, results->client_time_in_us, in shell_tcp_upload_print_periodic()
594 shell_fprintf(sh, SHELL_NORMAL, " | "); in shell_tcp_upload_print_periodic()
595 shell_fprintf(sh, SHELL_NORMAL, "Packets: %6u | ", in shell_tcp_upload_print_periodic()
597 shell_fprintf(sh, SHELL_NORMAL, in shell_tcp_upload_print_periodic()
600 shell_fprintf(sh, SHELL_NORMAL, "Rate: "); in shell_tcp_upload_print_periodic()
601 print_number(sh, client_rate_in_kbps, KBPS, KBPS_UNIT); in shell_tcp_upload_print_periodic()
602 shell_fprintf(sh, SHELL_NORMAL, "\n"); in shell_tcp_upload_print_periodic()
610 const struct shell *sh = user_data; in udp_upload_cb() local
617 shell_udp_upload_print_stats(sh, result); in udp_upload_cb()
622 shell_fprintf(sh, SHELL_ERROR, "UDP upload failed\n"); in udp_upload_cb()
634 const struct shell *sh = user_data; in tcp_upload_cb() local
641 shell_tcp_upload_print_periodic(sh, result); in tcp_upload_cb()
645 shell_tcp_upload_print_stats(sh, result); in tcp_upload_cb()
650 shell_fprintf(sh, SHELL_ERROR, "TCP upload failed\n"); in tcp_upload_cb()
673 static void send_ping(const struct shell *sh, in send_ping() argument
684 shell_fprintf(sh, SHELL_WARNING, "Cannot send ping (%d)\n", ret); in send_ping()
700 shell_fprintf(sh, SHELL_WARNING, "ping %s timeout\n", in send_ping()
707 static int execute_upload(const struct shell *sh, in execute_upload() argument
714 shell_fprintf(sh, SHELL_NORMAL, "Duration:\t"); in execute_upload()
715 print_number_64(sh, (uint64_t)param->duration_ms * USEC_PER_MSEC, TIME_US, in execute_upload()
717 shell_fprintf(sh, SHELL_NORMAL, "\n"); in execute_upload()
718 shell_fprintf(sh, SHELL_NORMAL, "Packet size:\t%u bytes\n", in execute_upload()
720 shell_fprintf(sh, SHELL_NORMAL, "Rate:\t\t%u kbps\n", in execute_upload()
722 shell_fprintf(sh, SHELL_NORMAL, "Starting...\n"); in execute_upload()
731 send_ping(sh, &ipv6->sin6_addr, MSEC_PER_SEC); in execute_upload()
738 shell_fprintf(sh, SHELL_NORMAL, "Rate:\t\t"); in execute_upload()
739 print_number(sh, param->rate_kbps, KBPS, KBPS_UNIT); in execute_upload()
740 shell_fprintf(sh, SHELL_NORMAL, "\n"); in execute_upload()
743 shell_fprintf(sh, SHELL_NORMAL, "Packet duration %u ms\n", in execute_upload()
746 shell_fprintf(sh, SHELL_NORMAL, "Packet duration %u us\n", in execute_upload()
752 (void *)sh); in execute_upload()
754 shell_fprintf(sh, SHELL_ERROR, in execute_upload()
761 shell_fprintf(sh, SHELL_ERROR, in execute_upload()
766 shell_udp_upload_print_stats(sh, &results); in execute_upload()
770 shell_fprintf(sh, SHELL_WARNING, in execute_upload()
778 (void *)sh); in execute_upload()
780 shell_fprintf(sh, SHELL_ERROR, in execute_upload()
787 shell_fprintf(sh, SHELL_ERROR, in execute_upload()
792 shell_tcp_upload_print_stats(sh, &results); in execute_upload()
796 shell_fprintf(sh, SHELL_WARNING, in execute_upload()
833 static int shell_cmd_upload(const struct shell *sh, size_t argc, in shell_cmd_upload() argument
860 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
877 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
890 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
901 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
915 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
920 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
930 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
940 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
945 shell_help(sh); in shell_cmd_upload()
950 shell_help(sh); in shell_cmd_upload()
960 shell_fprintf(sh, SHELL_NORMAL, in shell_cmd_upload()
967 ret = parse_ipv6_addr(sh, argv[start + 1], port_str, &ipv6); in shell_cmd_upload()
969 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
973 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
979 shell_fprintf(sh, SHELL_NORMAL, "Connecting to %s\n", in shell_cmd_upload()
986 ret = parse_ipv4_addr(sh, argv[start + 1], port_str, &ipv4); in shell_cmd_upload()
988 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
992 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
998 shell_fprintf(sh, SHELL_NORMAL, "Connecting to %s\n", in shell_cmd_upload()
1005 ret = parse_ipv6_addr(sh, argv[start + 1], port_str, &ipv6); in shell_cmd_upload()
1007 ret = parse_ipv4_addr(sh, argv[start + 1], port_str, &ipv4); in shell_cmd_upload()
1009 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
1013 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
1019 shell_fprintf(sh, SHELL_NORMAL, in shell_cmd_upload()
1025 shell_fprintf(sh, SHELL_NORMAL, in shell_cmd_upload()
1050 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload()
1057 return execute_upload(sh, &param, is_udp, async); in shell_cmd_upload()
1060 static int cmd_tcp_upload(const struct shell *sh, size_t argc, char *argv[]) in cmd_tcp_upload() argument
1062 return shell_cmd_upload(sh, argc, argv, IPPROTO_TCP); in cmd_tcp_upload()
1065 static int cmd_udp_upload(const struct shell *sh, size_t argc, char *argv[]) in cmd_udp_upload() argument
1067 return shell_cmd_upload(sh, argc, argv, IPPROTO_UDP); in cmd_udp_upload()
1070 static int shell_cmd_upload2(const struct shell *sh, size_t argc, in shell_cmd_upload2() argument
1093 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1110 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1123 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1134 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1148 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1153 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1163 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1173 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1178 shell_help(sh); in shell_cmd_upload2()
1183 shell_help(sh); in shell_cmd_upload2()
1195 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1200 shell_fprintf(sh, SHELL_NORMAL, in shell_cmd_upload2()
1207 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1212 shell_fprintf(sh, SHELL_NORMAL, in shell_cmd_upload2()
1236 shell_fprintf(sh, SHELL_WARNING, in shell_cmd_upload2()
1243 return execute_upload(sh, &param, is_udp, async); in shell_cmd_upload2()
1246 static int cmd_tcp_upload2(const struct shell *sh, size_t argc, in cmd_tcp_upload2() argument
1249 return shell_cmd_upload2(sh, argc, argv, IPPROTO_TCP); in cmd_tcp_upload2()
1252 static int cmd_udp_upload2(const struct shell *sh, size_t argc, in cmd_udp_upload2() argument
1255 return shell_cmd_upload2(sh, argc, argv, IPPROTO_UDP); in cmd_udp_upload2()
1258 static int cmd_tcp(const struct shell *sh, size_t argc, char *argv[]) in cmd_tcp() argument
1261 shell_help(sh); in cmd_tcp()
1265 shell_fprintf(sh, SHELL_INFO, "TCP support is not enabled. " in cmd_tcp()
1271 static int cmd_udp(const struct shell *sh, size_t argc, char *argv[]) in cmd_udp() argument
1274 shell_help(sh); in cmd_udp()
1278 shell_fprintf(sh, SHELL_INFO, "UDP support is not enabled. " in cmd_udp()
1284 static int cmd_connectap(const struct shell *sh, size_t argc, char *argv[]) in cmd_connectap() argument
1286 shell_fprintf(sh, SHELL_INFO, in cmd_connectap()
1296 const struct shell *sh = user_data; in tcp_session_cb() local
1300 shell_fprintf(sh, SHELL_NORMAL, "New TCP session started.\n"); in tcp_session_cb()
1315 shell_fprintf(sh, SHELL_NORMAL, "TCP session ended\n"); in tcp_session_cb()
1317 shell_fprintf(sh, SHELL_NORMAL, " Duration:\t\t"); in tcp_session_cb()
1318 print_number_64(sh, result->time_in_us, TIME_US, TIME_US_UNIT); in tcp_session_cb()
1319 shell_fprintf(sh, SHELL_NORMAL, "\n"); in tcp_session_cb()
1321 shell_fprintf(sh, SHELL_NORMAL, " rate:\t\t\t"); in tcp_session_cb()
1322 print_number(sh, rate_in_kbps, KBPS, KBPS_UNIT); in tcp_session_cb()
1323 shell_fprintf(sh, SHELL_NORMAL, "\n"); in tcp_session_cb()
1329 shell_fprintf(sh, SHELL_ERROR, "TCP session error.\n"); in tcp_session_cb()
1337 static int cmd_tcp_download_stop(const struct shell *sh, size_t argc, in cmd_tcp_download_stop() argument
1344 shell_fprintf(sh, SHELL_WARNING, "TCP server not running!\n"); in cmd_tcp_download_stop()
1348 shell_fprintf(sh, SHELL_NORMAL, "TCP server stopped\n"); in cmd_tcp_download_stop()
1353 static int cmd_tcp_download(const struct shell *sh, size_t argc, in cmd_tcp_download() argument
1361 start = shell_cmd_download(sh, argc, argv, &param); in cmd_tcp_download()
1363 shell_fprintf(sh, SHELL_WARNING, in cmd_tcp_download()
1368 ret = zperf_bind_host(sh, argc - start, &argv[start], &param); in cmd_tcp_download()
1370 shell_fprintf(sh, SHELL_WARNING, in cmd_tcp_download()
1372 shell_help(sh); in cmd_tcp_download()
1376 ret = zperf_tcp_download(&param, tcp_session_cb, (void *)sh); in cmd_tcp_download()
1378 shell_fprintf(sh, SHELL_WARNING, in cmd_tcp_download()
1382 shell_fprintf(sh, SHELL_ERROR, in cmd_tcp_download()
1387 shell_fprintf(sh, SHELL_NORMAL, in cmd_tcp_download()
1396 static int cmd_version(const struct shell *sh, size_t argc, char *argv[]) in cmd_version() argument
1398 shell_fprintf(sh, SHELL_NORMAL, "Version: %s\nConfig: %s\n", in cmd_version()