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 do { \ 13 if (sh) { \ 14 shell_print_impl(sh, fmt, ##__VA_ARGS__); \ 15 } else { \ 16 printk(fmt, ##__VA_ARGS__); \ 17 } \ 18 } while (false) 19 20 #define PR_SHELL(sh, fmt, ...) \ 21 do { \ 22 if (sh) { \ 23 shell_print_impl(sh, fmt, ##__VA_ARGS__); \ 24 } else { \ 25 printk(fmt, ##__VA_ARGS__); \ 26 } \ 27 } while (false) 28 29 #define PR_ERROR(fmt, ...) \ 30 do { \ 31 if (sh) { \ 32 shell_error_impl(sh, fmt, ##__VA_ARGS__); \ 33 } else { \ 34 printk(fmt, ##__VA_ARGS__); \ 35 } \ 36 } while (false) 37 38 #define PR_INFO(fmt, ...) \ 39 do { \ 40 if (sh) { \ 41 shell_info_impl(sh, fmt, ##__VA_ARGS__); \ 42 } else { \ 43 printk(fmt, ##__VA_ARGS__); \ 44 } \ 45 } while (false) 46 47 #define PR_WARNING(fmt, ...) \ 48 do { \ 49 if (sh) { \ 50 shell_warn_impl(sh, fmt, ##__VA_ARGS__); \ 51 } else { \ 52 printk(fmt, ##__VA_ARGS__); \ 53 } \ 54 } while (false) 55 56 #include "net_private.h" 57 #include "../ip/ipv6.h" 58 59 struct net_shell_user_data { 60 const struct shell *sh; 61 void *user_data; 62 }; 63 64 #if !defined(NET_VLAN_MAX_COUNT) 65 #define MAX_IFACE_COUNT NET_IF_MAX_CONFIGS 66 #else 67 #define MAX_IFACE_COUNT NET_VLAN_MAX_COUNT 68 #endif 69 70 #if defined(CONFIG_NET_IPV6) && !defined(CONFIG_NET_IPV4) 71 #define ADDR_LEN NET_IPV6_ADDR_LEN 72 #elif defined(CONFIG_NET_IPV4) && !defined(CONFIG_NET_IPV6) 73 #define ADDR_LEN NET_IPV4_ADDR_LEN 74 #else 75 #define ADDR_LEN NET_IPV6_ADDR_LEN 76 #endif 77 78 #if defined(CONFIG_NET_SHELL_DYN_CMD_COMPLETION) 79 #define IFACE_DYN_CMD &iface_index 80 #else 81 #define IFACE_DYN_CMD NULL 82 #endif /* CONFIG_NET_SHELL_DYN_CMD_COMPLETION */ 83 84 const char *addrtype2str(enum net_addr_type addr_type); 85 const char *addrstate2str(enum net_addr_state addr_state); 86 void get_addresses(struct net_context *context, 87 char addr_local[], int local_len, 88 char addr_remote[], int remote_len); 89 void events_enable(void); 90 int get_iface_idx(const struct shell *sh, char *index_str); 91 const char *iface2str(struct net_if *iface, const char **extra); 92 void ipv6_frag_cb(struct net_ipv6_reassembly *reass, void *user_data); 93