net: shell: Make shell commands non-static to allow reuse.

Some applications may want to reuse implementations of these
commands for debugging/diagnostics purpose even if they don't
use net shell per se, or implement an alternative shell.

Jira: ZEP-2064

Change-Id: I48cb66ccc41bd41a75a4eb8eb3c366316ec5a096
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
Paul Sokolovsky 2017-04-27 15:35:30 +03:00 committed by Jukka Rissanen
commit ff3b019054
2 changed files with 37 additions and 24 deletions

View file

@ -620,7 +620,7 @@ buf:
/* Put the actual shell commands after this */ /* Put the actual shell commands after this */
static int shell_cmd_allocs(int argc, char *argv[]) int net_shell_cmd_allocs(int argc, char *argv[])
{ {
ARG_UNUSED(argc); ARG_UNUSED(argc);
ARG_UNUSED(argv); ARG_UNUSED(argv);
@ -636,7 +636,7 @@ static int shell_cmd_allocs(int argc, char *argv[])
return 0; return 0;
} }
static int shell_cmd_conn(int argc, char *argv[]) int net_shell_cmd_conn(int argc, char *argv[])
{ {
int count = 0; int count = 0;
@ -793,7 +793,7 @@ static void print_dns_info(struct dns_resolve_context *ctx)
} }
#endif #endif
static int shell_cmd_dns(int argc, char *argv[]) int net_shell_cmd_dns(int argc, char *argv[])
{ {
#if defined(CONFIG_DNS_RESOLVER) #if defined(CONFIG_DNS_RESOLVER)
#define DNS_TIMEOUT 2000 /* ms */ #define DNS_TIMEOUT 2000 /* ms */
@ -881,7 +881,7 @@ static int shell_cmd_dns(int argc, char *argv[])
return 0; return 0;
} }
static int shell_cmd_iface(int argc, char *argv[]) int net_shell_cmd_iface(int argc, char *argv[])
{ {
ARG_UNUSED(argc); ARG_UNUSED(argc);
ARG_UNUSED(argv); ARG_UNUSED(argv);
@ -972,7 +972,7 @@ static void context_info(struct net_context *context, void *user_data)
#endif /* CONFIG_NET_CONTEXT_NET_PKT_POOL */ #endif /* CONFIG_NET_CONTEXT_NET_PKT_POOL */
} }
static int shell_cmd_mem(int argc, char *argv[]) int net_shell_cmd_mem(int argc, char *argv[])
{ {
struct k_mem_slab *rx, *tx; struct k_mem_slab *rx, *tx;
struct net_buf_pool *rx_data, *tx_data; struct net_buf_pool *rx_data, *tx_data;
@ -1059,7 +1059,7 @@ static void nbr_cb(struct net_nbr *nbr, void *user_data)
} }
#endif #endif
static int shell_cmd_nbr(int argc, char *argv[]) int net_shell_cmd_nbr(int argc, char *argv[])
{ {
#if defined(CONFIG_NET_IPV6) #if defined(CONFIG_NET_IPV6)
int count = 0; int count = 0;
@ -1233,7 +1233,7 @@ static int _ping_ipv4(char *host)
#endif /* CONFIG_NET_IPV4 */ #endif /* CONFIG_NET_IPV4 */
#endif /* CONFIG_NET_IPV6 || CONFIG_NET_IPV4 */ #endif /* CONFIG_NET_IPV6 || CONFIG_NET_IPV4 */
static int shell_cmd_ping(int argc, char *argv[]) int net_shell_cmd_ping(int argc, char *argv[])
{ {
char *host; char *host;
int ret; int ret;
@ -1276,7 +1276,7 @@ wait_reply:
return 0; return 0;
} }
static int shell_cmd_route(int argc, char *argv[]) int net_shell_cmd_route(int argc, char *argv[])
{ {
ARG_UNUSED(argc); ARG_UNUSED(argc);
ARG_UNUSED(argv); ARG_UNUSED(argv);
@ -1299,7 +1299,7 @@ extern char _main_stack[];
extern char _interrupt_stack[]; extern char _interrupt_stack[];
#endif #endif
static int shell_cmd_stacks(int argc, char *argv[]) int net_shell_cmd_stacks(int argc, char *argv[])
{ {
#if defined(CONFIG_INIT_STACKS) #if defined(CONFIG_INIT_STACKS)
unsigned int stack_offset, pcnt, unused; unsigned int stack_offset, pcnt, unused;
@ -1346,7 +1346,7 @@ static int shell_cmd_stacks(int argc, char *argv[])
return 0; return 0;
} }
static int shell_cmd_stats(int argc, char *argv[]) int net_shell_cmd_stats(int argc, char *argv[])
{ {
ARG_UNUSED(argc); ARG_UNUSED(argc);
ARG_UNUSED(argv); ARG_UNUSED(argv);
@ -1528,7 +1528,7 @@ static void tcp_sent_cb(struct net_context *context,
} }
#endif #endif
static int shell_cmd_tcp(int argc, char *argv[]) int net_shell_cmd_tcp(int argc, char *argv[])
{ {
#if defined(CONFIG_NET_TCP) #if defined(CONFIG_NET_TCP)
int arg = 1; int arg = 1;
@ -1642,7 +1642,7 @@ static int shell_cmd_tcp(int argc, char *argv[])
return 0; return 0;
} }
static int shell_cmd_help(int argc, char *argv[]) int net_shell_cmd_help(int argc, char *argv[])
{ {
ARG_UNUSED(argc); ARG_UNUSED(argc);
ARG_UNUSED(argv); ARG_UNUSED(argv);
@ -1670,18 +1670,18 @@ static int shell_cmd_help(int argc, char *argv[])
static struct shell_cmd net_commands[] = { static struct shell_cmd net_commands[] = {
/* Keep the commands in alphabetical order */ /* Keep the commands in alphabetical order */
{ "allocs", shell_cmd_allocs, NULL }, { "allocs", net_shell_cmd_allocs, NULL },
{ "conn", shell_cmd_conn, NULL }, { "conn", net_shell_cmd_conn, NULL },
{ "dns", shell_cmd_dns, NULL }, { "dns", net_shell_cmd_dns, NULL },
{ "help", shell_cmd_help, NULL }, { "help", net_shell_cmd_help, NULL },
{ "iface", shell_cmd_iface, NULL }, { "iface", net_shell_cmd_iface, NULL },
{ "mem", shell_cmd_mem, NULL }, { "mem", net_shell_cmd_mem, NULL },
{ "nbr", shell_cmd_nbr, NULL }, { "nbr", net_shell_cmd_nbr, NULL },
{ "ping", shell_cmd_ping, NULL }, { "ping", net_shell_cmd_ping, NULL },
{ "route", shell_cmd_route, NULL }, { "route", net_shell_cmd_route, NULL },
{ "stacks", shell_cmd_stacks, NULL }, { "stacks", net_shell_cmd_stacks, NULL },
{ "stats", shell_cmd_stats, NULL }, { "stats", net_shell_cmd_stats, NULL },
{ "tcp", shell_cmd_tcp, NULL }, { "tcp", net_shell_cmd_tcp, NULL },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };

View file

@ -19,4 +19,17 @@ void net_shell_init(void);
#define net_shell_init(...) #define net_shell_init(...)
#endif /* CONFIG_NET_SHELL */ #endif /* CONFIG_NET_SHELL */
int net_shell_cmd_allocs(int argc, char *argv[]);
int net_shell_cmd_conn(int argc, char *argv[]);
int net_shell_cmd_dns(int argc, char *argv[]);
int net_shell_cmd_iface(int argc, char *argv[]);
int net_shell_cmd_mem(int argc, char *argv[]);
int net_shell_cmd_nbr(int argc, char *argv[]);
int net_shell_cmd_ping(int argc, char *argv[]);
int net_shell_cmd_route(int argc, char *argv[]);
int net_shell_cmd_stacks(int argc, char *argv[]);
int net_shell_cmd_stats(int argc, char *argv[]);
int net_shell_cmd_tcp(int argc, char *argv[]);
int net_shell_cmd_help(int argc, char *argv[]);
#endif /* __NET_SHELL_H */ #endif /* __NET_SHELL_H */