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
/*
 * 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

28 29
# include "conf/nwfilter_params.h"

30 31 32 33 34 35 36 37
enum howDetect {
  DETECT_DHCP = 1,
  DETECT_STATIC = 2,
};

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

    int status;
    pthread_t thread;
51
    volatile bool terminate;
52 53
};

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

S
Stefan Berger 已提交
65
virNWFilterIPAddrLearnReqPtr virNWFilterLookupLearnReq(int ifindex);
66
int virNWFilterTerminateLearnReq(const char *ifname);
67

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

71 72
int virNWFilterLearnInit(void);
void virNWFilterLearnShutdown(void);
73
void virNWFilterLearnThreadsTerminate(bool allowNewThreads);
74 75

#endif /* __NWFILTER_LEARNIPADDR_H */