1 /* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of either: 4 * 5 * a) The GNU Lesser General Public License as published by the Free 6 * Software Foundation; either version 2.1, or (at your option) any 7 * later version, 8 * 9 * OR 10 * 11 * b) The two-clause BSD license. 12 * 13 * These licenses can be found with the distribution in the file LICENSES 14 */ 15 16 17 18 19 #ifndef INC_SPF_DNS_RR 20 #define INC_SPF_DNS_RR 21 22 #include "spf_dns.h" 23 24 /** 25 * Data from a DNS RR. 26 * 27 * The strings in this union are usually malloc'ed larger than the 28 * size of the union. Only create pointers to it! 29 */ 30 typedef 31 union 32 { 33 struct in_addr a; 34 char ptr[1]; 35 char mx[1]; 36 char txt[1]; 37 struct in6_addr aaaa; 38 } SPF_dns_rr_data_t; 39 40 /** 41 * A DNS packet. 42 * 43 * This structure does not semantically match the DNS packet 44 * structure. It assumes that only one RR type was of interest, 45 * and that all RRs in the packet are of that type. 46 * 47 * This is also used in spf_dns_zone.c 48 */ 49 typedef 50 struct SPF_dns_rr_struct 51 { 52 /* query information */ 53 char *domain; /**< FQDN queried for. */ 54 size_t domain_buf_len;/**< Alloced size of domain. */ 55 56 ns_type rr_type; /**< Type of RR queried for. */ 57 58 /* answer information */ 59 int num_rr; /**< Number of RR returned in RR. */ 60 SPF_dns_rr_data_t **rr; /**< RR set returned. */ 61 size_t *rr_buf_len;/**< Alloced size of each RR. */ 62 int rr_buf_num;/**< Number of RR allocated. */ 63 64 time_t ttl; /**< Raw TTL. */ 65 time_t utc_ttl; /**< TTL adjusted to UTC. */ 66 SPF_dns_stat_t herrno; /**< h_error returned from query. */ 67 68 /* misc information */ 69 void *hook; /**< Used by DNS layers. */ 70 SPF_dns_server_t *source; /**< Which layer created this RR. */ 71 } SPF_dns_rr_t; 72 73 SPF_dns_rr_t *SPF_dns_rr_new(void); 74 void SPF_dns_rr_free(SPF_dns_rr_t *spfrr); 75 SPF_dns_rr_t *SPF_dns_rr_new_init(SPF_dns_server_t *spf_dns_server, 76 const char *domain, 77 ns_type rr_type, int ttl, 78 SPF_dns_stat_t herrno); 79 SPF_dns_rr_t *SPF_dns_rr_new_nxdomain(SPF_dns_server_t *spf_dns_server, 80 const char *domain); 81 82 SPF_errcode_t SPF_dns_rr_buf_realloc(SPF_dns_rr_t *spfrr, 83 int idx, size_t len ); 84 SPF_errcode_t SPF_dns_rr_dup(SPF_dns_rr_t **dstp, SPF_dns_rr_t *src); 85 86 87 #endif 88