2008-10-10 13:57:13 +00:00
|
|
|
/*
|
|
|
|
* network_driver.h: core driver methods for managing networks
|
|
|
|
*
|
util: capabilities detection for dnsmasq
In order to optionally take advantage of new features in dnsmasq when
the host's version of dnsmasq supports them, but still be able to run
on hosts that don't support the new features, we need to be able to
detect the version of dnsmasq running on the host, and possibly
determine from the help output what options are in this dnsmasq.
This patch implements a greatly simplified version of the capabilities
code we already have for qemu. A dnsmasqCaps device can be created and
populated either from running a program on disk, reading a file with
the concatenated output of "dnsmasq --version; dnsmasq --help", or
examining a buffer in memory that contains the concatenated output of
those two commands. Simple functions to retrieve capabilities flags,
the version number, and the path of the binary are also included.
bridge_driver.c creates a single dnsmasqCaps object at driver startup,
and disposes of it at driver shutdown. Any time it must be used, the
dnsmasqCapsRefresh method is called - it checks the mtime of the
binary, and re-runs the checks if the binary has changed.
networkxml2argvtest.c creates 2 "artificial" dnsmasqCaps objects at
startup - one "restricted" (doesn't support --bind-dynamic) and one
"full" (does support --bind-dynamic). Some of the test cases use one
and some the other, to make sure both code pathes are tested.
2012-11-20 17:22:15 +00:00
|
|
|
* Copyright (C) 2006-2012 Red Hat, Inc.
|
2008-10-10 13:57:13 +00:00
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2008-10-10 13:57:13 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __VIR_NETWORK__DRIVER_H
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_NETWORK__DRIVER_H
|
2008-10-10 13:57:13 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <config.h>
|
2008-10-10 13:57:13 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
2011-06-24 10:04:38 +00:00
|
|
|
# include "network_conf.h"
|
2011-07-04 06:27:12 +00:00
|
|
|
# include "domain_conf.h"
|
2012-12-12 16:27:01 +00:00
|
|
|
# include "vircommand.h"
|
2012-12-12 16:43:54 +00:00
|
|
|
# include "virdnsmasq.h"
|
2008-10-10 13:57:13 +00:00
|
|
|
|
|
|
|
int networkRegister(void);
|
2011-07-04 06:27:12 +00:00
|
|
|
|
|
|
|
# if WITH_NETWORK
|
|
|
|
int networkAllocateActualDevice(virDomainNetDefPtr iface)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
int networkNotifyActualDevice(virDomainNetDefPtr iface)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
int networkReleaseActualDevice(virDomainNetDefPtr iface)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
|
2011-07-07 04:24:08 +00:00
|
|
|
int networkGetNetworkAddress(const char *netname, char **netaddr)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
|
2012-12-06 17:20:39 +00:00
|
|
|
int networkDnsmasqConfContents(virNetworkObjPtr network,
|
|
|
|
const char *pidfile,
|
|
|
|
char **configstr,
|
|
|
|
dnsmasqContext *dctx,
|
|
|
|
dnsmasqCapsPtr caps);
|
2011-07-04 06:27:12 +00:00
|
|
|
# else
|
|
|
|
/* Define no-op replacements that don't drag in any link dependencies. */
|
|
|
|
# define networkAllocateActualDevice(iface) 0
|
2012-11-21 13:59:47 +00:00
|
|
|
# define networkNotifyActualDevice(iface) (iface=iface, 0)
|
|
|
|
# define networkReleaseActualDevice(iface) (iface=iface, 0)
|
2011-07-26 11:57:34 +00:00
|
|
|
# define networkGetNetworkAddress(netname, netaddr) (-2)
|
2012-12-06 17:20:39 +00:00
|
|
|
# define networkDnsmasqConfContents(network, pidfile, configstr, \
|
|
|
|
dctx, caps) 0
|
2011-07-04 06:27:12 +00:00
|
|
|
# endif
|
2008-10-10 13:57:13 +00:00
|
|
|
|
2011-06-27 14:55:13 +00:00
|
|
|
typedef char *(*networkDnsmasqLeaseFileNameFunc)(const char *netname);
|
|
|
|
|
|
|
|
/* this allows the testsuite to replace the lease filename resolver function */
|
|
|
|
extern networkDnsmasqLeaseFileNameFunc networkDnsmasqLeaseFileName;
|
|
|
|
|
2008-10-10 13:57:13 +00:00
|
|
|
#endif /* __VIR_NETWORK__DRIVER_H */
|