FreeRTOS_DNS.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * FreeRTOS+TCP V2.3.2 LTS Patch 1
  3. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * http://aws.amazon.com/freertos
  23. * http://www.FreeRTOS.org
  24. */
  25. #ifndef FREERTOS_DNS_H
  26. #define FREERTOS_DNS_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Application level configuration options. */
  31. #include "FreeRTOSIPConfig.h"
  32. #include "IPTraceMacroDefaults.h"
  33. /* The Link-local Multicast Name Resolution (LLMNR)
  34. * is included.
  35. * Note that a special MAC address is required in addition to the NIC's actual
  36. * MAC address: 01:00:5E:00:00:FC
  37. *
  38. * The target IP address will be 224.0.0.252
  39. */
  40. #if ( ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN )
  41. #define ipLLMNR_IP_ADDR 0xE00000FCUL
  42. #else
  43. #define ipLLMNR_IP_ADDR 0xFC0000E0UL
  44. #endif /* ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN */
  45. #define ipLLMNR_PORT 5355 /* Standard LLMNR port. */
  46. #define ipDNS_PORT 53 /* Standard DNS port. */
  47. #define ipDHCP_CLIENT 67
  48. #define ipDHCP_SERVER 68
  49. #define ipNBNS_PORT 137 /* NetBIOS Name Service. */
  50. #define ipNBDGM_PORT 138 /* Datagram Service, not included. */
  51. #if ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_NBNS == 1 )
  52. /*
  53. * The following function should be provided by the user and return true if it
  54. * matches the domain name.
  55. */
  56. extern BaseType_t xApplicationDNSQueryHook( const char * pcName );
  57. #endif /* ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_NBNS == 1 ) */
  58. /*
  59. * LLMNR is very similar to DNS, so is handled by the DNS routines.
  60. */
  61. uint32_t ulDNSHandlePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer );
  62. #if ( ipconfigUSE_LLMNR == 1 )
  63. /* The LLMNR MAC address is 01:00:5e:00:00:fc */
  64. extern const MACAddress_t xLLMNR_MacAdress;
  65. #endif /* ipconfigUSE_LLMNR */
  66. #if ( ipconfigUSE_NBNS != 0 )
  67. /*
  68. * Inspect a NetBIOS Names-Service message. If the name matches with ours
  69. * (xApplicationDNSQueryHook returns true) an answer will be sent back.
  70. * Note that LLMNR is a better protocol for name services on a LAN as it is
  71. * less polluted
  72. */
  73. uint32_t ulNBNSHandlePacket( NetworkBufferDescriptor_t * pxNetworkBuffer );
  74. #endif /* ipconfigUSE_NBNS */
  75. #if ( ipconfigUSE_DNS_CACHE != 0 )
  76. /* Look for the indicated host name in the DNS cache. Returns the IPv4
  77. * address if present, or 0x0 otherwise. */
  78. uint32_t FreeRTOS_dnslookup( const char * pcHostName );
  79. /* Remove all entries from the DNS cache. */
  80. void FreeRTOS_dnsclear( void );
  81. #endif /* ipconfigUSE_DNS_CACHE != 0 */
  82. #if ( ipconfigDNS_USE_CALLBACKS != 0 )
  83. /*
  84. * Users may define this type of function as a callback.
  85. * It will be called when a DNS reply is received or when a timeout has been reached.
  86. */
  87. typedef void (* FOnDNSEvent ) ( const char * /* pcName */,
  88. void * /* pvSearchID */,
  89. uint32_t /* ulIPAddress */ );
  90. /*
  91. * Asynchronous version of gethostbyname()
  92. * xTimeout is in units of ms.
  93. */
  94. uint32_t FreeRTOS_gethostbyname_a( const char * pcHostName,
  95. FOnDNSEvent pCallback,
  96. void * pvSearchID,
  97. TickType_t uxTimeout );
  98. void FreeRTOS_gethostbyname_cancel( void * pvSearchID );
  99. #endif /* if ( ipconfigDNS_USE_CALLBACKS != 0 ) */
  100. /*
  101. * Lookup a IPv4 node in a blocking-way.
  102. * It returns a 32-bit IP-address, 0 when not found.
  103. * gethostbyname() is already deprecated.
  104. */
  105. uint32_t FreeRTOS_gethostbyname( const char * pcHostName );
  106. #if ( ipconfigDNS_USE_CALLBACKS == 1 )
  107. /*
  108. * The function vDNSInitialise() initialises the DNS module.
  109. * It will be called "internally", by the IP-task.
  110. */
  111. void vDNSInitialise( void );
  112. #endif /* ( ipconfigDNS_USE_CALLBACKS == 1 ) */
  113. #if ( ipconfigDNS_USE_CALLBACKS == 1 )
  114. /*
  115. * A function local to the library.
  116. */
  117. extern void vDNSCheckCallBack( void * pvSearchID );
  118. #endif
  119. #ifdef __cplusplus
  120. } /* extern "C" */
  121. #endif
  122. #endif /* FREERTOS_DNS_H */