123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103(*
* Copyright (c) 2005-2006 Tim Deegan <tjd@phlegethon.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* dnsrr.ml --- datatypes and handling for DNS RRs and RRSets
*
*)(* Mnemonicity! *)typeserial=int32typecstr=stringHashcons.hash_consed(* DNS node: everything we know about a domain name *)anddnsnode={owner:Name.tHashcons.hash_consed;mutablerrsets:rrsetlist;}(* RRSet: TTL, type, and some number of rdata *)andrrset={ttl:int32;rdata:rdata;}andrrsig={rrsig_type:Packet.rr_type;rrsig_alg:Packet.dnssec_alg;rrsig_labels:char;rrsig_ttl:int32;rrsig_expiry:int32;rrsig_incept:int32;rrsig_keytag:int;rrsig_name:Name.t;rrsig_sig:string;}andrdata=|AofIpaddr.V4.tlist(* always length = 1 *)|AAAAofIpaddr.V6.tlist(* always length = 1 *)|AFSDBof(Cstruct.uint16*dnsnode)list|CNAMEofdnsnodelist|HINFOof(cstr*cstr)list|ISDNof(cstr*cstroption)list|MBofdnsnodelist(* MD and MF are obsolete; use MX for them *)|MGofdnsnodelist|MINFOof(dnsnode*dnsnode)list|MRofdnsnodelist|MXof(Cstruct.uint16*dnsnode)list|NSofdnsnodelist|PTRofdnsnodelist|RPof(dnsnode*dnsnode)list|RTof(Cstruct.uint16*dnsnode)list|SOAof(dnsnode*dnsnode*serial*int32*int32*int32*int32)list|SRVof(Cstruct.uint16*Cstruct.uint16*Cstruct.uint16*dnsnode)list|TXTof(cstrlist)list(* | UNSPEC of cstr list*)|Unknownofint*cstrlist|WKSof(Ipaddr.V4.t*Cstruct.byte*cstr)list|X25ofcstrlist|DNSKEYof(int*int*cstr)list|DSof(int*Packet.dnssec_alg*Packet.digest_alg*cstr)list|RRSIGofrrsiglist(* XXX add other RR types *)(* wire-domain type for non-rfc1035 rdata? *)letrdata_to_string=function|A_->"A"|AAAA_->"AAAA"|AFSDB_->"AFSDB"|CNAME_->"CNAME"|HINFO_->"HINFO"|ISDN_->"ISDN"|MB_->"MB"|MG_->"MG"|MINFO_->"MINFO"|MR_->"MR"|MX_->"MX"|NS_->"NS"|PTR_->"PTR"|RP_->"RP"|RT_->"RT"|SOA_->"SOA"|SRV_->"SRV"|TXT_->"TXT"|Unknown_->"Unknown"|WKS_->"WKS"|X25_->"X25"|DNSKEY_->"DNSKEY"|RRSIG_->"RRSIG"|DS_->"DS"