]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: move virNWFilterBindingDefPtr into its own files
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 10 May 2018 13:30:42 +0000 (14:30 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 26 Jun 2018 10:22:07 +0000 (11:22 +0100)
There's no code sharing between virNWFilterDef and
virNWFilterBindingDefPtr types, so it is clearer if they live in
separate source files and headers.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/Makefile.inc.am
src/conf/nwfilter_conf.c
src/conf/nwfilter_conf.h
src/conf/virnwfilterbindingdef.c [new file with mode: 0644]
src/conf/virnwfilterbindingdef.h [new file with mode: 0644]
src/libvirt_private.syms

index 6d7b0f076b27355eff273718d748b31fe7abee46..f5fb323233bf0276f13c920f1f12bd783702fe69 100644 (file)
@@ -85,6 +85,8 @@ NWFILTER_CONF_SOURCES = \
        conf/nwfilter_conf.h \
        conf/virnwfilterobj.c \
        conf/virnwfilterobj.h \
+       conf/virnwfilterbindingdef.c \
+       conf/virnwfilterbindingdef.h \
        $(NULL)
 
 STORAGE_CONF_SOURCES = \
index 6422f6b8ea9df189b9a12d095e926fb25adb9661..de26a6d034e971825385eda4373e1222ff327f06 100644 (file)
@@ -3265,57 +3265,3 @@ virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr rule)
         return true;
     return false;
 }
-
-
-void
-virNWFilterBindingDefFree(virNWFilterBindingDefPtr def)
-{
-    if (!def)
-        return;
-
-    VIR_FREE(def->ownername);
-    VIR_FREE(def->portdevname);
-    VIR_FREE(def->linkdevname);
-    VIR_FREE(def->filter);
-    virHashFree(def->filterparams);
-
-    VIR_FREE(def);
-}
-
-
-virNWFilterBindingDefPtr
-virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src)
-{
-    virNWFilterBindingDefPtr ret;
-
-    if (VIR_ALLOC(ret) < 0)
-        return NULL;
-
-    if (VIR_STRDUP(ret->ownername, src->ownername) < 0)
-        goto error;
-
-    memcpy(ret->owneruuid, src->owneruuid, sizeof(ret->owneruuid));
-
-    if (VIR_STRDUP(ret->portdevname, src->portdevname) < 0)
-        goto error;
-
-    if (VIR_STRDUP(ret->linkdevname, src->linkdevname) < 0)
-        goto error;
-
-    ret->mac = src->mac;
-
-    if (VIR_STRDUP(ret->filter, src->filter) < 0)
-        goto error;
-
-    if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
-        goto error;
-
-    if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) < 0)
-        goto error;
-
-    return ret;
-
- error:
-    virNWFilterBindingDefFree(ret);
-    return NULL;
-}
index c72171f2f24a3bf66c33c67e2674f26c6dd69cbf..08fc07c55c2fc84302087c40aba357a4afc07980 100644 (file)
@@ -545,19 +545,6 @@ struct _virNWFilterDef {
     virNWFilterEntryPtr *filterEntries;
 };
 
-typedef struct _virNWFilterBindingDef virNWFilterBindingDef;
-typedef virNWFilterBindingDef *virNWFilterBindingDefPtr;
-
-struct _virNWFilterBindingDef {
-    char *ownername;
-    unsigned char owneruuid[VIR_UUID_BUFLEN];
-    char *portdevname;
-    char *linkdevname;
-    virMacAddr mac;
-    char *filter;
-    virHashTablePtr filterparams;
-};
-
 
 typedef enum {
     STEP_APPLY_NEW,
@@ -663,10 +650,6 @@ virNWFilterRuleIsProtocolIPv6(virNWFilterRuleDefPtr rule);
 bool
 virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr rule);
 
-void
-virNWFilterBindingDefFree(virNWFilterBindingDefPtr binding);
-virNWFilterBindingDefPtr
-virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src);
 
 VIR_ENUM_DECL(virNWFilterRuleAction);
 VIR_ENUM_DECL(virNWFilterRuleDirection);
diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbindingdef.c
new file mode 100644 (file)
index 0000000..c7533d4
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * virnwfilterbindingdef.c: network filter binding XML processing
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * 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/>.
+ */
+
+#include <config.h>
+
+#include "viralloc.h"
+#include "virerror.h"
+#include "virstring.h"
+#include "nwfilter_params.h"
+#include "virnwfilterbindingdef.h"
+
+
+#define VIR_FROM_THIS VIR_FROM_NWFILTER
+
+void
+virNWFilterBindingDefFree(virNWFilterBindingDefPtr def)
+{
+    if (!def)
+        return;
+
+    VIR_FREE(def->ownername);
+    VIR_FREE(def->portdevname);
+    VIR_FREE(def->linkdevname);
+    VIR_FREE(def->filter);
+    virHashFree(def->filterparams);
+
+    VIR_FREE(def);
+}
+
+
+virNWFilterBindingDefPtr
+virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src)
+{
+    virNWFilterBindingDefPtr ret;
+
+    if (VIR_ALLOC(ret) < 0)
+        return NULL;
+
+    if (VIR_STRDUP(ret->ownername, src->ownername) < 0)
+        goto error;
+
+    memcpy(ret->owneruuid, src->owneruuid, sizeof(ret->owneruuid));
+
+    if (VIR_STRDUP(ret->portdevname, src->portdevname) < 0)
+        goto error;
+
+    if (VIR_STRDUP(ret->linkdevname, src->linkdevname) < 0)
+        goto error;
+
+    ret->mac = src->mac;
+
+    if (VIR_STRDUP(ret->filter, src->filter) < 0)
+        goto error;
+
+    if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
+        goto error;
+
+    if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) < 0)
+        goto error;
+
+    return ret;
+
+ error:
+    virNWFilterBindingDefFree(ret);
+    return NULL;
+}
diff --git a/src/conf/virnwfilterbindingdef.h b/src/conf/virnwfilterbindingdef.h
new file mode 100644 (file)
index 0000000..e3b18af
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * virnwfilterbindingdef.h: network filter binding XML processing
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * 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/>.
+ *
+ */
+#ifndef VIR_NWFILTER_BINDING_DEF_H
+# define VIR_NWFILTER_BINDING_DEF_H
+
+# include "internal.h"
+# include "virmacaddr.h"
+# include "virhash.h"
+
+typedef struct _virNWFilterBindingDef virNWFilterBindingDef;
+typedef virNWFilterBindingDef *virNWFilterBindingDefPtr;
+
+struct _virNWFilterBindingDef {
+    char *ownername;
+    unsigned char owneruuid[VIR_UUID_BUFLEN];
+    char *portdevname;
+    char *linkdevname;
+    virMacAddr mac;
+    char *filter;
+    virHashTablePtr filterparams;
+};
+
+
+void
+virNWFilterBindingDefFree(virNWFilterBindingDefPtr binding);
+virNWFilterBindingDefPtr
+virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src);
+
+#endif /* VIR_NWFILTER_BINDING_DEF_H */
index 91b6235328927aa9422ad6250a748c3b8902105c..433b7bbd298613caf4de7fb98425aa085204f88f 100644 (file)
@@ -787,8 +787,6 @@ virDomainNumatuneSpecifiedMaxNode;
 
 
 # conf/nwfilter_conf.h
-virNWFilterBindingDefCopy;
-virNWFilterBindingDefFree;
 virNWFilterCallbackDriversLock;
 virNWFilterCallbackDriversUnlock;
 virNWFilterChainSuffixTypeToString;
@@ -1049,6 +1047,11 @@ virNodeDeviceObjListNumOfDevices;
 virNodeDeviceObjListRemove;
 
 
+# conf/virnwfilterbindingdef.h
+virNWFilterBindingDefCopy;
+virNWFilterBindingDefFree;
+
+
 # conf/virnwfilterobj.h
 virNWFilterObjGetDef;
 virNWFilterObjGetNewDef;