OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [ns/] [dns/] [current/] [doc/] [dns.sgml] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
2
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
28
29
 
30
31
DNS for eCos and RedBoot
32
33
34
eCos and
35
RedBoot
36
can both use the DNS package to perform network name lookups.
37
38
39
40
DNS
41
42
DNS API
43
The DNS client uses the normal BSD API for performing lookups:
44
gethostbyname(),
45
gethostbyaddr(),
46
getaddrinfo(),
47
getnameinfo().
48
49
There are a few restrictions:
50
51
52
If the DNS server returns multiple authoritive records
53
for a host name to gethostbyname, the hostent will only contain a record for the
54
first entry. If multiple records are desired, use
55
getaddrinfo, which will return multiple results.
56
57
58
The code has been made thread safe. ie multiple threads
59
may call
60
gethostbyname()
61
 without causing problems to the hostent structure returned. What
62
is not safe is one thread using both
63
gethostbyname()
64
 and
65
gethostbyaddr().
66
A call to one will destroy the results from the previous call
67
to the other function. getaddrinfo() and
68
getnameinfo() are thread
69
safe and so these are the preferred interfaces. They are also address
70
family independent so making it easier to port code to IPv6.
71
72
The DNS client will only return IPv4 addresses to
73
RedBoot. At the moment this is not really a limitation,
74
since RedBoot only supports IPv4 and not IPv6.
75
76
77
To initialise the DNS client the following function must be
78
called:
79
#include <network.h>
80
int cyg_dns_res_start(char * dns_server)
81
 
82
Where dns_server is the address of the DNS server. The address
83
must be in numeric form and can be either an IPv4 or an IPv6 address.
84
85
There also exists a deprecated function to start the DNS
86
client:
87
88
int cyg_dns_res_init(struct in_addr *dns_server)
89
where dns_server is the address of the DNS server
90
the client should query. The address should be in network order and
91
can only be an IPv4 address.
92
93
 
94
 On error both this function returns -1, otherwise
95
 
96
been called, they will fail and return NULL, unless numeric host addresses
97
are passed. In this cause, the address will be converted and returned
98
without the need for a lookup.
99
 
100
A default, hard coded, server may be specified in the CDL option
101
CYGDAT_NS_DNS_DEFAULT_SERVER. The use of this is
102
controlled by CYGPKG_NS_DNS_DEFAULT. If this is
103
enabled, init_all_network_interfaces() will
104
initialize the resolver with the hard coded address. The DHCP client
105
or user code my override this address by calling
106
cyg_dns_res_init again. 
107
 
108
The DNS client understands the concepts of the target being
109
in a domain. By default no domain will be used. Host name lookups
110
should be for fully qualified names. The domain name can be set
111
and retrieved using the functions:
112
113
  
114
    int getdomainname
115
    char *name
116
    size_t len
117
  
118
  
119
    int setdomainname
120
    const char *name
121
    size_t len
122
  
123
124
125
 
126
Alternatively, a hard coded domain name can be set using CDL.
127
The boolean CYGPKG_NS_DNS_DOMAINNAME enables this
128
and the domain name is taken from
129
CYGPKG_NS_DNS_DOMAINNAME_NAME.
130
 
131
Once set, the DNS client will use some simple heuristics when
132
      deciding how to use the domainname. If the name given to the
133
      client ends with a "." it is assumed to be a FQDN and the domain
134
      name will not be used. If the name contains a "." somewhere
135
      within it, first a lookup will be performed without the
136
      domainname. If that fails the domainname will be appended and
137
      looked up. If the name does not contain a ".", the domainname is
138
      appended and used for the first query. If that fails, the
139
      unadorned name is lookup.
140
141
      The getaddrinfo will return both IPv4 and
142
        IPv6 addresses for a given host name, when IPv6 is enabled in
143
        the eCos configuration.  The CDL option
144
        CYGOPT_NS_DNS_FIRST_FAMILY controls the order
145
        IPv6 and IPv4 addresses are returned in the linked list of
146
        addrinfo structures. If the value
147
        AF_INET is used, the IPv4 addresses will be
148
        first. If the value AF_INET6, which is the
149
        default, is used, IPv6 address will be first. This ordering will
150
        control how clients attempt to connect to servers, ie using IPv6
151
        or IPv4 first.
152
      
153
    
154
    
155
      DNS Client Testing
156
 
157
      The DNS client has a test program, dns1.c, which tests many of
158
        the features of the DNS client and the functions
159
        gethostbyname(),
160
        gethostbyaddr(),
161
        getaddrinfo(),
162
        getnameinfo().
163
      
164
      In order for this test to work, a DNS server must be configured
165
        with a number of names and addresses. The following is an example
166
        forward address resolution database for bind v9, which explains the
167
        requirements.
168
 
169
      
170
        $TTL            680400
171
        @               IN      SOA     lunn.org.       andrew.lunn.lunn.org (
172
        2003041801      ; serial
173
        10800           ; refresh
174
        1800            ; retry
175
        3600000         ; expire
176
        259200)         ; mimimum
177
        IN      NS      londo.lunn.org.
178
 
179
        hostnamev4      IN      A       192.168.88.1
180
        cnamev4         IN      CNAME   hostnamev4
181
        hostnamev6      IN      AAAA    fec0::88:4:3:2:1
182
        cnamev6         IN      CNAME   hostnamev6
183
        hostnamev46     IN      A       192.168.88.2
184
        hostnamev46     IN      AAAA    fec0::88:4:3:2:2
185
        cnamev46        IN      CNAME   hostnamev46
186
      
187
      The actual names and addresses do not matter, since they are
188
        configurable in the test. What is important is the relationship
189
        between the names and the addresses and there family. ie
190
        hostnamev4 should map to one IPv4 address. hostnamev46 should
191
        map to both an IPv4 and an IPv6 address. cnamev4 should be a
192
        CNAME record for hostname4. Reverse lookup information is also
193
        needed by the test.
194
      
195
      The information placed into the DNS server is also need in the
196
        test case. A structure is defined to hold this
197
        information:
198
      
199
        struct test_info_s {
200
            char * dns_server_v4;
201
            char * dns_server_v6;
202
            char * domain_name;
203
            char * hostname_v4;
204
            char * cname_v4;
205
            char * ip_addr_v4;
206
            char * hostname_v6;
207
            char * cname_v6;
208
            char * ip_addr_v6;
209
            char * hostname_v46;
210
            char * cname_v46;
211
            char * ip_addr_v46_v4;
212
            char * ip_addr_v46_v6;
213
        };
214
        
215
      The test program may hold a number of such structures for
216
        different DNS server. The test will use each structure in turn
217
        to perform the tests.  If IPv6 is not enabled in the eCos
218
        configuration, the entries which use IPv6 may be assigned to
219
        NULL.
220
        
221
    
222
  
223

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.