resolve.h revision 102644
1181834Sroberto/* 2181834Sroberto * Copyright (c) 1995 - 2002 Kungliga Tekniska H�gskolan 3181834Sroberto * (Royal Institute of Technology, Stockholm, Sweden). 4200576Sroberto * All rights reserved. 5181834Sroberto * 6181834Sroberto * Redistribution and use in source and binary forms, with or without 7181834Sroberto * modification, are permitted provided that the following conditions 8181834Sroberto * are met: 9181834Sroberto * 10181834Sroberto * 1. Redistributions of source code must retain the above copyright 11181834Sroberto * notice, this list of conditions and the following disclaimer. 12181834Sroberto * 13181834Sroberto * 2. Redistributions in binary form must reproduce the above copyright 14181834Sroberto * notice, this list of conditions and the following disclaimer in the 15181834Sroberto * documentation and/or other materials provided with the distribution. 16181834Sroberto * 17181834Sroberto * 3. Neither the name of the Institute nor the names of its contributors 18181834Sroberto * may be used to endorse or promote products derived from this software 19181834Sroberto * without specific prior written permission. 20181834Sroberto * 21181834Sroberto * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22200576Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23181834Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24181834Sroberto * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25181834Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26181834Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27181834Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28181834Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29181834Sroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30181834Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31181834Sroberto * SUCH DAMAGE. 32181834Sroberto */ 33181834Sroberto 34181834Sroberto/* $Id: resolve.h,v 1.15 2002/08/26 13:30:16 assar Exp $ */ 35181834Sroberto 36181834Sroberto#ifndef __RESOLVE_H__ 37200576Sroberto#define __RESOLVE_H__ 38181834Sroberto 39181834Sroberto/* We use these, but they are not always present in <arpa/nameser.h> */ 40181834Sroberto 41181834Sroberto#ifndef T_TXT 42181834Sroberto#define T_TXT 16 43181834Sroberto#endif 44181834Sroberto#ifndef T_AFSDB 45181834Sroberto#define T_AFSDB 18 46181834Sroberto#endif 47181834Sroberto#ifndef T_SIG 48181834Sroberto#define T_SIG 24 49181834Sroberto#endif 50181834Sroberto#ifndef T_KEY 51181834Sroberto#define T_KEY 25 52181834Sroberto#endif 53181834Sroberto#ifndef T_AAAA 54181834Sroberto#define T_AAAA 28 55181834Sroberto#endif 56181834Sroberto#ifndef T_SRV 57181834Sroberto#define T_SRV 33 58181834Sroberto#endif 59181834Sroberto#ifndef T_NAPTR 60181834Sroberto#define T_NAPTR 35 61181834Sroberto#endif 62181834Sroberto#ifndef T_CERT 63181834Sroberto#define T_CERT 37 64181834Sroberto#endif 65181834Sroberto 66181834Sroberto#define dns_query rk_dns_query 67181834Sroberto#define mx_record rk_mx_record 68181834Sroberto#define srv_record rk_srv_record 69181834Sroberto#define key_record rk_key_record 70181834Sroberto#define sig_record rk_sig_record 71181834Sroberto#define cert_record rk_cert_record 72181834Sroberto#define resource_record rk_resource_record 73181834Sroberto#define dns_reply rk_dns_reply 74181834Sroberto 75181834Sroberto#define dns_lookup rk_dns_lookup 76181834Sroberto#define dns_free_data rk_dns_free_data 77181834Sroberto#define dns_string_to_type rk_dns_string_to_type 78181834Sroberto#define dns_type_to_string rk_dns_type_to_string 79181834Sroberto#define dns_srv_order rk_dns_srv_order 80181834Sroberto 81181834Srobertostruct dns_query{ 82181834Sroberto char *domain; 83181834Sroberto unsigned type; 84181834Sroberto unsigned class; 85181834Sroberto}; 86181834Sroberto 87181834Srobertostruct mx_record{ 88181834Sroberto unsigned preference; 89181834Sroberto char domain[1]; 90181834Sroberto}; 91181834Sroberto 92181834Srobertostruct srv_record{ 93181834Sroberto unsigned priority; 94181834Sroberto unsigned weight; 95181834Sroberto unsigned port; 96181834Sroberto char target[1]; 97181834Sroberto}; 98181834Sroberto 99181834Srobertostruct key_record { 100181834Sroberto unsigned flags; 101181834Sroberto unsigned protocol; 102181834Sroberto unsigned algorithm; 103181834Sroberto size_t key_len; 104181834Sroberto u_char key_data[1]; 105181834Sroberto}; 106181834Sroberto 107181834Srobertostruct sig_record { 108181834Sroberto unsigned type; 109181834Sroberto unsigned algorithm; 110181834Sroberto unsigned labels; 111181834Sroberto unsigned orig_ttl; 112181834Sroberto unsigned sig_expiration; 113181834Sroberto unsigned sig_inception; 114181834Sroberto unsigned key_tag; 115181834Sroberto char *signer; 116181834Sroberto unsigned sig_len; 117181834Sroberto char sig_data[1]; /* also includes signer */ 118181834Sroberto}; 119181834Sroberto 120181834Srobertostruct cert_record { 121181834Sroberto unsigned type; 122181834Sroberto unsigned tag; 123181834Sroberto unsigned algorithm; 124181834Sroberto size_t cert_len; 125181834Sroberto u_char cert_data[1]; 126181834Sroberto}; 127181834Sroberto 128181834Srobertostruct resource_record{ 129181834Sroberto char *domain; 130181834Sroberto unsigned type; 131181834Sroberto unsigned class; 132181834Sroberto unsigned ttl; 133181834Sroberto unsigned size; 134181834Sroberto union { 135181834Sroberto void *data; 136181834Sroberto struct mx_record *mx; 137181834Sroberto struct mx_record *afsdb; /* mx and afsdb are identical */ 138181834Sroberto struct srv_record *srv; 139181834Sroberto struct in_addr *a; 140181834Sroberto char *txt; 141181834Sroberto struct key_record *key; 142181834Sroberto struct cert_record *cert; 143181834Sroberto struct sig_record *sig; 144181834Sroberto }u; 145181834Sroberto struct resource_record *next; 146181834Sroberto}; 147181834Sroberto 148181834Sroberto#ifndef T_A /* XXX if <arpa/nameser.h> isn't included */ 149181834Srobertotypedef int HEADER; /* will never be used */ 150181834Sroberto#endif 151181834Sroberto 152181834Srobertostruct dns_reply{ 153181834Sroberto HEADER h; 154181834Sroberto struct dns_query q; 155181834Sroberto struct resource_record *head; 156181834Sroberto}; 157181834Sroberto 158181834Sroberto 159181834Srobertostruct dns_reply* dns_lookup(const char *, const char *); 160181834Srobertovoid dns_free_data(struct dns_reply *); 161181834Srobertoint dns_string_to_type(const char *name); 162181834Srobertoconst char *dns_type_to_string(int type); 163181834Srobertovoid dns_srv_order(struct dns_reply*); 164181834Sroberto 165181834Sroberto#endif /* __RESOLVE_H__ */ 166181834Sroberto