1 /*
2  * Copyright (c) 2017 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/logging/log.h>
8 LOG_MODULE_REGISTER(net_telnet_sample, LOG_LEVEL_DBG);
9 
10 #include <zephyr/kernel.h>
11 #include <zephyr/linker/sections.h>
12 #include <errno.h>
13 #include <stdio.h>
14 
15 #include <zephyr/net/net_core.h>
16 #include <zephyr/net/net_if.h>
17 #include <zephyr/net/net_mgmt.h>
18 
19 #include "net_sample_common.h"
20 
21 #if defined(CONFIG_NET_IPV6)
22 #define MCAST_IP6ADDR "ff84::2"
23 
setup_ipv6(void)24 static void setup_ipv6(void)
25 {
26 	struct in6_addr addr;
27 	struct net_if *iface = net_if_get_default();
28 
29 	if (net_addr_pton(AF_INET6, MCAST_IP6ADDR, &addr)) {
30 		LOG_ERR("Invalid address: %s", MCAST_IP6ADDR);
31 		return;
32 	}
33 
34 	net_if_ipv6_maddr_add(iface, &addr);
35 }
36 #else
37 #define setup_ipv6(...)
38 #endif /* CONFIG_NET_IPV6 */
39 
main(void)40 int main(void)
41 {
42 	LOG_INF("Starting Telnet sample");
43 
44 	wait_for_network();
45 	setup_ipv6();
46 	return 0;
47 }
48