[PATCH 01/26] Move virNWFilterTechDriver struct out of nwfilter_conf.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The virNWFilterTechDriver struct is nothing todo with the nwfilter
XML configuration. It stores data specific to the driver implementation
so should be in a header in the driver directory instead.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/Makefile.am                           |   1 +
 src/conf/nwfilter_conf.h                  |  86 ----------------------
 src/nwfilter/nwfilter_dhcpsnoop.h         |   2 +
 src/nwfilter/nwfilter_ebiptables_driver.h |   2 +
 src/nwfilter/nwfilter_gentech_driver.h    |   1 +
 src/nwfilter/nwfilter_learnipaddr.h       |   1 +
 src/nwfilter/nwfilter_tech_driver.h       | 115 ++++++++++++++++++++++++++++++
 7 files changed, 122 insertions(+), 86 deletions(-)
 create mode 100644 src/nwfilter/nwfilter_tech_driver.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 21d56fc..7e9a702 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -858,6 +858,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 071343e..aded4de 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 c6b45d1..6e73eb3 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 d909abb..8a17452 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 52bd1f6..da85508 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 783dc16..0195d10 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 <net/if.h>
 
 enum howDetect {
diff --git a/src/nwfilter/nwfilter_tech_driver.h b/src/nwfilter/nwfilter_tech_driver.h
new file mode 100644
index 0000000..5777757
--- /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
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Stefan Berger <stefanb@xxxxxxxxxx>
+ */
+
+#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__ */
-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]