1 /* 2 firedns.h - firedns library declarations 3 Copyright (C) 2002 Ian Gulliver 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of version 2 of the GNU General Public License as 7 published by the Free Software Foundation. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 #ifndef _FIREDNS_H 20 #define _FIREDNS_H 21 22 #include <sys/types.h> 23 #include <sys/socket.h> 24 #include <netinet/in.h> 25 26 #ifndef _FIREDNS_C 27 extern const char firedns_version[]; 28 extern const int firedns_mx_port[]; 29 extern const char *firedns_mx_name[]; 30 #endif 31 32 #ifndef AF_INET6 33 struct in6_addr { 34 unsigned char s6_addr[16]; 35 }; 36 #endif 37 38 #define FIREDNS_MX_SMTP 0 39 #define FIREDNS_MX_QMTP 1 40 41 struct firedns_ip4list { 42 struct in_addr ip; 43 struct firedns_ip4list *next; 44 }; 45 46 struct firedns_ip6list { 47 struct in6_addr ip; 48 struct firedns_ip6list *next; 49 }; 50 51 struct firedns_mxlist { 52 unsigned int priority; 53 unsigned int protocol; 54 struct firedns_ip4list *ip4list; 55 struct firedns_ip6list *ip6list; 56 char *cname; 57 char *name; 58 struct firedns_mxlist *next; 59 }; 60 61 struct firedns_txtlist { 62 char *txt; 63 struct firedns_txtlist *next; 64 }; 65 66 void firedns_init(); 67 68 /* non-blocking functions */ 69 struct in_addr *firedns_aton4(const char * const ipstring); 70 struct in6_addr *firedns_aton6(const char * const ipstring); 71 char *firedns_ntoa4(const struct in_addr * const ip); 72 char *firedns_ntoa6(const struct in6_addr * const ip); 73 int firedns_getip4(const char * const name); 74 int firedns_getip4list(const char * const name); 75 int firedns_getip6(const char * const name); 76 int firedns_getip6list(const char * const name); 77 int firedns_gettxt(const char * const name); 78 int firedns_gettxtlist(const char * const name); 79 int firedns_getmx(const char * const name); 80 int firedns_getmxlist(const char * const name); 81 int firedns_getname4(const struct in_addr * const ip); 82 int firedns_getname6(const struct in6_addr * const ip); 83 int firedns_getcname(const char * const name); 84 int firedns_dnsbl_lookup_a(const struct in_addr * const ip, const char * const name); 85 int firedns_dnsbl_lookup_txt(const struct in_addr * const ip, const char * const name); 86 char *firedns_getresult(const int fd); 87 88 /* buffer pass-in non-blocking functions */ 89 struct in_addr *firedns_aton4_s(const char * const ipstring, struct in_addr * const ip); 90 struct in6_addr *firedns_aton6_s(const char * const ipstring, struct in6_addr * const ip); 91 char *firedns_ntoa4_s(const struct in_addr * const ip, char * const result); 92 char *firedns_ntoa6_s(const struct in6_addr * const ip, char * const result); 93 char *firedns_getresult_s(const int fd, char * const result); 94 95 /* thread-safe functions that allocate their own buffers */ 96 struct in_addr *firedns_aton4_r(const char * const ipstring); 97 struct in6_addr *firedns_aton6_r(const char * const ipstring); 98 char *firedns_ntoa4_r(const struct in_addr * const ip); 99 char *firedns_ntoa6_r(const struct in6_addr * const ip); 100 char *firedns_getresult_r(const int fd); 101 102 /* low-timeout blocking functions */ 103 struct in_addr *firedns_resolveip4(const char * const name); 104 struct firedns_ip4list *firedns_resolveip4list(const char * const name); 105 struct in6_addr *firedns_resolveip6(const char * const name); 106 struct firedns_ip6list *firedns_resolveip6list(const char * const name); 107 char *firedns_resolvetxt(const char * const name); 108 struct firedns_txtlist *firedns_resolvetxtlist(const char * const name); 109 char *firedns_resolvemx(const char * const name); 110 struct firedns_mxlist *firedns_resolvemxlist(const char * const name); 111 struct firedns_mxlist *firedns_resolvemxalist(const char * const name); 112 char *firedns_resolvename4(const struct in_addr * const ip); 113 char *firedns_resolvename6(const struct in6_addr * const ip); 114 char *firedns_resolvecname(const char * const name); 115 116 /* reentrant low-timeout blocking functions */ 117 struct in_addr *firedns_resolveip4_r(const char * const name); 118 struct firedns_ip4list *firedns_resolveip4list_r(const char * const name); 119 struct in6_addr *firedns_resolveip6_r(const char * const name); 120 struct firedns_ip6list *firedns_resolveip6list_r(const char * const name); 121 char *firedns_resolvetxt_r(const char * const name); 122 struct firedns_txtlist *firedns_resolvetxtlist_r(const char * const name); 123 char *firedns_resolvemx_r(const char * const name); 124 struct firedns_mxlist *firedns_resolvemxlist_r(const char * const name); 125 char *firedns_resolvename4_r(const struct in_addr * const ip); 126 char *firedns_resolvename6_r(const struct in6_addr * const ip); 127 char *firedns_resolvecname_r(const char * const name); 128 129 /* misc functions */ 130 void firedns_free_mxalist(struct firedns_mxlist *list); 131 132 #endif 133