Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /* DNS resolver interface definitions.
0003  *
0004  * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
0005  * Written by David Howells (dhowells@redhat.com)
0006  *
0007  * This program is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU General Public Licence
0009  * as published by the Free Software Foundation; either version
0010  * 2 of the Licence, or (at your option) any later version.
0011  */
0012 
0013 #ifndef _UAPI_LINUX_DNS_RESOLVER_H
0014 #define _UAPI_LINUX_DNS_RESOLVER_H
0015 
0016 #include <linux/types.h>
0017 
0018 /*
0019  * Type of payload.
0020  */
0021 enum dns_payload_content_type {
0022     DNS_PAYLOAD_IS_SERVER_LIST  = 0, /* List of servers, requested by srv=1 */
0023 };
0024 
0025 /*
0026  * Type of address that might be found in an address record.
0027  */
0028 enum dns_payload_address_type {
0029     DNS_ADDRESS_IS_IPV4     = 0, /* 4-byte AF_INET address */
0030     DNS_ADDRESS_IS_IPV6     = 1, /* 16-byte AF_INET6 address */
0031 };
0032 
0033 /*
0034  * Type of protocol used to access a server.
0035  */
0036 enum dns_payload_protocol_type {
0037     DNS_SERVER_PROTOCOL_UNSPECIFIED = 0,
0038     DNS_SERVER_PROTOCOL_UDP     = 1, /* Use UDP to talk to the server */
0039     DNS_SERVER_PROTOCOL_TCP     = 2, /* Use TCP to talk to the server */
0040 };
0041 
0042 /*
0043  * Source of record included in DNS resolver payload.
0044  */
0045 enum dns_record_source {
0046     DNS_RECORD_UNAVAILABLE      = 0, /* No source available (empty record) */
0047     DNS_RECORD_FROM_CONFIG      = 1, /* From local configuration data */
0048     DNS_RECORD_FROM_DNS_A       = 2, /* From DNS A or AAAA record */
0049     DNS_RECORD_FROM_DNS_AFSDB   = 3, /* From DNS AFSDB record */
0050     DNS_RECORD_FROM_DNS_SRV     = 4, /* From DNS SRV record */
0051     DNS_RECORD_FROM_NSS     = 5, /* From NSS */
0052     NR__dns_record_source
0053 };
0054 
0055 /*
0056  * Status of record included in DNS resolver payload.
0057  */
0058 enum dns_lookup_status {
0059     DNS_LOOKUP_NOT_DONE     = 0, /* No lookup has been made */
0060     DNS_LOOKUP_GOOD         = 1, /* Good records obtained */
0061     DNS_LOOKUP_GOOD_WITH_BAD    = 2, /* Good records, some decoding errors */
0062     DNS_LOOKUP_BAD          = 3, /* Couldn't decode results */
0063     DNS_LOOKUP_GOT_NOT_FOUND    = 4, /* Got a "Not Found" result */
0064     DNS_LOOKUP_GOT_LOCAL_FAILURE    = 5, /* Local failure during lookup */
0065     DNS_LOOKUP_GOT_TEMP_FAILURE = 6, /* Temporary failure during lookup */
0066     DNS_LOOKUP_GOT_NS_FAILURE   = 7, /* Name server failure */
0067     NR__dns_lookup_status
0068 };
0069 
0070 /*
0071  * Header at the beginning of binary format payload.
0072  */
0073 struct dns_payload_header {
0074     __u8        zero;       /* Zero byte: marks this as not being text */
0075     __u8        content;    /* enum dns_payload_content_type */
0076     __u8        version;    /* Encoding version */
0077 } __packed;
0078 
0079 /*
0080  * Header at the beginning of a V1 server list.  This is followed directly by
0081  * the server records.  Each server records begins with a struct of type
0082  * dns_server_list_v1_server.
0083  */
0084 struct dns_server_list_v1_header {
0085     struct dns_payload_header hdr;
0086     __u8        source;     /* enum dns_record_source */
0087     __u8        status;     /* enum dns_lookup_status */
0088     __u8        nr_servers; /* Number of server records following this */
0089 } __packed;
0090 
0091 /*
0092  * Header at the beginning of each V1 server record.  This is followed by the
0093  * characters of the name with no NUL-terminator, followed by the address
0094  * records for that server.  Each address record begins with a struct of type
0095  * struct dns_server_list_v1_address.
0096  */
0097 struct dns_server_list_v1_server {
0098     __u16       name_len;   /* Length of name (LE) */
0099     __u16       priority;   /* Priority (as SRV record) (LE) */
0100     __u16       weight;     /* Weight (as SRV record) (LE) */
0101     __u16       port;       /* UDP/TCP port number (LE) */
0102     __u8        source;     /* enum dns_record_source */
0103     __u8        status;     /* enum dns_lookup_status */
0104     __u8        protocol;   /* enum dns_payload_protocol_type */
0105     __u8        nr_addrs;
0106 } __packed;
0107 
0108 /*
0109  * Header at the beginning of each V1 address record.  This is followed by the
0110  * bytes of the address, 4 for IPV4 and 16 for IPV6.
0111  */
0112 struct dns_server_list_v1_address {
0113     __u8        address_type;   /* enum dns_payload_address_type */
0114 } __packed;
0115 
0116 #endif /* _UAPI_LINUX_DNS_RESOLVER_H */