2013-03-04 16:30:40 +00:00
|
|
|
/*
|
|
|
|
* virfirewall.h: integration with firewalls
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* 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, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:51 +00:00
|
|
|
#pragma once
|
2013-03-04 16:30:40 +00:00
|
|
|
|
2019-06-18 16:12:51 +00:00
|
|
|
#include "internal.h"
|
|
|
|
#include "virautoclean.h"
|
2013-03-04 16:30:40 +00:00
|
|
|
|
|
|
|
typedef struct _virFirewall virFirewall;
|
|
|
|
typedef virFirewall *virFirewallPtr;
|
|
|
|
|
|
|
|
typedef struct _virFirewallRule virFirewallRule;
|
|
|
|
typedef virFirewallRule *virFirewallRulePtr;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
VIR_FIREWALL_LAYER_ETHERNET,
|
|
|
|
VIR_FIREWALL_LAYER_IPV4,
|
|
|
|
VIR_FIREWALL_LAYER_IPV6,
|
|
|
|
|
|
|
|
VIR_FIREWALL_LAYER_LAST,
|
|
|
|
} virFirewallLayer;
|
|
|
|
|
|
|
|
virFirewallPtr virFirewallNew(void);
|
|
|
|
|
|
|
|
void virFirewallFree(virFirewallPtr firewall);
|
|
|
|
|
2017-01-02 18:15:30 +00:00
|
|
|
/**
|
|
|
|
* virFirewallAddRule:
|
|
|
|
* @firewall: firewall ruleset to add to
|
|
|
|
* @layer: the firewall layer to change
|
|
|
|
* @...: NULL terminated list of strings for the rule
|
|
|
|
*
|
|
|
|
* Add any type of rule to the firewall ruleset.
|
|
|
|
*
|
|
|
|
* Returns the new rule
|
|
|
|
*/
|
2019-06-18 16:12:51 +00:00
|
|
|
#define virFirewallAddRule(firewall, layer, ...) \
|
2017-01-04 11:47:01 +00:00
|
|
|
virFirewallAddRuleFull(firewall, layer, false, NULL, NULL, __VA_ARGS__)
|
2013-03-04 16:30:40 +00:00
|
|
|
|
|
|
|
typedef int (*virFirewallQueryCallback)(virFirewallPtr firewall,
|
2018-12-04 16:33:28 +00:00
|
|
|
virFirewallLayer layer,
|
2013-03-04 16:30:40 +00:00
|
|
|
const char *const *lines,
|
|
|
|
void *opaque);
|
|
|
|
|
|
|
|
virFirewallRulePtr virFirewallAddRuleFull(virFirewallPtr firewall,
|
|
|
|
virFirewallLayer layer,
|
|
|
|
bool ignoreErrors,
|
|
|
|
virFirewallQueryCallback cb,
|
|
|
|
void *opaque,
|
|
|
|
...)
|
2019-10-14 12:13:31 +00:00
|
|
|
G_GNUC_NULL_TERMINATED;
|
2013-03-04 16:30:40 +00:00
|
|
|
|
|
|
|
void virFirewallRemoveRule(virFirewallPtr firewall,
|
|
|
|
virFirewallRulePtr rule);
|
|
|
|
|
|
|
|
void virFirewallRuleAddArg(virFirewallPtr firewall,
|
|
|
|
virFirewallRulePtr rule,
|
|
|
|
const char *arg)
|
|
|
|
ATTRIBUTE_NONNULL(3);
|
|
|
|
|
|
|
|
void virFirewallRuleAddArgFormat(virFirewallPtr firewall,
|
|
|
|
virFirewallRulePtr rule,
|
|
|
|
const char *fmt, ...)
|
2019-10-15 11:35:07 +00:00
|
|
|
ATTRIBUTE_NONNULL(3) G_GNUC_PRINTF(3, 4);
|
2013-03-04 16:30:40 +00:00
|
|
|
|
|
|
|
void virFirewallRuleAddArgSet(virFirewallPtr firewall,
|
|
|
|
virFirewallRulePtr rule,
|
|
|
|
const char *const *args)
|
|
|
|
ATTRIBUTE_NONNULL(3);
|
|
|
|
|
|
|
|
void virFirewallRuleAddArgList(virFirewallPtr firewall,
|
|
|
|
virFirewallRulePtr rule,
|
|
|
|
...)
|
2019-10-14 12:13:31 +00:00
|
|
|
G_GNUC_NULL_TERMINATED;
|
2013-03-04 16:30:40 +00:00
|
|
|
|
|
|
|
size_t virFirewallRuleGetArgCount(virFirewallRulePtr rule);
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
/* Ignore all errors when applying rules, so no
|
|
|
|
* rollback block will be required */
|
|
|
|
VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS = (1 << 0),
|
|
|
|
} virFirewallTransactionFlags;
|
|
|
|
|
|
|
|
void virFirewallStartTransaction(virFirewallPtr firewall,
|
|
|
|
unsigned int flags);
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
/* Execute previous rollback block before this
|
|
|
|
* one, to chain cleanup */
|
|
|
|
VIR_FIREWALL_ROLLBACK_INHERIT_PREVIOUS = (1 << 0),
|
|
|
|
} virFirewallRollbackFlags;
|
|
|
|
|
|
|
|
void virFirewallStartRollback(virFirewallPtr firewall,
|
|
|
|
unsigned int flags);
|
|
|
|
|
|
|
|
int virFirewallApply(virFirewallPtr firewall);
|
|
|
|
|
2014-12-22 21:57:21 +00:00
|
|
|
void virFirewallSetLockOverride(bool avoid);
|
|
|
|
|
2019-02-07 17:18:52 +00:00
|
|
|
VIR_DEFINE_AUTOPTR_FUNC(virFirewall, virFirewallFree);
|