iPXE
|
DNS self-tests. More...
Go to the source code of this file.
Data Structures | |
struct | dns_encode_test |
A DNS encoding test. More... | |
struct | dns_decode_test |
A DNS decoding test. More... | |
struct | dns_compare_test |
A DNS comparison test. More... | |
struct | dns_copy_test |
A DNS copying test. More... | |
struct | dns_list_test |
A DNS search list test. More... | |
Macros | |
#define | DATA(...) { __VA_ARGS__ } |
Define inline data. More... | |
#define | DNS_ENCODE(_name, _string, _data) |
Define a DNS encoding test. More... | |
#define | dns_encode_ok(test) dns_encode_okx ( test, __FILE__, __LINE__ ) |
#define | dns_encode_fail_ok(test) dns_encode_fail_okx ( test, __FILE__, __LINE__ ) |
#define | DNS_DECODE(_name, _data, _offset, _string) |
Define a DNS decoding test. More... | |
#define | dns_decode_ok(test) dns_decode_okx ( test, __FILE__, __LINE__ ) |
#define | dns_decode_fail_ok(test) dns_decode_fail_okx ( test, __FILE__, __LINE__ ) |
#define | DNS_COMPARE(_name, _first_data, _first_offset, _second_data, _second_offset) |
Define a DNS comparison test. More... | |
#define | dns_compare_ok(test) dns_compare_okx ( test, __FILE__, __LINE__ ) |
#define | dns_compare_fail_ok(test) dns_compare_fail_okx ( test, __FILE__, __LINE__ ) |
#define | DNS_COPY(_name, _src_data, _src_offset, _dst_data, _dst_offset) |
Define a DNS copying test. More... | |
#define | dns_copy_ok(test) dns_copy_okx ( test, __FILE__, __LINE__ ) |
#define | dns_copy_fail_ok(test) dns_copy_fail_okx ( test, __FILE__, __LINE__ ) |
#define | DNS_LIST(_name, _list, _strings) |
Define a DNS search list test. More... | |
#define | dns_list_ok(test) dns_list_okx ( test, __FILE__, __LINE__ ) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | dns_encode_okx (struct dns_encode_test *test, const char *file, unsigned int line) |
Report DNS encoding test result. More... | |
static void | dns_encode_fail_okx (struct dns_encode_test *test, const char *file, unsigned int line) |
Report DNS encoding failure test result. More... | |
static void | dns_decode_okx (struct dns_decode_test *test, const char *file, unsigned int line) |
Report DNS decoding test result. More... | |
static void | dns_decode_fail_okx (struct dns_decode_test *test, const char *file, unsigned int line) |
Report DNS decoding failure test result. More... | |
static void | dns_compare_okx (struct dns_compare_test *test, const char *file, unsigned int line) |
Report DNS comparison test result. More... | |
static void | dns_compare_fail_okx (struct dns_compare_test *test, const char *file, unsigned int line) |
Report DNS comparison test failure result. More... | |
static void | dns_copy_okx (struct dns_copy_test *test, const char *file, unsigned int line) |
Report a DNS copying test result. More... | |
static void | dns_copy_fail_okx (struct dns_copy_test *test, const char *file, unsigned int line) |
Report a DNS copying failure test result. More... | |
static void | dns_list_okx (struct dns_list_test *test, const char *file, unsigned int line) |
Report DNS search list test result. More... | |
DNS_ENCODE (encode_simple, "ipxe.org", DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)) | |
DNS_ENCODE (encode_single, "foo", DATA(3, 'f', 'o', 'o', 0)) | |
DNS_ENCODE (encode_absolute, "git.ipxe.org.", DATA(3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)) | |
DNS_ENCODE (encode_empty, "", DATA(0)) | |
DNS_ENCODE (encode_root, ".", DATA(0)) | |
DNS_ENCODE (encode_initial_dot, ".foo", DATA()) | |
DNS_ENCODE (encode_double_dot, "ipxe..org", DATA()) | |
DNS_ENCODE (encode_solo_double_dot, "..", DATA()) | |
DNS_ENCODE (encode_trailing_double_dot, "ipxe.org..", DATA()) | |
DNS_ENCODE (encode_overlength, "this-label-is-maliciously-long-in-an-attempt-to-overflow-the-" "length-field-and-generate-a-length-which-looks-like-a-" "compression-pointer", DATA()) | |
DNS_DECODE (decode_simple, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0, "ipxe.org") | |
DNS_DECODE (decode_ptr, DATA(3, 'o', 'r', 'g', 0, 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 0xc0, 0x00), 5, "git.ipxe.org") | |
DNS_DECODE (decode_root, DATA(0), 0, "") | |
DNS_DECODE (decode_incomplete_name, DATA(4, 'i', 'p', 'x', 'e'), 0, NULL) | |
DNS_DECODE (decode_incomplete_label, DATA(4, 'i', 'p', 'x'), 0, NULL) | |
DNS_DECODE (decode_incomplete_ptr, DATA(3, 'o', 'r', 'g', 0, 4, 'i', 'p', 'x', 'e', 0xc0), 5, NULL) | |
DNS_DECODE (decode_forward, DATA(0xc0, 0x02, 3, 'f', 'o', 'o', 0), 0, NULL) | |
DNS_DECODE (decode_infinite, DATA(4, 'i', 'p', 'x', 'e', 0xc0, 0x00), 0, NULL) | |
DNS_DECODE (decode_empty, DATA(), 0, NULL) | |
DNS_COMPARE (compare_simple, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0) | |
DNS_COMPARE (compare_ptr, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0, DATA(3, 'o', 'r', 'g', 0, 4, 'i', 'p', 'x', 'e', 0xc0, 0x00), 5) | |
DNS_COMPARE (compare_case, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0, DATA(4, 'i', 'p', 'x', 'e', 3, 'O', 'R', 'G', 0), 0) | |
DNS_COMPARE (compare_mismatch, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0, DATA(4, 'g', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0) | |
DNS_COMPARE (compare_infinite, DATA(3, 'f', 'o', 'o', 0xc0, 0x00), 0, DATA(3, 'f', 'o', 'o', 0xc0, 0x00), 0) | |
DNS_COPY (copy_simple, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0) | |
DNS_COPY (copy_offset, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0, DATA( 'f', 'o', 'o', 0, 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 4) | |
DNS_COPY (copy_ptr, DATA(3, 'o', 'r', 'g', 0, 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 0xc0, 0x00), 5, DATA(3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0), 0) | |
DNS_COPY (copy_infinite, DATA(4, 'l', 'o', 'o', 'p', 7, 'f', 'o', 'r', 'e', 'v', 'e', 'r', 0xc0, 0x05), 0, DATA(), 0) | |
DNS_LIST (search, DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0, 4, 'b', 'o', 'o', 't', 0xc0, 0x00, 3, 'd', 'e', 'v', 0xc0, 0x0a, 11, 'n', 'e', 't', 'w', 'o', 'r', 'k', 'b', 'o', 'o', 't', 0xc0, 0x05), DATA("ipxe.org", "boot.ipxe.org", "dev.boot.ipxe.org", "networkboot.org")) | |
static void | dns_test_exec (void) |
Perform DNS self-test. More... | |
Variables | |
struct self_test dns_test | __self_test |
DNS self-test. More... | |
DNS self-tests.
Definition in file dns_test.c.
#define DATA | ( | ... | ) | { __VA_ARGS__ } |
Define inline data.
Definition at line 41 of file dns_test.c.
#define DNS_ENCODE | ( | _name, | |
_string, | |||
_data | |||
) |
Define a DNS encoding test.
_name | Test name |
_string | Test string |
_data | Expected encoded data |
test | DNS encoding test |
Definition at line 61 of file dns_test.c.
#define dns_encode_ok | ( | test | ) | dns_encode_okx ( test, __FILE__, __LINE__ ) |
Definition at line 100 of file dns_test.c.
#define dns_encode_fail_ok | ( | test | ) | dns_encode_fail_okx ( test, __FILE__, __LINE__ ) |
Definition at line 117 of file dns_test.c.
#define DNS_DECODE | ( | _name, | |
_data, | |||
_offset, | |||
_string | |||
) |
Define a DNS decoding test.
_name | Test name |
_data | RFC1035-encoded data |
_offset | Starting offset within encoded data |
_string | Expected decoded string |
test | DNS decoding test |
Definition at line 137 of file dns_test.c.
#define dns_decode_ok | ( | test | ) | dns_decode_okx ( test, __FILE__, __LINE__ ) |
Definition at line 175 of file dns_test.c.
#define dns_decode_fail_ok | ( | test | ) | dns_decode_fail_okx ( test, __FILE__, __LINE__ ) |
Definition at line 191 of file dns_test.c.
#define DNS_COMPARE | ( | _name, | |
_first_data, | |||
_first_offset, | |||
_second_data, | |||
_second_offset | |||
) |
Define a DNS comparison test.
_name | Test name |
_first_data | First RFC1035-encoded data |
_first_offset | Starting offset within first encoded data |
_second_data | Second RFC1035-encoded data |
_second_offset | Starting offset within second encoded data |
test | DNS comparison test |
Definition at line 212 of file dns_test.c.
#define dns_compare_ok | ( | test | ) | dns_compare_okx ( test, __FILE__, __LINE__ ) |
Definition at line 241 of file dns_test.c.
#define dns_compare_fail_ok | ( | test | ) | dns_compare_fail_okx ( test, __FILE__, __LINE__ ) |
Definition at line 255 of file dns_test.c.
#define DNS_COPY | ( | _name, | |
_src_data, | |||
_src_offset, | |||
_dst_data, | |||
_dst_offset | |||
) |
Define a DNS copying test.
_name | Test name |
_src_data | Source RFC1035-encoded data |
_src_offset | Starting offset within source encoded data |
_dst_data | Expected copied RFC1035-encoded data |
_dst_offset | Starting offset withint copied encoded data |
test | DNS copying test |
Definition at line 276 of file dns_test.c.
#define dns_copy_ok | ( | test | ) | dns_copy_okx ( test, __FILE__, __LINE__ ) |
Definition at line 328 of file dns_test.c.
#define dns_copy_fail_ok | ( | test | ) | dns_copy_fail_okx ( test, __FILE__, __LINE__ ) |
Definition at line 346 of file dns_test.c.
#define DNS_LIST | ( | _name, | |
_list, | |||
_strings | |||
) |
Define a DNS search list test.
_name | Test name |
_list | RFC1035-encoded data |
_strings | Expected decoded strings |
test | DNS search list test |
Definition at line 366 of file dns_test.c.
#define dns_list_ok | ( | test | ) | dns_list_okx ( test, __FILE__, __LINE__ ) |
Definition at line 421 of file dns_test.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Report DNS encoding test result.
test | DNS encoding test |
file | Test code file |
line | Test code line |
Definition at line 76 of file dns_test.c.
References data, DBGC, DBGC_HDA, dns_encode(), len, memcmp(), memset(), name, okx, and test.
|
static |
Report DNS encoding failure test result.
test | DNS encoding test |
file | Test code file |
line | Test code line |
Definition at line 109 of file dns_test.c.
|
static |
Report DNS decoding test result.
test | DNS decoding test |
file | Test code file |
line | Test code line |
Definition at line 155 of file dns_test.c.
References DBGC, DBGC_HDA, dns_decode(), len, NULL, okx, strcmp(), strlen(), and test.
|
static |
Report DNS decoding failure test result.
test | DNS decoding test |
file | Test code file |
line | Test code line |
Definition at line 184 of file dns_test.c.
References dns_decode(), len, NULL, okx, and test.
|
static |
Report DNS comparison test result.
test | DNS comparison test |
file | Test code file |
line | Test code line |
Definition at line 236 of file dns_test.c.
References dns_compare(), okx, and test.
|
static |
Report DNS comparison test failure result.
test | DNS comparison test |
file | Test code file |
line | Test code line |
Definition at line 250 of file dns_test.c.
References dns_compare(), okx, and test.
|
static |
Report a DNS copying test result.
test | DNS copying test |
file | Test code file |
line | Test code line |
Definition at line 300 of file dns_test.c.
References dns_name::data, data, DBGC, DBGC_HDA, dns_copy(), len, dns_name::len, memcmp(), memcpy(), memset(), dns_name::offset, okx, and test.
|
static |
Report a DNS copying failure test result.
test | DNS copying test |
file | Test code file |
line | Test code line |
Definition at line 337 of file dns_test.c.
References dns_copy(), len, memset(), okx, and test.
|
static |
Report DNS search list test result.
test | DNS search list test |
file | Test code file |
line | Test code line |
Definition at line 387 of file dns_test.c.
References DBGC, DBGC_HDA, dns_decode(), dns_skip(), len, memcpy(), name, offset, okx, strcmp(), strlen(), and test.
DNS_ENCODE | ( | encode_single | , |
"foo" | , | ||
DATA(3, 'f', 'o', 'o', 0) | |||
) |
DNS_ENCODE | ( | encode_absolute | , |
"git.ipxe.org." | , | ||
DATA(3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | |||
) |
DNS_ENCODE | ( | encode_empty | , |
"" | , | ||
DATA(0) | |||
) |
DNS_ENCODE | ( | encode_root | , |
"." | , | ||
DATA(0) | |||
) |
DNS_ENCODE | ( | encode_initial_dot | , |
".foo" | , | ||
DATA() | |||
) |
DNS_ENCODE | ( | encode_double_dot | , |
"ipxe..org" | , | ||
DATA() | |||
) |
DNS_ENCODE | ( | encode_solo_double_dot | , |
".." | , | ||
DATA() | |||
) |
DNS_ENCODE | ( | encode_trailing_double_dot | , |
"ipxe.org.." | , | ||
DATA() | |||
) |
DNS_ENCODE | ( | encode_overlength | , |
"this-label-is-maliciously-long-in-an-attempt-to-overflow-the-" "length-field-and-generate-a-length-which-looks-like-a-" "compression-pointer" | , | ||
DATA() | |||
) |
DNS_DECODE | ( | decode_ptr | , |
DATA(3, 'o', 'r', 'g', 0, 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 0xc0, 0x00) | , | ||
5 | , | ||
"git.ipxe.org" | |||
) |
DNS_DECODE | ( | decode_root | , |
DATA(0) | , | ||
0 | , | ||
"" | |||
) |
DNS_DECODE | ( | decode_incomplete_ptr | , |
DATA(3, 'o', 'r', 'g', 0, 4, 'i', 'p', 'x', 'e', 0xc0) | , | ||
5 | , | ||
NULL | |||
) |
DNS_COMPARE | ( | compare_simple | , |
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | , | ||
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | |||
) |
DNS_COMPARE | ( | compare_ptr | , |
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | , | ||
DATA(3, 'o', 'r', 'g', 0, 4, 'i', 'p', 'x', 'e', 0xc0, 0x00) | , | ||
5 | |||
) |
DNS_COMPARE | ( | compare_case | , |
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | , | ||
DATA(4, 'i', 'p', 'x', 'e', 3, 'O', 'R', 'G', 0) | , | ||
0 | |||
) |
DNS_COMPARE | ( | compare_mismatch | , |
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | , | ||
DATA(4, 'g', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | |||
) |
DNS_COMPARE | ( | compare_infinite | , |
DATA(3, 'f', 'o', 'o', 0xc0, 0x00) | , | ||
0 | , | ||
DATA(3, 'f', 'o', 'o', 0xc0, 0x00) | , | ||
0 | |||
) |
DNS_COPY | ( | copy_simple | , |
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | , | ||
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | |||
) |
DNS_COPY | ( | copy_offset | , |
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | , | ||
DATA('f', 'o', 'o', 0, 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
4 | |||
) |
DNS_COPY | ( | copy_ptr | , |
DATA(3, 'o', 'r', 'g', 0, 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 0xc0, 0x00) | , | ||
5 | , | ||
DATA(3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0) | , | ||
0 | |||
) |
DNS_COPY | ( | copy_infinite | , |
DATA(4, 'l', 'o', 'o', 'p', 7, 'f', 'o', 'r', 'e', 'v', 'e', 'r', 0xc0, 0x05) | , | ||
0 | , | ||
DATA() | , | ||
0 | |||
) |
DNS_LIST | ( | search | , |
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0, 4, 'b', 'o', 'o', 't', 0xc0, 0x00, 3, 'd', 'e', 'v', 0xc0, 0x0a, 11, 'n', 'e', 't', 'w', 'o', 'r', 'k', 'b', 'o', 'o', 't', 0xc0, 0x05) | , | ||
DATA("ipxe.org", "boot.ipxe.org", "dev.boot.ipxe.org", "networkboot.org") | |||
) |
|
static |
Perform DNS self-test.
Definition at line 563 of file dns_test.c.
References dns_compare_fail_ok, dns_compare_ok, dns_copy_fail_ok, dns_copy_ok, dns_decode_fail_ok, dns_decode_ok, dns_encode_fail_ok, dns_encode_ok, and dns_list_ok.
struct self_test dns_test __self_test |
DNS self-test.
Definition at line 606 of file dns_test.c.