2008-07-11 10:48:34 +00:00
|
|
|
/*
|
|
|
|
* network_conf.h: network XML handling
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006-2008 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2006-2008 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
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NETWORK_CONF_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __NETWORK_CONF_H__
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/tree.h>
|
|
|
|
# include <libxml/xpath.h>
|
2008-11-04 23:22:06 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
|
|
|
# include "threads.h"
|
2008-07-11 10:48:34 +00:00
|
|
|
|
|
|
|
/* 2 possible types of forwarding */
|
|
|
|
enum virNetworkForwardType {
|
|
|
|
VIR_NETWORK_FORWARD_NONE = 0,
|
|
|
|
VIR_NETWORK_FORWARD_NAT,
|
|
|
|
VIR_NETWORK_FORWARD_ROUTE,
|
|
|
|
|
|
|
|
VIR_NETWORK_FORWARD_LAST,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virNetworkDHCPRangeDef virNetworkDHCPRangeDef;
|
|
|
|
typedef virNetworkDHCPRangeDef *virNetworkDHCPRangeDefPtr;
|
|
|
|
struct _virNetworkDHCPRangeDef {
|
|
|
|
char *start;
|
|
|
|
char *end;
|
2009-11-06 16:50:54 +00:00
|
|
|
int size;
|
2008-07-11 10:48:34 +00:00
|
|
|
};
|
|
|
|
|
2008-08-20 12:50:29 +00:00
|
|
|
typedef struct _virNetworkDHCPHostDef virNetworkDHCPHostDef;
|
|
|
|
typedef virNetworkDHCPHostDef *virNetworkDHCPHostDefPtr;
|
|
|
|
struct _virNetworkDHCPHostDef {
|
|
|
|
char *mac;
|
|
|
|
char *name;
|
|
|
|
char *ip;
|
|
|
|
};
|
|
|
|
|
2008-07-11 10:48:34 +00:00
|
|
|
typedef struct _virNetworkDef virNetworkDef;
|
|
|
|
typedef virNetworkDef *virNetworkDefPtr;
|
|
|
|
struct _virNetworkDef {
|
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
char *bridge; /* Name of bridge device */
|
2008-09-08 12:45:29 +00:00
|
|
|
char *domain;
|
2008-07-11 10:48:34 +00:00
|
|
|
unsigned long delay; /* Bridge forward delay (ms) */
|
2010-01-19 12:07:32 +00:00
|
|
|
unsigned int stp :1; /* Spanning tree protocol */
|
2008-07-11 10:48:34 +00:00
|
|
|
|
|
|
|
int forwardType; /* One of virNetworkForwardType constants */
|
|
|
|
char *forwardDev; /* Destination device for forwarding */
|
|
|
|
|
|
|
|
char *ipAddress; /* Bridge IP address */
|
|
|
|
char *netmask;
|
|
|
|
char *network;
|
|
|
|
|
|
|
|
unsigned int nranges; /* Zero or more dhcp ranges */
|
|
|
|
virNetworkDHCPRangeDefPtr ranges;
|
2008-08-20 12:50:29 +00:00
|
|
|
|
|
|
|
unsigned int nhosts; /* Zero or more dhcp hosts */
|
|
|
|
virNetworkDHCPHostDefPtr hosts;
|
2009-09-21 20:50:25 +00:00
|
|
|
|
|
|
|
char *tftproot;
|
|
|
|
char *bootfile;
|
2009-10-28 14:57:49 +00:00
|
|
|
char *bootserver;
|
2008-07-11 10:48:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virNetworkObj virNetworkObj;
|
|
|
|
typedef virNetworkObj *virNetworkObjPtr;
|
|
|
|
struct _virNetworkObj {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 22:00:14 +00:00
|
|
|
|
2008-07-11 10:48:34 +00:00
|
|
|
pid_t dnsmasqPid;
|
|
|
|
unsigned int active : 1;
|
|
|
|
unsigned int autostart : 1;
|
|
|
|
unsigned int persistent : 1;
|
|
|
|
|
|
|
|
virNetworkDefPtr def; /* The current definition */
|
|
|
|
virNetworkDefPtr newDef; /* New definition to activate at shutdown */
|
2008-10-10 14:50:26 +00:00
|
|
|
};
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
typedef struct _virNetworkObjList virNetworkObjList;
|
|
|
|
typedef virNetworkObjList *virNetworkObjListPtr;
|
|
|
|
struct _virNetworkObjList {
|
|
|
|
unsigned int count;
|
|
|
|
virNetworkObjPtr *objs;
|
2008-07-11 10:48:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline int
|
Rename internal APis
Rename virDomainIsActive to virDomainObjIsActive, and
virInterfaceIsActive to virInterfaceObjIsActive and finally
virNetworkIsActive to virNetworkObjIsActive.
* src/conf/domain_conf.c, src/conf/domain_conf.h,
src/conf/interface_conf.h, src/conf/network_conf.c,
src/conf/network_conf.h, src/lxc/lxc_driver.c,
src/network/bridge_driver.c, src/opennebula/one_driver.c,
src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c: Update for
renamed APIs.
2009-10-20 14:51:03 +00:00
|
|
|
virNetworkObjIsActive(const virNetworkObjPtr net)
|
2008-07-11 10:48:34 +00:00
|
|
|
{
|
|
|
|
return net->active;
|
|
|
|
}
|
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const unsigned char *uuid);
|
2008-10-10 14:50:26 +00:00
|
|
|
virNetworkObjPtr virNetworkFindByName(const virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const char *name);
|
|
|
|
|
|
|
|
|
|
|
|
void virNetworkDefFree(virNetworkDefPtr def);
|
|
|
|
void virNetworkObjFree(virNetworkObjPtr net);
|
2008-10-10 14:50:26 +00:00
|
|
|
void virNetworkObjListFree(virNetworkObjListPtr vms);
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
virNetworkObjPtr virNetworkAssignDef(virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const virNetworkDefPtr def);
|
2008-10-10 14:50:26 +00:00
|
|
|
void virNetworkRemoveInactive(virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const virNetworkObjPtr net);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
virNetworkDefPtr virNetworkDefParseString(const char *xmlStr);
|
|
|
|
virNetworkDefPtr virNetworkDefParseFile(const char *filename);
|
|
|
|
virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml,
|
2008-07-11 10:48:34 +00:00
|
|
|
xmlNodePtr root);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
char *virNetworkDefFormat(const virNetworkDefPtr def);
|
2008-07-11 10:48:34 +00:00
|
|
|
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkSaveXML(const char *configDir,
|
2009-01-20 22:36:10 +00:00
|
|
|
virNetworkDefPtr def,
|
|
|
|
const char *xml);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkSaveConfig(const char *configDir,
|
2009-01-20 22:36:10 +00:00
|
|
|
virNetworkDefPtr def);
|
2008-07-11 10:48:34 +00:00
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const char *configDir,
|
|
|
|
const char *autostartDir,
|
|
|
|
const char *file);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
|
2008-07-11 10:48:34 +00:00
|
|
|
const char *configDir,
|
|
|
|
const char *autostartDir);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkDeleteConfig(const char *configDir,
|
2009-01-20 22:36:10 +00:00
|
|
|
const char *autostartDir,
|
2008-07-11 10:48:34 +00:00
|
|
|
virNetworkObjPtr net);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
char *virNetworkConfigFile(const char *dir,
|
2009-01-20 22:36:10 +00:00
|
|
|
const char *name);
|
|
|
|
|
2009-03-02 17:37:03 +00:00
|
|
|
int virNetworkBridgeInUse(const virNetworkObjListPtr nets,
|
|
|
|
const char *bridge,
|
|
|
|
const char *skipname);
|
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
char *virNetworkAllocateBridge(const virNetworkObjListPtr nets,
|
2009-04-21 19:00:06 +00:00
|
|
|
const char *template);
|
2009-03-02 17:37:03 +00:00
|
|
|
|
2010-02-10 10:22:52 +00:00
|
|
|
int virNetworkSetBridgeName(const virNetworkObjListPtr nets,
|
2009-05-29 14:18:57 +00:00
|
|
|
virNetworkDefPtr def,
|
|
|
|
int check_collision);
|
2009-01-20 22:36:10 +00:00
|
|
|
|
2008-12-04 20:53:20 +00:00
|
|
|
void virNetworkObjLock(virNetworkObjPtr obj);
|
|
|
|
void virNetworkObjUnlock(virNetworkObjPtr obj);
|
|
|
|
|
2008-07-11 10:48:34 +00:00
|
|
|
#endif /* __NETWORK_CONF_H__ */
|