Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef _ARPA_NAMESER_H
  2. #define _ARPA_NAMESER_H
  3.  
  4. #include <sys/cdefs.h>
  5. #include <endian.h>
  6.  
  7. __BEGIN_DECLS
  8.  
  9. #define NS_PACKETSZ     512     /* maximum packet size */
  10. #define NS_MAXDNAME     1025    /* maximum domain name */
  11. #define NS_MAXCDNAME    255     /* maximum compressed domain name */
  12. #define NS_MAXLABEL     63      /* maximum length of domain label */
  13. #define NS_HFIXEDSZ     12      /* #/bytes of fixed data in header */
  14. #define NS_QFIXEDSZ     4       /* #/bytes of fixed data in query */
  15. #define NS_RRFIXEDSZ    10      /* #/bytes of fixed data in r record */
  16. #define NS_INT32SZ      4       /* #/bytes of data in a u_int32_t */
  17. #define NS_INT16SZ      2       /* #/bytes of data in a u_int16_t */
  18. #define NS_INT8SZ       1       /* #/bytes of data in a u_int8_t */
  19. #define NS_INADDRSZ     4       /* IPv4 T_A */
  20. #define NS_IN6ADDRSZ    16      /* IPv6 T_AAAA */
  21. #define NS_CMPRSFLGS    0xc0    /* Flag bits indicating name compression. */
  22. #define NS_DEFAULTPORT  53      /* For both TCP and UDP. */
  23.  
  24. /*
  25.  * Currently defined type values for resources and queries.
  26.  */
  27. typedef enum __ns_type {
  28.         ns_t_invalid = 0,       /* Cookie. */
  29.         ns_t_a = 1,             /* Host address. */
  30.         ns_t_ns = 2,            /* Authoritative server. */
  31.         ns_t_md = 3,            /* Mail destination. */
  32.         ns_t_mf = 4,            /* Mail forwarder. */
  33.         ns_t_cname = 5,         /* Canonical name. */
  34.         ns_t_soa = 6,           /* Start of authority zone. */
  35.         ns_t_mb = 7,            /* Mailbox domain name. */
  36.         ns_t_mg = 8,            /* Mail group member. */
  37.         ns_t_mr = 9,            /* Mail rename name. */
  38.         ns_t_null = 10,         /* Null resource record. */
  39.         ns_t_wks = 11,          /* Well known service. */
  40.         ns_t_ptr = 12,          /* Domain name pointer. */
  41.         ns_t_hinfo = 13,        /* Host information. */
  42.         ns_t_minfo = 14,        /* Mailbox information. */
  43.         ns_t_mx = 15,           /* Mail routing information. */
  44.         ns_t_txt = 16,          /* Text strings. */
  45.         ns_t_rp = 17,           /* Responsible person. */
  46.         ns_t_afsdb = 18,        /* AFS cell database. */
  47.         ns_t_x25 = 19,          /* X_25 calling address. */
  48.         ns_t_isdn = 20,         /* ISDN calling address. */
  49.         ns_t_rt = 21,           /* Router. */
  50.         ns_t_nsap = 22,         /* NSAP address. */
  51.         ns_t_nsap_ptr = 23,     /* Reverse NSAP lookup (deprecated). */
  52.         ns_t_sig = 24,          /* Security signature. */
  53.         ns_t_key = 25,          /* Security key. */
  54.         ns_t_px = 26,           /* X.400 mail mapping. */
  55.         ns_t_gpos = 27,         /* Geographical position (withdrawn). */
  56.         ns_t_aaaa = 28,         /* Ip6 Address. */
  57.         ns_t_loc = 29,          /* Location Information. */
  58.         ns_t_nxt = 30,          /* Next domain (security). */
  59.         ns_t_eid = 31,          /* Endpoint identifier. */
  60.         ns_t_nimloc = 32,       /* Nimrod Locator. */
  61.         ns_t_srv = 33,          /* Server Selection. */
  62.         ns_t_atma = 34,         /* ATM Address */
  63.         ns_t_naptr = 35,        /* Naming Authority PoinTeR */
  64.         ns_t_kx = 36,           /* Key Exchange */
  65.         ns_t_cert = 37,         /* Certification record */
  66.         ns_t_a6 = 38,           /* IPv6 address (deprecates AAAA) */
  67.         ns_t_dname = 39,        /* Non-terminal DNAME (for IPv6) */
  68.         ns_t_sink = 40,         /* Kitchen sink (experimentatl) */
  69.         ns_t_opt = 41,          /* EDNS0 option (meta-RR) */
  70.         ns_t_tsig = 250,        /* Transaction signature. */
  71.         ns_t_ixfr = 251,        /* Incremental zone transfer. */
  72.         ns_t_axfr = 252,        /* Transfer zone of authority. */
  73.         ns_t_mailb = 253,       /* Transfer mailbox records. */
  74.         ns_t_maila = 254,       /* Transfer mail agent records. */
  75.         ns_t_any = 255,         /* Wildcard match. */
  76.         ns_t_zxfr = 256,        /* BIND-specific, nonstandard. */
  77.         ns_t_max = 65536
  78. } ns_type;
  79.  
  80. /*
  81.  * Values for class field
  82.  */
  83. typedef enum __ns_class {
  84.         ns_c_invalid = 0,       /* Cookie. */
  85.         ns_c_in = 1,            /* Internet. */
  86.         ns_c_2 = 2,             /* unallocated/unsupported. */
  87.         ns_c_chaos = 3,         /* MIT Chaos-net. */
  88.         ns_c_hs = 4,            /* MIT Hesiod. */
  89.         /* Query class values which do not appear in resource records */
  90.         ns_c_none = 254,        /* for prereq. sections in update requests */
  91.         ns_c_any = 255,         /* Wildcard match. */
  92.         ns_c_max = 65536
  93. } ns_class;
  94.  
  95. /*
  96.  * Currently defined opcodes.
  97.  */
  98. typedef enum __ns_opcode {
  99.         ns_o_query = 0,         /* Standard query. */
  100.         ns_o_iquery = 1,        /* Inverse query (deprecated/unsupported). */
  101.         ns_o_status = 2,        /* Name server status query (unsupported). */
  102.                                 /* Opcode 3 is undefined/reserved. */
  103.         ns_o_notify = 4,        /* Zone change notification. */
  104.         ns_o_update = 5,        /* Zone update message. */
  105.         ns_o_max = 6
  106. } ns_opcode;
  107.  
  108. /*
  109.  * Currently defined response codes.
  110.  */
  111. typedef enum __ns_rcode {
  112.         ns_r_noerror = 0,       /* No error occurred. */
  113.         ns_r_formerr = 1,       /* Format error. */
  114.         ns_r_servfail = 2,      /* Server failure. */
  115.         ns_r_nxdomain = 3,      /* Name error. */
  116.         ns_r_notimpl = 4,       /* Unimplemented. */
  117.         ns_r_refused = 5,       /* Operation refused. */
  118.         /* these are for BIND_UPDATE */
  119.         ns_r_yxdomain = 6,      /* Name exists */
  120.         ns_r_yxrrset = 7,       /* RRset exists */
  121.         ns_r_nxrrset = 8,       /* RRset does not exist */
  122.         ns_r_notauth = 9,       /* Not authoritative for zone */
  123.         ns_r_notzone = 10,      /* Zone of record different from zone section */
  124.         ns_r_max = 11,
  125.         /* The following are TSIG extended errors */
  126.         ns_r_badsig = 16,
  127.         ns_r_badkey = 17,
  128.         ns_r_badtime = 18
  129. } ns_rcode;
  130.  
  131. typedef struct {
  132.         unsigned        id :16;         /* query identification number */
  133. #if BYTE_ORDER == BIG_ENDIAN
  134.                         /* fields in third byte */
  135.         unsigned        qr: 1;          /* response flag */
  136.         unsigned        opcode: 4;      /* purpose of message */
  137.         unsigned        aa: 1;          /* authoritive answer */
  138.         unsigned        tc: 1;          /* truncated message */
  139.         unsigned        rd: 1;          /* recursion desired */
  140.                         /* fields in fourth byte */
  141.         unsigned        ra: 1;          /* recursion available */
  142.         unsigned        unused :1;      /* unused bits (MBZ as of 4.9.3a3) */
  143.         unsigned        ad: 1;          /* authentic data from named */
  144.         unsigned        cd: 1;          /* checking disabled by resolver */
  145.         unsigned        rcode :4;       /* response code */
  146. #endif
  147. #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
  148.                         /* fields in third byte */
  149.         unsigned        rd :1;          /* recursion desired */
  150.         unsigned        tc :1;          /* truncated message */
  151.         unsigned        aa :1;          /* authoritive answer */
  152.         unsigned        opcode :4;      /* purpose of message */
  153.         unsigned        qr :1;          /* response flag */
  154.                         /* fields in fourth byte */
  155.         unsigned        rcode :4;       /* response code */
  156.         unsigned        cd: 1;          /* checking disabled by resolver */
  157.         unsigned        ad: 1;          /* authentic data from named */
  158.         unsigned        unused :1;      /* unused bits (MBZ as of 4.9.3a3) */
  159.         unsigned        ra :1;          /* recursion available */
  160. #endif
  161.                         /* remaining bytes */
  162.         unsigned        qdcount :16;    /* number of question entries */
  163.         unsigned        ancount :16;    /* number of answer entries */
  164.         unsigned        nscount :16;    /* number of authority entries */
  165.         unsigned        arcount :16;    /* number of resource entries */
  166. } HEADER;
  167.  
  168. #define PACKETSZ        NS_PACKETSZ
  169. #define MAXDNAME        NS_MAXDNAME
  170. #define MAXCDNAME       NS_MAXCDNAME
  171. #define MAXLABEL        NS_MAXLABEL
  172. #define HFIXEDSZ        NS_HFIXEDSZ
  173. #define QFIXEDSZ        NS_QFIXEDSZ
  174. #define RRFIXEDSZ       NS_RRFIXEDSZ
  175. #define INT32SZ         NS_INT32SZ
  176. #define INT16SZ         NS_INT16SZ
  177. #define INADDRSZ        NS_INADDRSZ
  178. #define IN6ADDRSZ       NS_IN6ADDRSZ
  179. #define INDIR_MASK      NS_CMPRSFLGS
  180. #define NAMESERVER_PORT NS_DEFAULTPORT
  181.  
  182. #define S_ZONE          ns_s_zn
  183. #define S_PREREQ        ns_s_pr
  184. #define S_UPDATE        ns_s_ud
  185. #define S_ADDT          ns_s_ar
  186.  
  187. #define QUERY           ns_o_query
  188. #define IQUERY          ns_o_iquery
  189. #define STATUS          ns_o_status
  190. #define NS_NOTIFY_OP    ns_o_notify
  191. #define NS_UPDATE_OP    ns_o_update
  192.  
  193. #define NOERROR         ns_r_noerror
  194. #define FORMERR         ns_r_formerr
  195. #define SERVFAIL        ns_r_servfail
  196. #define NXDOMAIN        ns_r_nxdomain
  197. #define NOTIMP          ns_r_notimpl
  198. #define REFUSED         ns_r_refused
  199. #define YXDOMAIN        ns_r_yxdomain
  200. #define YXRRSET         ns_r_yxrrset
  201. #define NXRRSET         ns_r_nxrrset
  202. #define NOTAUTH         ns_r_notauth
  203. #define NOTZONE         ns_r_notzone
  204.  
  205. #define DELETE          ns_uop_delete
  206. #define ADD             ns_uop_add
  207.  
  208. #define T_A             ns_t_a
  209. #define T_NS            ns_t_ns
  210. #define T_MD            ns_t_md
  211. #define T_MF            ns_t_mf
  212. #define T_CNAME         ns_t_cname
  213. #define T_SOA           ns_t_soa
  214. #define T_MB            ns_t_mb
  215. #define T_MG            ns_t_mg
  216. #define T_MR            ns_t_mr
  217. #define T_NULL          ns_t_null
  218. #define T_WKS           ns_t_wks
  219. #define T_PTR           ns_t_ptr
  220. #define T_HINFO         ns_t_hinfo
  221. #define T_MINFO         ns_t_minfo
  222. #define T_MX            ns_t_mx
  223. #define T_TXT           ns_t_txt
  224. #define T_RP            ns_t_rp
  225. #define T_AFSDB         ns_t_afsdb
  226. #define T_X25           ns_t_x25
  227. #define T_ISDN          ns_t_isdn
  228. #define T_RT            ns_t_rt
  229. #define T_NSAP          ns_t_nsap
  230. #define T_NSAP_PTR      ns_t_nsap_ptr
  231. #define T_SIG           ns_t_sig
  232. #define T_KEY           ns_t_key
  233. #define T_PX            ns_t_px
  234. #define T_GPOS          ns_t_gpos
  235. #define T_AAAA          ns_t_aaaa
  236. #define T_LOC           ns_t_loc
  237. #define T_NXT           ns_t_nxt
  238. #define T_EID           ns_t_eid
  239. #define T_NIMLOC        ns_t_nimloc
  240. #define T_SRV           ns_t_srv
  241. #define T_ATMA          ns_t_atma
  242. #define T_NAPTR         ns_t_naptr
  243. #define T_TSIG          ns_t_tsig
  244. #define T_IXFR          ns_t_ixfr
  245. #define T_AXFR          ns_t_axfr
  246. #define T_MAILB         ns_t_mailb
  247. #define T_MAILA         ns_t_maila
  248. #define T_ANY           ns_t_any
  249.  
  250. #define C_IN            ns_c_in
  251. #define C_CHAOS         ns_c_chaos
  252. #define C_HS            ns_c_hs
  253. #define C_NONE          ns_c_none
  254. #define C_ANY           ns_c_any
  255.  
  256. __END_DECLS
  257.  
  258. #endif
  259.