samples: net: echo-server: Fix compile error for missing IP proto

Make sure that the echo-server compiles ok if IPv6 or IPv4 is
disabled when VLAN is enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-01-29 13:29:46 +02:00
commit 1d324a1b20

View file

@ -55,27 +55,35 @@ static int setup_iface(struct net_if *iface, const char *ipv6_addr,
LOG_ERR("Cannot enable VLAN for tag %d (%d)", vlan_tag, ret);
}
if (IS_ENABLED(CONFIG_NET_IPV6)) {
if (net_addr_pton(AF_INET6, ipv6_addr, &addr6)) {
LOG_ERR("Invalid address: %s", ipv6_addr);
return -EINVAL;
}
ifaddr = net_if_ipv6_addr_add(iface, &addr6, NET_ADDR_MANUAL, 0);
ifaddr = net_if_ipv6_addr_add(iface, &addr6,
NET_ADDR_MANUAL, 0);
if (!ifaddr) {
LOG_ERR("Cannot add %s to interface %p", ipv6_addr, iface);
LOG_ERR("Cannot add %s to interface %p",
ipv6_addr, iface);
return -EINVAL;
}
}
if (IS_ENABLED(CONFIG_NET_IPV4)) {
if (net_addr_pton(AF_INET, ipv4_addr, &addr4)) {
LOG_ERR("Invalid address: %s", ipv6_addr);
return -EINVAL;
}
ifaddr = net_if_ipv4_addr_add(iface, &addr4, NET_ADDR_MANUAL, 0);
ifaddr = net_if_ipv4_addr_add(iface, &addr4,
NET_ADDR_MANUAL, 0);
if (!ifaddr) {
LOG_ERR("Cannot add %s to interface %p", ipv4_addr, iface);
LOG_ERR("Cannot add %s to interface %p",
ipv4_addr, iface);
return -EINVAL;
}
}
LOG_DBG("Interface %p VLAN tag %d setup done.", iface, vlan_tag);