dns.h

Go to the documentation of this file.
00001 #ifndef _GPXE_DNS_H
00002 #define _GPXE_DNS_H
00003 
00004 /** @file
00005  *
00006  * DNS protocol
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011 
00012 #include <stdint.h>
00013 #include <gpxe/in.h>
00014 
00015 /*
00016  * Constants
00017  *
00018  */
00019 
00020 #define DNS_TYPE_A              1
00021 #define DNS_TYPE_CNAME          5
00022 #define DNS_TYPE_ANY            255
00023 
00024 #define DNS_CLASS_IN            1
00025 #define DNS_CLASS_CS            2
00026 #define DNS_CLASS_CH            3
00027 #define DNS_CLASS_HS            4
00028 
00029 #define DNS_FLAG_QUERY          ( 0x00 << 15 )
00030 #define DNS_FLAG_RESPONSE       ( 0x01 << 15 )
00031 #define DNS_FLAG_QR(flags)      ( (flags) & ( 0x01 << 15 ) )
00032 #define DNS_FLAG_OPCODE_QUERY   ( 0x00 << 11 )
00033 #define DNS_FLAG_OPCODE_IQUERY  ( 0x01 << 11 )
00034 #define DNS_FLAG_OPCODE_STATUS  ( 0x02 << 11 )
00035 #define DNS_FLAG_OPCODE(flags)  ( (flags) & ( 0x0f << 11 ) )
00036 #define DNS_FLAG_RD             ( 0x01 << 8 )
00037 #define DNS_FLAG_RA             ( 0x01 << 7 )
00038 #define DNS_FLAG_RCODE_OK       ( 0x00 << 0 )
00039 #define DNS_FLAG_RCODE_NX       ( 0x03 << 0 )
00040 #define DNS_FLAG_RCODE(flags)   ( (flags) & ( 0x0f << 0 ) )
00041 
00042 #define DNS_PORT                53
00043 #define DNS_MAX_RETRIES         3
00044 #define DNS_MAX_CNAME_RECURSION 0x30
00045 
00046 /*
00047  * DNS protocol structures
00048  *
00049  */
00050 struct dns_header {
00051         uint16_t        id;
00052         uint16_t        flags;
00053         uint16_t        qdcount;
00054         uint16_t        ancount;
00055         uint16_t        nscount;
00056         uint16_t        arcount;
00057 } __attribute__ (( packed ));
00058 
00059 struct dns_query_info {
00060         uint16_t        qtype;
00061         uint16_t        qclass;
00062 } __attribute__ (( packed ));
00063 
00064 struct dns_query {
00065         struct dns_header dns;
00066         char            payload[ 256 + sizeof ( struct dns_query_info ) ];
00067 } __attribute__ (( packed ));
00068 
00069 struct dns_rr_info_common {
00070         uint16_t        type;
00071         uint16_t        class;
00072         uint32_t        ttl;
00073         uint16_t        rdlength;
00074 } __attribute__ (( packed ));
00075 
00076 struct dns_rr_info_a {
00077         struct dns_rr_info_common common;
00078         struct in_addr in_addr;
00079 } __attribute__ (( packed ));
00080 
00081 struct dns_rr_info_cname {
00082         struct dns_rr_info_common common;
00083         char cname[0];
00084 } __attribute__ (( packed ));
00085 
00086 union dns_rr_info {
00087         struct dns_rr_info_common common;
00088         struct dns_rr_info_a a;
00089         struct dns_rr_info_cname cname;
00090 };
00091 
00092 #endif /* _GPXE_DNS_H */

Generated on Tue Apr 6 20:01:06 2010 for gPXE by  doxygen 1.5.7.1