1b528cefcSMark Murray /* 28373020dSJacques Vidrine * Copyright (c) 1995 - 2002 Kungliga Tekniska H�gskolan 3b528cefcSMark Murray * (Royal Institute of Technology, Stockholm, Sweden). 4b528cefcSMark Murray * All rights reserved. 5b528cefcSMark Murray * 6b528cefcSMark Murray * Redistribution and use in source and binary forms, with or without 7b528cefcSMark Murray * modification, are permitted provided that the following conditions 8b528cefcSMark Murray * are met: 9b528cefcSMark Murray * 10b528cefcSMark Murray * 1. Redistributions of source code must retain the above copyright 11b528cefcSMark Murray * notice, this list of conditions and the following disclaimer. 12b528cefcSMark Murray * 13b528cefcSMark Murray * 2. Redistributions in binary form must reproduce the above copyright 14b528cefcSMark Murray * notice, this list of conditions and the following disclaimer in the 15b528cefcSMark Murray * documentation and/or other materials provided with the distribution. 16b528cefcSMark Murray * 17b528cefcSMark Murray * 3. Neither the name of the Institute nor the names of its contributors 18b528cefcSMark Murray * may be used to endorse or promote products derived from this software 19b528cefcSMark Murray * without specific prior written permission. 20b528cefcSMark Murray * 21b528cefcSMark Murray * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22b528cefcSMark Murray * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23b528cefcSMark Murray * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24b528cefcSMark Murray * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25b528cefcSMark Murray * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26b528cefcSMark Murray * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27b528cefcSMark Murray * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28b528cefcSMark Murray * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29b528cefcSMark Murray * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30b528cefcSMark Murray * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31b528cefcSMark Murray * SUCH DAMAGE. 32b528cefcSMark Murray */ 33b528cefcSMark Murray 348373020dSJacques Vidrine /* $Id: resolve.h,v 1.15 2002/08/26 13:30:16 assar Exp $ */ 35b528cefcSMark Murray 36b528cefcSMark Murray #ifndef __RESOLVE_H__ 37b528cefcSMark Murray #define __RESOLVE_H__ 38b528cefcSMark Murray 39b528cefcSMark Murray /* We use these, but they are not always present in <arpa/nameser.h> */ 40b528cefcSMark Murray 41b528cefcSMark Murray #ifndef T_TXT 42b528cefcSMark Murray #define T_TXT 16 43b528cefcSMark Murray #endif 44b528cefcSMark Murray #ifndef T_AFSDB 45b528cefcSMark Murray #define T_AFSDB 18 46b528cefcSMark Murray #endif 475e9cd1aeSAssar Westerlund #ifndef T_SIG 485e9cd1aeSAssar Westerlund #define T_SIG 24 495e9cd1aeSAssar Westerlund #endif 505e9cd1aeSAssar Westerlund #ifndef T_KEY 515e9cd1aeSAssar Westerlund #define T_KEY 25 525e9cd1aeSAssar Westerlund #endif 538373020dSJacques Vidrine #ifndef T_AAAA 548373020dSJacques Vidrine #define T_AAAA 28 558373020dSJacques Vidrine #endif 56b528cefcSMark Murray #ifndef T_SRV 57b528cefcSMark Murray #define T_SRV 33 58b528cefcSMark Murray #endif 59b528cefcSMark Murray #ifndef T_NAPTR 60b528cefcSMark Murray #define T_NAPTR 35 61b528cefcSMark Murray #endif 625e9cd1aeSAssar Westerlund #ifndef T_CERT 635e9cd1aeSAssar Westerlund #define T_CERT 37 645e9cd1aeSAssar Westerlund #endif 65b528cefcSMark Murray 668373020dSJacques Vidrine #define dns_query rk_dns_query 678373020dSJacques Vidrine #define mx_record rk_mx_record 688373020dSJacques Vidrine #define srv_record rk_srv_record 698373020dSJacques Vidrine #define key_record rk_key_record 708373020dSJacques Vidrine #define sig_record rk_sig_record 718373020dSJacques Vidrine #define cert_record rk_cert_record 728373020dSJacques Vidrine #define resource_record rk_resource_record 738373020dSJacques Vidrine #define dns_reply rk_dns_reply 748373020dSJacques Vidrine 758373020dSJacques Vidrine #define dns_lookup rk_dns_lookup 768373020dSJacques Vidrine #define dns_free_data rk_dns_free_data 778373020dSJacques Vidrine #define dns_string_to_type rk_dns_string_to_type 788373020dSJacques Vidrine #define dns_type_to_string rk_dns_type_to_string 798373020dSJacques Vidrine #define dns_srv_order rk_dns_srv_order 808373020dSJacques Vidrine 81b528cefcSMark Murray struct dns_query{ 82b528cefcSMark Murray char *domain; 83b528cefcSMark Murray unsigned type; 84b528cefcSMark Murray unsigned class; 85b528cefcSMark Murray }; 86b528cefcSMark Murray 87b528cefcSMark Murray struct mx_record{ 88b528cefcSMark Murray unsigned preference; 89b528cefcSMark Murray char domain[1]; 90b528cefcSMark Murray }; 91b528cefcSMark Murray 92b528cefcSMark Murray struct srv_record{ 93b528cefcSMark Murray unsigned priority; 94b528cefcSMark Murray unsigned weight; 95b528cefcSMark Murray unsigned port; 96b528cefcSMark Murray char target[1]; 97b528cefcSMark Murray }; 98b528cefcSMark Murray 995e9cd1aeSAssar Westerlund struct key_record { 1005e9cd1aeSAssar Westerlund unsigned flags; 1015e9cd1aeSAssar Westerlund unsigned protocol; 1025e9cd1aeSAssar Westerlund unsigned algorithm; 1035e9cd1aeSAssar Westerlund size_t key_len; 1045e9cd1aeSAssar Westerlund u_char key_data[1]; 1055e9cd1aeSAssar Westerlund }; 1065e9cd1aeSAssar Westerlund 1075e9cd1aeSAssar Westerlund struct sig_record { 1085e9cd1aeSAssar Westerlund unsigned type; 1095e9cd1aeSAssar Westerlund unsigned algorithm; 1105e9cd1aeSAssar Westerlund unsigned labels; 1115e9cd1aeSAssar Westerlund unsigned orig_ttl; 1125e9cd1aeSAssar Westerlund unsigned sig_expiration; 1135e9cd1aeSAssar Westerlund unsigned sig_inception; 1145e9cd1aeSAssar Westerlund unsigned key_tag; 1155e9cd1aeSAssar Westerlund char *signer; 1165e9cd1aeSAssar Westerlund unsigned sig_len; 1175e9cd1aeSAssar Westerlund char sig_data[1]; /* also includes signer */ 1185e9cd1aeSAssar Westerlund }; 1195e9cd1aeSAssar Westerlund 1205e9cd1aeSAssar Westerlund struct cert_record { 1215e9cd1aeSAssar Westerlund unsigned type; 1225e9cd1aeSAssar Westerlund unsigned tag; 1235e9cd1aeSAssar Westerlund unsigned algorithm; 1245e9cd1aeSAssar Westerlund size_t cert_len; 1255e9cd1aeSAssar Westerlund u_char cert_data[1]; 1265e9cd1aeSAssar Westerlund }; 1275e9cd1aeSAssar Westerlund 128b528cefcSMark Murray struct resource_record{ 129b528cefcSMark Murray char *domain; 130b528cefcSMark Murray unsigned type; 131b528cefcSMark Murray unsigned class; 132b528cefcSMark Murray unsigned ttl; 133b528cefcSMark Murray unsigned size; 134b528cefcSMark Murray union { 135b528cefcSMark Murray void *data; 136b528cefcSMark Murray struct mx_record *mx; 137b528cefcSMark Murray struct mx_record *afsdb; /* mx and afsdb are identical */ 138b528cefcSMark Murray struct srv_record *srv; 139b528cefcSMark Murray struct in_addr *a; 140b528cefcSMark Murray char *txt; 1415e9cd1aeSAssar Westerlund struct key_record *key; 1425e9cd1aeSAssar Westerlund struct cert_record *cert; 1435e9cd1aeSAssar Westerlund struct sig_record *sig; 144b528cefcSMark Murray }u; 145b528cefcSMark Murray struct resource_record *next; 146b528cefcSMark Murray }; 147b528cefcSMark Murray 148b528cefcSMark Murray #ifndef T_A /* XXX if <arpa/nameser.h> isn't included */ 149b528cefcSMark Murray typedef int HEADER; /* will never be used */ 150b528cefcSMark Murray #endif 151b528cefcSMark Murray 152b528cefcSMark Murray struct dns_reply{ 153b528cefcSMark Murray HEADER h; 154b528cefcSMark Murray struct dns_query q; 155b528cefcSMark Murray struct resource_record *head; 156b528cefcSMark Murray }; 157b528cefcSMark Murray 158b528cefcSMark Murray 159b528cefcSMark Murray struct dns_reply* dns_lookup(const char *, const char *); 160b528cefcSMark Murray void dns_free_data(struct dns_reply *); 1615e9cd1aeSAssar Westerlund int dns_string_to_type(const char *name); 1625e9cd1aeSAssar Westerlund const char *dns_type_to_string(int type); 1634137ff4cSJacques Vidrine void dns_srv_order(struct dns_reply*); 164b528cefcSMark Murray 165b528cefcSMark Murray #endif /* __RESOLVE_H__ */ 166