nwfilter_learnipaddr.h 2.6 KB
Newer Older
1 2 3 4
/*
 * nwfilter_learnipaddr.h: support for learning IP address used by a VM
 *                         on an interface
 *
5
 * Copyright (C) 2012 Red Hat, Inc.
6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * 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
20
 * License along with this library.  If not, see
O
Osier Yang 已提交
21
 * <http://www.gnu.org/licenses/>.
22 23 24 25 26 27 28
 *
 * Author: Stefan Berger <stefanb@us.ibm.com>
 */

#ifndef __NWFILTER_LEARNIPADDR_H
# define __NWFILTER_LEARNIPADDR_H

29
# include "conf/nwfilter_params.h"
30
# include <net/if.h>
31

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

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

    int status;
    pthread_t thread;
53
    volatile bool terminate;
54 55
};

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

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

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

73 74
int virNWFilterLearnInit(void);
void virNWFilterLearnShutdown(void);
75
void virNWFilterLearnThreadsTerminate(bool allowNewThreads);
76 77

#endif /* __NWFILTER_LEARNIPADDR_H */