drivers: net: loopback: Register loopback IP address to the interface
Regsiter loopback IPv4/IPv6 to the loopback interface during interface initialization. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
6f46124d6e
commit
4e9b9a7fdf
4 changed files with 26 additions and 0 deletions
|
@ -33,9 +33,31 @@ int loopback_dev_init(const struct device *dev)
|
|||
|
||||
static void loopback_init(struct net_if *iface)
|
||||
{
|
||||
struct net_if_addr *ifaddr;
|
||||
|
||||
/* RFC 7042, s.2.1.1. address to use in documentation */
|
||||
net_if_set_link_addr(iface, "\x00\x00\x5e\x00\x53\xff", 6,
|
||||
NET_LINK_DUMMY);
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET_IPV4)) {
|
||||
struct in_addr ipv4_loopback = INADDR_LOOPBACK_INIT;
|
||||
|
||||
ifaddr = net_if_ipv4_addr_add(iface, &ipv4_loopback,
|
||||
NET_ADDR_AUTOCONF, 0);
|
||||
if (!ifaddr) {
|
||||
LOG_ERR("Failed to register IPv4 loopback address");
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET_IPV6)) {
|
||||
struct in6_addr ipv6_loopback = IN6ADDR_LOOPBACK_INIT;
|
||||
|
||||
ifaddr = net_if_ipv6_addr_add(iface, &ipv6_loopback,
|
||||
NET_ADDR_AUTOCONF, 0);
|
||||
if (!ifaddr) {
|
||||
LOG_ERR("Failed to register IPv6 loopback address");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int loopback_send(const struct device *dev, struct net_pkt *pkt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue