interface.h 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * interface.h: interface helper APIs for libvirt
 *
 * Copyright (C) 2010 IBM Corporation, Inc.
 *
 * See COPYING.LIB for the License of this software
 *
 * Stefan Berger <stefanb@us.ibm.com>
 */
#ifndef __VIR_INTERFACE_H__
# define __VIR_INTERFACE_H__

13 14 15 16 17 18 19 20 21 22 23 24 25
# include <stdint.h>

# if __linux__

#  include <sys/socket.h>
#  include <linux/netlink.h>

# else

struct nlattr;

# endif

26 27
# include "datatypes.h"

28 29 30
int ifaceGetFlags(const char *name, short *flags);
int ifaceIsUp(const char *name, bool *up);

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
int ifaceCtrl(const char *name, bool up);

static inline int ifaceUp(const char *name) {
    return ifaceCtrl(name, true);
}

static inline int ifaceDown(const char *name) {
    return ifaceCtrl(name, false);
}

int ifaceCheck(bool reportError, const char *ifname,
               const unsigned char *macaddr, int ifindex);

int ifaceGetIndex(bool reportError, const char *ifname, int *ifindex);

46 47
int ifaceGetVlanID(const char *vlanifname, int *vlanid);

48 49 50 51
int ifaceSetMacaddr(const char *ifname, const unsigned char *macaddr);

int ifaceGetMacaddr(const char *ifname, unsigned char *macaddr);

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
int ifaceMacvtapLinkAdd(const char *type,
                        const unsigned char *macaddress, int macaddrsize,
                        const char *ifname,
                        const char *srcdev,
                        uint32_t macvlan_mode,
                        int *retry);

int ifaceLinkDel(const char *ifname);

int ifaceMacvtapLinkDump(bool nltarget_kernel, const char *ifname, int ifindex,
                         struct nlattr **tb, unsigned char **recvbuf,
                         uint32_t (*getPidFunc)(void));

int ifaceGetNthParent(int ifindex, const char *ifname, unsigned int nthParent,
                      int *parent_ifindex, char *parent_ifname,
                      unsigned int *nth);

int ifaceReplaceMacAddress(const unsigned char *macaddress,
                           const char *linkdev,
                           const char *stateDir);

int ifaceRestoreMacAddress(const char *linkdev,
                           const char *stateDir);

76
#endif /* __VIR_INTERFACE_H__ */