2009-07-15 17:34:04 +00:00
|
|
|
/*
|
|
|
|
* interface_conf.h: interface XML handling entry points
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006-2009 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: Daniel Veillard <veillard@redhat.com>
|
|
|
|
* Laine Stump <laine@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INTERFACE_CONF_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __INTERFACE_CONF_H__
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/tree.h>
|
|
|
|
# include <libxml/xpath.h>
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
|
|
|
# include "util.h"
|
|
|
|
# include "threads.h"
|
2009-07-15 17:34:04 +00:00
|
|
|
|
|
|
|
/* There is currently 3 types of interfaces */
|
|
|
|
|
|
|
|
enum virInterfaceType {
|
|
|
|
VIR_INTERFACE_TYPE_ETHERNET, /* simple ethernet */
|
|
|
|
VIR_INTERFACE_TYPE_BRIDGE, /* bridge interface */
|
|
|
|
VIR_INTERFACE_TYPE_BOND, /* bonding interface */
|
|
|
|
VIR_INTERFACE_TYPE_VLAN, /* vlan description */
|
|
|
|
|
|
|
|
VIR_INTERFACE_TYPE_LAST,
|
|
|
|
};
|
|
|
|
|
|
|
|
VIR_ENUM_DECL(virInterface)
|
|
|
|
|
|
|
|
/* types of start mode */
|
|
|
|
|
|
|
|
enum virInterfaceStartMode {
|
2009-10-28 08:55:33 +00:00
|
|
|
VIR_INTERFACE_START_UNSPECIFIED = 0, /* not given in config */
|
|
|
|
VIR_INTERFACE_START_NONE, /* specified as not defined */
|
2009-07-15 17:34:04 +00:00
|
|
|
VIR_INTERFACE_START_ONBOOT, /* startup at boot */
|
|
|
|
VIR_INTERFACE_START_HOTPLUG, /* on hotplug */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum virInterfaceBondMode {
|
|
|
|
VIR_INTERFACE_BOND_NONE = 0,
|
|
|
|
VIR_INTERFACE_BOND_BALRR, /* balance-rr */
|
|
|
|
VIR_INTERFACE_BOND_ABACKUP, /* active backup */
|
|
|
|
VIR_INTERFACE_BOND_BALXOR, /* balance-xor */
|
|
|
|
VIR_INTERFACE_BOND_BCAST, /* broadcast */
|
|
|
|
VIR_INTERFACE_BOND_8023AD, /* 802.3ad */
|
|
|
|
VIR_INTERFACE_BOND_BALTLB, /* balance-tlb */
|
|
|
|
VIR_INTERFACE_BOND_BALALB, /* balance-alb */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum virInterfaceBondMonit {
|
|
|
|
VIR_INTERFACE_BOND_MONIT_NONE = 0,
|
|
|
|
VIR_INTERFACE_BOND_MONIT_MII, /* mii based monitoring */
|
|
|
|
VIR_INTERFACE_BOND_MONIT_ARP, /* arp based monitoring */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum virInterfaceBondMiiCarrier {
|
|
|
|
VIR_INTERFACE_BOND_MII_NONE = 0,
|
|
|
|
VIR_INTERFACE_BOND_MII_IOCTL, /* mii/ethtool ioctl */
|
|
|
|
VIR_INTERFACE_BOND_MII_NETIF, /* netif_carrier_ok */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum virInterfaceBondArpValid {
|
|
|
|
VIR_INTERFACE_BOND_ARP_NONE = 0,
|
|
|
|
VIR_INTERFACE_BOND_ARP_ACTIVE, /* validate active */
|
|
|
|
VIR_INTERFACE_BOND_ARP_BACKUP, /* validate backup */
|
|
|
|
VIR_INTERFACE_BOND_ARP_ALL, /* validate all */
|
|
|
|
};
|
|
|
|
|
2010-01-02 01:40:25 +00:00
|
|
|
struct _virInterfaceDef; /* forward declaration required for bridge/bond */
|
2009-07-15 17:34:04 +00:00
|
|
|
|
|
|
|
typedef struct _virInterfaceBridgeDef virInterfaceBridgeDef;
|
|
|
|
typedef virInterfaceBridgeDef *virInterfaceBridgeDefPtr;
|
|
|
|
struct _virInterfaceBridgeDef {
|
|
|
|
int stp; /* 0, 1 or -1 if undefined */
|
2010-01-02 01:40:23 +00:00
|
|
|
char *delay;
|
2009-07-15 17:34:04 +00:00
|
|
|
int nbItf; /* number of defined interfaces */
|
2010-01-02 01:40:25 +00:00
|
|
|
struct _virInterfaceDef **itf;/* interfaces */
|
2009-07-15 17:34:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virInterfaceBondDef virInterfaceBondDef;
|
|
|
|
typedef virInterfaceBondDef *virInterfaceBondDefPtr;
|
|
|
|
struct _virInterfaceBondDef {
|
|
|
|
int mode; /* virInterfaceBondMode */
|
|
|
|
int monit; /* virInterfaceBondMonit */
|
|
|
|
int frequency; /* miimon frequency in ms */
|
|
|
|
int downdelay; /* miimon downdelay */
|
|
|
|
int updelay; /* miimon updelay */
|
|
|
|
int carrier; /* virInterfaceBondMiiCarrier */
|
|
|
|
int interval; /* arp monitoring interval */
|
|
|
|
char *target; /* arp monitoring target */
|
|
|
|
int validate; /* virInterfaceBondArpmValid */
|
|
|
|
int nbItf; /* number of defined interfaces */
|
2010-01-02 01:40:25 +00:00
|
|
|
struct _virInterfaceDef **itf; /* interfaces ethernet only */
|
2009-07-15 17:34:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virInterfaceVlanDef virInterfaceVlanDef;
|
|
|
|
typedef virInterfaceVlanDef *virInterfaceVlanDefPtr;
|
|
|
|
struct _virInterfaceVlanDef {
|
|
|
|
char *tag; /* TAG for vlan */
|
|
|
|
char *devname; /* device name for vlan */
|
|
|
|
};
|
|
|
|
|
2009-10-28 13:13:18 +00:00
|
|
|
typedef struct _virInterfaceIpDef virInterfaceIpDef;
|
|
|
|
typedef virInterfaceIpDef *virInterfaceIpDefPtr;
|
|
|
|
struct _virInterfaceIpDef {
|
|
|
|
char *address; /* ip address */
|
|
|
|
int prefix; /* ip prefix */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-07-15 17:34:04 +00:00
|
|
|
typedef struct _virInterfaceProtocolDef virInterfaceProtocolDef;
|
|
|
|
typedef virInterfaceProtocolDef *virInterfaceProtocolDefPtr;
|
|
|
|
struct _virInterfaceProtocolDef {
|
2009-10-28 13:13:18 +00:00
|
|
|
char *family; /* ipv4 or ipv6 */
|
2009-07-15 17:34:04 +00:00
|
|
|
int dhcp; /* use dhcp */
|
|
|
|
int peerdns; /* dhcp peerdns ? */
|
2009-10-28 13:13:18 +00:00
|
|
|
int autoconf; /* only useful if family is ipv6 */
|
|
|
|
int nips;
|
|
|
|
virInterfaceIpDefPtr *ips; /* ptr to array of ips[nips] */
|
2009-07-15 17:34:04 +00:00
|
|
|
char *gateway; /* route gateway */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _virInterfaceDef virInterfaceDef;
|
|
|
|
typedef virInterfaceDef *virInterfaceDefPtr;
|
|
|
|
struct _virInterfaceDef {
|
|
|
|
int type; /* interface type */
|
|
|
|
char *name; /* interface name */
|
|
|
|
unsigned int mtu; /* maximum transmit size in byte */
|
|
|
|
char *mac; /* MAC address */
|
|
|
|
|
|
|
|
enum virInterfaceStartMode startmode; /* how it is started */
|
|
|
|
|
|
|
|
union {
|
|
|
|
virInterfaceBridgeDef bridge;
|
|
|
|
virInterfaceVlanDef vlan;
|
|
|
|
virInterfaceBondDef bond;
|
|
|
|
} data;
|
|
|
|
|
2009-10-28 13:13:18 +00:00
|
|
|
int nprotos;
|
|
|
|
virInterfaceProtocolDefPtr *protos; /* ptr to array of protos[nprotos] */
|
2009-07-15 17:34:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virInterfaceObj virInterfaceObj;
|
|
|
|
typedef virInterfaceObj *virInterfaceObjPtr;
|
|
|
|
struct _virInterfaceObj {
|
|
|
|
virMutex lock;
|
|
|
|
|
2010-01-19 12:07:32 +00:00
|
|
|
unsigned int active:1; /* 1 if interface is active (up) */
|
2009-07-15 17:34:04 +00:00
|
|
|
virInterfaceDefPtr def; /* The interface definition */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virInterfaceObjList virInterfaceObjList;
|
|
|
|
typedef virInterfaceObjList *virInterfaceObjListPtr;
|
|
|
|
struct _virInterfaceObjList {
|
|
|
|
unsigned int count;
|
|
|
|
virInterfaceObjPtr *objs;
|
|
|
|
};
|
|
|
|
|
2009-07-21 13:40:55 +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
|
|
|
virInterfaceObjIsActive(const virInterfaceObjPtr iface)
|
2009-07-21 13:40:55 +00:00
|
|
|
{
|
|
|
|
return iface->active;
|
|
|
|
}
|
|
|
|
|
|
|
|
int virInterfaceFindByMACString(const virInterfaceObjListPtr interfaces,
|
|
|
|
const char *mac,
|
|
|
|
virInterfaceObjPtr *matches, int maxmatches);
|
|
|
|
virInterfaceObjPtr virInterfaceFindByName(const virInterfaceObjListPtr
|
|
|
|
interfaces,
|
2009-07-15 17:34:04 +00:00
|
|
|
const char *name);
|
|
|
|
|
|
|
|
|
|
|
|
void virInterfaceDefFree(virInterfaceDefPtr def);
|
2009-07-22 17:18:19 +00:00
|
|
|
void virInterfaceObjFree(virInterfaceObjPtr iface);
|
2009-07-15 17:34:04 +00:00
|
|
|
void virInterfaceObjListFree(virInterfaceObjListPtr vms);
|
2011-05-09 19:17:26 +00:00
|
|
|
int virInterfaceObjListClone(virInterfaceObjListPtr src,
|
|
|
|
virInterfaceObjListPtr dest);
|
|
|
|
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2010-02-10 12:28:05 +00:00
|
|
|
virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces,
|
2009-07-15 17:34:04 +00:00
|
|
|
const virInterfaceDefPtr def);
|
|
|
|
void virInterfaceRemove(virInterfaceObjListPtr interfaces,
|
2009-07-22 17:18:19 +00:00
|
|
|
const virInterfaceObjPtr iface);
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2010-02-10 12:28:05 +00:00
|
|
|
virInterfaceDefPtr virInterfaceDefParseString(const char *xmlStr);
|
|
|
|
virInterfaceDefPtr virInterfaceDefParseFile(const char *filename);
|
|
|
|
virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr xml,
|
2009-07-15 17:34:04 +00:00
|
|
|
xmlNodePtr root);
|
|
|
|
|
2010-02-10 12:28:05 +00:00
|
|
|
char *virInterfaceDefFormat(const virInterfaceDefPtr def);
|
2009-07-15 17:34:04 +00:00
|
|
|
|
|
|
|
void virInterfaceObjLock(virInterfaceObjPtr obj);
|
|
|
|
void virInterfaceObjUnlock(virInterfaceObjPtr obj);
|
|
|
|
|
|
|
|
#endif /* __INTERFACE_CONF_H__ */
|