nwfilter_learnipaddr.h 2.5 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-2013 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 "nwfilter_tech_driver.h"
31
# include <net/if.h>
32

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

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

    int status;
52
    volatile bool terminate;
53 54
};

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

65
bool virNWFilterHasLearnReq(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 */