eCos Reference Manual
Prev | Chapter 49. DNS | Next

# DNS Client Testing

The DNS client has a test program, dns1.c, which tests many of the features of the DNS client and the functions `gethostbyname(),` `gethostbyaddr()`, `getaddrinfo()`, `getnameinfo()`.

In order for this test to work, a DNS server must be configured with a number of names and addresses. The following is an example forward address resolution database for bind v9, which explains the requirements.

            $TTL            680400
            @               IN      SOA     lunn.org.       andrew.lunn.lunn.org (
            2003041801      ; serial
            10800           ; refresh
            1800            ; retry
            3600000         ; expire
            259200)         ; mimimum
            IN      NS      londo.lunn.org.

            hostnamev4      IN      A       192.168.88.1
            cnamev4         IN      CNAME   hostnamev4
            hostnamev6      IN      AAAA    fec0::88:4:3:2:1
            cnamev6         IN      CNAME   hostnamev6
            hostnamev46     IN      A       192.168.88.2
            hostnamev46     IN      AAAA    fec0::88:4:3:2:2
            cnamev46        IN      CNAME   hostnamev46

The actual names and addresses do not matter, since they are configurable in the test. What is important is the relationship between the names and the addresses and there family. ie hostnamev4 should map to one IPv4 address. hostnamev46 should map to both an IPv4 and an IPv6 address. cnamev4 should be a CNAME record for hostname4. Reverse lookup information is also needed by the test.

The information placed into the DNS server is also need in the test case. A structure is defined to hold this information:

            struct test_info_s {
                char * dns_server_v4;
                char * dns_server_v6;
                char * domain_name;
                char * hostname_v4;
                char * cname_v4;
                char * ip_addr_v4;
                char * hostname_v6;
                char * cname_v6;
                char * ip_addr_v6;
                char * hostname_v46;
                char * cname_v46;
                char * ip_addr_v46_v4;
                char * ip_addr_v46_v6;
            };

The test program may hold a number of such structures for different DNS server. The test will use each structure in turn to perform the tests. If IPv6 is not enabled in the eCos configuration, the entries which use IPv6 may be assigned to NULL.

Prev | Home | Next
DNS | Up | IPSEC for eCos