iPXE
Data Structures | Defines | Functions | Variables
dns_test.c File Reference

DNS self-tests. More...

#include <string.h>
#include <assert.h>
#include <ipxe/dns.h>
#include <ipxe/test.h>

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...

Defines

#define DATA(...)   { __VA_ARGS__ }
 Define inline data.
#define DNS_ENCODE(_name, _string, _data)
 Define a DNS encoding test.
#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.
#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.
#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.
#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.
#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.
static void dns_encode_fail_okx (struct dns_encode_test *test, const char *file, unsigned int line)
 Report DNS encoding failure test result.
static void dns_decode_okx (struct dns_decode_test *test, const char *file, unsigned int line)
 Report DNS decoding test result.
static void dns_decode_fail_okx (struct dns_decode_test *test, const char *file, unsigned int line)
 Report DNS decoding failure test result.
static void dns_compare_okx (struct dns_compare_test *test, const char *file, unsigned int line)
 Report DNS comparison test result.
static void dns_compare_fail_okx (struct dns_compare_test *test, const char *file, unsigned int line)
 Report DNS comparison test failure result.
static void dns_copy_okx (struct dns_copy_test *test, const char *file, unsigned int line)
 Report a DNS copying test result.
static void dns_copy_fail_okx (struct dns_copy_test *test, const char *file, unsigned int line)
 Report a DNS copying failure test result.
static void dns_list_okx (struct dns_list_test *test, const char *file, unsigned int line)
 Report DNS search list test result.
 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.

Variables

struct self_test dns_test __self_test
 DNS self-test.

Detailed Description

DNS self-tests.

Definition in file dns_test.c.


Define Documentation

#define DATA (   ...)    { __VA_ARGS__ }

Define inline data.

Definition at line 41 of file dns_test.c.

#define DNS_ENCODE (   _name,
  _string,
  _data 
)
Value:
static const uint8_t _name ## __data[] = _data;                 \
        static struct dns_encode_test _name = {                         \
                .string = _string,                                      \
                .data = _name ## __data,                                \
                .len = sizeof ( _name ## __data ),                      \
        }

Define a DNS encoding test.

Parameters:
_nameTest name
_stringTest string
_dataExpected encoded data
Return values:
testDNS 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.

Referenced by dns_test_exec().

#define dns_encode_fail_ok (   test)    dns_encode_fail_okx ( test, __FILE__, __LINE__ )

Definition at line 117 of file dns_test.c.

Referenced by dns_test_exec().

#define DNS_DECODE (   _name,
  _data,
  _offset,
  _string 
)
Value:
static uint8_t _name ## __data[] = _data;                       \
        static struct dns_decode_test _name = {                         \
                .name = {                                               \
                        .data = _name ## __data,                        \
                        .offset = _offset,                              \
                        .len = sizeof ( _name ## __data ),              \
                },                                                      \
                .string = _string,                                      \
        }

Define a DNS decoding test.

Parameters:
_nameTest name
_dataRFC1035-encoded data
_offsetStarting offset within encoded data
_stringExpected decoded string
Return values:
testDNS 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.

Referenced by dns_test_exec().

#define dns_decode_fail_ok (   test)    dns_decode_fail_okx ( test, __FILE__, __LINE__ )

Definition at line 191 of file dns_test.c.

Referenced by dns_test_exec().

#define DNS_COMPARE (   _name,
  _first_data,
  _first_offset,
  _second_data,
  _second_offset 
)
Value:
static uint8_t _name ## __first_data[] = _first_data;           \
        static uint8_t _name ## __second_data[] = _second_data;         \
        static struct dns_compare_test _name = {                        \
                .first = {                                              \
                        .data = _name ## __first_data,                  \
                        .offset = _first_offset,                        \
                        .len = sizeof ( _name ## __first_data ),        \
                },                                                      \
                .second = {                                             \
                        .data = _name ## __second_data,                 \
                        .offset = _second_offset,                       \
                        .len = sizeof ( _name ## __second_data ),       \
                },                                                      \
        }

Define a DNS comparison test.

Parameters:
_nameTest name
_first_dataFirst RFC1035-encoded data
_first_offsetStarting offset within first encoded data
_second_dataSecond RFC1035-encoded data
_second_offsetStarting offset within second encoded data
Return values:
testDNS 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.

Referenced by dns_test_exec().

#define dns_compare_fail_ok (   test)    dns_compare_fail_okx ( test, __FILE__, __LINE__ )

Definition at line 255 of file dns_test.c.

Referenced by dns_test_exec().

#define DNS_COPY (   _name,
  _src_data,
  _src_offset,
  _dst_data,
  _dst_offset 
)
Value:
static uint8_t _name ## __src_data[] = _src_data;               \
        static uint8_t _name ## __dst_data[] = _dst_data;               \
        static struct dns_copy_test _name = {                           \
                .src = {                                                \
                        .data = _name ## __src_data,                    \
                        .offset = _src_offset,                          \
                        .len = sizeof ( _name ## __src_data ),          \
                },                                                      \
                .dst = {                                                \
                        .data = _name ## __dst_data,                    \
                        .offset = _dst_offset,                          \
                        .len = sizeof ( _name ## __dst_data ),          \
                },                                                      \
        }

Define a DNS copying test.

Parameters:
_nameTest name
_src_dataSource RFC1035-encoded data
_src_offsetStarting offset within source encoded data
_dst_dataExpected copied RFC1035-encoded data
_dst_offsetStarting offset withint copied encoded data
Return values:
testDNS 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.

Referenced by dns_test_exec().

#define dns_copy_fail_ok (   test)    dns_copy_fail_okx ( test, __FILE__, __LINE__ )

Definition at line 346 of file dns_test.c.

Referenced by dns_test_exec().

#define DNS_LIST (   _name,
  _list,
  _strings 
)
Value:
static uint8_t _name ## __list[] = _list;                       \
        static const char * _name ## __strings[] = _strings;            \
        static struct dns_list_test _name = {                           \
                .list = {                                               \
                        .data = _name ## __list,                        \
                        .offset = 0,                                    \
                        .len = sizeof ( _name ## __list ),              \
                },                                                      \
                .strings = _name ## __strings,                          \
                .count = ( sizeof ( _name ## __strings ) /              \
                           sizeof ( _name ## __strings[0] ) ),          \
        }

Define a DNS search list test.

Parameters:
_nameTest name
_listRFC1035-encoded data
_stringsExpected decoded strings
Return values:
testDNS 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.

Referenced by dns_test_exec().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void dns_encode_okx ( struct dns_encode_test test,
const char *  file,
unsigned int  line 
) [static]

Report DNS encoding test result.

Parameters:
testDNS encoding test
fileTest code file
lineTest code line

Definition at line 76 of file dns_test.c.

References dns_name::data, dns_encode_test::data, data, DBGC, DBGC_HDA, dns_encode(), dns_name::len, dns_encode_test::len, len, memcmp(), memset(), okx, and dns_encode_test::string.

                                                 {
        uint8_t data[ test->len ];
        struct dns_name name;
        int len;

        /* Check ability to determine length with no buffer */
        memset ( &name, 0, sizeof ( name ) );
        len = dns_encode ( test->string, &name );
        okx ( len >= 0, file, line );
        okx ( len == test->len, file, line );

        /* Check encoded name */
        name.data = data;
        name.len = sizeof ( data );
        len = dns_encode ( test->string, &name );
        okx ( len >= 0, file, line );
        if ( len >= 0 ) {
                okx ( len == test->len, file, line );
                okx ( memcmp ( data, test->data, test->len ) == 0, file, line );
                DBGC ( test, "DNS encoded \"%s\" to:\n", test->string );
                DBGC_HDA ( test, 0, data, len );
        }
}
static void dns_encode_fail_okx ( struct dns_encode_test test,
const char *  file,
unsigned int  line 
) [static]

Report DNS encoding failure test result.

Parameters:
testDNS encoding test
fileTest code file
lineTest code line

Definition at line 109 of file dns_test.c.

References dns_name::data, dns_encode(), len, NULL, okx, and dns_encode_test::string.

                                                                        {
        struct dns_name name = { .data = NULL, .len = 0 };
        int len;

        len = dns_encode ( test->string, &name );
        okx ( len < 0, file, line );
}
static void dns_decode_okx ( struct dns_decode_test test,
const char *  file,
unsigned int  line 
) [static]

Report DNS decoding test result.

Parameters:
testDNS decoding test
fileTest code file
lineTest code line

Definition at line 155 of file dns_test.c.

References dns_name::data, DBGC, DBGC_HDA, dns_decode(), dns_name::len, len, dns_decode_test::name, NULL, dns_name::offset, okx, strcmp(), dns_decode_test::string, and strlen().

                                                 {
        char string[ strlen ( test->string ) + 1 /* NUL */ ];
        int len;

        /* Check ability to determine length with no buffer */
        len = dns_decode ( &test->name, NULL, 0 );
        okx ( len >= 0, file, line );
        okx ( len == ( ( int ) strlen ( test->string ) ), file, line );

        /* Check decoded string */
        len = dns_decode ( &test->name, string, sizeof ( string ) );
        okx ( len >= 0, file, line );
        if ( len >= 0 ) {
                okx ( strcmp ( string, test->string ) == 0, file, line );
                DBGC ( test, "DNS decoded \"%s\" from offset %#zx in:\n",
                       string, test->name.offset );
                DBGC_HDA ( test, 0, test->name.data, test->name.len );
        }
}
static void dns_decode_fail_okx ( struct dns_decode_test test,
const char *  file,
unsigned int  line 
) [static]

Report DNS decoding failure test result.

Parameters:
testDNS decoding test
fileTest code file
lineTest code line

Definition at line 184 of file dns_test.c.

References dns_decode(), len, dns_decode_test::name, NULL, and okx.

                                                                        {
        int len;

        len = dns_decode ( &test->name, NULL, 0 );
        okx ( len < 0, file, line );
}
static void dns_compare_okx ( struct dns_compare_test test,
const char *  file,
unsigned int  line 
) [static]

Report DNS comparison test result.

Parameters:
testDNS comparison test
fileTest code file
lineTest code line

Definition at line 236 of file dns_test.c.

References dns_compare(), dns_compare_test::first, okx, and dns_compare_test::second.

                                                  {

        okx ( dns_compare ( &test->first, &test->second ) == 0, file, line );
}
static void dns_compare_fail_okx ( struct dns_compare_test test,
const char *  file,
unsigned int  line 
) [static]

Report DNS comparison test failure result.

Parameters:
testDNS comparison test
fileTest code file
lineTest code line

Definition at line 250 of file dns_test.c.

References dns_compare(), dns_compare_test::first, okx, and dns_compare_test::second.

                                                                         {

        okx ( dns_compare ( &test->first, &test->second ) != 0, file, line );
}
static void dns_copy_okx ( struct dns_copy_test test,
const char *  file,
unsigned int  line 
) [static]

Report a DNS copying test result.

Parameters:
testDNS copying test
fileTest code file
lineTest code line

Definition at line 300 of file dns_test.c.

References dns_name::data, data, DBGC, DBGC_HDA, dns_copy(), dns_copy_test::dst, dns_name::len, len, memcmp(), memcpy(), memset(), dns_name::offset, okx, and dns_copy_test::src.

                                                                 {
        uint8_t data[ test->dst.len ];
        struct dns_name dst;
        int len;

        /* Check ability to determine length with no buffer */
        memset ( &dst, 0, sizeof ( dst ) );
        len = dns_copy ( &test->src, &dst );
        okx ( len >= 0, file, line );
        okx ( len == ( ( int ) ( test->dst.len - test->dst.offset ) ),
              file, line );

        /* Check copied name */
        dst.data = data;
        dst.offset = test->dst.offset;
        dst.len = sizeof ( data );
        memcpy ( dst.data, test->dst.data, test->dst.offset );
        len = dns_copy ( &test->src, &dst );
        okx ( len >= 0, file, line );
        okx ( len == ( ( int ) ( test->dst.len - test->dst.offset ) ),
              file, line );
        okx ( memcmp ( data, test->dst.data, sizeof ( data ) ) == 0,
              file, line );
        DBGC ( test, "DNS copied:\n" );
        DBGC_HDA ( test, 0, test->src.data, test->src.len );
        DBGC_HDA ( test, 0, data, ( test->dst.offset + len ) );
}
static void dns_copy_fail_okx ( struct dns_copy_test test,
const char *  file,
unsigned int  line 
) [static]

Report a DNS copying failure test result.

Parameters:
testDNS copying test
fileTest code file
lineTest code line

Definition at line 337 of file dns_test.c.

References dns_copy(), len, memset(), okx, and dns_copy_test::src.

                                                                      {
        struct dns_name dst;
        int len;

        memset ( &dst, 0, sizeof ( dst ) );
        len = dns_copy ( &test->src, &dst );
        okx ( len < 0, file, line );
}
static void dns_list_okx ( struct dns_list_test test,
const char *  file,
unsigned int  line 
) [static]

Report DNS search list test result.

Parameters:
testDNS search list test
fileTest code file
lineTest code line

Definition at line 387 of file dns_test.c.

References dns_list_test::count, dns_name::data, DBGC, DBGC_HDA, dns_decode(), dns_skip(), dns_name::len, len, dns_list_test::list, memcpy(), dns_name::offset, offset, okx, strcmp(), dns_list_test::strings, and strlen().

                                               {
        struct dns_name name;
        unsigned int i;

        DBGC ( test, "DNS search list:\n" );
        DBGC_HDA ( test, 0, test->list.data, test->list.len );
        memcpy ( &name, &test->list, sizeof ( name ) );
        for ( i = 0 ; i < test->count ; i++ ) {
                char buf[ strlen ( test->strings[i] ) + 1 /* NUL */ ];
                int len;
                int offset;

                /* Decode this name */
                len = dns_decode ( &name, buf, sizeof ( buf ) );
                okx ( len >= 0, file, line );
                if ( len >= 0 ) {
                        okx ( len == ( ( int ) strlen ( test->strings[i] ) ),
                              file, line );
                        okx ( strcmp ( buf, test->strings[i] ) == 0,
                              file, line );
                        DBGC ( test, "DNS search list found \"%s\" at offset "
                               "%#zx\n", buf, name.offset );
                }

                /* Skip to next name */
                offset = dns_skip ( &name );
                okx ( offset >= 0, file, line );
                name.offset = offset;
        }

        /* Check that we have consumed the whole search list */
        okx ( name.offset == name.len, file, line );
}
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)  ,
,
"ipxe.org"   
)
DNS_DECODE ( decode_ptr  ,
DATA(3, 'o', 'r', 'g', 0, 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 0xc0, 0x00)  ,
,
"git.ipxe.org"   
)
DNS_DECODE ( decode_root  ,
DATA(0)  ,
,
""   
)
DNS_DECODE ( decode_incomplete_name  ,
DATA(4, 'i', 'p', 'x', 'e')  ,
,
NULL   
)
DNS_DECODE ( decode_incomplete_label  ,
DATA(4, 'i', 'p', 'x')  ,
,
NULL   
)
DNS_DECODE ( decode_incomplete_ptr  ,
DATA(3, 'o', 'r', 'g', 0, 4, 'i', 'p', 'x', 'e', 0xc0)  ,
,
NULL   
)
DNS_DECODE ( decode_forward  ,
DATA(0xc0, 0x02, 3, 'f', 'o', 'o', 0)  ,
,
NULL   
)
DNS_DECODE ( decode_infinite  ,
DATA(4, 'i', 'p', 'x', 'e', 0xc0, 0x00)  ,
,
NULL   
)
DNS_DECODE ( decode_empty  ,
DATA()  ,
,
NULL   
)
DNS_COMPARE ( compare_simple  ,
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
,
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
 
)
DNS_COMPARE ( compare_ptr  ,
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
,
DATA(3, 'o', 'r', 'g', 0, 4, 'i', 'p', 'x', 'e', 0xc0, 0x00)  ,
 
)
DNS_COMPARE ( compare_case  ,
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
,
DATA(4, 'i', 'p', 'x', 'e', 3, 'O', 'R', 'G', 0)  ,
 
)
DNS_COMPARE ( compare_mismatch  ,
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
,
DATA(4, 'g', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
 
)
DNS_COMPARE ( compare_infinite  ,
DATA(3, 'f', 'o', 'o', 0xc0, 0x00)  ,
,
DATA(3, 'f', 'o', 'o', 0xc0, 0x00)  ,
 
)
DNS_COPY ( copy_simple  ,
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
,
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
 
)
DNS_COPY ( copy_offset  ,
DATA(4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
,
DATA( 'f', 'o', 'o', 0, 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
 
)
DNS_COPY ( copy_ptr  ,
DATA(3, 'o', 'r', 'g', 0, 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 0xc0, 0x00)  ,
,
DATA(3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0)  ,
 
)
DNS_COPY ( copy_infinite  ,
DATA(4, 'l', 'o', 'o', 'p', 7, 'f', 'o', 'r', 'e', 'v', 'e', 'r', 0xc0, 0x05)  ,
,
DATA()  ,
 
)
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  ) [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.

                                   {

        /* Encoding tests */
        dns_encode_ok ( &encode_simple );
        dns_encode_ok ( &encode_single );
        dns_encode_ok ( &encode_absolute );
        dns_encode_ok ( &encode_empty );
        dns_encode_ok ( &encode_root );
        dns_encode_fail_ok ( &encode_initial_dot );
        dns_encode_fail_ok ( &encode_double_dot );
        dns_encode_fail_ok ( &encode_solo_double_dot );
        dns_encode_fail_ok ( &encode_trailing_double_dot );
        dns_encode_fail_ok ( &encode_overlength );

        /* Decoding tests */
        dns_decode_ok ( &decode_simple );
        dns_decode_ok ( &decode_ptr );
        dns_decode_ok ( &decode_root );
        dns_decode_fail_ok ( &decode_incomplete_name );
        dns_decode_fail_ok ( &decode_incomplete_label );
        dns_decode_fail_ok ( &decode_incomplete_ptr );
        dns_decode_fail_ok ( &decode_forward );
        dns_decode_fail_ok ( &decode_infinite );
        dns_decode_fail_ok ( &decode_empty );

        /* Comparison tests */
        dns_compare_ok ( &compare_simple );
        dns_compare_ok ( &compare_ptr );
        dns_compare_ok ( &compare_case );
        dns_compare_fail_ok ( &compare_mismatch );
        dns_compare_fail_ok ( &compare_infinite );

        /* Copying tests */
        dns_copy_ok ( &copy_simple );
        dns_copy_ok ( &copy_offset );
        dns_copy_ok ( &copy_ptr );
        dns_copy_fail_ok ( &copy_infinite );

        /* Search list tets */
        dns_list_ok ( &search );
}

Variable Documentation

struct self_test dns_test __self_test
Initial value:
 {
        .name = "dns",
        .exec = dns_test_exec,
}

DNS self-test.

Definition at line 606 of file dns_test.c.