nwfilter_learnipaddr.h 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/*
 * nwfilter_learnipaddr.h: support for learning IP address used by a VM
 *                         on an interface
 *
 * Copyright (C) 2010 IBM Corp.
 * Copyright (C) 2010 Stefan Berger
 *
 * 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: Stefan Berger <stefanb@us.ibm.com>
 */

#ifndef __NWFILTER_LEARNIPADDR_H
# define __NWFILTER_LEARNIPADDR_H

enum howDetect {
  DETECT_DHCP = 1,
  DETECT_STATIC = 2,
};

typedef struct _virNWFilterIPAddrLearnReq virNWFilterIPAddrLearnReq;
typedef virNWFilterIPAddrLearnReq *virNWFilterIPAddrLearnReqPtr;
struct _virNWFilterIPAddrLearnReq {
36
    virNWFilterTechDriverPtr techdriver;
37
    char ifname[IF_NAMESIZE];
S
Stefan Berger 已提交
38
    int ifindex;
39 40 41 42 43 44 45 46 47 48 49 50
    char linkdev[IF_NAMESIZE];
    enum virDomainNetType nettype;
    unsigned char macaddr[VIR_MAC_BUFLEN];
    char *filtername;
    virNWFilterHashTablePtr filterparams;
    virNWFilterDriverStatePtr driver;
    enum howDetect howDetect;

    int status;
    pthread_t thread;
};

51 52
int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
                              const char *ifname,
S
Stefan Berger 已提交
53
                              int ifindex,
54 55 56 57 58 59 60 61
                              const char *linkdev,
                              enum virDomainNetType nettype,
                              const unsigned char *macaddr,
                              const char *filtername,
                              virNWFilterHashTablePtr filterparams,
                              virNWFilterDriverStatePtr driver,
                              enum howDetect howDetect);

S
Stefan Berger 已提交
62
virNWFilterIPAddrLearnReqPtr virNWFilterLookupLearnReq(int ifindex);
63 64 65 66 67


void virNWFilterDelIpAddrForIfname(const char *ifname);
const char *virNWFilterGetIpAddrForIfname(const char *ifname);

S
Stefan Berger 已提交
68 69 70
int virNWFilterLockIface(const char *ifname) ATTRIBUTE_RETURN_CHECK;
void virNWFilterUnlockIface(const char *ifname);

71 72 73 74
int virNWFilterLearnInit(void);
void virNWFilterLearnShutdown(void);

#endif /* __NWFILTER_LEARNIPADDR_H */