netdb.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #ifndef _NETDB_H_
  2. /*
  3. * Copyright (C) 2002 by egnite Software GmbH. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the copyright holders nor the names of
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  21. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  22. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  25. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  26. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  27. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  28. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * For additional information see http://www.ethernut.de/
  32. *
  33. * -
  34. * Copyright (c) 1980, 1983, 1988, 1993
  35. * The Regents of the University of California. All rights reserved.
  36. *
  37. * Redistribution and use in source and binary forms, with or without
  38. * modification, are permitted provided that the following conditions
  39. * are met:
  40. * 1. Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * 2. Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in the
  44. * documentation and/or other materials provided with the distribution.
  45. * 3. Neither the name of the University nor the names of its contributors
  46. * may be used to endorse or promote products derived from this software
  47. * without specific prior written permission.
  48. *
  49. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59. * SUCH DAMAGE.
  60. *
  61. * -
  62. * Portions Copyright (c) 1993 by Digital Equipment Corporation.
  63. *
  64. * Permission to use, copy, modify, and distribute this software for any
  65. * purpose with or without fee is hereby granted, provided that the above
  66. * copyright notice and this permission notice appear in all copies, and that
  67. * the name of Digital Equipment Corporation not be used in advertising or
  68. * publicity pertaining to distribution of the document or software without
  69. * specific, written prior permission.
  70. *
  71. * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  72. * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  73. * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
  74. * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  75. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  76. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  77. * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  78. * SOFTWARE.
  79. */
  80. /*
  81. * $Log$
  82. * Revision 1.9 2009/03/05 22:16:57 freckle
  83. * use __NUT_EMULATION instead of __APPLE__, __linux__, or __CYGWIN__
  84. *
  85. * Revision 1.8 2008/08/11 06:59:58 haraldkipp
  86. * BSD types replaced by stdint types (feature request #1282721).
  87. *
  88. * Revision 1.7 2008/02/15 17:07:09 haraldkipp
  89. * Added routine to query DNS IP settings.
  90. *
  91. * Revision 1.6 2005/07/26 15:49:59 haraldkipp
  92. * Cygwin support added.
  93. *
  94. * Revision 1.5 2005/04/04 19:33:40 freckle
  95. * added creation of include/netdb_orig.h, include/sys/socket_orig.h and
  96. * include/netinet/in_orig.h to allow unix emulation to use tcp/ip sockets
  97. *
  98. * Revision 1.4 2004/04/15 19:28:02 drsung
  99. * New function NutDnsGetMxByDomain to request
  100. * an MX record from DNS server.
  101. *
  102. * Revision 1.3 2004/03/16 16:48:27 haraldkipp
  103. * Added Jan Dubiec's H8/300 port.
  104. *
  105. * Revision 1.2 2003/07/20 18:26:41 haraldkipp
  106. * Support secondary DNS.
  107. *
  108. * Revision 1.1.1.1 2003/05/09 14:41:03 haraldkipp
  109. * Initial using 3.2.1
  110. *
  111. * Revision 1.5 2003/05/06 18:38:33 harald
  112. * Cleanup
  113. *
  114. * Revision 1.4 2003/02/04 18:00:36 harald
  115. * Version 3 released
  116. *
  117. * Revision 1.3 2002/06/26 17:29:14 harald
  118. * First pre-release with 2.4 stack
  119. *
  120. */
  121. /* use native version on unix emulation */
  122. #ifdef __NUT_EMULATION__
  123. #include <netdb_orig.h>
  124. /* assure _NETDB_H_ is set */
  125. #undef _NETDB_H_
  126. #define _NETDB_H_
  127. #else /* unix emulation */
  128. #define _NETDB_H_
  129. #include <sys/types.h>
  130. #include <stdint.h>
  131. #include <compiler.h> // For NUT_DEPRECATED
  132. /*
  133. * Error return codes.
  134. */
  135. #define NETDB_INTERNAL -1 /* see errno */
  136. #define NETDB_SUCCESS 0 /* no problem */
  137. #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
  138. #define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */
  139. #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  140. #define NO_DATA 4 /* Valid name, no data record of requested type */
  141. #define NO_ADDRESS NO_DATA /* no address, look for MX record */
  142. #endif /* unix emulation */
  143. typedef struct {
  144. uint8_t *doc_hostname;
  145. uint8_t *doc_domain;
  146. uint32_t doc_ip1;
  147. uint32_t doc_ip2;
  148. } DNSCONFIG;
  149. extern void NutDnsConfig2(const uint8_t * hostname, const uint8_t * domain, uint32_t pdnsip, uint32_t sdnsip);
  150. extern void NutDnsGetConfig2(char ** hostname, char ** domain, uint32_t *pdnsip, uint32_t *sdnsip);
  151. extern void NutDnsConfig(const uint8_t *hostname, const uint8_t *domain, uint32_t dnsip) NUT_DEPRECATED;
  152. extern uint32_t NutDnsGetHostByName(const uint8_t *hostname);
  153. extern uint8_t NutDnsGetHostsByName(const uint8_t * hostname, uint32_t * ip_all);
  154. extern uint32_t NutDnsGetMxByDomain(const uint8_t * hostname);
  155. #endif