Skip to content

Commit

Permalink
net: shell: Allow user to disable not used commands
Browse files Browse the repository at this point in the history
User can set CONFIG_NET_SHELL_SHOW_DISABLED_COMMANDS=n to prevent
unused net-shell commands from showing. This can save flash as
the disabled commands will not be shown in net-shell listing.

Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
jukkar authored and fabiobaltieri committed Sep 23, 2024
1 parent 9d9398f commit 8aab3ca
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 27 deletions.
133 changes: 131 additions & 2 deletions subsys/net/ip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,136 @@ config NET_SHELL
Activate shell module that provides network commands like
ping to the console.

if NET_SHELL

config NET_SHELL_SHOW_DISABLED_COMMANDS
bool "Show disabled command information"
default y
help
By default all the network shell commands are there and the
command itself will print out that it is disabled and how to
enable it. If you do not need this and only want to see the
commands that you can actively use, then you can save a little
bit of flash by not showing commands that cannot be used with
current configuration.

config NET_SHELL_ETHERNET_SUPPORTED
bool "Ethernet related configuration"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_L2_ETHERNET

config NET_SHELL_CAPTURE_SUPPORTED
bool "Packet capture configuration"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_CAPTURE

config NET_SHELL_DHCPV4_SUPPORTED
bool "DHCPv4 start / stop"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_DHCPV4_SERVER || NET_DHCPV4

config NET_SHELL_DHCPV6_SUPPORTED
bool "DHCPv6 start / stop"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_DHCPV6

config NET_SHELL_DNS_RESOLVER_SUPPORTED
bool "DNS resolver"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || DNS_RESOLVER

config NET_SHELL_EVENT_MONITOR_SUPPORTED
bool "Network management event monitoring configuration"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_MGMT_EVENT_MONITOR

config NET_SHELL_GPTP_SUPPORTED
bool "gPTP monitoring"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_GPTP

config NET_SHELL_HTTP_SERVER_SUPPORTED
bool "HTTP server status"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || HTTP_SERVER

config NET_SHELL_CONNECTION_MANAGER_SUPPORTED
bool "Connection manager status"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_CONNECTION_MANAGER

config NET_SHELL_IPV4_SUPPORTED
bool "IPv4 config"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_NATIVE_IPV4 && NET_IPV4)

config NET_SHELL_IPV6_SUPPORTED
bool "IPv6 config"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_NATIVE_IPV6 && NET_IPV6)

config NET_SHELL_IP_SUPPORTED
bool "Generic IP utilities"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_IP

config NET_SHELL_PKT_ALLOC_SUPPORTED
bool "Packet allocation monitoring"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_DEBUG_NET_PKT_ALLOC

config NET_SHELL_PPP_SUPPORTED
bool "PPP config"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_L2_PPP

config NET_SHELL_POWER_MANAGEMENT_SUPPORTED
bool "Network power management resume / suspend"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_POWER_MANAGEMENT

config NET_SHELL_ROUTE_SUPPORTED
bool "IP routing config"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_ROUTE && NET_NATIVE)

config NET_SHELL_SOCKETS_SERVICE_SUPPORTED
bool "Socket service status"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_SOCKETS_SERVICE

config NET_SHELL_STATISTICS_SUPPORTED
bool "Network statistics monitoring"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_STATISTICS

config NET_SHELL_TCP_SUPPORTED
bool "Send / receive TCP data"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_NATIVE_TCP && NET_TCP)

config NET_SHELL_UDP_SUPPORTED
bool "Send / receive UDP data"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_NATIVE_UDP && NET_UDP)

config NET_SHELL_VIRTUAL_SUPPORTED
bool "Virtual network interface management"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_L2_VIRTUAL

config NET_SHELL_VLAN_SUPPORTED
bool "Virtual LAN config"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_VLAN

config NET_SHELL_WEBSOCKET_SUPPORTED
bool "Websocket client status"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || WEBSOCKET_CLIENT

config NET_SHELL_DYN_CMD_COMPLETION
bool "Network shell dynamic command completion"
depends on NET_SHELL
default y
help
Enable various net-shell command to support dynamic command
Expand All @@ -191,12 +318,14 @@ config NET_SHELL_DYN_CMD_COMPLETION

config NET_SHELL_REQUIRE_TX_THREAD
bool
depends on NET_SHELL && (SHELL_BACKEND_TELNET || SHELL_BACKEND_MQTT)
depends on SHELL_BACKEND_TELNET || SHELL_BACKEND_MQTT
default y if NET_ARP
help
Hidden symbol indicating that network shell requires separate TX
thread due to possible deadlocks during shell/net stack operations.

endif # NET_SHELL

config NET_TC_TX_COUNT
int "How many Tx traffic classes to have for each network device"
default 1 if USERSPACE || USB_DEVICE_NETWORK || \
Expand Down
50 changes: 25 additions & 25 deletions subsys/net/lib/shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ zephyr_library_include_directories(. ${ZEPHYR_BASE}/subsys/net/lib)
zephyr_library_include_directories(. ${ZEPHYR_BASE}/subsys/net/ip)
zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS mbedTLS)

zephyr_library_sources(allocs.c)
zephyr_library_sources(arp.c)
zephyr_library_sources(capture.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_PKT_ALLOC_SUPPORTED allocs.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_ETHERNET_SUPPORTED arp.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_CAPTURE_SUPPORTED capture.c)
zephyr_library_sources(conn.c)
zephyr_library_sources(dhcpv4.c)
zephyr_library_sources(dhcpv6.c)
zephyr_library_sources(dns.c)
zephyr_library_sources(events.c)
zephyr_library_sources(gptp.c)
zephyr_library_sources(http.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_DHCPV4_SUPPORTED dhcpv4.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_DHCPV6_SUPPORTED dhcpv6.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_DNS_RESOLVER_SUPPORTED dns.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_EVENT_MONITOR_SUPPORTED events.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_GPTP_SUPPORTED gptp.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_HTTP_SERVER_SUPPORTED http.c)
zephyr_library_sources(iface.c)
zephyr_library_sources(cm.c)
zephyr_library_sources(ipv4.c)
zephyr_library_sources(ipv6.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_CONNECTION_MANAGER_SUPPORTED cm.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_IPV4_SUPPORTED ipv4.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_IPV6_SUPPORTED ipv6.c)
zephyr_library_sources(mem.c)
zephyr_library_sources(nbr.c)
zephyr_library_sources(ping.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_IPV6_SUPPORTED nbr.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_IP_SUPPORTED ping.c)
zephyr_library_sources(pkt.c)
zephyr_library_sources(ppp.c)
zephyr_library_sources(resume.c)
zephyr_library_sources(route.c)
zephyr_library_sources(sockets.c)
zephyr_library_sources(stats.c)
zephyr_library_sources(suspend.c)
zephyr_library_sources(tcp.c)
zephyr_library_sources(udp.c)
zephyr_library_sources(virtual.c)
zephyr_library_sources(vlan.c)
zephyr_library_sources(websocket.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_PPP_SUPPORTED ppp.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_POWER_MANAGEMENT_SUPPORTED resume.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_ROUTE_SUPPORTED route.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_SOCKETS_SERVICE_SUPPORTED sockets.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_STATISTICS_SUPPORTED stats.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_POWER_MANAGEMENT_SUPPORTED suspend.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_TCP_SUPPORTED tcp.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_UDP_SUPPORTED udp.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_VIRTUAL_SUPPORTED virtual.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_VLAN_SUPPORTED vlan.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_WEBSOCKET_SUPPORTED websocket.c)

0 comments on commit 8aab3ca

Please sign in to comment.