net.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*++
  2. Copyright (c) 2015 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. net.h
  9. Abstract:
  10. This header contains internal definitions for networking support in the
  11. C library.
  12. Author:
  13. Evan Green 23-Jan-2015
  14. --*/
  15. //
  16. // ------------------------------------------------------------------- Includes
  17. //
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. //
  22. // Define the standard reserved port number for DNS requests.
  23. //
  24. #define DNS_PORT_NUMBER 53
  25. //
  26. // Define DNS request/response flags. These flags code a 16-bit field assuming
  27. // a little endian machine.
  28. //
  29. #define DNS_HEADER_FLAG_RESPONSE 0x0080
  30. #define DNS_HEADER_OPCODE_SHIFT 3
  31. #define DNS_HEADER_OPCODE_QUERY 0x0
  32. #define DNS_HEADER_OPCODE_INVERSE_QUERY 0x1
  33. #define DNS_HEADER_OPCODE_STATUS 0x2
  34. #define DNS_HEADER_OPCODE_UPDATE 0x5
  35. #define DNS_HEADER_OPCODE_MASK 0xF
  36. #define DNS_HEADER_FLAG_AUTHORITATIVE_ANSWER 0x0004
  37. #define DNS_HEADER_FLAG_TRUNCATION 0x0002
  38. #define DNS_HEADER_FLAG_RECURSION_DESIRED 0x0001
  39. #define DNS_EHADER_FLAG_RECURSION_AVAILABLE 0x8000
  40. #define DNS_HEADER_RESPONSE_SHIFT 8
  41. #define DNS_HEADER_RESPONSE_SUCCESS 0x0
  42. #define DNS_HEADER_RESPONSE_FORMAT_ERROR 0x1
  43. #define DNS_HEADER_RESPONSE_SERVER_FAILURE 0x2
  44. #define DNS_HEADER_RESPONSE_NAME_ERROR 0x3
  45. #define DNS_HEADER_RESPONSE_NOT_IMPLEMENTED 0x4
  46. #define DNS_HEADER_RESPONSE_REFUSED 0x5
  47. #define DNS_HEADER_RESPONSE_MASK 0xF
  48. #define DNS_COMPRESSION_MASK 0xC0
  49. #define DNS_COMPRESSION_VALUE 0xC0
  50. #define DNS_MAX_NAME 255
  51. #define NETWORK_DEVICE_COUNT_ESTIMATE 5
  52. //
  53. // ------------------------------------------------------ Data Type Definitions
  54. //
  55. /*++
  56. Structure Description:
  57. This structure defines a DNS request and response header.
  58. Members:
  59. Identifier - Stores a 16-bit identifier used to uniquely identify the
  60. request.
  61. Flags - Stores a set of flags relating to the request or response.
  62. QuestionCount - Stores the number of questions in the remainder of the
  63. packet.
  64. AnswerCount - Stores the numer of answers in the remainder of the packet.
  65. NameServerCount - Stores the number of name server responses in the packet.
  66. AdditionalResourceCount - Stores the number of additional resources in the
  67. packet.
  68. --*/
  69. #pragma pack(push, 1)
  70. typedef struct _DNS_HEADER {
  71. USHORT Identifier;
  72. USHORT Flags;
  73. USHORT QuestionCount;
  74. USHORT AnswerCount;
  75. USHORT NameServerCount;
  76. USHORT AdditionalResourceCount;
  77. } PACKED DNS_HEADER, *PDNS_HEADER;
  78. #pragma pack(pop)
  79. //
  80. // -------------------------------------------------------------------- Globals
  81. //
  82. //
  83. // Define the network device information UUID.
  84. //
  85. extern UUID ClNetworkDeviceInformationUuid;
  86. //
  87. // -------------------------------------------------------- Function Prototypes
  88. //