|
iPXE
|
IPv4 tests. More...
#include <stdint.h>#include <string.h>#include <assert.h>#include <byteswap.h>#include <ipxe/in.h>#include <ipxe/ip.h>#include <ipxe/test.h>#include "netdev_test.h"Go to the source code of this file.
Macros | |
| #define | IPV4(a, b, c, d) htonl ( ( (a) << 24 ) | ( (b) << 16 ) | ( (c) << 8 ) | (d) ) |
| Define inline IPv4 address. More... | |
| #define | inet_ntoa_ok(addr, text) inet_ntoa_okx ( addr, text, __FILE__, __LINE__ ) |
| #define | inet_aton_ok(text, addr) inet_aton_okx ( text, addr, __FILE__, __LINE__ ) |
| #define | inet_aton_fail_ok(text) inet_aton_fail_okx ( text, __FILE__, __LINE__ ) |
| #define | ipv4_route_ok(dest, scope, next, egress, src, bcast) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| static void | inet_ntoa_okx (uint32_t addr, const char *text, const char *file, unsigned int line) |
| Report an inet_ntoa() test result. More... | |
| static void | inet_aton_okx (const char *text, uint32_t addr, const char *file, unsigned int line) |
| Report an inet_aton() test result. More... | |
| static void | inet_aton_fail_okx (const char *text, const char *file, unsigned int line) |
| Report an inet_aton() failure test result. More... | |
| static void | ipv4_route_okx (const char *dest, struct testnet *scope, const char *next, struct testnet *egress, const char *src, int bcast, const char *file, unsigned int line) |
| Report an ipv4_route() test result. More... | |
| TESTNET (net0, { "dhcp/ip", "192.168.0.1" }, { "dhcp/netmask", "255.255.255.0" }, { "dhcp/gateway", "192.168.0.254" }) | |
| net0: Single address and gateway (DHCP assignment) More... | |
| TESTNET (net1, { "dhcp/ip", "192.168.0.2" }, { "dhcp/netmask", "255.255.255.0" }, { "dhcp/gateway", "192.168.0.254" }) | |
| net1: Single address and gateway (DHCP assignment) More... | |
| TESTNET (net2, { "ip", "10.31.31.0" }, { "netmask", "255.255.255.254" }, { "gateway", "10.31.31.1" }) | |
| net2: Small /31 subnet mask More... | |
| TESTNET (net3, { "ip", "10.32.32.32" }, { "netmask", "255.255.255.255" }, { "gateway", "192.168.32.254" }) | |
| net3: Small /32 subnet mask More... | |
| TESTNET (net4, { "ip", "192.168.86.1" }, { "netmask", "255.255.240.0" }) | |
| net4: Local subnet with no gateway More... | |
| TESTNET (net5, { "ip", "10.42.0.1" }, { "netmask", "255.255.0.0" }, { "gateway", "10.42.0.254" }, { "static-routes", "19:0a:2b:2b:80:0a:2a:2b:2b:" "10:c0:a8:0a:2a:c0:a8:" "18:c0:a8:00:00:00:00:00:" "00:0a:2a:01:01" }) | |
| net5: Static routes More... | |
| static void | ipv4_test_exec (void) |
| Perform IPv4 self-tests. More... | |
Variables | |
| struct self_test ipv4_test | __self_test |
| IPv4 self-test. More... | |
IPv4 tests.
Definition in file ipv4_test.c.
| #define IPV4 | ( | a, | |
| b, | |||
| c, | |||
| d | |||
| ) | htonl ( ( (a) << 24 ) | ( (b) << 16 ) | ( (c) << 8 ) | (d) ) |
Define inline IPv4 address.
Definition at line 45 of file ipv4_test.c.
| #define inet_ntoa_ok | ( | addr, | |
| text | |||
| ) | inet_ntoa_okx ( addr, text, __FILE__, __LINE__ ) |
Definition at line 70 of file ipv4_test.c.
| #define inet_aton_ok | ( | text, | |
| addr | |||
| ) | inet_aton_okx ( text, addr, __FILE__, __LINE__ ) |
Definition at line 90 of file ipv4_test.c.
| #define inet_aton_fail_ok | ( | text | ) | inet_aton_fail_okx ( text, __FILE__, __LINE__ ) |
Definition at line 107 of file ipv4_test.c.
Definition at line 184 of file ipv4_test.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Report an inet_ntoa() test result.
| addr | IPv4 address |
| text | Expected textual representation |
| file | Test code file |
| line | Test code line |
Definition at line 56 of file ipv4_test.c.
References addr, DBG, in, inet_ntoa(), ntohl, okx, and strcmp().
|
static |
Report an inet_aton() test result.
| text | Textual representation |
| addr | Expected IPv4 address |
| file | Test code file |
| line | Test code line |
Definition at line 81 of file ipv4_test.c.
References addr, DBG, inet_aton(), inet_ntoa(), okx, and in_addr::s_addr.
|
static |
Report an inet_aton() failure test result.
| text | Textual representation |
| file | Test code file |
| line | Test code line |
Definition at line 100 of file ipv4_test.c.
References inet_aton(), and okx.
|
static |
Report an ipv4_route() test result.
| dest | Destination address |
| scope | Destination scope test network device, or NULL |
| next | Expected next hop address (on success) |
| egress | Expected egress device, or NULL to expect failure |
| src | Expected source address (on success) |
| bcast | Expected broadcast packet (on success) |
| file | Test code file |
| line | Test code line |
Definition at line 122 of file ipv4_test.c.
References ipv4_miniroute::address, assert(), DBG, dest, testnet::dev, ipv4_miniroute::hostmask, inet_aton(), inet_ntoa(), ipv4_route(), device::name, testnet::netdev, ipv4_miniroute::netdev, next, NULL, okx, in_addr::s_addr, scope, and src.
| TESTNET | ( | net0 | , |
| { "dhcp/ip", "192.168.0.1" } | , | ||
| { "dhcp/netmask", "255.255.255.0" } | , | ||
| { "dhcp/gateway", "192.168.0.254" } | |||
| ) |
net0: Single address and gateway (DHCP assignment)
| TESTNET | ( | net1 | , |
| { "dhcp/ip", "192.168.0.2" } | , | ||
| { "dhcp/netmask", "255.255.255.0" } | , | ||
| { "dhcp/gateway", "192.168.0.254" } | |||
| ) |
net1: Single address and gateway (DHCP assignment)
| TESTNET | ( | net2 | , |
| { "ip", "10.31.31.0" } | , | ||
| { "netmask", "255.255.255.254" } | , | ||
| { "gateway", "10.31.31.1" } | |||
| ) |
net2: Small /31 subnet mask
| TESTNET | ( | net3 | , |
| { "ip", "10.32.32.32" } | , | ||
| { "netmask", "255.255.255.255" } | , | ||
| { "gateway", "192.168.32.254" } | |||
| ) |
net3: Small /32 subnet mask
| TESTNET | ( | net4 | , |
| { "ip", "192.168.86.1" } | , | ||
| { "netmask", "255.255.240.0" } | |||
| ) |
net4: Local subnet with no gateway
| TESTNET | ( | net5 | , |
| { "ip", "10.42.0.1" } | , | ||
| { "netmask", "255.255.0.0" } | , | ||
| { "gateway", "10.42.0.254" } | , | ||
| { "static-routes", "19:0a:2b:2b:80:0a:2a:2b:2b:" "10:c0:a8:0a:2a:c0:a8:" "18:c0:a8:00:00:00:00:00:" "00:0a:2a:01:01" } | |||
| ) |
net5: Static routes
|
static |
Perform IPv4 self-tests.
Definition at line 232 of file ipv4_test.c.
References IN_IS_CLASSA, IN_IS_CLASSB, IN_IS_CLASSC, IN_IS_MULTICAST, inet_aton_fail_ok, inet_aton_ok, inet_ntoa_ok, IPV4, ipv4_route_ok, NULL, ok, testnet_close_ok, testnet_ok, testnet_open_ok, testnet_remove_ok, and testnet_set_ok.
| struct self_test ipv4_test __self_test |
IPv4 self-test.
Definition at line 362 of file ipv4_test.c.
1.8.15