net: tests: Add tests for IPv4 netmask, gateway and subnet compare
Unit tests added for checking network interface netmask, gateway and IPv4 subnet compare utility functions. Change-Id: I5b4a07d6a064097ab41ad6552d14181b1631eb53 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
667d15de85
commit
6e3c12a820
1 changed files with 19 additions and 0 deletions
|
@ -179,6 +179,10 @@ void main(void)
|
|||
struct net_if_addr *ifaddr1, *ifaddr2;
|
||||
struct net_if_mcast_addr *ifmaddr1;
|
||||
struct in_addr addr4 = { { { 192, 168, 0, 1 } } };
|
||||
struct in_addr match_addr = { { { 192, 168, 0, 2 } } };
|
||||
struct in_addr fail_addr = { { { 10, 1, 0, 2 } } };
|
||||
struct in_addr netmask = { { { 255, 255, 255, 0 } } };
|
||||
struct in_addr gw = { { { 192, 168, 0, 42 } } };
|
||||
struct in_addr loopback4 = { { { 127, 0, 0, 1 } } };
|
||||
struct net_if *iface;
|
||||
int i;
|
||||
|
@ -410,5 +414,20 @@ void main(void)
|
|||
}
|
||||
}
|
||||
|
||||
iface = net_if_get_default();
|
||||
|
||||
net_if_set_gw(iface, &gw);
|
||||
net_if_set_netmask(iface, &netmask);
|
||||
|
||||
if (net_ipv4_addr_mask_cmp(iface, &fail_addr)) {
|
||||
printk("IPv4 wrong match failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!net_ipv4_addr_mask_cmp(iface, &match_addr)) {
|
||||
printk("IPv4 match failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printk("IP address checks passed\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue