Commit graph

83 commits

Author SHA1 Message Date
Georges Oates_Larsen 7fa6b53ac3 net: shell: Add IPv4 and IPv6 connectivity events
Add descriptions for recently introduced IPv4 and IPv6
connectivity events to the net event monitor.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2024-06-10 00:59:34 -07:00
Robert Lubos 3501d6e6d4 net: shell: ipv4: Add information about ACD
Print information in IPv4 shell whether address conflict detection is
enabled or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos a89dd1a6f6 net: shell: Add ACD events to the event monitor
Include new ACD events in the shell event monitor.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Kapil Bhatt 8a52b64875 net: shell: Add random MAC address generation
Add option for setting a random MAC address to
the net iface set_mac command. With random option
a random MAC address can be assigned to an interface.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-05-30 11:55:27 +01:00
Jukka Rissanen 3d1b8c6116 net: shell: Add command to show HTTP server information
The new command is "net http" which shows all services and
related resources defined in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 15:51:20 +02:00
Jukka Rissanen f9ac565f12 net: shell: Pretty print websocket output
Fixing the websocket command output to align the fields and
printing interface index instead of a pointer value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Jukka Rissanen bd496541d7 net: shell: Print ref count information for IPv4 and IPv6 addresses
When printing IPv4 and IPv6 address information in "net ipv4" and
"net ipv6" commands, print also reference count of the IP address.
This is useful for debugging purposes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen a7e332dc18 net: ipv6: Add Privacy Extension events to net_mgmt
Add events to be generated when privacy extension is enabled
or disabled, or when allow/deny filter is added or deleted.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen c741c524ae net: shell: Add information about IPv6 privacy extension
When executing "net iface" command, print current status of
IPv6 privacy extension if it is enabled in config file.

The "net ipv6 ..." command prints IPv6 privacy extension
information, and can add or delete IPv6 prefix filters.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen ce4a13ae79 net: ipv6: Generate an event for deprecated address
If IPv6 address expires and moves to deprecated state, then
send a mgmt event so that listeners can act on it.
One such action is to close a socket bound to that source address
so that the address can be released.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Konrad Derda 701b6aed4b net: shell: print interfaces per multicast route entry
This commit change a method of printing multicast routes by showing
all interfaces per entry instead of aggregating them by interface.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-04-17 14:39:35 +02:00
Jonathan Rico e3ff993000 Network: L2: remove IPSP
Remove IPSP support from the tree.

It has no maintainers, and is regularly broken. The fact that it's
nontrivial to set-up in linux makes it hard to fix reported issues.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-04-11 12:48:50 +02:00
Jukka Rissanen 78a0cfbd94 net: shell: capture: Set capture device if user did not use shell
If user created the capture device using the API and not via
the shell, then the device name was not set. Use the default
capture device in this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-04-04 17:02:11 +02:00
Jukka Rissanen 2064306d41 net: capture: Generate events when starting / stopping capture
The event NET_EVENT_CAPTURE_STARTED is generated when the
capture is enabled, and NET_EVENT_CAPTURE_STOPPED when capture
is disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-04-04 17:02:11 +02:00
Jukka Rissanen eff03ca071 net: shell: Add printout when hostname changes
Add hostname changed printout to event monitor. As the name
says, it is generated when the hostname of the device changes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-04-03 15:40:16 +01:00
Robert Lubos 8e2722e1ca net: Provide separate configs for TX/RX memory pool for variable bufs
Instead of having a single config specifying the memory pool size for
variable-sized net buffers, have a separate one for TX and RX for better
configuration granularity when optimizing memory usage of the
application.

Deprecate the old configuration but use its value as a default (for now)
for the new configs. This will need to change when the config is
deleted.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-03-29 15:56:07 -05:00
Jukka Rissanen 0de1a75f91 net: shell: Print multicast join status for iface cmd
Print information whether a multicast address is properly
joined to a multicast group when print addresses using
"net iface" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-28 09:41:38 +00:00
Jukka Rissanen 999c169d9d net: shell: Print VLAN name instead of interface type
As the interface type is always Virtual, no need to print it.
Print instead the name of the network interface as it is more
useful to the user.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-28 09:41:38 +00:00
Jukka Rissanen eb11a8af1c net: shell: Refactor VLAN configuration prints
Rework the way VLAN configuration is printed out.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-28 09:41:38 +00:00
Jukka Rissanen 09abd850d9 net: shell: Do not print DHCPv4 info if IPv4 is not available
If the network interface does not enable IPv4, then it is pointless
to print DHCPv4 information when invoking "iface" shell command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-22 21:00:37 -05:00
Pieter De Gendt e2f0b92fda net: lib: shell: Fix IPv6 neighbor build
When building net shell without IPv6 native support we can't use neighbor
support.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-03-08 10:02:02 +00:00
Pieter De Gendt 0db120abd4 net: lib: shell: iface: Fix when building ethernet without IP support
The count stack variable is also used when CONFIG_NET_L2_ETHERNET_MGMT is
enabled. Make sure it is available.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-03-06 15:23:52 -06:00
Florian La Roche e8b843b913 net: shell: keep event_mon_handler compatible to k_thread_entry_t
Nearly all other code places for k_thread_entry_t also keep
unused params in place to stay compatible with k_thread_entry_t.

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
2024-03-05 14:58:29 +00:00
Jukka Rissanen a943d7fd53 net: Convert various address loops to use ARRAY_FOR_EACH macro
Convert various networking subsystem files to use ARRAY_FOR_EACH
macro to make the looping more robust.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-03 18:58:29 +01:00
Jukka Rissanen 1b0f9e865e net: ipv4: Make netmask IPv4 address specific
The netmask should be tied to the IPv4 address instead of being
global for the network interface.

If there is only one IPv4 address specified to the network interface,
nothing changes from user point of view. But if there are more than
one IPv4 address / network interface, the netmask must be specified
to each address separately.

This means that net_if_ipv4_get_netmask() and net_if_ipv4_set_netmask()
functions should not be used as they only work reliably if there is
only one IPv4 address in the network interface.

The new net_if_ipv4_get_netmask_by_addr() and
net_if_ipv4_set_netmask_by_addr() functions should be used as they make
sure that the netmask is tied to correct IPv4 address in the network
interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-03 18:58:29 +01:00
Tomasz Bursztyka 4d48f066a1 net/shell: Fixing a trivial error code
As for adding an ipv6 address, removing one should return the same error
code when the network interface is not found.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2024-03-01 15:33:53 +01:00
Tomasz Bursztyka 366402a0c7 net/shell: Net shell has no mandatory support for IPv6 MLD
It's an optional support, and it should not select it by default.
Improving information message in case such support is disabled.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2024-03-01 15:33:53 +01:00
Jukka Rissanen bdfcc753c8 net: shell: Print mgmt socket information properly
The "net sockets" command did not print network management
socket information properly but claimed that the socket
was IPv4 one which it is not.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-28 09:39:27 +01:00
Pisit Sawangvonganan 7b8a9e1818 net: shell: ensure the shell sh is valid before call shell_printf
It is possible that the `sh` was not set before use.
This change adds a NULL check for `sh` in the following macros:
PR, PR_SHELL, PR_ERROR, PR_INFO, and PR_WARNING.
In case `sh` is NULL, the above macros will call `printk` instead.

Fixes #68793

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-02-26 11:41:03 +00:00
Mateusz Karlic bdd09558bb net: shell: ipv4: Add command to set gateway
Add a command `net ipv4 gateway` that allows
setting IPv4 gateway for an interface from net shell.

Signed-off-by: Mateusz Karlic <mkarlic@antmicro.com>
2024-02-26 11:53:56 +01:00
Jukka Rissanen 7da14d3129 net: shell: Clarify the name of the virtual interface
The net-shell printed virtual interface name so that it got
the impression it was the network interface name which is not
correct. Now the name is printed as "Virtual name" which is
unambiguous.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-29 10:58:33 +00:00
Robert Lubos 2c70c5d74a net: shell: Implement DHCPv4 server shell commands
Implement DHCPv4 shell module, which allows to start/stop DHCPv4 server
operation, and print server status (address leases).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Jukka Rissanen 38cacc7f63 net: shell: Make the thread name longer for sockets command
The thread name output field was a bit too short in "net sockets"
command, so make it 25 char long.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen d3bfef8399 net: shell: Do not crash if no sockets are found
The "net sockets" command was not checking if there is any
sockets in the system before trying to access them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen 6033161216 net: shell: Avoid gcc warning print with string catenation
gcc prints this warning message

'strncat' specified bound 1 equals source length [-Wstringop-overflow=]
   58 |                 strncat(fd, "C", 1);

There was no error in the code but avoid the warning by not using
strncat().

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-16 10:00:45 +01:00
Jukka Rissanen f5e95852ce net: shell: Add sockets services prints
The socket services users to "net sockets" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-16 10:00:45 +01:00
Jukka Rissanen 1a0b6745bd net: shell: Print more Ethernet statistics
Various Ethernet error statistics values were not printed
by the shell.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-22 09:53:26 +01:00
Jukka Rissanen 477a4a5d34 net: shell: Rename the common.h to be more unique
As the common.h is only meant to be used by the network
shell files, rename it to be more descriptive in order to
avoid possible conflicts with any other common.h file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-13 20:13:39 +01:00
Pieter De Gendt 35761f724d net: lib: shell: Add CoAP descriptions to event monitor
Add a description for each CoAP event on L4.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 10:34:39 +00:00
Robert Lubos 839553a7d9 net: shell: ping: Fix double packet unref in ping reply handler
This was somehow missed, but since ICMP rework, message handlers should
not dereference the packet, as it's done by the ICMP lib.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-04 14:30:26 +01:00
Ibe Van de Veire 1d0f47b005 net: ip: igmp: add igmpv3 support
Added igmpv3 support based on the already existing structure for igmpv2.
The already existing api is not modified to prevent breaking exisiting
applications.

Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
2023-11-21 15:50:31 +01:00
Robert Lubos 8a75a4b9db net: shell: Fix array indexing with dynamic iface command
Network interface numbering starts from 1, therefore when accessing
help/index array, the interface index should not be used directly, but
rather decremented by 1, to avoid out-of-bound access on those arrays.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:47 +01:00
Jukka Rissanen b0d0f60389 net: shell: Print device and wifi information for iface cmd
If the interface is WiFi one, then print information about it.
Also the device information is useful to know so print device
name corresponding to the network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-06 15:51:36 -06:00
Jukka Rissanen e44de3e381 net: shell: Join IPv6 mcast group if needed
If user adds IPv6 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-27 10:52:48 +02:00
Jukka Rissanen 1467d7fa7b net: shell: Join IPv4 mcast group if needed
If user adds IPv4 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.

Fixes #64389

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-27 10:52:48 +02:00
Jukka Rissanen 8a58104396 net: shell: Add net-sockets command
The new "net sockets" command will utilize the object core
support to track and show information about BSD sockets that
are created in the system. This command is able to show info
for all network sockets (native, offloaded etc) in the system.

Example of the output of the new command:

uart:~$ net sockets
 Creator  Name       Flags  FD   Lifetime (ms) Sent  Received

    main  af_inet46  6ST    0    3260          819   498
    main  af_inet46  4ST    1    2110          469   142
    main  af_inet46  6DU    2    2110          9941  9941
    main  af_inet46  4DU    3    2110          1375  621

4 active sockets found.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 11:11:30 +02:00
Robert Lubos c6fd2b2d44 net: shell: Fix unexpected timeout on loopback ping
In case ping is sent to own address, the request is looped back to the
stack and served before ping work had a chance to reschedule. In result,
when the final ping reply has been server, and ping operation finalized
with `ping_done()`, the work was rescheduled one last time, causing the
ping timeout to be reported. Fix this by rescheduling the work before
sending the actual request, so that the reply handler can cancel the
work properly in such case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-24 09:05:20 +02:00
Jukka Rissanen 63d9c8fa06 net: shell: Print v4-mapping-to-v6 address properly
The remote address of the connection is checked whether
it is v4-mapping-to-v6 address in which case we should
print it such.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Robert Lubos 05361edb1b net: shell: Fix TCP connect behavior
Fix two issues with net tcp command:

* The `net tcp` commands are still based on net_context API. For TCP,
  the API caller (net shell) should add one extra reference to the
  allocated net context, to prevent premature context release in case of
  connection teardown. Currently that was not the case, and the context
  was released too early, resulting in missing final ACK from the Zephyr
  side on connection close.

* The net context API should not be called from the registered connect
  callback, as this creates a temporary deadlock situation. The
  net_context_connect() function blocks until the connection is
  established, or an error or timeout occurs. For that time the
  net_context mutex is being locked. In case of connection error (for
  example after receiving RST packet) the connect callback is called,
  indicating an error. If we try to call net_context API from within, a
  deadlock situation takes place, as the context mutex is still locked
  by the net_context_connect() (called from the shell thread). This
  blocks the further execution of the TCP stack and can result in an
  unexpected behavior (like for example retransmitting the SYN packet,
  which takes place from yet another thread, TCP work queue).
  Fix this, by releasing the net context not from the callback directly,
  but based on the return value from net_context_connect().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-23 16:08:37 +02:00
Yong Cong Sin 1f60c1379e net: shell: fix compilation errors
`suspend.c` and `resume.c` are missing the `zephyr/pm/device.h`
add that to fix compilation warning

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-23 14:20:23 +01:00