1 /* 2 * scamper_firewall.h 3 * 4 * $Id: scamper_firewall.h,v 1.5 2016/08/07 10:27:56 mjl Exp $ 5 * 6 * Copyright (C) 2008-2010 The University of Waikato 7 * Copyright (C) 2016 Matthew Luckie 8 * Author: Matthew Luckie 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation, version 2. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 23 */ 24 25 #ifndef __SCAMPER_FIREWALL_H 26 #define __SCAMPER_FIREWALL_H 27 28 #define SCAMPER_FIREWALL_RULE_TYPE_5TUPLE 0x1 29 30 /* handle returned when a firewall entry is added to the table */ 31 typedef struct scamper_firewall_entry scamper_firewall_entry_t; 32 33 #ifdef __SCAMPER_ADDR_H 34 typedef struct scamper_firewall_rule 35 { 36 uint16_t type; 37 union 38 { 39 struct fivetuple 40 { 41 uint8_t proto; 42 scamper_addr_t *src; 43 scamper_addr_t *dst; 44 uint16_t sport; 45 uint16_t dport; 46 } fivetuple; 47 } un; 48 } scamper_firewall_rule_t; 49 50 scamper_firewall_entry_t *scamper_firewall_entry_get(scamper_firewall_rule_t *); 51 #endif 52 53 #define sfw_5tuple_proto un.fivetuple.proto 54 #define sfw_5tuple_src un.fivetuple.src 55 #define sfw_5tuple_dst un.fivetuple.dst 56 #define sfw_5tuple_sport un.fivetuple.sport 57 #define sfw_5tuple_dport un.fivetuple.dport 58 59 void scamper_firewall_entry_free(scamper_firewall_entry_t *); 60 61 /* routines to handle initialising structures to manage the firewall */ 62 int scamper_firewall_init(const char *opt); 63 void scamper_firewall_cleanup(void); 64 65 #ifdef HAVE_IPFW 66 int scamper_firewall_ipfw_init(void); 67 void scamper_firewall_ipfw_cleanup(void); 68 int scamper_firewall_ipfw_add(int n,int af,int p,void *s,void *d,int sp,int dp); 69 int scamper_firewall_ipfw_del(int n,int af); 70 #endif 71 72 #ifdef HAVE_PF 73 int scamper_firewall_pf_init(const char *anchor); 74 int scamper_firewall_pf_add(int n,int af,int p,void *s,void *d,int sp,int dp); 75 int scamper_firewall_pf_del(int n); 76 void scamper_firewall_pf_cleanup(void); 77 #endif 78 79 #endif /* __SCAMPER_FIREWALL_H */ 80