diff --git a/src/Makefile.am b/src/Makefile.am index 5fb9e88b03..a5a7ff320b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -860,6 +860,7 @@ UTIL_IO_HELPER_SOURCES = \ # Network filters NWFILTER_DRIVER_SOURCES = \ nwfilter/nwfilter_driver.h nwfilter/nwfilter_driver.c \ + nwfilter/nwfilter_tech_driver.h \ nwfilter/nwfilter_gentech_driver.c \ nwfilter/nwfilter_gentech_driver.h \ nwfilter/nwfilter_dhcpsnoop.c \ diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 071343ed14..aded4de4e5 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -567,19 +567,6 @@ struct _virNWFilterDriverState { }; -typedef struct _virNWFilterTechDriver virNWFilterTechDriver; -typedef virNWFilterTechDriver *virNWFilterTechDriverPtr; - - -typedef struct _virNWFilterRuleInst virNWFilterRuleInst; -typedef virNWFilterRuleInst *virNWFilterRuleInstPtr; -struct _virNWFilterRuleInst { - size_t ndata; - void **data; - virNWFilterTechDriverPtr techdriver; -}; - - enum UpdateStep { STEP_APPLY_NEW, STEP_TEAR_NEW, @@ -594,79 +581,6 @@ struct domUpdateCBStruct { }; -typedef int (*virNWFilterTechDrvInit)(bool privileged); -typedef void (*virNWFilterTechDrvShutdown)(void); - -enum virDomainNetType; - -typedef int (*virNWFilterRuleCreateInstance)(enum virDomainNetType nettype, - virNWFilterDefPtr filter, - virNWFilterRuleDefPtr rule, - const char *ifname, - virNWFilterHashTablePtr vars, - virNWFilterRuleInstPtr res); - -typedef int (*virNWFilterRuleApplyNewRules)(const char *ifname, - int nruleInstances, - void **_inst); - -typedef int (*virNWFilterRuleTeardownNewRules)(const char *ifname); - -typedef int (*virNWFilterRuleTeardownOldRules)(const char *ifname); - -typedef int (*virNWFilterRuleRemoveRules)(const char *ifname, - int nruleInstances, - void **_inst); - -typedef int (*virNWFilterRuleAllTeardown)(const char *ifname); - -typedef int (*virNWFilterRuleFreeInstanceData)(void * _inst); - -typedef int (*virNWFilterRuleDisplayInstanceData)(void *_inst); - -typedef int (*virNWFilterCanApplyBasicRules)(void); - -typedef int (*virNWFilterApplyBasicRules)(const char *ifname, - const virMacAddr *macaddr); - -typedef int (*virNWFilterApplyDHCPOnlyRules)(const char *ifname, - const virMacAddr *macaddr, - virNWFilterVarValuePtr dhcpsrvs, - bool leaveTemporary); - -typedef int (*virNWFilterRemoveBasicRules)(const char *ifname); - -typedef int (*virNWFilterDropAllRules)(const char *ifname); - -enum techDrvFlags { - TECHDRV_FLAG_INITIALIZED = (1 << 0), -}; - -struct _virNWFilterTechDriver { - const char *name; - enum techDrvFlags flags; - - virNWFilterTechDrvInit init; - virNWFilterTechDrvShutdown shutdown; - - virNWFilterRuleCreateInstance createRuleInstance; - virNWFilterRuleApplyNewRules applyNewRules; - virNWFilterRuleTeardownNewRules tearNewRules; - virNWFilterRuleTeardownOldRules tearOldRules; - virNWFilterRuleRemoveRules removeRules; - virNWFilterRuleAllTeardown allTeardown; - virNWFilterRuleFreeInstanceData freeRuleInstance; - virNWFilterRuleDisplayInstanceData displayRuleInstance; - - virNWFilterCanApplyBasicRules canApplyBasicRules; - virNWFilterApplyBasicRules applyBasicRules; - virNWFilterApplyDHCPOnlyRules applyDHCPOnlyRules; - virNWFilterDropAllRules applyDropAllRules; - virNWFilterRemoveBasicRules removeBasicRules; -}; - - - void virNWFilterRuleDefFree(virNWFilterRuleDefPtr def); void virNWFilterDefFree(virNWFilterDefPtr def); diff --git a/src/nwfilter/nwfilter_dhcpsnoop.h b/src/nwfilter/nwfilter_dhcpsnoop.h index c6b45d16c7..6e73eb3b78 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.h +++ b/src/nwfilter/nwfilter_dhcpsnoop.h @@ -25,6 +25,8 @@ #ifndef __NWFILTER_DHCPSNOOP_H # define __NWFILTER_DHCPSNOOP_H +# include "nwfilter_tech_driver.h" + int virNWFilterDHCPSnoopInit(void); void virNWFilterDHCPSnoopShutdown(void); int virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, diff --git a/src/nwfilter/nwfilter_ebiptables_driver.h b/src/nwfilter/nwfilter_ebiptables_driver.h index d909abb9d3..8a17452e92 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.h +++ b/src/nwfilter/nwfilter_ebiptables_driver.h @@ -23,6 +23,8 @@ #ifndef VIR_NWFILTER_EBTABLES_DRIVER_H__ # define VIR_NWFILTER_EBTABLES_DRIVER_H__ +# include "nwfilter_tech_driver.h" + # define MAX_CHAINNAME_LENGTH 32 /* see linux/netfilter_bridge/ebtables.h */ enum RuleType { diff --git a/src/nwfilter/nwfilter_gentech_driver.h b/src/nwfilter/nwfilter_gentech_driver.h index 52bd1f6777..da85508dc0 100644 --- a/src/nwfilter/nwfilter_gentech_driver.h +++ b/src/nwfilter/nwfilter_gentech_driver.h @@ -25,6 +25,7 @@ # define __NWFILTER_GENTECH_DRIVER_H # include "nwfilter_conf.h" +# include "nwfilter_tech_driver.h" virNWFilterTechDriverPtr virNWFilterTechDriverForName(const char *name); diff --git a/src/nwfilter/nwfilter_learnipaddr.h b/src/nwfilter/nwfilter_learnipaddr.h index 783dc16734..0195d1011c 100644 --- a/src/nwfilter/nwfilter_learnipaddr.h +++ b/src/nwfilter/nwfilter_learnipaddr.h @@ -27,6 +27,7 @@ # define __NWFILTER_LEARNIPADDR_H # include "conf/nwfilter_params.h" +# include "nwfilter_tech_driver.h" # include enum howDetect { diff --git a/src/nwfilter/nwfilter_tech_driver.h b/src/nwfilter/nwfilter_tech_driver.h new file mode 100644 index 0000000000..5777757796 --- /dev/null +++ b/src/nwfilter/nwfilter_tech_driver.h @@ -0,0 +1,115 @@ +/* + * nwfilter_tech_driver.h: network filter technology driver interface + * + * Copyright (C) 2006-2014 Red Hat, Inc. + * Copyright (C) 2006-2008 Daniel P. Berrange + * + * Copyright (C) 2010 IBM Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Author: Stefan Berger + */ + +#ifndef __NWFILTER_TECH_DRIVER_H__ +# define __NWFILTER_TECH_DRIVER_H__ + +# include "nwfilter_conf.h" + +typedef struct _virNWFilterTechDriver virNWFilterTechDriver; +typedef virNWFilterTechDriver *virNWFilterTechDriverPtr; + + +typedef struct _virNWFilterRuleInst virNWFilterRuleInst; +typedef virNWFilterRuleInst *virNWFilterRuleInstPtr; +struct _virNWFilterRuleInst { + size_t ndata; + void **data; + virNWFilterTechDriverPtr techdriver; +}; + + +typedef int (*virNWFilterTechDrvInit)(bool privileged); +typedef void (*virNWFilterTechDrvShutdown)(void); + +enum virDomainNetType; + +typedef int (*virNWFilterRuleCreateInstance)(enum virDomainNetType nettype, + virNWFilterDefPtr filter, + virNWFilterRuleDefPtr rule, + const char *ifname, + virNWFilterHashTablePtr vars, + virNWFilterRuleInstPtr res); + +typedef int (*virNWFilterRuleApplyNewRules)(const char *ifname, + int nruleInstances, + void **_inst); + +typedef int (*virNWFilterRuleTeardownNewRules)(const char *ifname); + +typedef int (*virNWFilterRuleTeardownOldRules)(const char *ifname); + +typedef int (*virNWFilterRuleRemoveRules)(const char *ifname, + int nruleInstances, + void **_inst); + +typedef int (*virNWFilterRuleAllTeardown)(const char *ifname); + +typedef int (*virNWFilterRuleFreeInstanceData)(void * _inst); + +typedef int (*virNWFilterRuleDisplayInstanceData)(void *_inst); + +typedef int (*virNWFilterCanApplyBasicRules)(void); + +typedef int (*virNWFilterApplyBasicRules)(const char *ifname, + const virMacAddr *macaddr); + +typedef int (*virNWFilterApplyDHCPOnlyRules)(const char *ifname, + const virMacAddr *macaddr, + virNWFilterVarValuePtr dhcpsrvs, + bool leaveTemporary); + +typedef int (*virNWFilterRemoveBasicRules)(const char *ifname); + +typedef int (*virNWFilterDropAllRules)(const char *ifname); + +enum techDrvFlags { + TECHDRV_FLAG_INITIALIZED = (1 << 0), +}; + +struct _virNWFilterTechDriver { + const char *name; + enum techDrvFlags flags; + + virNWFilterTechDrvInit init; + virNWFilterTechDrvShutdown shutdown; + + virNWFilterRuleCreateInstance createRuleInstance; + virNWFilterRuleApplyNewRules applyNewRules; + virNWFilterRuleTeardownNewRules tearNewRules; + virNWFilterRuleTeardownOldRules tearOldRules; + virNWFilterRuleRemoveRules removeRules; + virNWFilterRuleAllTeardown allTeardown; + virNWFilterRuleFreeInstanceData freeRuleInstance; + virNWFilterRuleDisplayInstanceData displayRuleInstance; + + virNWFilterCanApplyBasicRules canApplyBasicRules; + virNWFilterApplyBasicRules applyBasicRules; + virNWFilterApplyDHCPOnlyRules applyDHCPOnlyRules; + virNWFilterDropAllRules applyDropAllRules; + virNWFilterRemoveBasicRules removeBasicRules; +}; + +#endif /* __NWFILTER_TECH_DRIVER_H__ */