On Fri, Dec 21, 2012 at 04:49:36PM +0100, Michal Privoznik wrote:
This API returns dynamically allocated array of IP addresses for
all domain interfaces.
---
include/libvirt/libvirt.h.in | 49 ++++++++++++++++++++++++++++++
python/generator.py | 2 ++
src/driver.h | 6 ++++
src/libvirt.c | 71 ++++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 ++++
5 files changed, 134 insertions(+)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index c6739d7..3eb7ced 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -4564,6 +4564,55 @@ int virDomainFSTrim(virDomainPtr dom,
unsigned long long minimum,
unsigned int flags);
+typedef enum {
+ VIR_INTERFACE_BROADCAST = (1 << 0), /* Broadcast address valid. */
+ VIR_INTERFACE_PPP = (1 << 1), /* Interface is point-to-point. */
+ /* we can add new flags here */
+} virDomainInterfaceType;
+
+typedef enum {
+ VIR_IP_ADDR_TYPE_IPV4,
+ VIR_IP_ADDR_TYPE_IPV6,
+
+#ifdef VIR_ENUM_SENTINELS
+ VIR_IP_ADDR_TYPE_LAST
+#endif
+} virIPAddrType;
+
+
+typedef struct _virDomainInterfaceIPAddress virDomainIPAddress;
+typedef virDomainIPAddress *virDomainIPAddressPtr;
+struct _virDomainInterfaceIPAddress {
+ int type; /* virIPAddrType */
+ char *addr; /* IP address */
+ int prefix; /* IP address prefix */
+ char *dstaddr; /* Broadcast address (if @flags & VIR_INTERFACE_BROADCAST),
+ PPP destination address (if @flags & VIR_INTERFACE_PPP) */
+};
+
+typedef struct _virDomainInterface virDomainInterface;
+typedef virDomainInterface *virDomainInterfacePtr;
+struct _virDomainInterface {
+ char *name; /* interface name */
+ unsigned int flags; /* virDomainInterfaceType */
+ char *hwaddr; /* hardware address */
+ unsigned int ip_addrs_count; /* number of items in @ip_addr */
+ virDomainIPAddressPtr ip_addrs; /* array of IP addresses */
+};
+
+typedef enum {
+ VIR_DOMAIN_INTERFACE_ADDRS_DEFAULT = 0, /* hypervisor choice */
+ VIR_DOMAIN_INTERFACE_ADDRS_GUEST_AGENT = 1, /* use guest agent */
+ VIR_DOMAIN_INTERFACE_ADDRS_NWFILTER = 2, /* use nwfilter learning code */
+ /* etc ... */
+} virDomainInterfacesAddressesMethod;
+
+
+int virDomainInterfacesAddresses(virDomainPtr domain,
+ virDomainInterfacePtr *ifaces,
+ unsigned int method,
+ unsigned int flags);
I tend to prefer it if we use "virDomainInterfacePtr **ifaces"
as we did with the vir*ListAll() methods. eg an array of pointers
to objects, rather than array of objects.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|