network: rename NetworkConfigSection -> ConfigSection
And move it and relevant functions to conf-parser.[ch].
This commit is contained in:
@@ -46,15 +46,15 @@ static L2tpSession* l2tp_session_free(L2tpSession *s) {
|
||||
if (s->tunnel && s->section)
|
||||
ordered_hashmap_remove(s->tunnel->sessions_by_section, s->section);
|
||||
|
||||
network_config_section_free(s->section);
|
||||
config_section_free(s->section);
|
||||
free(s->name);
|
||||
return mfree(s);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(L2tpSession, l2tp_session_free);
|
||||
DEFINE_SECTION_CLEANUP_FUNCTIONS(L2tpSession, l2tp_session_free);
|
||||
|
||||
static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned section_line, L2tpSession **ret) {
|
||||
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
|
||||
_cleanup_(config_section_freep) ConfigSection *n = NULL;
|
||||
_cleanup_(l2tp_session_freep) L2tpSession *s = NULL;
|
||||
int r;
|
||||
|
||||
@@ -63,7 +63,7 @@ static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned
|
||||
assert(filename);
|
||||
assert(section_line > 0);
|
||||
|
||||
r = network_config_section_new(filename, section_line, &n);
|
||||
r = config_section_new(filename, section_line, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -83,7 +83,7 @@ static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned
|
||||
.section = TAKE_PTR(n),
|
||||
};
|
||||
|
||||
r = ordered_hashmap_ensure_put(&t->sessions_by_section, &network_config_hash_ops, s->section, s);
|
||||
r = ordered_hashmap_ensure_put(&t->sessions_by_section, &config_section_hash_ops, s->section, s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef struct L2tpTunnel L2tpTunnel;
|
||||
|
||||
typedef struct L2tpSession {
|
||||
L2tpTunnel *tunnel;
|
||||
NetworkConfigSection *section;
|
||||
ConfigSection *section;
|
||||
|
||||
char *name;
|
||||
|
||||
|
||||
+15
-15
@@ -43,16 +43,16 @@ static ReceiveAssociation* macsec_receive_association_free(ReceiveAssociation *c
|
||||
if (c->macsec && c->section)
|
||||
ordered_hashmap_remove(c->macsec->receive_associations_by_section, c->section);
|
||||
|
||||
network_config_section_free(c->section);
|
||||
config_section_free(c->section);
|
||||
security_association_clear(&c->sa);
|
||||
|
||||
return mfree(c);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
|
||||
DEFINE_SECTION_CLEANUP_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
|
||||
|
||||
static int macsec_receive_association_new_static(MACsec *s, const char *filename, unsigned section_line, ReceiveAssociation **ret) {
|
||||
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
|
||||
_cleanup_(config_section_freep) ConfigSection *n = NULL;
|
||||
_cleanup_(macsec_receive_association_freep) ReceiveAssociation *c = NULL;
|
||||
int r;
|
||||
|
||||
@@ -61,7 +61,7 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
|
||||
assert(filename);
|
||||
assert(section_line > 0);
|
||||
|
||||
r = network_config_section_new(filename, section_line, &n);
|
||||
r = config_section_new(filename, section_line, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -82,7 +82,7 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
|
||||
|
||||
security_association_init(&c->sa);
|
||||
|
||||
r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &network_config_hash_ops, c->section, c);
|
||||
r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &config_section_hash_ops, c->section, c);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -103,12 +103,12 @@ static ReceiveChannel* macsec_receive_channel_free(ReceiveChannel *c) {
|
||||
ordered_hashmap_remove(c->macsec->receive_channels_by_section, c->section);
|
||||
}
|
||||
|
||||
network_config_section_free(c->section);
|
||||
config_section_free(c->section);
|
||||
|
||||
return mfree(c);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
|
||||
DEFINE_SECTION_CLEANUP_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
|
||||
|
||||
static int macsec_receive_channel_new(MACsec *s, uint64_t sci, ReceiveChannel **ret) {
|
||||
ReceiveChannel *c;
|
||||
@@ -129,7 +129,7 @@ static int macsec_receive_channel_new(MACsec *s, uint64_t sci, ReceiveChannel **
|
||||
}
|
||||
|
||||
static int macsec_receive_channel_new_static(MACsec *s, const char *filename, unsigned section_line, ReceiveChannel **ret) {
|
||||
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
|
||||
_cleanup_(config_section_freep) ConfigSection *n = NULL;
|
||||
_cleanup_(macsec_receive_channel_freep) ReceiveChannel *c = NULL;
|
||||
int r;
|
||||
|
||||
@@ -138,7 +138,7 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
|
||||
assert(filename);
|
||||
assert(section_line > 0);
|
||||
|
||||
r = network_config_section_new(filename, section_line, &n);
|
||||
r = config_section_new(filename, section_line, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -154,7 +154,7 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
|
||||
|
||||
c->section = TAKE_PTR(n);
|
||||
|
||||
r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &network_config_hash_ops, c->section, c);
|
||||
r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &config_section_hash_ops, c->section, c);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -170,16 +170,16 @@ static TransmitAssociation* macsec_transmit_association_free(TransmitAssociation
|
||||
if (a->macsec && a->section)
|
||||
ordered_hashmap_remove(a->macsec->transmit_associations_by_section, a->section);
|
||||
|
||||
network_config_section_free(a->section);
|
||||
config_section_free(a->section);
|
||||
security_association_clear(&a->sa);
|
||||
|
||||
return mfree(a);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
|
||||
DEFINE_SECTION_CLEANUP_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
|
||||
|
||||
static int macsec_transmit_association_new_static(MACsec *s, const char *filename, unsigned section_line, TransmitAssociation **ret) {
|
||||
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
|
||||
_cleanup_(config_section_freep) ConfigSection *n = NULL;
|
||||
_cleanup_(macsec_transmit_association_freep) TransmitAssociation *a = NULL;
|
||||
int r;
|
||||
|
||||
@@ -188,7 +188,7 @@ static int macsec_transmit_association_new_static(MACsec *s, const char *filenam
|
||||
assert(filename);
|
||||
assert(section_line > 0);
|
||||
|
||||
r = network_config_section_new(filename, section_line, &n);
|
||||
r = config_section_new(filename, section_line, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -209,7 +209,7 @@ static int macsec_transmit_association_new_static(MACsec *s, const char *filenam
|
||||
|
||||
security_association_init(&a->sa);
|
||||
|
||||
r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &network_config_hash_ops, a->section, a);
|
||||
r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &config_section_hash_ops, a->section, a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -39,14 +39,14 @@ typedef struct SecurityAssociation {
|
||||
|
||||
typedef struct TransmitAssociation {
|
||||
MACsec *macsec;
|
||||
NetworkConfigSection *section;
|
||||
ConfigSection *section;
|
||||
|
||||
SecurityAssociation sa;
|
||||
} TransmitAssociation;
|
||||
|
||||
typedef struct ReceiveAssociation {
|
||||
MACsec *macsec;
|
||||
NetworkConfigSection *section;
|
||||
ConfigSection *section;
|
||||
|
||||
MACsecSCI sci;
|
||||
SecurityAssociation sa;
|
||||
@@ -54,7 +54,7 @@ typedef struct ReceiveAssociation {
|
||||
|
||||
typedef struct ReceiveChannel {
|
||||
MACsec *macsec;
|
||||
NetworkConfigSection *section;
|
||||
ConfigSection *section;
|
||||
|
||||
MACsecSCI sci;
|
||||
ReceiveAssociation *rxsa[MACSEC_MAX_ASSOCIATION_NUMBER];
|
||||
|
||||
@@ -47,7 +47,7 @@ static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
|
||||
hashmap_remove(peer->wireguard->peers_by_section, peer->section);
|
||||
}
|
||||
|
||||
network_config_section_free(peer->section);
|
||||
config_section_free(peer->section);
|
||||
|
||||
while ((mask = peer->ipmasks)) {
|
||||
LIST_REMOVE(ipmasks, peer->ipmasks, mask);
|
||||
@@ -65,10 +65,10 @@ static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
|
||||
return mfree(peer);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(WireguardPeer, wireguard_peer_free);
|
||||
DEFINE_SECTION_CLEANUP_FUNCTIONS(WireguardPeer, wireguard_peer_free);
|
||||
|
||||
static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigned section_line, WireguardPeer **ret) {
|
||||
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
|
||||
_cleanup_(config_section_freep) ConfigSection *n = NULL;
|
||||
_cleanup_(wireguard_peer_freep) WireguardPeer *peer = NULL;
|
||||
int r;
|
||||
|
||||
@@ -77,7 +77,7 @@ static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigne
|
||||
assert(filename);
|
||||
assert(section_line > 0);
|
||||
|
||||
r = network_config_section_new(filename, section_line, &n);
|
||||
r = config_section_new(filename, section_line, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -99,7 +99,7 @@ static int wireguard_peer_new_static(Wireguard *w, const char *filename, unsigne
|
||||
|
||||
LIST_PREPEND(peers, w->peers, peer);
|
||||
|
||||
r = hashmap_ensure_put(&w->peers_by_section, &network_config_hash_ops, peer->section, peer);
|
||||
r = hashmap_ensure_put(&w->peers_by_section, &config_section_hash_ops, peer->section, peer);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ typedef struct WireguardIPmask {
|
||||
|
||||
typedef struct WireguardPeer {
|
||||
Wireguard *wireguard;
|
||||
NetworkConfigSection *section;
|
||||
ConfigSection *section;
|
||||
|
||||
uint8_t public_key[WG_KEY_LEN];
|
||||
uint8_t preshared_key[WG_KEY_LEN];
|
||||
|
||||
Reference in New Issue
Block a user