dns_resolver.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /* DNS resolver interface definitions.
  3. *
  4. * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells ([email protected])
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public Licence
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the Licence, or (at your option) any later version.
  11. */
  12. #ifndef _UAPI_LINUX_DNS_RESOLVER_H
  13. #define _UAPI_LINUX_DNS_RESOLVER_H
  14. #include <linux/types.h>
  15. /*
  16. * Type of payload.
  17. */
  18. enum dns_payload_content_type {
  19. DNS_PAYLOAD_IS_SERVER_LIST = 0, /* List of servers, requested by srv=1 */
  20. };
  21. /*
  22. * Type of address that might be found in an address record.
  23. */
  24. enum dns_payload_address_type {
  25. DNS_ADDRESS_IS_IPV4 = 0, /* 4-byte AF_INET address */
  26. DNS_ADDRESS_IS_IPV6 = 1, /* 16-byte AF_INET6 address */
  27. };
  28. /*
  29. * Type of protocol used to access a server.
  30. */
  31. enum dns_payload_protocol_type {
  32. DNS_SERVER_PROTOCOL_UNSPECIFIED = 0,
  33. DNS_SERVER_PROTOCOL_UDP = 1, /* Use UDP to talk to the server */
  34. DNS_SERVER_PROTOCOL_TCP = 2, /* Use TCP to talk to the server */
  35. };
  36. /*
  37. * Source of record included in DNS resolver payload.
  38. */
  39. enum dns_record_source {
  40. DNS_RECORD_UNAVAILABLE = 0, /* No source available (empty record) */
  41. DNS_RECORD_FROM_CONFIG = 1, /* From local configuration data */
  42. DNS_RECORD_FROM_DNS_A = 2, /* From DNS A or AAAA record */
  43. DNS_RECORD_FROM_DNS_AFSDB = 3, /* From DNS AFSDB record */
  44. DNS_RECORD_FROM_DNS_SRV = 4, /* From DNS SRV record */
  45. DNS_RECORD_FROM_NSS = 5, /* From NSS */
  46. NR__dns_record_source
  47. };
  48. /*
  49. * Status of record included in DNS resolver payload.
  50. */
  51. enum dns_lookup_status {
  52. DNS_LOOKUP_NOT_DONE = 0, /* No lookup has been made */
  53. DNS_LOOKUP_GOOD = 1, /* Good records obtained */
  54. DNS_LOOKUP_GOOD_WITH_BAD = 2, /* Good records, some decoding errors */
  55. DNS_LOOKUP_BAD = 3, /* Couldn't decode results */
  56. DNS_LOOKUP_GOT_NOT_FOUND = 4, /* Got a "Not Found" result */
  57. DNS_LOOKUP_GOT_LOCAL_FAILURE = 5, /* Local failure during lookup */
  58. DNS_LOOKUP_GOT_TEMP_FAILURE = 6, /* Temporary failure during lookup */
  59. DNS_LOOKUP_GOT_NS_FAILURE = 7, /* Name server failure */
  60. NR__dns_lookup_status
  61. };
  62. /*
  63. * Header at the beginning of binary format payload.
  64. */
  65. struct dns_payload_header {
  66. __u8 zero; /* Zero byte: marks this as not being text */
  67. __u8 content; /* enum dns_payload_content_type */
  68. __u8 version; /* Encoding version */
  69. } __packed;
  70. /*
  71. * Header at the beginning of a V1 server list. This is followed directly by
  72. * the server records. Each server records begins with a struct of type
  73. * dns_server_list_v1_server.
  74. */
  75. struct dns_server_list_v1_header {
  76. struct dns_payload_header hdr;
  77. __u8 source; /* enum dns_record_source */
  78. __u8 status; /* enum dns_lookup_status */
  79. __u8 nr_servers; /* Number of server records following this */
  80. } __packed;
  81. /*
  82. * Header at the beginning of each V1 server record. This is followed by the
  83. * characters of the name with no NUL-terminator, followed by the address
  84. * records for that server. Each address record begins with a struct of type
  85. * struct dns_server_list_v1_address.
  86. */
  87. struct dns_server_list_v1_server {
  88. __u16 name_len; /* Length of name (LE) */
  89. __u16 priority; /* Priority (as SRV record) (LE) */
  90. __u16 weight; /* Weight (as SRV record) (LE) */
  91. __u16 port; /* UDP/TCP port number (LE) */
  92. __u8 source; /* enum dns_record_source */
  93. __u8 status; /* enum dns_lookup_status */
  94. __u8 protocol; /* enum dns_payload_protocol_type */
  95. __u8 nr_addrs;
  96. } __packed;
  97. /*
  98. * Header at the beginning of each V1 address record. This is followed by the
  99. * bytes of the address, 4 for IPV4 and 16 for IPV6.
  100. */
  101. struct dns_server_list_v1_address {
  102. __u8 address_type; /* enum dns_payload_address_type */
  103. } __packed;
  104. #endif /* _UAPI_LINUX_DNS_RESOLVER_H */