10 FILE_LICENCE ( GPL2_OR_LATER );
15 /** DNS server port */
18 /** An RFC1035-encoded DNS name */
22 /** Offset of name within data */
24 /** Total length of data */
29 * Test for a DNS compression pointer
31 * @v byte Initial byte
32 * @ret is_compressed Is a compression pointer
34 #define DNS_IS_COMPRESSED( byte ) ( (byte) & 0xc0 )
37 * Extract DNS compression pointer
39 * @v word Initial word
42 #define DNS_COMPRESSED_OFFSET( word ) ( (word) & ~0xc000 )
45 * Extract DNS label length
47 * @v byte Initial byte
48 * @ret len Label length
50 #define DNS_LABEL_LEN( byte ) ( (byte) & ~0xc0 )
52 /** Maximum length of a single DNS label */
53 #define DNS_MAX_LABEL_LEN 0x3f
55 /** Maximum length of a DNS name (mandated by RFC1035 section 2.3.4) */
56 #define DNS_MAX_NAME_LEN 255
58 /** Maximum depth of CNAME recursion
60 * This is a policy decision.
62 #define DNS_MAX_CNAME_RECURSION 32
64 /** A DNS packet header */
66 /** Query identifier */
70 /** Number of question records */
72 /** Number of answer records */
74 /** Number of name server records */
76 /** Number of additional records */
78 } __attribute__ (( packed ));
80 /** Recursion desired flag */
81 #define DNS_FLAG_RD 0x0100
89 } __attribute__ (( packed ));
92 #define DNS_CLASS_IN 1
94 /** A DNS resource record */
95 struct dns_rr_common {
102 /** Resource data length */
104 } __attribute__ (( packed ));
106 /** Type of a DNS "A" record */
109 /** A DNS "A" record */
112 struct dns_rr_common common;
114 struct in_addr in_addr;
115 } __attribute__ (( packed ));
117 /** Type of a DNS "AAAA" record */
118 #define DNS_TYPE_AAAA 28
120 /** A DNS "AAAA" record */
123 struct dns_rr_common common;
125 struct in6_addr in6_addr;
126 } __attribute__ (( packed ));
128 /** Type of a DNS "NAME" record */
129 #define DNS_TYPE_CNAME 5
131 /** A DNS "CNAME" record */
132 struct dns_rr_cname {
134 struct dns_rr_common common;
135 } __attribute__ (( packed ));
137 /** A DNS resource record */
140 struct dns_rr_common common;
144 struct dns_rr_aaaa aaaa;
145 /** "CNAME" record */
146 struct dns_rr_cname cname;
149 extern int dns_encode ( const char *string, struct dns_name *name );
150 extern int dns_decode ( struct dns_name *name, char *data, size_t len );
151 extern int dns_compare ( struct dns_name *first, struct dns_name *second );
152 extern int dns_copy ( struct dns_name *src, struct dns_name *dst );
153 extern int dns_skip ( struct dns_name *name );
155 #endif /* _IPXE_DNS_H */