1/* 2 * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 * 9 */ 10 11/* 12 * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska H�gskolan 13 * (Royal Institute of Technology, Stockholm, Sweden). 14 * All rights reserved. 15 * 16 * Redistribution and use in source and binary forms, with or without 17 * modification, are permitted provided that the following conditions 18 * are met: 19 * 20 * 1. Redistributions of source code must retain the above copyright 21 * notice, this list of conditions and the following disclaimer. 22 * 23 * 2. Redistributions in binary form must reproduce the above copyright 24 * notice, this list of conditions and the following disclaimer in the 25 * documentation and/or other materials provided with the distribution. 26 * 27 * 3. Neither the name of the Institute nor the names of its contributors 28 * may be used to endorse or promote products derived from this software 29 * without specific prior written permission. 30 * 31 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 34 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 41 * SUCH DAMAGE. 42 */ 43 44/* $Id: sm_resolve.h,v 8.9 2013-11-22 20:51:56 ca Exp $ */ 45 46#if DNSMAP || DANE 47# ifndef __ROKEN_RESOLVE_H__ 48# define __ROKEN_RESOLVE_H__ 49 50/* We use these, but they are not always present in <arpa/nameser.h> */ 51 52# ifndef T_TXT 53# define T_TXT 16 54# endif 55# ifndef T_AFSDB 56# define T_AFSDB 18 57# endif 58# ifndef T_SRV 59# define T_SRV 33 60# endif 61# ifndef T_NAPTR 62# define T_NAPTR 35 63# endif 64# ifndef T_RRSIG 65# define T_RRSIG 46 66# endif 67# ifndef T_TLSA 68# define T_TLSA 52 69# endif 70 71typedef struct 72{ 73 char *dns_q_domain; 74 unsigned int dns_q_type; 75 unsigned int dns_q_class; 76} DNS_QUERY_T; 77 78typedef struct 79{ 80 unsigned int mx_r_preference; 81 char mx_r_domain[1]; 82} MX_RECORD_T; 83 84typedef struct 85{ 86 unsigned int srv_r_priority; 87 unsigned int srv_r_weight; 88 unsigned int srv_r_port; 89 char srv_r_target[1]; 90} SRV_RECORDT_T; 91 92 93typedef struct resource_record RESOURCE_RECORD_T; 94 95struct resource_record 96{ 97 char *rr_domain; 98 unsigned int rr_type; 99 unsigned int rr_class; 100 unsigned int rr_ttl; 101 unsigned int rr_size; 102 union 103 { 104 void *rr_data; 105 MX_RECORD_T *rr_mx; 106 MX_RECORD_T *rr_afsdb; /* mx and afsdb are identical */ 107 SRV_RECORDT_T *rr_srv; 108# if NETINET 109 struct in_addr *rr_a; 110# endif 111# if NETINET6 112 struct in6_addr *rr_aaaa; 113# endif 114 char *rr_txt; 115 } rr_u; 116 RESOURCE_RECORD_T *rr_next; 117}; 118 119# if !defined(T_A) && !defined(T_AAAA) 120/* XXX if <arpa/nameser.h> isn't included */ 121typedef int HEADER; /* will never be used */ 122# endif 123 124typedef struct 125{ 126 HEADER dns_r_h; 127 DNS_QUERY_T dns_r_q; 128 RESOURCE_RECORD_T *dns_r_head; 129} DNS_REPLY_T; 130 131#define SM_DNS_FL_EDNS0 0x01 132#define SM_DNS_FL_DNSSEC 0x02 133 134/* flags for parse_dns_reply() et.al. */ 135#define RR_AS_TEXT 0x01 /* convert some RRs to text, e.g., TLSA */ 136#define RR_RAW 0x02 /* return some RRs as "raw" data */ 137 /* currently not used (set, but not read) */ 138#define RR_NO_CNAME 0x04 /* do not try CNAME lookup */ 139#define RR_ONLY_CNAME 0x08 /* if !RR_NO_CNAME" return only CNAME */ 140 141extern void dns_free_data __P((DNS_REPLY_T *)); 142extern int dns_string_to_type __P((const char *)); 143extern const char *dns_type_to_string __P((int)); 144extern DNS_REPLY_T *dns_lookup_map __P((const char *, int, int, time_t, 145 int, unsigned int)); 146extern DNS_REPLY_T *dns_lookup_int __P((const char *, int, int, time_t, 147 int, unsigned int, unsigned int, int *, int *)); 148# if 0 149extern DNS_REPLY_T *dns_lookup __P((const char *domain, 150 const char *type_name, 151 time_t retrans, 152 int retry)); 153# endif /* 0 */ 154 155# if DANE 156struct hostent *dns2he __P((DNS_REPLY_T *, int)); 157# endif 158 159/* what to do if family is not supported? add SM_ASSERT()? */ 160#define FAM2T_(family) (((family) == AF_INET) ? T_A : T_AAAA) 161 162# if DNSSEC_TEST 163const char *herrno2txt __P((int)); 164int setherrnofromstring __P((const char *, int *)); 165int getttlfromstring __P((const char *)); 166int tstdns_search __P((const char *, int, int, u_char *, int)); 167int tstdns_querydomain __P((const char *, const char *, int, int, unsigned char *, int)); 168 169# ifdef _DEFINE_SMR_GLOBALS 170# define SMR_EXTERN 171# else 172# define SMR_EXTERN extern 173# endif 174SMR_EXTERN char *NameSearchList; 175# undef SMR_EXTERN 176extern void dns_setns __P((struct in_addr *, unsigned int)); 177extern int nsportip __P((char *)); 178# endif /* DNSSEC_TEST*/ 179 180#ifndef RES_TRUSTAD 181# define RES_TRUSTAD 0 182#endif 183#define SM_RES_DNSSEC (RES_USE_EDNS0|RES_USE_DNSSEC|RES_TRUSTAD) 184 185# endif /* ! __ROKEN_RESOLVE_H__ */ 186#endif /* DNSMAP || DANE */ 187