1 /*
2  * nwfilter_tech_driver.h: network filter technology driver interface
3  *
4  * Copyright (C) 2006-2014 Red Hat, Inc.
5  * Copyright (C) 2006-2008 Daniel P. Berrange
6  *
7  * Copyright (C) 2010 IBM Corporation
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library.  If not, see
21  * <http://www.gnu.org/licenses/>.
22  */
23 
24 #pragma once
25 
26 #include "virnwfilterobj.h"
27 
28 typedef struct _virNWFilterTechDriver virNWFilterTechDriver;
29 
30 
31 typedef struct _virNWFilterRuleInst virNWFilterRuleInst;
32 struct _virNWFilterRuleInst {
33     const char *chainSuffix;
34     virNWFilterChainPriority chainPriority;
35     virNWFilterRuleDef *def;
36     virNWFilterRulePriority priority;
37     GHashTable *vars;
38 };
39 
40 
41 typedef int (*virNWFilterTechDrvInit)(bool privileged);
42 typedef void (*virNWFilterTechDrvShutdown)(void);
43 
44 typedef int (*virNWFilterRuleApplyNewRules)(const char *ifname,
45                                             virNWFilterRuleInst **rules,
46                                             size_t nrules);
47 
48 typedef int (*virNWFilterRuleTeardownNewRules)(const char *ifname);
49 
50 typedef int (*virNWFilterRuleTeardownOldRules)(const char *ifname);
51 
52 typedef int (*virNWFilterRuleAllTeardown)(const char *ifname);
53 
54 typedef int (*virNWFilterCanApplyBasicRules)(void);
55 
56 typedef int (*virNWFilterApplyBasicRules)(const char *ifname,
57                                           const virMacAddr *macaddr);
58 
59 typedef int (*virNWFilterApplyDHCPOnlyRules)(const char *ifname,
60                                              const virMacAddr *macaddr,
61                                              virNWFilterVarValue *dhcpsrvs,
62                                              bool leaveTemporary);
63 
64 typedef int (*virNWFilterRemoveBasicRules)(const char *ifname);
65 
66 typedef int (*virNWFilterDropAllRules)(const char *ifname);
67 
68 enum techDrvFlags {
69     TECHDRV_FLAG_INITIALIZED = (1 << 0),
70 };
71 
72 struct _virNWFilterTechDriver {
73     const char *name;
74     enum techDrvFlags flags;
75 
76     virNWFilterTechDrvInit init;
77     virNWFilterTechDrvShutdown shutdown;
78 
79     virNWFilterRuleApplyNewRules applyNewRules;
80     virNWFilterRuleTeardownNewRules tearNewRules;
81     virNWFilterRuleTeardownOldRules tearOldRules;
82     virNWFilterRuleAllTeardown allTeardown;
83 
84     virNWFilterCanApplyBasicRules canApplyBasicRules;
85     virNWFilterApplyBasicRules applyBasicRules;
86     virNWFilterApplyDHCPOnlyRules applyDHCPOnlyRules;
87     virNWFilterDropAllRules applyDropAllRules;
88     virNWFilterRemoveBasicRules removeBasicRules;
89 };
90