1 /* $Id: dnsrbl.h,v 1.11 2016/01/03 05:06:32 manu Exp $ */ 2 3 /* 4 * Copyright (c) 2006 Emmanuel Dreyfus 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Emmanuel Dreyfus 18 * 19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 * OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include "spf.h" 33 #include "acl.h" 34 35 #ifndef NS_MAXDNAME 36 #define NS_MAXDNAME 1025 37 #endif 38 39 LIST_HEAD(dnsrbllist, dnsrbl_entry); 40 41 struct dnsrbl_entry { 42 char d_name[QSTRLEN + 1]; 43 char d_domain[NS_MAXDNAME + 1]; 44 sockaddr_t d_blacklisted; 45 ipaddr d_mask; 46 LIST_ENTRY(dnsrbl_entry) d_list; 47 }; 48 49 struct dnsrbl_list { 50 struct dnsrbl_entry *dl_dnsrbl; 51 LIST_ENTRY(dnsrbl_list) dl_list; 52 }; 53 54 void dnsrbl_init(void); 55 int dnsrbl_check_source(acl_data_t *, acl_stage_t, 56 struct acl_param *, struct mlfi_priv *); 57 char *iptorevstr(struct sockaddr *, socklen_t, char *, size_t); 58 void dnsrbl_source_add(char *, char *, struct sockaddr *, int); 59 struct dnsrbl_entry *dnsrbl_byname(char *); 60 void dnsrbl_clear(void); 61 void dnsrbl_list_cleanup(struct mlfi_priv *); 62 char *dnsrbl_dump_matches(struct mlfi_priv *, char *, size_t); 63