]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
network: provide internal API to return IP of a network
authorLaine Stump <laine@laine.org>
Thu, 7 Jul 2011 04:24:08 +0000 (00:24 -0400)
committerDaniel Veillard <veillard@redhat.com>
Mon, 25 Jul 2011 05:48:55 +0000 (13:48 +0800)
commit239322cbd4d559231b1e6cfb6a71c6c884752026
tree9490e820e49c9f19ef06ae36450eaa7c91b9e05f
parentc5d1592e20899917b038463a77cd47eac2ce55a9
network: provide internal API to return IP of a network

The new listenNetwork attribute needs to learn an IP address based on a
named network. This patch provides a function networkGetNetworkAddress
which provides that.

Some networks have an IP address explicitly in their configuration
(ie, those with a forward type of "none", "route", or "nat"). For
those, we can just return the IP address from the config.

The rest will have a physical device associated with them (either via
<bridge name='...'/>, <forward ... dev='...'/>, or possibly via a pool
of interfaces inside the network's <forward> element) and we will need
to ask the kernel for a current IP address of that device (via the
newly added ifaceGetIPAddress)

If networkGetNetworkAddress encounters an error while trying to learn
the address for a network, it will return -1. In the case that libvirt
has been compiled without the network driver, the call is a macro
which reduces to -2. This allows differentiating between a failure of
the network driver, and its complete absence.
src/libvirt_network.syms
src/network/bridge_driver.c
src/network/bridge_driver.h