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:
parent
92481765a2
commit
1d324a1b20
1 changed files with 25 additions and 17 deletions
|
@ -55,26 +55,34 @@ static int setup_iface(struct net_if *iface, const char *ipv6_addr,
|
||||||
LOG_ERR("Cannot enable VLAN for tag %d (%d)", vlan_tag, ret);
|
LOG_ERR("Cannot enable VLAN for tag %d (%d)", vlan_tag, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_addr_pton(AF_INET6, ipv6_addr, &addr6)) {
|
if (IS_ENABLED(CONFIG_NET_IPV6)) {
|
||||||
LOG_ERR("Invalid address: %s", ipv6_addr);
|
if (net_addr_pton(AF_INET6, ipv6_addr, &addr6)) {
|
||||||
return -EINVAL;
|
LOG_ERR("Invalid address: %s", ipv6_addr);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ifaddr = net_if_ipv6_addr_add(iface, &addr6, NET_ADDR_MANUAL, 0);
|
if (IS_ENABLED(CONFIG_NET_IPV4)) {
|
||||||
if (!ifaddr) {
|
if (net_addr_pton(AF_INET, ipv4_addr, &addr4)) {
|
||||||
LOG_ERR("Cannot add %s to interface %p", ipv6_addr, iface);
|
LOG_ERR("Invalid address: %s", ipv6_addr);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_addr_pton(AF_INET, ipv4_addr, &addr4)) {
|
ifaddr = net_if_ipv4_addr_add(iface, &addr4,
|
||||||
LOG_ERR("Invalid address: %s", ipv6_addr);
|
NET_ADDR_MANUAL, 0);
|
||||||
return -EINVAL;
|
if (!ifaddr) {
|
||||||
}
|
LOG_ERR("Cannot add %s to interface %p",
|
||||||
|
ipv4_addr, iface);
|
||||||
ifaddr = net_if_ipv4_addr_add(iface, &addr4, NET_ADDR_MANUAL, 0);
|
return -EINVAL;
|
||||||
if (!ifaddr) {
|
}
|
||||||
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);
|
LOG_DBG("Interface %p VLAN tag %d setup done.", iface, vlan_tag);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue