mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
util: add virFirewallDPolicyExists()
Signed-off-by: Eric Garver <eric@garver.life> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
ab56f84976
commit
d0e4d2fde7
@ -2365,6 +2365,7 @@ virFirewallDGetVersion;
|
||||
virFirewallDGetZones;
|
||||
virFirewallDInterfaceSetZone;
|
||||
virFirewallDIsRegistered;
|
||||
virFirewallDPolicyExists;
|
||||
virFirewallDSynchronize;
|
||||
virFirewallDZoneExists;
|
||||
|
||||
|
@ -296,6 +296,37 @@ virFirewallDZoneExists(const char *match)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virFirewallDPolicyExists:
|
||||
* @match: name of policy to look for
|
||||
*
|
||||
* Returns true if the requested policy exists, or false if it doesn't exist
|
||||
*/
|
||||
bool
|
||||
virFirewallDPolicyExists(const char *match)
|
||||
{
|
||||
size_t npolicies = 0, i;
|
||||
char **policies = NULL;
|
||||
bool result = false;
|
||||
|
||||
if (virFirewallDGetPolicies(&policies, &npolicies) < 0)
|
||||
goto cleanup;
|
||||
|
||||
for (i = 0; i < npolicies; i++) {
|
||||
if (STREQ_NULLABLE(policies[i], match))
|
||||
result = true;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
VIR_DEBUG("Requested policy '%s' %s exist",
|
||||
match, result ? "does" : "doesn't");
|
||||
for (i = 0; i < npolicies; i++)
|
||||
VIR_FREE(policies[i]);
|
||||
VIR_FREE(policies);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virFirewallDApplyRule:
|
||||
* @layer: which layer to apply the rule to
|
||||
|
@ -35,6 +35,7 @@ int virFirewallDIsRegistered(void);
|
||||
int virFirewallDGetZones(char ***zones, size_t *nzones);
|
||||
int virFirewallDGetPolicies(char ***policies, size_t *npolicies);
|
||||
bool virFirewallDZoneExists(const char *match);
|
||||
bool virFirewallDPolicyExists(const char *match);
|
||||
int virFirewallDApplyRule(virFirewallLayer layer,
|
||||
char **args, size_t argsLen,
|
||||
bool ignoreErrors,
|
||||
|
Loading…
x
Reference in New Issue
Block a user