1 |
786 |
skrzyp |
#ifndef CYGONCE_NS_DNS_DNS_H
|
2 |
|
|
#define CYGONCE_NS_DNS_DNS_H
|
3 |
|
|
//=============================================================================
|
4 |
|
|
//
|
5 |
|
|
// dns.h
|
6 |
|
|
//
|
7 |
|
|
// DNS client code.
|
8 |
|
|
//
|
9 |
|
|
//=============================================================================
|
10 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//=============================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): andrew.lunn
|
45 |
|
|
// Contributors:andrew.lunn, jskov
|
46 |
|
|
// Date: 2001-09-18
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//=============================================================================
|
51 |
|
|
|
52 |
|
|
#include <network.h>
|
53 |
|
|
#include <netinet/in.h>
|
54 |
|
|
|
55 |
|
|
#ifndef _POSIX_SOURCE
|
56 |
|
|
/* Initialise the DNS client with the address of the server. The
|
57 |
|
|
address should be a IPv4 or IPv6 numeric address */
|
58 |
|
|
__externC int cyg_dns_res_start(char * server);
|
59 |
|
|
|
60 |
|
|
/* Old interface which is deprecated */
|
61 |
|
|
__externC int cyg_dns_res_init(struct in_addr *dns_server);
|
62 |
|
|
|
63 |
|
|
/* Functions to manipulate the domainname */
|
64 |
|
|
__externC int getdomainname(char *name, size_t len);
|
65 |
|
|
__externC int setdomainname(const char *name, size_t len);
|
66 |
|
|
#endif
|
67 |
|
|
|
68 |
|
|
// Host name / IP mapping
|
69 |
|
|
struct hostent {
|
70 |
|
|
char *h_name; /* official name of host */
|
71 |
|
|
char **h_aliases; /* alias list */
|
72 |
|
|
int h_addrtype; /* host address type */
|
73 |
|
|
int h_length; /* length of address */
|
74 |
|
|
char **h_addr_list; /* list of addresses */
|
75 |
|
|
};
|
76 |
|
|
#define h_addr h_addr_list[0] /* for backward compatibility */
|
77 |
|
|
|
78 |
|
|
__externC struct hostent *gethostbyname(const char *host);
|
79 |
|
|
__externC struct hostent *gethostbyaddr(const char *addr, int len, int type);
|
80 |
|
|
|
81 |
|
|
// Error reporting
|
82 |
|
|
__externC int h_errno;
|
83 |
|
|
__externC const char* hstrerror(int err);
|
84 |
|
|
|
85 |
|
|
#define DNS_SUCCESS 0
|
86 |
|
|
#define HOST_NOT_FOUND 1
|
87 |
|
|
#define TRY_AGAIN 2
|
88 |
|
|
#define NO_RECOVERY 3
|
89 |
|
|
#define NO_DATA 4
|
90 |
|
|
|
91 |
|
|
// Interface between the DNS client and getaddrinfo
|
92 |
|
|
__externC int
|
93 |
|
|
cyg_dns_getaddrinfo(const char * hostname,
|
94 |
|
|
struct sockaddr addrs[], int num,
|
95 |
|
|
int family, char **canon);
|
96 |
|
|
// Interface between the DNS client and getnameinfo
|
97 |
|
|
__externC int
|
98 |
|
|
cyg_dns_getnameinfo(const struct sockaddr * sa, char * host, size_t hostlen);
|
99 |
|
|
|
100 |
|
|
//-----------------------------------------------------------------------------
|
101 |
|
|
#endif // CYGONCE_NS_DNS_DNS_H
|
102 |
|
|
// End of dns.h
|