1 /*
2  * Copyright (c) 2016 Intel Corporation
3  * Copyright (c) 2023 Nordic Semiconductor ASA
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <zephyr/shell/shell.h>
9 #include <zephyr/net/net_ip.h>
10 
11 #define PR(fmt, ...)						\
12 	shell_fprintf(sh, SHELL_NORMAL, fmt, ##__VA_ARGS__)
13 
14 #define PR_SHELL(sh, fmt, ...)				\
15 	shell_fprintf(sh, SHELL_NORMAL, fmt, ##__VA_ARGS__)
16 
17 #define PR_ERROR(fmt, ...)					\
18 	shell_fprintf(sh, SHELL_ERROR, fmt, ##__VA_ARGS__)
19 
20 #define PR_INFO(fmt, ...)					\
21 	shell_fprintf(sh, SHELL_INFO, fmt, ##__VA_ARGS__)
22 
23 #define PR_WARNING(fmt, ...)					\
24 	shell_fprintf(sh, SHELL_WARNING, fmt, ##__VA_ARGS__)
25 
26 #include "net_private.h"
27 #include "../ip/ipv6.h"
28 
29 struct net_shell_user_data {
30 	const struct shell *sh;
31 	void *user_data;
32 };
33 
34 #if !defined(NET_VLAN_MAX_COUNT)
35 #define MAX_IFACE_COUNT NET_IF_MAX_CONFIGS
36 #else
37 #define MAX_IFACE_COUNT NET_VLAN_MAX_COUNT
38 #endif
39 
40 #if defined(CONFIG_NET_IPV6) && !defined(CONFIG_NET_IPV4)
41 #define ADDR_LEN NET_IPV6_ADDR_LEN
42 #elif defined(CONFIG_NET_IPV4) && !defined(CONFIG_NET_IPV6)
43 #define ADDR_LEN NET_IPV4_ADDR_LEN
44 #else
45 #define ADDR_LEN NET_IPV6_ADDR_LEN
46 #endif
47 
48 #if defined(CONFIG_NET_SHELL_DYN_CMD_COMPLETION)
49 #define IFACE_DYN_CMD &iface_index
50 #else
51 #define IFACE_DYN_CMD NULL
52 #endif /* CONFIG_NET_SHELL_DYN_CMD_COMPLETION */
53 
54 const char *addrtype2str(enum net_addr_type addr_type);
55 const char *addrstate2str(enum net_addr_state addr_state);
56 void get_addresses(struct net_context *context,
57 		   char addr_local[], int local_len,
58 		   char addr_remote[], int remote_len);
59 void events_enable(void);
60 int get_iface_idx(const struct shell *sh, char *index_str);
61 const char *iface2str(struct net_if *iface, const char **extra);
62 void ipv6_frag_cb(struct net_ipv6_reassembly *reass, void *user_data);
63