#include "console.h"
Go to the source code of this file.
Functions | |
cmd_state_t | cmd_ttcp (int argc, char *argv[], void *ctx) |
cmd_state_t cmd_ttcp | ( | int | argc, | |
char * | argv[], | |||
void * | ctx | |||
) |
Definition at line 599 of file ttcp.c.
References ttcp::buflen, CMD_DONE, ttcp::mode, ttcp::nbuf, ttcp::port, printk(), str2ip(), TTCP_MODE_RECEIVE, TTCP_MODE_TRANSMIT, ttcp_start(), ttcp::udp, and ttcp::verbose.
Referenced by wl_init_complete_cb().
00600 { 00601 00602 int c; 00603 int mode = TTCP_MODE_TRANSMIT; 00604 int verbose = 0; 00605 uint16_t buflen = 1024; 00606 uint16_t nbuf = 1024; 00607 uint16_t port = 2000; 00608 int udp = 0; 00609 struct ip_addr addr = { 0 }; 00610 00611 optind = 1; 00612 while ((c = getopt(argc, argv, "utrl:n:p:v")) != -1) { 00613 switch (c) { 00614 case 't': 00615 mode = TTCP_MODE_TRANSMIT; 00616 break; 00617 case 'r': 00618 mode = TTCP_MODE_RECEIVE; 00619 break; 00620 case 'l': 00621 buflen = atoi(optarg); 00622 break; 00623 case 'v': 00624 verbose = 1; 00625 break; 00626 case 'n': 00627 nbuf = atoi(optarg); 00628 break; 00629 case 'u': 00630 udp = 1; 00631 break; 00632 case 'p': 00633 port = atoi(optarg); 00634 break; 00635 } 00636 } 00637 00638 if (mode == TTCP_MODE_TRANSMIT) { 00639 if (optind >= argc) { 00640 printk("%s", usage); 00641 return CMD_DONE; 00642 } 00643 00644 addr = str2ip(argv[optind]); 00645 if (!addr.addr) { 00646 printk("%s", usage); 00647 return CMD_DONE; 00648 } 00649 } 00650 00651 if (ttcp_start(addr, port, NULL, NULL, mode, nbuf, buflen, udp, 00652 verbose)) 00653 return CMD_DONE; 00654 00655 return CMD_DONE; 00656 }