---
 libvirt-gobject/Makefile.am                        |   5 +-
 .../libvirt-gobject-network-dhcp-lease-private.h   |  34 +++
 .../libvirt-gobject-network-dhcp-lease.c           | 252 +++++++++++++++++++++
 .../libvirt-gobject-network-dhcp-lease.h           |  85 +++++++
 libvirt-gobject/libvirt-gobject.h                  |   1 +
 libvirt-gobject/libvirt-gobject.sym                |  13 ++
 6 files changed, 389 insertions(+), 1 deletion(-)
 create mode 100644 libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h
 create mode 100644 libvirt-gobject/libvirt-gobject-network-dhcp-lease.c
 create mode 100644 libvirt-gobject/libvirt-gobject-network-dhcp-lease.h

diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index 7163c7d..8464f04 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -13,6 +13,7 @@ GOBJECT_HEADER_FILES = \
                        libvirt-gobject-domain.h \
                        libvirt-gobject-interface.h \
                        libvirt-gobject-network.h \
+                       libvirt-gobject-network-dhcp-lease.h \
                        libvirt-gobject-network-filter.h \
                        libvirt-gobject-node-device.h \
                        libvirt-gobject-secret.h \
@@ -22,7 +23,8 @@ GOBJECT_HEADER_FILES = \
                        libvirt-gobject-connection.h \
                        libvirt-gobject-manager.h
 noinst_HEADERS = \
-                       libvirt-gobject-storage-pool-private.h
+                       libvirt-gobject-storage-pool-private.h \
+                       libvirt-gobject-network-dhcp-lease-private.h
 GOBJECT_SOURCE_FILES = \
                        libvirt-gobject-main.c \
                        libvirt-gobject-domain-snapshot.c \
@@ -32,6 +34,7 @@ GOBJECT_SOURCE_FILES = \
                        libvirt-gobject-domain.c \
                        libvirt-gobject-interface.c \
                        libvirt-gobject-network.c \
+                       libvirt-gobject-network-dhcp-lease.c \
                        libvirt-gobject-network-filter.c \
                        libvirt-gobject-node-device.c \
                        libvirt-gobject-secret.c \
diff --git a/libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h 
b/libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h
new file mode 100644
index 0000000..eaf6c2f
--- /dev/null
+++ b/libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h
@@ -0,0 +1,34 @@
+/*
+ * libvirt-gobject-network-dhcp-lease-private.h: libvirt gobject integration
+ *
+ * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2015 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/>.
+ *
+ * Authors: Zeeshan Ali (Khattak) <zeesha...@gnome.org>
+ *          Daniel P. Berrange <berra...@redhat.com>
+ */
+
+#ifndef __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_PRIVATE_H__
+#define __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_PRIVATE_H__
+
+G_BEGIN_DECLS
+
+GVirNetworkDHCPLease *gvir_network_dhcp_lease_new(virNetworkDHCPLeasePtr 
handle);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_PRIVATE_H__ */
diff --git a/libvirt-gobject/libvirt-gobject-network-dhcp-lease.c 
b/libvirt-gobject/libvirt-gobject-network-dhcp-lease.c
new file mode 100644
index 0000000..6ac3c14
--- /dev/null
+++ b/libvirt-gobject/libvirt-gobject-network-dhcp-lease.c
@@ -0,0 +1,252 @@
+/*
+ * libvirt-gobject-network-dhcp-lease.c: libvirt glib integration
+ *
+ * Copyright (C) 2008 Daniel P. Berrange
+ * Copyright (C) 2015 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/>.
+ *
+ * Authors: Zeeshan Ali (Khattak) <zeesha...@gnome.org>
+ *          Daniel P. Berrange <berra...@redhat.com>
+ */
+
+#include <config.h>
+
+#include <libvirt/virterror.h>
+#include <string.h>
+
+#include "libvirt-glib/libvirt-glib.h"
+#include "libvirt-gobject/libvirt-gobject.h"
+#include "libvirt-gobject-compat.h"
+#include "libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h"
+
+#define GVIR_NETWORK_DHCP_LEASE_GET_PRIVATE(obj)                         \
+        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_NETWORK_DHCP_LEASE, 
GVirNetworkDHCPLeasePrivate))
+
+struct _GVirNetworkDHCPLeasePrivate
+{
+    virNetworkDHCPLeasePtr handle;
+};
+
+G_DEFINE_TYPE(GVirNetworkDHCPLease, gvir_network_dhcp_lease, G_TYPE_OBJECT);
+
+enum {
+    PROP_0,
+    PROP_HANDLE,
+};
+
+static void gvir_network_dhcp_lease_get_property(GObject *object,
+                                                 guint prop_id,
+                                                 GValue *value,
+                                                 GParamSpec *pspec)
+{
+    GVirNetworkDHCPLease *lease = GVIR_NETWORK_DHCP_LEASE(object);
+    GVirNetworkDHCPLeasePrivate *priv = lease->priv;
+
+    switch (prop_id) {
+    case PROP_HANDLE:
+        g_value_set_pointer(value, priv->handle);
+        break;
+
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
+}
+
+static void gvir_network_dhcp_lease_set_property(GObject *object,
+                                                 guint prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec *pspec)
+{
+    GVirNetworkDHCPLease *lease = GVIR_NETWORK_DHCP_LEASE(object);
+    GVirNetworkDHCPLeasePrivate *priv = lease->priv;
+
+    switch (prop_id) {
+    case PROP_HANDLE:
+        if (priv->handle)
+            virNetworkDHCPLeaseFree(priv->handle);
+        priv->handle = g_value_get_pointer(value);
+        break;
+
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
+}
+
+
+static void gvir_network_dhcp_lease_finalize(GObject *object)
+{
+    GVirNetworkDHCPLease *lease = GVIR_NETWORK_DHCP_LEASE(object);
+    GVirNetworkDHCPLeasePrivate *priv = lease->priv;
+
+    g_debug("Finalize GVirNetworkDHCPLease=%p", lease);
+
+    virNetworkDHCPLeaseFree(priv->handle);
+
+    G_OBJECT_CLASS(gvir_network_dhcp_lease_parent_class)->finalize(object);
+}
+
+static void gvir_network_dhcp_lease_class_init(GVirNetworkDHCPLeaseClass 
*klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = gvir_network_dhcp_lease_finalize;
+    object_class->get_property = gvir_network_dhcp_lease_get_property;
+    object_class->set_property = gvir_network_dhcp_lease_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_HANDLE,
+                                    g_param_spec_pointer("handle",
+                                                         "Handle",
+                                                         "The lease handle",
+                                                         G_PARAM_READWRITE |
+                                                         
G_PARAM_CONSTRUCT_ONLY |
+                                                         G_PARAM_PRIVATE |
+                                                         
G_PARAM_STATIC_STRINGS));
+
+    g_type_class_add_private(klass, sizeof(GVirNetworkDHCPLeasePrivate));
+}
+
+
+static void gvir_network_dhcp_lease_init(GVirNetworkDHCPLease *lease)
+{
+    g_debug("Init GVirNetworkDHCPLease=%p", lease);
+
+    lease->priv = GVIR_NETWORK_DHCP_LEASE_GET_PRIVATE(lease);
+}
+
+GVirNetworkDHCPLease *gvir_network_dhcp_lease_new(virNetworkDHCPLeasePtr 
handle)
+{
+    return g_object_new(GVIR_TYPE_NETWORK_DHCP_LEASE,
+                        "handle", handle,
+                        NULL);
+}
+
+/**
+ * gvir_network_dhcp_lease_get_iface:
+ * @lease: the lease
+ *
+ * Returns: (transfer none): The network interface name.
+ */
+const gchar *gvir_network_dhcp_lease_get_iface(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), NULL);
+
+    return lease->priv->handle->iface;
+}
+
+/**
+ * gvir_network_dhcp_lease_get_expiry_time:
+ * @lease: the lease
+ *
+ * Returns: The expiry time of this lease, as seconds since epoch.
+ */
+gint64 gvir_network_dhcp_lease_get_expiry_time(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), -1);
+
+    return lease->priv->handle->expirytime;
+}
+
+/**
+ * gvir_network_dhcp_lease_get_ip_type:
+ * @lease: the lease
+ *
+ * Returns: The type of IP, see %GVirIPAddrType for possible values.
+ */
+gint gvir_network_dhcp_lease_get_ip_type(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), -1);
+
+    return lease->priv->handle->type;
+}
+
+/**
+ * gvir_network_dhcp_lease_get_mac:
+ * @lease: the lease
+ *
+ * Returns: (transfer none): The MAC address.
+ */
+const gchar *gvir_network_dhcp_lease_get_mac(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), NULL);
+
+    return lease->priv->handle->mac;
+}
+
+/**
+ * gvir_network_dhcp_lease_get_iaid:
+ * @lease: the lease
+ *
+ * Returns: (transfer none): The IAID.
+ */
+const gchar *gvir_network_dhcp_lease_get_iaid(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), NULL);
+
+    return lease->priv->handle->iaid;
+}
+
+/**
+ * gvir_network_dhcp_lease_get_ip:
+ * @lease: the lease
+ *
+ * Returns: (transfer none): The IP address.
+ */
+const gchar *gvir_network_dhcp_lease_get_ip(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), NULL);
+
+    return lease->priv->handle->ipaddr;
+}
+
+/**
+ * gvir_network_dhcp_lease_get_prefix:
+ * @lease: the lease
+ *
+ * Returns: The number of network address bits in the IP address.
+ */
+guint gvir_network_dhcp_lease_get_prefix(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), 0);
+
+    return lease->priv->handle->prefix;
+}
+
+/**
+ * gvir_network_dhcp_lease_get_hostname:
+ * @lease: the lease
+ *
+ * Returns: (transfer none): The hostname.
+ */
+const gchar *gvir_network_dhcp_lease_get_hostname(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), NULL);
+
+    return lease->priv->handle->hostname;
+}
+
+/**
+ * gvir_network_dhcp_lease_get_client_id:
+ * @lease: the lease
+ *
+ * Returns: (transfer none): The client ID or DUID.
+ */
+const gchar *gvir_network_dhcp_lease_get_client_id(GVirNetworkDHCPLease *lease)
+{
+    g_return_val_if_fail(GVIR_IS_NETWORK_DHCP_LEASE(lease), NULL);
+
+    return lease->priv->handle->clientid;
+}
diff --git a/libvirt-gobject/libvirt-gobject-network-dhcp-lease.h 
b/libvirt-gobject/libvirt-gobject-network-dhcp-lease.h
new file mode 100644
index 0000000..a011d65
--- /dev/null
+++ b/libvirt-gobject/libvirt-gobject-network-dhcp-lease.h
@@ -0,0 +1,85 @@
+/*
+ * libvirt-gobject-network-dhcp-lease.h: libvirt gobject integration
+ *
+ * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2015 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/>.
+ *
+ * Authors: Zeeshan Ali (Khattak) <zeesha...@gnome.org>
+ *          Daniel P. Berrange <berra...@redhat.com>
+ */
+
+#if !defined(__LIBVIRT_GOBJECT_H__) && !defined(LIBVIRT_GOBJECT_BUILD)
+#error "Only <libvirt-gobject/libvirt-gobject.h> can be included directly."
+#endif
+
+#ifndef __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_H__
+#define __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_H__
+
+G_BEGIN_DECLS
+
+/**
+ * GVirIPAddrType:
+ * @GVIR_IP_ADDR_TYPE_IPV4: IPv4 Address.
+ * @GVIR_IP_ADDR_TYPE_IPV6: IPv6 Address.
+ */
+typedef enum {
+    GVIR_IP_ADDR_TYPE_IPV4 =   0,
+    GVIR_IP_ADDR_TYPE_IPV6 =   1
+} GVirIPAddrType;
+
+#define GVIR_TYPE_NETWORK_DHCP_LEASE            
(gvir_network_dhcp_lease_get_type ())
+#define GVIR_NETWORK_DHCP_LEASE(obj)            (G_TYPE_CHECK_INSTANCE_CAST 
((obj), GVIR_TYPE_NETWORK_DHCP_LEASE, GVirNetworkDHCPLease))
+#define GVIR_NETWORK_DHCP_LEASE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST 
((klass), GVIR_TYPE_NETWORK_DHCP_LEASE, GVirNetworkDHCPLeaseClass))
+#define GVIR_IS_NETWORK_DHCP_LEASE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE 
((obj), GVIR_TYPE_NETWORK_DHCP_LEASE))
+#define GVIR_IS_NETWORK_DHCP_LEASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE 
((klass), GVIR_TYPE_NETWORK_DHCP_LEASE))
+#define GVIR_NETWORK_DHCP_LEASE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS 
((obj), GVIR_TYPE_NETWORK_DHCP_LEASE, GVirNetworkDHCPLeaseClass))
+
+typedef struct _GVirNetworkDHCPLease GVirNetworkDHCPLease;
+typedef struct _GVirNetworkDHCPLeasePrivate GVirNetworkDHCPLeasePrivate;
+typedef struct _GVirNetworkDHCPLeaseClass GVirNetworkDHCPLeaseClass;
+
+struct _GVirNetworkDHCPLease
+{
+    GObject parent;
+
+    GVirNetworkDHCPLeasePrivate *priv;
+
+    /* Do not add fields to this struct */
+};
+
+struct _GVirNetworkDHCPLeaseClass
+{
+    GObjectClass parent_class;
+
+    gpointer padding[7];
+};
+
+GType gvir_network_dhcp_lease_get_type(void);
+
+const gchar *gvir_network_dhcp_lease_get_iface(GVirNetworkDHCPLease *lease);
+gint64 gvir_network_dhcp_lease_get_expiry_time(GVirNetworkDHCPLease *lease);
+gint gvir_network_dhcp_lease_get_ip_type(GVirNetworkDHCPLease *lease);
+const gchar *gvir_network_dhcp_lease_get_mac(GVirNetworkDHCPLease *lease);
+const gchar *gvir_network_dhcp_lease_get_iaid(GVirNetworkDHCPLease *lease);
+const gchar *gvir_network_dhcp_lease_get_ip(GVirNetworkDHCPLease *lease);
+guint gvir_network_dhcp_lease_get_prefix(GVirNetworkDHCPLease *lease);
+const gchar *gvir_network_dhcp_lease_get_hostname(GVirNetworkDHCPLease *lease);
+const gchar *gvir_network_dhcp_lease_get_client_id(GVirNetworkDHCPLease 
*lease);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.h 
b/libvirt-gobject/libvirt-gobject.h
index 2b95070..d542482 100644
--- a/libvirt-gobject/libvirt-gobject.h
+++ b/libvirt-gobject/libvirt-gobject.h
@@ -37,6 +37,7 @@
 #include <libvirt-gobject/libvirt-gobject-domain.h>
 #include <libvirt-gobject/libvirt-gobject-interface.h>
 #include <libvirt-gobject/libvirt-gobject-network.h>
+#include <libvirt-gobject/libvirt-gobject-network-dhcp-lease.h>
 #include <libvirt-gobject/libvirt-gobject-network-filter.h>
 #include <libvirt-gobject/libvirt-gobject-node-device.h>
 #include <libvirt-gobject/libvirt-gobject-secret.h>
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index 88ca271..dfd858a 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -287,6 +287,19 @@ LIBVIRT_GOBJECT_0.2.2 {
        gvir_connection_get_networks;
 
        gvir_interface_get_mac;
+
+       gvir_ip_addr_type_get_type;
+
+       gvir_network_dhcp_lease_get_client_id;
+       gvir_network_dhcp_lease_get_expiry_time;
+       gvir_network_dhcp_lease_get_hostname;
+       gvir_network_dhcp_lease_get_iaid;
+       gvir_network_dhcp_lease_get_iface;
+       gvir_network_dhcp_lease_get_ip;
+       gvir_network_dhcp_lease_get_ip_type;
+       gvir_network_dhcp_lease_get_mac;
+       gvir_network_dhcp_lease_get_prefix;
+       gvir_network_dhcp_lease_get_type;
 } LIBVIRT_GOBJECT_0.2.1;
 
 # .... define new API here using predicted next version number ....
-- 
2.4.3

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

Reply via email to