net: tests: Add IPv4 address unit tests
These tests will check that caller is able to set IPv4 address to a network interface and check if an address is one of the assigned to a network interface. Change-Id: I8aa748c40fbc02eef50ccf76d10a0057ef29021b Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
cf5c1db262
commit
7851aecc1c
1 changed files with 21 additions and 0 deletions
|
@ -178,6 +178,8 @@ void main(void)
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } };
|
||||
struct net_if_addr *ifaddr1, *ifaddr2;
|
||||
struct net_if_mcast_addr *ifmaddr1;
|
||||
struct in_addr addr4 = { { { 192, 168, 0, 1 } } };
|
||||
struct in_addr loopback4 = { { { 127, 0, 0, 1 } } };
|
||||
|
||||
TEST_BYTE_1(0xde, "DE");
|
||||
TEST_BYTE_1(0x09, "09");
|
||||
|
@ -291,5 +293,24 @@ void main(void)
|
|||
return;
|
||||
}
|
||||
|
||||
ifaddr1 = net_if_ipv4_addr_add(__net_if_start,
|
||||
&addr4,
|
||||
NET_ADDR_MANUAL,
|
||||
0);
|
||||
if (!ifaddr1) {
|
||||
printk("IPv4 interface address add failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!net_is_my_ipv4_addr(&addr4)) {
|
||||
printk("My IPv4 address check failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (net_is_my_ipv4_addr(&loopback4)) {
|
||||
printk("My IPv4 loopback address check failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printk("IP address checks passed\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue