Skip to content

Commit 8aab3ca

Browse files
jukkarfabiobaltieri
authored andcommitted
net: shell: Allow user to disable not used commands
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]>
1 parent 9d9398f commit 8aab3ca

File tree

2 files changed

+156
-27
lines changed

2 files changed

+156
-27
lines changed

subsys/net/ip/Kconfig

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,136 @@ config NET_SHELL
174174
Activate shell module that provides network commands like
175175
ping to the console.
176176

177+
if NET_SHELL
178+
179+
config NET_SHELL_SHOW_DISABLED_COMMANDS
180+
bool "Show disabled command information"
181+
default y
182+
help
183+
By default all the network shell commands are there and the
184+
command itself will print out that it is disabled and how to
185+
enable it. If you do not need this and only want to see the
186+
commands that you can actively use, then you can save a little
187+
bit of flash by not showing commands that cannot be used with
188+
current configuration.
189+
190+
config NET_SHELL_ETHERNET_SUPPORTED
191+
bool "Ethernet related configuration"
192+
default y
193+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_L2_ETHERNET
194+
195+
config NET_SHELL_CAPTURE_SUPPORTED
196+
bool "Packet capture configuration"
197+
default y
198+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_CAPTURE
199+
200+
config NET_SHELL_DHCPV4_SUPPORTED
201+
bool "DHCPv4 start / stop"
202+
default y
203+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_DHCPV4_SERVER || NET_DHCPV4
204+
205+
config NET_SHELL_DHCPV6_SUPPORTED
206+
bool "DHCPv6 start / stop"
207+
default y
208+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_DHCPV6
209+
210+
config NET_SHELL_DNS_RESOLVER_SUPPORTED
211+
bool "DNS resolver"
212+
default y
213+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || DNS_RESOLVER
214+
215+
config NET_SHELL_EVENT_MONITOR_SUPPORTED
216+
bool "Network management event monitoring configuration"
217+
default y
218+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_MGMT_EVENT_MONITOR
219+
220+
config NET_SHELL_GPTP_SUPPORTED
221+
bool "gPTP monitoring"
222+
default y
223+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_GPTP
224+
225+
config NET_SHELL_HTTP_SERVER_SUPPORTED
226+
bool "HTTP server status"
227+
default y
228+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || HTTP_SERVER
229+
230+
config NET_SHELL_CONNECTION_MANAGER_SUPPORTED
231+
bool "Connection manager status"
232+
default y
233+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_CONNECTION_MANAGER
234+
235+
config NET_SHELL_IPV4_SUPPORTED
236+
bool "IPv4 config"
237+
default y
238+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_NATIVE_IPV4 && NET_IPV4)
239+
240+
config NET_SHELL_IPV6_SUPPORTED
241+
bool "IPv6 config"
242+
default y
243+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_NATIVE_IPV6 && NET_IPV6)
244+
245+
config NET_SHELL_IP_SUPPORTED
246+
bool "Generic IP utilities"
247+
default y
248+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_IP
249+
250+
config NET_SHELL_PKT_ALLOC_SUPPORTED
251+
bool "Packet allocation monitoring"
252+
default y
253+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_DEBUG_NET_PKT_ALLOC
254+
255+
config NET_SHELL_PPP_SUPPORTED
256+
bool "PPP config"
257+
default y
258+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_L2_PPP
259+
260+
config NET_SHELL_POWER_MANAGEMENT_SUPPORTED
261+
bool "Network power management resume / suspend"
262+
default y
263+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_POWER_MANAGEMENT
264+
265+
config NET_SHELL_ROUTE_SUPPORTED
266+
bool "IP routing config"
267+
default y
268+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_ROUTE && NET_NATIVE)
269+
270+
config NET_SHELL_SOCKETS_SERVICE_SUPPORTED
271+
bool "Socket service status"
272+
default y
273+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_SOCKETS_SERVICE
274+
275+
config NET_SHELL_STATISTICS_SUPPORTED
276+
bool "Network statistics monitoring"
277+
default y
278+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_STATISTICS
279+
280+
config NET_SHELL_TCP_SUPPORTED
281+
bool "Send / receive TCP data"
282+
default y
283+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_NATIVE_TCP && NET_TCP)
284+
285+
config NET_SHELL_UDP_SUPPORTED
286+
bool "Send / receive UDP data"
287+
default y
288+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || (NET_NATIVE_UDP && NET_UDP)
289+
290+
config NET_SHELL_VIRTUAL_SUPPORTED
291+
bool "Virtual network interface management"
292+
default y
293+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_L2_VIRTUAL
294+
295+
config NET_SHELL_VLAN_SUPPORTED
296+
bool "Virtual LAN config"
297+
default y
298+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_VLAN
299+
300+
config NET_SHELL_WEBSOCKET_SUPPORTED
301+
bool "Websocket client status"
302+
default y
303+
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || WEBSOCKET_CLIENT
304+
177305
config NET_SHELL_DYN_CMD_COMPLETION
178306
bool "Network shell dynamic command completion"
179-
depends on NET_SHELL
180307
default y
181308
help
182309
Enable various net-shell command to support dynamic command
@@ -191,12 +318,14 @@ config NET_SHELL_DYN_CMD_COMPLETION
191318

192319
config NET_SHELL_REQUIRE_TX_THREAD
193320
bool
194-
depends on NET_SHELL && (SHELL_BACKEND_TELNET || SHELL_BACKEND_MQTT)
321+
depends on SHELL_BACKEND_TELNET || SHELL_BACKEND_MQTT
195322
default y if NET_ARP
196323
help
197324
Hidden symbol indicating that network shell requires separate TX
198325
thread due to possible deadlocks during shell/net stack operations.
199326

327+
endif # NET_SHELL
328+
200329
config NET_TC_TX_COUNT
201330
int "How many Tx traffic classes to have for each network device"
202331
default 1 if USERSPACE || USB_DEVICE_NETWORK || \

subsys/net/lib/shell/CMakeLists.txt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@ zephyr_library_include_directories(. ${ZEPHYR_BASE}/subsys/net/lib)
66
zephyr_library_include_directories(. ${ZEPHYR_BASE}/subsys/net/ip)
77
zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS mbedTLS)
88

9-
zephyr_library_sources(allocs.c)
10-
zephyr_library_sources(arp.c)
11-
zephyr_library_sources(capture.c)
9+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_PKT_ALLOC_SUPPORTED allocs.c)
10+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_ETHERNET_SUPPORTED arp.c)
11+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_CAPTURE_SUPPORTED capture.c)
1212
zephyr_library_sources(conn.c)
13-
zephyr_library_sources(dhcpv4.c)
14-
zephyr_library_sources(dhcpv6.c)
15-
zephyr_library_sources(dns.c)
16-
zephyr_library_sources(events.c)
17-
zephyr_library_sources(gptp.c)
18-
zephyr_library_sources(http.c)
13+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_DHCPV4_SUPPORTED dhcpv4.c)
14+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_DHCPV6_SUPPORTED dhcpv6.c)
15+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_DNS_RESOLVER_SUPPORTED dns.c)
16+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_EVENT_MONITOR_SUPPORTED events.c)
17+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_GPTP_SUPPORTED gptp.c)
18+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_HTTP_SERVER_SUPPORTED http.c)
1919
zephyr_library_sources(iface.c)
20-
zephyr_library_sources(cm.c)
21-
zephyr_library_sources(ipv4.c)
22-
zephyr_library_sources(ipv6.c)
20+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_CONNECTION_MANAGER_SUPPORTED cm.c)
21+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_IPV4_SUPPORTED ipv4.c)
22+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_IPV6_SUPPORTED ipv6.c)
2323
zephyr_library_sources(mem.c)
24-
zephyr_library_sources(nbr.c)
25-
zephyr_library_sources(ping.c)
24+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_IPV6_SUPPORTED nbr.c)
25+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_IP_SUPPORTED ping.c)
2626
zephyr_library_sources(pkt.c)
27-
zephyr_library_sources(ppp.c)
28-
zephyr_library_sources(resume.c)
29-
zephyr_library_sources(route.c)
30-
zephyr_library_sources(sockets.c)
31-
zephyr_library_sources(stats.c)
32-
zephyr_library_sources(suspend.c)
33-
zephyr_library_sources(tcp.c)
34-
zephyr_library_sources(udp.c)
35-
zephyr_library_sources(virtual.c)
36-
zephyr_library_sources(vlan.c)
37-
zephyr_library_sources(websocket.c)
27+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_PPP_SUPPORTED ppp.c)
28+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_POWER_MANAGEMENT_SUPPORTED resume.c)
29+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_ROUTE_SUPPORTED route.c)
30+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_SOCKETS_SERVICE_SUPPORTED sockets.c)
31+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_STATISTICS_SUPPORTED stats.c)
32+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_POWER_MANAGEMENT_SUPPORTED suspend.c)
33+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_TCP_SUPPORTED tcp.c)
34+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_UDP_SUPPORTED udp.c)
35+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_VIRTUAL_SUPPORTED virtual.c)
36+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_VLAN_SUPPORTED vlan.c)
37+
zephyr_library_sources_ifdef(CONFIG_NET_SHELL_WEBSOCKET_SUPPORTED websocket.c)

0 commit comments

Comments
 (0)