Signed-off-by: K Shiva Kiran <shiva_kr(a)riseup.net>
---
src/conf/virnwfilterobj.c | 46 +++++++++++++++++++++++++++++++++++++++
src/conf/virnwfilterobj.h | 5 +++++
src/libvirt_private.syms | 1 +
3 files changed, 52 insertions(+)
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index 6456add593..eab864fe2e 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -635,3 +635,49 @@ virNWFilterObjUnlock(virNWFilterObj *obj)
{
virMutexUnlock(&obj->lock);
}
+
+
+char *
+virNWFilterObjGetMetadata(virNWFilterObj *obj,
+ int type,
+ const char *uri)
+{
+ virNWFilterDef *def;
+ char *ret = NULL;
+
+ if (type >= VIR_NWFILTER_METADATA_LAST) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("unknown metadata type '%1$d'"), type);
+ return NULL;
+ }
+
+ if (!(def = virNWFilterObjGetDef(obj)))
+ return NULL;
+
+ switch ((virNWFilterMetadataType) type) {
+ case VIR_NWFILTER_METADATA_DESCRIPTION:
+ ret = g_strdup(def->description);
+ break;
+
+ case VIR_NWFILTER_METADATA_TITLE:
+ ret = g_strdup(def->title);
+ break;
+
+ case VIR_NWFILTER_METADATA_ELEMENT:
+ if (!def->metadata)
+ break;
+
+ if (virXMLExtractNamespaceXML(def->metadata, uri, &ret) < 0)
+ return NULL;
+ break;
+
+ case VIR_NWFILTER_METADATA_LAST:
+ break;
+ }
+
+ if (!ret)
+ virReportError(VIR_ERR_NO_NWFILTER_METADATA, "%s",
+ _("Requested metadata element is not present"));
+
+ return ret;
+}
diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h
index b67dc017c5..dd4dd63cee 100644
--- a/src/conf/virnwfilterobj.h
+++ b/src/conf/virnwfilterobj.h
@@ -117,3 +117,8 @@ virNWFilterObjLock(virNWFilterObj *obj);
void
virNWFilterObjUnlock(virNWFilterObj *obj);
+
+char *
+virNWFilterObjGetMetadata(virNWFilterObj *obj,
+ int type,
+ const char *uri);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1e3e407097..8c4983ae17 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1408,6 +1408,7 @@ virNWFilterBindingObjListRemove;
# conf/virnwfilterobj.h
virNWFilterObjGetDef;
+virNWFilterObjGetMetadata;
virNWFilterObjGetNewDef;
virNWFilterObjListAssignDef;
virNWFilterObjListExport;
--
2.42.0