Skip to content

Commit

Permalink
net: shell: Do not print DHCPv4 info if IPv4 is not available
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jukkar authored and dleach02 committed Mar 23, 2024
1 parent 6b9d01f commit 09abd85
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions subsys/net/lib/shell/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,18 +483,20 @@ static void iface_cb(struct net_if *iface, void *user_data)
#endif /* CONFIG_NET_IPV4 */

#if defined(CONFIG_NET_DHCPV4)
PR("DHCPv4 lease time : %u\n",
iface->config.dhcpv4.lease_time);
PR("DHCPv4 renew time : %u\n",
iface->config.dhcpv4.renewal_time);
PR("DHCPv4 server : %s\n",
net_sprint_ipv4_addr(&iface->config.dhcpv4.server_id));
PR("DHCPv4 requested : %s\n",
net_sprint_ipv4_addr(&iface->config.dhcpv4.requested_ip));
PR("DHCPv4 state : %s\n",
net_dhcpv4_state_name(iface->config.dhcpv4.state));
PR("DHCPv4 attempts : %d\n",
iface->config.dhcpv4.attempts);
if (net_if_flag_is_set(iface, NET_IF_IPV4)) {
PR("DHCPv4 lease time : %u\n",
iface->config.dhcpv4.lease_time);
PR("DHCPv4 renew time : %u\n",
iface->config.dhcpv4.renewal_time);
PR("DHCPv4 server : %s\n",
net_sprint_ipv4_addr(&iface->config.dhcpv4.server_id));
PR("DHCPv4 requested : %s\n",
net_sprint_ipv4_addr(&iface->config.dhcpv4.requested_ip));
PR("DHCPv4 state : %s\n",
net_dhcpv4_state_name(iface->config.dhcpv4.state));
PR("DHCPv4 attempts : %d\n",
iface->config.dhcpv4.attempts);
}
#endif /* CONFIG_NET_DHCPV4 */

#else
Expand Down

0 comments on commit 09abd85

Please sign in to comment.