mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 21:40:08 +01:00
firewall: rename NMUtilsShareRules to NMFirewallConfig
It's still not a very good name, but it seems better then NMUtilsShareRules. Currently, NMFirewallConfig is mostly about masquerading for shared mode. But in practice, it's a piece of configuration for something to configure in the firewall (the NAT and filter rules).
This commit is contained in:
parent
b1625697cb
commit
aa859d85d9
5 changed files with 32 additions and 32 deletions
|
|
@ -11572,7 +11572,7 @@ start_sharing(NMDevice *self, NMIP4Config *config, GError **error)
|
|||
NMConnection * conn;
|
||||
NMSettingConnection * s_con;
|
||||
gboolean announce_android_metered;
|
||||
NMUtilsShareRules * share_rules;
|
||||
NMFirewallConfig * firewall_config;
|
||||
|
||||
g_return_val_if_fail(config, FALSE);
|
||||
|
||||
|
|
@ -11597,9 +11597,9 @@ start_sharing(NMDevice *self, NMIP4Config *config, GError **error)
|
|||
req = nm_device_get_act_request(self);
|
||||
g_return_val_if_fail(req, FALSE);
|
||||
|
||||
share_rules = nm_utils_share_rules_new(ip_iface, ip4_addr->address, ip4_addr->plen);
|
||||
firewall_config = nm_firewall_config_new(ip_iface, ip4_addr->address, ip4_addr->plen);
|
||||
|
||||
nm_act_request_set_shared(req, share_rules);
|
||||
nm_act_request_set_shared(req, firewall_config);
|
||||
|
||||
conn = nm_act_request_get_applied_connection(req);
|
||||
s_con = nm_connection_get_setting_connection(conn);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
#include "settings/nm-settings-connection.h"
|
||||
|
||||
typedef struct {
|
||||
CList call_ids_lst_head;
|
||||
NMUtilsShareRules *share_rules;
|
||||
CList call_ids_lst_head;
|
||||
NMFirewallConfig *firewall_config;
|
||||
} NMActRequestPrivate;
|
||||
|
||||
struct _NMActRequest {
|
||||
|
|
@ -250,31 +250,31 @@ nm_act_request_clear_secrets(NMActRequest *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMUtilsShareRules *
|
||||
NMFirewallConfig *
|
||||
nm_act_request_get_shared(NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_ACT_REQUEST(req), FALSE);
|
||||
|
||||
return NM_ACT_REQUEST_GET_PRIVATE(req)->share_rules;
|
||||
return NM_ACT_REQUEST_GET_PRIVATE(req)->firewall_config;
|
||||
}
|
||||
|
||||
void
|
||||
nm_act_request_set_shared(NMActRequest *req, NMUtilsShareRules *rules)
|
||||
nm_act_request_set_shared(NMActRequest *req, NMFirewallConfig *rules)
|
||||
{
|
||||
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE(req);
|
||||
|
||||
g_return_if_fail(NM_IS_ACT_REQUEST(req));
|
||||
|
||||
if (priv->share_rules == rules)
|
||||
if (priv->firewall_config == rules)
|
||||
return;
|
||||
|
||||
if (priv->share_rules) {
|
||||
nm_utils_share_rules_apply(priv->share_rules, FALSE);
|
||||
priv->share_rules = NULL;
|
||||
if (priv->firewall_config) {
|
||||
nm_firewall_config_apply(priv->firewall_config, FALSE);
|
||||
priv->firewall_config = NULL;
|
||||
}
|
||||
if (rules) {
|
||||
priv->share_rules = rules;
|
||||
nm_utils_share_rules_apply(priv->share_rules, TRUE);
|
||||
priv->firewall_config = rules;
|
||||
nm_firewall_config_apply(priv->firewall_config, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -508,9 +508,9 @@ dispose(GObject *object)
|
|||
c_list_for_each_entry_safe (call_id, call_id_safe, &priv->call_ids_lst_head, call_ids_lst)
|
||||
_do_cancel_secrets(self, call_id, TRUE);
|
||||
|
||||
if (priv->share_rules) {
|
||||
nm_utils_share_rules_apply(priv->share_rules, FALSE);
|
||||
nm_clear_pointer(&priv->share_rules, nm_utils_share_rules_free);
|
||||
if (priv->firewall_config) {
|
||||
nm_firewall_config_apply(priv->firewall_config, FALSE);
|
||||
nm_clear_pointer(&priv->firewall_config, nm_firewall_config_free);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(nm_act_request_parent_class)->dispose(object);
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ NMConnection *nm_act_request_get_applied_connection(NMActRequest *req);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _NMUtilsShareRules;
|
||||
struct _NMFirewallConfig;
|
||||
|
||||
struct _NMUtilsShareRules *nm_act_request_get_shared(NMActRequest *req);
|
||||
struct _NMFirewallConfig *nm_act_request_get_shared(NMActRequest *req);
|
||||
|
||||
void nm_act_request_set_shared(NMActRequest *req, struct _NMUtilsShareRules *rules);
|
||||
void nm_act_request_set_shared(NMActRequest *req, struct _NMFirewallConfig *rules);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -327,23 +327,23 @@ _share_iptables_set_shared(gboolean add, const char *ip_iface, in_addr_t addr, g
|
|||
_share_iptables_set_shared_chains_delete(chain_input, chain_forward);
|
||||
}
|
||||
|
||||
struct _NMUtilsShareRules {
|
||||
struct _NMFirewallConfig {
|
||||
char * ip_iface;
|
||||
in_addr_t addr;
|
||||
guint8 plen;
|
||||
};
|
||||
|
||||
NMUtilsShareRules *
|
||||
nm_utils_share_rules_new(const char *ip_iface, in_addr_t addr, guint8 plen)
|
||||
NMFirewallConfig *
|
||||
nm_firewall_config_new(const char *ip_iface, in_addr_t addr, guint8 plen)
|
||||
{
|
||||
NMUtilsShareRules *self;
|
||||
NMFirewallConfig *self;
|
||||
|
||||
nm_assert(ip_iface);
|
||||
nm_assert(addr != 0u);
|
||||
nm_assert(plen <= 32);
|
||||
|
||||
self = g_slice_new(NMUtilsShareRules);
|
||||
*self = (NMUtilsShareRules){
|
||||
self = g_slice_new(NMFirewallConfig);
|
||||
*self = (NMFirewallConfig){
|
||||
.ip_iface = g_strdup(ip_iface),
|
||||
.addr = addr,
|
||||
.plen = plen,
|
||||
|
|
@ -352,7 +352,7 @@ nm_utils_share_rules_new(const char *ip_iface, in_addr_t addr, guint8 plen)
|
|||
}
|
||||
|
||||
void
|
||||
nm_utils_share_rules_free(NMUtilsShareRules *self)
|
||||
nm_firewall_config_free(NMFirewallConfig *self)
|
||||
{
|
||||
if (!self)
|
||||
return;
|
||||
|
|
@ -362,7 +362,7 @@ nm_utils_share_rules_free(NMUtilsShareRules *self)
|
|||
}
|
||||
|
||||
void
|
||||
nm_utils_share_rules_apply(NMUtilsShareRules *self, gboolean shared)
|
||||
nm_firewall_config_apply(NMFirewallConfig *self, gboolean shared)
|
||||
{
|
||||
_share_iptables_set_masquerade(shared, self->ip_iface, self->addr, self->plen);
|
||||
_share_iptables_set_shared(shared, self->ip_iface, self->addr, self->plen);
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
#ifndef __NM_FIREWALL_UTILS_H__
|
||||
#define __NM_FIREWALL_UTILS_H__
|
||||
|
||||
typedef struct _NMUtilsShareRules NMUtilsShareRules;
|
||||
typedef struct _NMFirewallConfig NMFirewallConfig;
|
||||
|
||||
NMUtilsShareRules *nm_utils_share_rules_new(const char *ip_iface, in_addr_t addr, guint8 plen);
|
||||
NMFirewallConfig *nm_firewall_config_new(const char *ip_iface, in_addr_t addr, guint8 plen);
|
||||
|
||||
void nm_utils_share_rules_free(NMUtilsShareRules *self);
|
||||
void nm_firewall_config_free(NMFirewallConfig *self);
|
||||
|
||||
void nm_utils_share_rules_apply(NMUtilsShareRules *self, gboolean shared);
|
||||
void nm_firewall_config_apply(NMFirewallConfig *self, gboolean shared);
|
||||
|
||||
#endif /* __NM_FIREWALL_UTILS_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue