]> git.ipfire.org Git - people/ms/network.git/commitdiff
networkd: Use typedef to keep type names shorter
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Feb 2023 17:44:42 +0000 (17:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Feb 2023 17:44:42 +0000 (17:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
25 files changed:
src/networkd/bus.c
src/networkd/bus.h
src/networkd/config.c
src/networkd/config.h
src/networkd/daemon-bus.c
src/networkd/daemon-bus.h
src/networkd/daemon.c
src/networkd/daemon.h
src/networkd/link.c
src/networkd/link.h
src/networkd/links.c
src/networkd/links.h
src/networkd/main.c
src/networkd/port-bus.c
src/networkd/port-bus.h
src/networkd/port.c
src/networkd/port.h
src/networkd/ports.c
src/networkd/ports.h
src/networkd/zone-bus.c
src/networkd/zone-bus.h
src/networkd/zone.c
src/networkd/zone.h
src/networkd/zones.c
src/networkd/zones.h

index 258aacdaedfb39a76daf5100f82645f5113b002c..1daa0352604c7af5aecb8bee32ed2f70dd77cf44 100644 (file)
 #include "logging.h"
 
 static int nw_bus_on_connect(sd_bus_message* m, void* data, sd_bus_error* error) {
-       struct nw_daemon* daemon = (struct nw_daemon*)data;
+       nw_daemon* daemon = (nw_daemon*)data;
 
        DEBUG("Connected to D-Bus\n");
 
        return 0;
 }
 
-int nw_bus_connect(sd_bus* bus, sd_event* loop, struct nw_daemon* daemon) {
+int nw_bus_connect(sd_bus* bus, sd_event* loop, nw_daemon* daemon) {
        int r;
 
        // Create a bus object
index 42ab2d312ffad2f79b1b996f6b4b9afe60b886fc..05b4c637c0d04dcde2790c46b59a93e13e98c3fd 100644 (file)
 
 #include "daemon.h"
 
-int nw_bus_connect(sd_bus* bus, sd_event* loop, struct nw_daemon* daemon);
+int nw_bus_connect(sd_bus* bus, sd_event* loop, nw_daemon* daemon);
 
 struct nw_bus_vtable_pair {
        const sd_bus_vtable* vtable;
        sd_bus_object_find_t object_find;
 };
 
-struct nw_bus_implementation {
+typedef struct nw_bus_implementation {
        const char* path;
        const char* interface;
        const sd_bus_vtable** vtables;
        const struct nw_bus_vtable_pair* fallback_vtables;
        sd_bus_node_enumerator_t node_enumerator;
        const struct nw_bus_implementation** children;
-};
+} nw_bus_implementation;
 
 #define BUS_FALLBACK_VTABLES(...) ((const struct nw_bus_vtable_pair[]) { __VA_ARGS__, {} })
-#define BUS_IMPLEMENTATIONS(...) ((const struct nw_bus_implementation* []) { __VA_ARGS__, NULL })
+#define BUS_IMPLEMENTATIONS(...) ((const nw_bus_implementation* []) { __VA_ARGS__, NULL })
 #define BUS_VTABLES(...) ((const sd_bus_vtable* []){ __VA_ARGS__, NULL })
 
 int nw_bus_register_implementation(sd_bus* bus,
-       const struct nw_bus_implementation* impl, void* data);
+       const nw_bus_implementation* impl, void* data);
 
 #endif /* NETWORKD_BUS_H */
index 17d6d890f4396fe45c07a5bf5839d5f9118858e2..b3d52845eb491d56407fe54788dbd974d37f5f8d 100644 (file)
@@ -50,7 +50,7 @@ static void nw_config_entry_free(struct nw_config_entry* entry) {
 }
 
 static struct nw_config_entry* nw_config_entry_create(
-               struct nw_config* config, const char* key) {
+               nw_config* config, const char* key) {
        int r;
 
        // Check input value
@@ -79,17 +79,17 @@ ERROR:
        return NULL;
 }
 
-static void nw_config_free(struct nw_config* config) {
+static void nw_config_free(nw_config* config) {
        // Flush all entries
        nw_config_flush(config);
 
        free(config);
 }
 
-int nw_config_create(struct nw_config** config, const char* path) {
+int nw_config_create(nw_config** config, const char* path) {
        int r;
 
-       struct nw_config* c = calloc(1, sizeof(*c));
+       nw_config* c = calloc(1, sizeof(*c));
        if (!c)
                return 1;
 
@@ -121,13 +121,13 @@ ERROR:
        return r;
 }
 
-struct nw_config* nw_config_ref(struct nw_config* config) {
+nw_config* nw_config_ref(nw_config* config) {
        config->nrefs++;
 
        return config;
 }
 
-struct nw_config* nw_config_unref(struct nw_config* config) {
+nw_config* nw_config_unref(nw_config* config) {
        if (--config->nrefs > 0)
                return config;
 
@@ -135,14 +135,14 @@ struct nw_config* nw_config_unref(struct nw_config* config) {
        return NULL;
 }
 
-const char* nw_config_path(struct nw_config* config) {
+const char* nw_config_path(nw_config* config) {
        if (*config->path)
                return config->path;
 
        return NULL;
 }
 
-int nw_config_flush(struct nw_config* config) {
+int nw_config_flush(nw_config* config) {
        struct nw_config_entry* entry = NULL;
 
        while (!STAILQ_EMPTY(&config->entries)) {
@@ -156,7 +156,7 @@ int nw_config_flush(struct nw_config* config) {
        return 0;
 }
 
-static int nw_config_readf(struct nw_config* config, FILE* f) {
+static int nw_config_readf(nw_config* config, FILE* f) {
        char* line = NULL;
        size_t length = 0;
        int r;
@@ -202,7 +202,7 @@ static int nw_config_readf(struct nw_config* config, FILE* f) {
        return r;
 }
 
-int nw_config_read(struct nw_config* config) {
+int nw_config_read(nw_config* config) {
        FILE* f = NULL;
        int r;
 
@@ -234,7 +234,7 @@ ERROR:
        return r;
 }
 
-static int nw_config_writef(struct nw_config* config, FILE* f) {
+static int nw_config_writef(nw_config* config, FILE* f) {
        struct nw_config_entry* entry = NULL;
        int r;
 
@@ -254,7 +254,7 @@ static int nw_config_writef(struct nw_config* config, FILE* f) {
        return 0;
 }
 
-int nw_config_write(struct nw_config* config) {
+int nw_config_write(nw_config* config) {
        int r;
 
        // We cannot write if path is not set
@@ -280,7 +280,7 @@ ERROR:
        return r;
 }
 
-static struct nw_config_entry* nw_config_find(struct nw_config* config, const char* key) {
+static struct nw_config_entry* nw_config_find(nw_config* config, const char* key) {
        struct nw_config_entry* entry = NULL;
 
        STAILQ_FOREACH(entry, &config->entries, nodes) {
@@ -296,7 +296,7 @@ static struct nw_config_entry* nw_config_find(struct nw_config* config, const ch
        return NULL;
 }
 
-int nw_config_del(struct nw_config* config, const char* key) {
+int nw_config_del(nw_config* config, const char* key) {
        struct nw_config_entry* entry = NULL;
 
        // Find an entry matching the key
@@ -315,7 +315,7 @@ int nw_config_del(struct nw_config* config, const char* key) {
        return 0;
 }
 
-const char* nw_config_get(struct nw_config* config, const char* key) {
+const char* nw_config_get(nw_config* config, const char* key) {
        struct nw_config_entry* entry = nw_config_find(config, key);
 
        // Return the value if found and set
@@ -326,7 +326,7 @@ const char* nw_config_get(struct nw_config* config, const char* key) {
        return NULL;
 }
 
-int nw_config_set(struct nw_config* config, const char* key, const char* value) {
+int nw_config_set(nw_config* config, const char* key, const char* value) {
        struct nw_config_entry* entry = NULL;
 
        // Delete the entry if val is NULL
@@ -347,7 +347,7 @@ int nw_config_set(struct nw_config* config, const char* key, const char* value)
        return nw_string_set(entry->value, value);
 }
 
-int nw_config_get_int(struct nw_config* config, const char* key, const int __default) {
+int nw_config_get_int(nw_config* config, const char* key, const int __default) {
        const char* value = nw_config_get(config, key);
 
        // Return zero if not set
@@ -357,7 +357,7 @@ int nw_config_get_int(struct nw_config* config, const char* key, const int __def
        return strtoul(value, NULL, 10);
 }
 
-int nw_config_set_int(struct nw_config* config, const char* key, const int value) {
+int nw_config_set_int(nw_config* config, const char* key, const int value) {
        char __value[1024];
        int r;
 
index b8d85550a97c5ddf0c29182d22091be2c40f0020..041a10e8840c0fbe3577a13fb8ad22a722d49d93 100644 (file)
 #define NETWORK_CONFIG_KEY_MAX_LENGTH          128
 #define NETWORK_CONFIG_VALUE_MAX_LENGTH                2048
 
-struct nw_config;
+typedef struct nw_config nw_config;
 
-int nw_config_create(struct nw_config** config, const char* path);
+int nw_config_create(nw_config** config, const char* path);
 
-struct nw_config* nw_config_ref(struct nw_config* config);
-struct nw_config* nw_config_unref(struct nw_config* config);
+nw_config* nw_config_ref(nw_config* config);
+nw_config* nw_config_unref(nw_config* config);
 
-const char* nw_config_path(struct nw_config* config);
+const char* nw_config_path(nw_config* config);
 
-int nw_config_flush(struct nw_config* config);
+int nw_config_flush(nw_config* config);
 
-int nw_config_read(struct nw_config* config);
-int nw_config_write(struct nw_config* config);
+int nw_config_read(nw_config* config);
+int nw_config_write(nw_config* config);
 
-int nw_config_del(struct nw_config* config, const char* key);
+int nw_config_del(nw_config* config, const char* key);
 
-const char* nw_config_get(struct nw_config* config, const char* key);
-int nw_config_set(struct nw_config* config, const char* key, const char* value);
+const char* nw_config_get(nw_config* config, const char* key);
+int nw_config_set(nw_config* config, const char* key, const char* value);
 
-int nw_config_get_int(struct nw_config* config, const char* key, const int __default);
-int nw_config_set_int(struct nw_config* config, const char* key, const int value);
+int nw_config_get_int(nw_config* config, const char* key, const int __default);
+int nw_config_set_int(nw_config* config, const char* key, const int value);
 
 #endif /* NETWORKD_CONFIG_H */
index ca0754f58275eb230eee54b73f4cc67b35fee750..93a041105ce848e484a5e23754d9cac7f7a62cf6 100644 (file)
@@ -26,7 +26,7 @@
 #include "zone-bus.h"
 
 static int nw_daemon_bus_reload(sd_bus_message* m, void* data, sd_bus_error* error) {
-       struct nw_daemon* daemon = (struct nw_daemon*)data;
+       nw_daemon* daemon = (nw_daemon*)data;
 
        // Reload the daemon
        nw_daemon_reload(daemon);
@@ -42,7 +42,7 @@ static const sd_bus_vtable daemon_vtable[] = {
        SD_BUS_VTABLE_END,
 };
 
-const struct nw_bus_implementation daemon_bus_impl = {
+const nw_bus_implementation daemon_bus_impl = {
        .path = "/org/ipfire/network1",
        .interface = "org.ipfire.network1",
        .vtables = BUS_VTABLES(daemon_vtable),
index 787e92a1151c0e9fbd08cb9620f8c6e8e7a15ca3..c31496332951cfca4edc043c4148fee5c7c3345f 100644 (file)
@@ -23,6 +23,6 @@
 
 #include "bus.h"
 
-extern const struct nw_bus_implementation daemon_bus_impl;
+extern const nw_bus_implementation daemon_bus_impl;
 
 #endif /* NETWORKD_DAEMON_BUS_H */
index c4acff55f8ed5fe43c992d24ab0232434024b843..9b9bf738c20ec00fce21279a4fd0478f32dc868b 100644 (file)
@@ -44,7 +44,7 @@
 struct nw_daemon {
        int nrefs;
 
-       struct nw_config* config;
+       nw_config* config;
 
        // Event Loop
        sd_event* loop;
@@ -59,13 +59,13 @@ struct nw_daemon {
        sd_device_monitor* devmon;
 
        // Links
-       struct nw_links* links;
+       nw_links* links;
 
        // Zones
-       struct nw_zones* zones;
+       nw_zones* zones;
 
        // Ports
-       struct nw_ports* ports;
+       nw_ports* ports;
 
 };
 
@@ -78,7 +78,7 @@ static int __nw_daemon_terminate(sd_event_source* source, const struct signalfd_
 
 static int __nw_daemon_reload(sd_event_source* source, const struct signalfd_siginfo* si,
                void* data) {
-       struct nw_daemon* daemon = (struct nw_daemon*)daemon;
+       nw_daemon* daemon = (nw_daemon*)daemon;
 
        DEBUG("Received signal to reload...\n");
 
@@ -88,7 +88,7 @@ static int __nw_daemon_reload(sd_event_source* source, const struct signalfd_sig
        return 0;
 }
 
-static int nw_daemon_setup_loop(struct nw_daemon* daemon) {
+static int nw_daemon_setup_loop(nw_daemon* daemon) {
        int r;
 
        // Fetch a reference to the default event loop
@@ -132,7 +132,7 @@ static int nw_daemon_setup_loop(struct nw_daemon* daemon) {
        return 0;
 }
 
-static int nw_daemon_load_config(struct nw_daemon* daemon) {
+static int nw_daemon_load_config(nw_daemon* daemon) {
        int r;
 
        // Read configuration file
@@ -148,7 +148,7 @@ static int nw_daemon_load_config(struct nw_daemon* daemon) {
        return r;
 }
 
-static int nw_start_device_monitor(struct nw_daemon* daemon) {
+static int nw_start_device_monitor(nw_daemon* daemon) {
        int r;
 
        const char* subsystems[] = {
@@ -199,7 +199,7 @@ static int nw_start_device_monitor(struct nw_daemon* daemon) {
        return 0;
 }
 
-static int nw_daemon_connect_rtnl(struct nw_daemon* daemon, int fd) {
+static int nw_daemon_connect_rtnl(nw_daemon* daemon, int fd) {
        int r;
 
        // Connect to Netlink
@@ -242,7 +242,7 @@ static int nw_daemon_connect_rtnl(struct nw_daemon* daemon, int fd) {
        return 0;
 }
 
-static int nw_daemon_enumerate_links(struct nw_daemon* daemon) {
+static int nw_daemon_enumerate_links(nw_daemon* daemon) {
        int r;
 
        // Create a new links container
@@ -253,7 +253,7 @@ static int nw_daemon_enumerate_links(struct nw_daemon* daemon) {
        return nw_links_enumerate(daemon->links);
 }
 
-static int nw_daemon_enumerate_ports(struct nw_daemon* daemon) {
+static int nw_daemon_enumerate_ports(nw_daemon* daemon) {
        int r;
 
        // Create a new ports container
@@ -264,7 +264,7 @@ static int nw_daemon_enumerate_ports(struct nw_daemon* daemon) {
        return nw_ports_enumerate(daemon->ports);
 }
 
-static int nw_daemon_enumerate(struct nw_daemon* daemon) {
+static int nw_daemon_enumerate(nw_daemon* daemon) {
        int r;
 
        // Links
@@ -280,7 +280,7 @@ static int nw_daemon_enumerate(struct nw_daemon* daemon) {
        return 0;
 }
 
-static int nw_daemon_setup(struct nw_daemon* daemon) {
+static int nw_daemon_setup(nw_daemon* daemon) {
        int r;
 
        // Read the configuration
@@ -316,10 +316,10 @@ static int nw_daemon_setup(struct nw_daemon* daemon) {
        return 0;
 }
 
-int nw_daemon_create(struct nw_daemon** daemon) {
+int nw_daemon_create(nw_daemon** daemon) {
        int r;
 
-       struct nw_daemon* d = calloc(1, sizeof(*d));
+       nw_daemon* d = calloc(1, sizeof(*d));
        if (!d)
                return 1;
 
@@ -342,7 +342,7 @@ ERROR:
        return r;
 }
 
-static void nw_daemon_cleanup(struct nw_daemon* daemon) {
+static void nw_daemon_cleanup(nw_daemon* daemon) {
        if (daemon->ports)
                nw_ports_unref(daemon->ports);
        if (daemon->zones)
@@ -353,7 +353,7 @@ static void nw_daemon_cleanup(struct nw_daemon* daemon) {
                nw_config_unref(daemon->config);
 }
 
-static void nw_daemon_free(struct nw_daemon* daemon) {
+static void nw_daemon_free(nw_daemon* daemon) {
        // Cleanup common objects
        nw_daemon_cleanup(daemon);
 
@@ -365,13 +365,13 @@ static void nw_daemon_free(struct nw_daemon* daemon) {
        free(daemon);
 }
 
-struct nw_daemon* nw_daemon_ref(struct nw_daemon* daemon) {
+nw_daemon* nw_daemon_ref(nw_daemon* daemon) {
        daemon->nrefs++;
 
        return daemon;
 }
 
-struct nw_daemon* nw_daemon_unref(struct nw_daemon* daemon) {
+nw_daemon* nw_daemon_unref(nw_daemon* daemon) {
        if (--daemon->nrefs > 0)
                return daemon;
 
@@ -382,7 +382,7 @@ struct nw_daemon* nw_daemon_unref(struct nw_daemon* daemon) {
 /*
        This function contains the main loop of the daemon...
 */
-int nw_daemon_run(struct nw_daemon* daemon) {
+int nw_daemon_run(nw_daemon* daemon) {
        int r;
 
        // We are now ready to process any requests
@@ -412,7 +412,7 @@ ERROR:
        return 1;
 }
 
-int nw_daemon_reload(struct nw_daemon* daemon) {
+int nw_daemon_reload(nw_daemon* daemon) {
        DEBUG("Reloading daemon...\n");
 
        // XXX TODO
@@ -423,32 +423,32 @@ int nw_daemon_reload(struct nw_daemon* daemon) {
 /*
        Netlink
 */
-sd_netlink* nw_daemon_get_rtnl(struct nw_daemon* daemon) {
+sd_netlink* nw_daemon_get_rtnl(nw_daemon* daemon) {
        return daemon->rtnl;
 }
 
 /*
        Links
 */
-struct nw_links* nw_daemon_links(struct nw_daemon* daemon) {
+nw_links* nw_daemon_links(nw_daemon* daemon) {
        return nw_links_ref(daemon->links);
 }
 
-void nw_daemon_drop_link(struct nw_daemon* daemon, struct nw_link* link) {
+void nw_daemon_drop_link(nw_daemon* daemon, nw_link* link) {
        if (!daemon->links)
                return;
 
        nw_links_drop_link(daemon->links, link);
 }
 
-struct nw_link* nw_daemon_get_link_by_ifindex(struct nw_daemon* daemon, int ifindex) {
+nw_link* nw_daemon_get_link_by_ifindex(nw_daemon* daemon, int ifindex) {
        if (!daemon->links)
                return NULL;
 
        return nw_links_get_by_ifindex(daemon->links, ifindex);
 }
 
-struct nw_link* nw_daemon_get_link_by_name(struct nw_daemon* daemon, const char* name) {
+nw_link* nw_daemon_get_link_by_name(nw_daemon* daemon, const char* name) {
        if (!daemon->links)
                return NULL;
 
@@ -458,11 +458,11 @@ struct nw_link* nw_daemon_get_link_by_name(struct nw_daemon* daemon, const char*
 /*
        Ports
 */
-struct nw_ports* nw_daemon_ports(struct nw_daemon* daemon) {
+nw_ports* nw_daemon_ports(nw_daemon* daemon) {
        return nw_ports_ref(daemon->ports);
 }
 
-struct nw_port* nw_daemon_get_port_by_name(struct nw_daemon* daemon, const char* name) {
+nw_port* nw_daemon_get_port_by_name(nw_daemon* daemon, const char* name) {
        if (!daemon->ports)
                return NULL;
 
@@ -473,11 +473,11 @@ struct nw_port* nw_daemon_get_port_by_name(struct nw_daemon* daemon, const char*
        Zones
 */
 
-struct nw_zones* nw_daemon_zones(struct nw_daemon* daemon) {
+nw_zones* nw_daemon_zones(nw_daemon* daemon) {
        return nw_zones_ref(daemon->zones);
 }
 
-struct nw_zone* nw_daemon_get_zone_by_name(struct nw_daemon* daemon, const char* name) {
+nw_zone* nw_daemon_get_zone_by_name(nw_daemon* daemon, const char* name) {
        if (!daemon->zones)
                return NULL;
 
index a40dd60d97e602e6cc63f462ba682c6de113d49b..169459918ec2b56549e9506af1bf1cd65a941704 100644 (file)
 
 #include <systemd/sd-netlink.h>
 
-struct nw_daemon;
+typedef struct nw_daemon nw_daemon;
 
 #include "link.h"
+#include "links.h"
+#include "port.h"
+#include "ports.h"
 #include "zone.h"
+#include "zones.h"
 
-int nw_daemon_create(struct nw_daemon** daemon);
+int nw_daemon_create(nw_daemon** daemon);
 
-struct nw_daemon* nw_daemon_ref(struct nw_daemon* daemon);
-struct nw_daemon* nw_daemon_unref(struct nw_daemon* daemon);
+nw_daemon* nw_daemon_ref(nw_daemon* daemon);
+nw_daemon* nw_daemon_unref(nw_daemon* daemon);
 
-int nw_daemon_run(struct nw_daemon* daemon);
+int nw_daemon_run(nw_daemon* daemon);
 
-int nw_daemon_reload(struct nw_daemon* daemon);
+int nw_daemon_reload(nw_daemon* daemon);
 
 /*
        Netlink
 */
-sd_netlink* nw_daemon_get_rtnl(struct nw_daemon* daemon);
+sd_netlink* nw_daemon_get_rtnl(nw_daemon* daemon);
 
 /*
        Links
 */
-struct nw_links* nw_daemon_links(struct nw_daemon* daemon);
-void nw_daemon_drop_link(struct nw_daemon* daemon, struct nw_link* link);
-struct nw_link* nw_daemon_get_link_by_ifindex(struct nw_daemon* daemon, int ifindex);
-struct nw_link* nw_daemon_get_link_by_name(struct nw_daemon* daemon, const char* name);
+nw_links* nw_daemon_links(nw_daemon* daemon);
+void nw_daemon_drop_link(nw_daemon* daemon, nw_link* link);
+nw_link* nw_daemon_get_link_by_ifindex(nw_daemon* daemon, int ifindex);
+nw_link* nw_daemon_get_link_by_name(nw_daemon* daemon, const char* name);
 
 /*
        Ports
 */
-struct nw_ports* nw_daemon_ports(struct nw_daemon* daemon);
-struct nw_port* nw_daemon_get_port_by_name(struct nw_daemon* daemon, const char* name);
+nw_ports* nw_daemon_ports(nw_daemon* daemon);
+nw_port* nw_daemon_get_port_by_name(nw_daemon* daemon, const char* name);
 
 /*
        Zones
 */
-struct nw_zones* nw_daemon_zones(struct nw_daemon* daemon);
-struct nw_zone* nw_daemon_get_zone_by_name(struct nw_daemon* daemon, const char* name);
+nw_zones* nw_daemon_zones(nw_daemon* daemon);
+nw_zone* nw_daemon_get_zone_by_name(nw_daemon* daemon, const char* name);
 
 #endif /* NETWORKD_DAEMON_H */
index 62be89371a6f9e5ba9f55648d68ec4358777a197..2f95dc3070d310c04bc1008a8626d9bcc1b218e1 100644 (file)
@@ -32,7 +32,7 @@
 #include "string.h"
 
 struct nw_link {
-       struct nw_daemon* daemon;
+       nw_daemon* daemon;
        int nrefs;
 
        // Interface Index
@@ -47,9 +47,9 @@ struct nw_link {
        uint32_t max_mtu;
 };
 
-int nw_link_create(struct nw_link** link, struct nw_daemon* daemon, int ifindex) {
+int nw_link_create(nw_link** link, nw_daemon* daemon, int ifindex) {
        // Allocate a new object
-       struct nw_link* l = calloc(1, sizeof(*l));
+       nw_link* l = calloc(1, sizeof(*l));
        if (!l)
                return 1;
 
@@ -69,20 +69,20 @@ int nw_link_create(struct nw_link** link, struct nw_daemon* daemon, int ifindex)
        return 0;
 }
 
-static void nw_link_free(struct nw_link* link) {
+static void nw_link_free(nw_link* link) {
        DEBUG("Freeing link (ifindex = %d)\n", link->ifindex);
 
        if (link->daemon)
                nw_daemon_unref(link->daemon);
 }
 
-struct nw_link* nw_link_ref(struct nw_link* link) {
+nw_link* nw_link_ref(nw_link* link) {
        link->nrefs++;
 
        return link;
 }
 
-struct nw_link* nw_link_unref(struct nw_link* link) {
+nw_link* nw_link_unref(nw_link* link) {
        if (--link->nrefs > 0)
                return link;
 
@@ -90,11 +90,11 @@ struct nw_link* nw_link_unref(struct nw_link* link) {
        return NULL;
 }
 
-int nw_link_ifindex(struct nw_link* link) {
+int nw_link_ifindex(nw_link* link) {
        return link->ifindex;
 }
 
-static int nw_link_update_ifname(struct nw_link* link, sd_netlink_message* message) {
+static int nw_link_update_ifname(nw_link* link, sd_netlink_message* message) {
        const char* ifname = NULL;
        int r;
 
@@ -120,7 +120,7 @@ static int nw_link_update_ifname(struct nw_link* link, sd_netlink_message* messa
        return 0;
 }
 
-static int nw_link_update_mtu(struct nw_link* link, sd_netlink_message* message) {
+static int nw_link_update_mtu(nw_link* link, sd_netlink_message* message) {
        uint32_t mtu = 0;
        uint32_t min_mtu = 0;
        uint32_t max_mtu = 0;
@@ -172,7 +172,7 @@ static int nw_link_update_mtu(struct nw_link* link, sd_netlink_message* message)
        This function is called whenever anything changes, so that we can
        update our internal link object.
 */
-static int nw_link_update(struct nw_link* link, sd_netlink_message* message) {
+static int nw_link_update(nw_link* link, sd_netlink_message* message) {
        int r;
 
        // Update the interface name
@@ -189,14 +189,14 @@ static int nw_link_update(struct nw_link* link, sd_netlink_message* message) {
 }
 
 int nw_link_process(sd_netlink* rtnl, sd_netlink_message* message, void* data) {
-       struct nw_links* links = NULL;
-       struct nw_link* link = NULL;
+       nw_links* links = NULL;
+       nw_link* link = NULL;
        const char* ifname = NULL;
        int ifindex;
        uint16_t type;
        int r;
 
-       struct nw_daemon* daemon = (struct nw_daemon*)data;
+       nw_daemon* daemon = (nw_daemon*)data;
 
        // Fetch links
        links = nw_daemon_links(daemon);
index 72ddfa99d5675ee67435da06b2f93c6fc729142c..acb5e7b3561e52b248e2f20c84580403d5ac8882 100644 (file)
 #ifndef NETWORKD_LINK_H
 #define NETWORKD_LINK_H
 
-struct nw_link;
+typedef struct nw_link nw_link;
 
 #include "daemon.h"
 
-int nw_link_create(struct nw_link** link, struct nw_daemon* daemon, int ifindex);
+int nw_link_create(nw_link** link, nw_daemon* daemon, int ifindex);
 
-struct nw_link* nw_link_ref(struct nw_link* link);
-struct nw_link* nw_link_unref(struct nw_link* link);
+nw_link* nw_link_ref(nw_link* link);
+nw_link* nw_link_unref(nw_link* link);
 
-int nw_link_ifindex(struct nw_link* link);
-const char* nw_link_name(struct nw_link* link);
+int nw_link_ifindex(nw_link* link);
+const char* nw_link_name(nw_link* link);
 
 int nw_link_process(sd_netlink* rtnl, sd_netlink_message* message, void* data);
 
index 7aa83a310957e28b176696a9695f97a9e91ddfb3..9f41034ca6ab21aebd927ce14aa1dfbb5d2e59a4 100644 (file)
 #include "links.h"
 
 struct nw_links_entry {
-       struct nw_link* link;
+       nw_link* link;
 
        // Link to the other entries
        STAILQ_ENTRY(nw_links_entry) nodes;
 };
 
 struct nw_links {
-       struct nw_daemon* daemon;
+       nw_daemon* daemon;
        int nrefs;
 
        // Link Entries
@@ -46,8 +46,8 @@ struct nw_links {
        unsigned int num;
 };
 
-int nw_links_create(struct nw_links** links, struct nw_daemon* daemon) {
-       struct nw_links* l = calloc(1, sizeof(*l));
+int nw_links_create(nw_links** links, nw_daemon* daemon) {
+       nw_links* l = calloc(1, sizeof(*l));
        if (!l)
                return 1;
 
@@ -66,7 +66,7 @@ int nw_links_create(struct nw_links** links, struct nw_daemon* daemon) {
        return 0;
 }
 
-static void nw_links_free(struct nw_links* links) {
+static void nw_links_free(nw_links* links) {
        struct nw_links_entry* entry = NULL;
 
        while (!STAILQ_EMPTY(&links->entries)) {
@@ -86,13 +86,13 @@ static void nw_links_free(struct nw_links* links) {
                nw_daemon_unref(links->daemon);
 }
 
-struct nw_links* nw_links_ref(struct nw_links* links) {
+nw_links* nw_links_ref(nw_links* links) {
        links->nrefs++;
 
        return links;
 }
 
-struct nw_links* nw_links_unref(struct nw_links* links) {
+nw_links* nw_links_unref(nw_links* links) {
        if (--links->nrefs > 0)
                return links;
 
@@ -100,7 +100,7 @@ struct nw_links* nw_links_unref(struct nw_links* links) {
        return NULL;
 }
 
-static struct nw_links_entry* nw_links_find_link(struct nw_links* links, const int ifindex) {
+static struct nw_links_entry* nw_links_find_link(nw_links* links, const int ifindex) {
        struct nw_links_entry* entry = NULL;
 
        STAILQ_FOREACH(entry, &links->entries, nodes) {
@@ -112,7 +112,7 @@ static struct nw_links_entry* nw_links_find_link(struct nw_links* links, const i
        return NULL;
 }
 
-int nw_links_add_link(struct nw_links* links, struct nw_link* link) {
+int nw_links_add_link(nw_links* links, struct nw_link* link) {
        // Allocate a new entry
        struct nw_links_entry* entry = calloc(1, sizeof(*entry));
        if (!entry)
@@ -130,7 +130,7 @@ int nw_links_add_link(struct nw_links* links, struct nw_link* link) {
        return 0;
 }
 
-void nw_links_drop_link(struct nw_links* links, struct nw_link* link) {
+void nw_links_drop_link(nw_links* links, struct nw_link* link) {
        struct nw_links_entry* entry = NULL;
 
        entry = nw_links_find_link(links, nw_link_ifindex(link));
@@ -143,7 +143,7 @@ void nw_links_drop_link(struct nw_links* links, struct nw_link* link) {
        links->num--;
 }
 
-int nw_links_enumerate(struct nw_links* links) {
+int nw_links_enumerate(nw_links* links) {
        sd_netlink_message* req = NULL;
        sd_netlink_message* res = NULL;
        int r;
@@ -184,7 +184,7 @@ ERROR:
        return r;
 }
 
-struct nw_link* nw_links_get_by_ifindex(struct nw_links* links, int ifindex) {
+nw_link* nw_links_get_by_ifindex(nw_links* links, int ifindex) {
        struct nw_links_entry* entry = NULL;
 
        entry = nw_links_find_link(links, ifindex);
@@ -194,7 +194,7 @@ struct nw_link* nw_links_get_by_ifindex(struct nw_links* links, int ifindex) {
        return nw_link_ref(entry->link);
 }
 
-struct nw_link* nw_links_get_by_name(struct nw_links* links, const char* name) {
+nw_link* nw_links_get_by_name(nw_links* links, const char* name) {
        struct nw_links_entry* entry = NULL;
 
        STAILQ_FOREACH(entry, &links->entries, nodes) {
index 2b5c787685a2a28bb6aa9fbba7d14b181e3b287f..21e6cfb3509a177822d2234e78ea67b9c53055e9 100644 (file)
 #include "daemon.h"
 #include "link.h"
 
-struct nw_links;
+typedef struct nw_links nw_links;
 
-int nw_links_create(struct nw_links** links, struct nw_daemon* daemon);
+int nw_links_create(nw_links** links, nw_daemon* daemon);
 
-struct nw_links* nw_links_ref(struct nw_links* links);
-struct nw_links* nw_links_unref(struct nw_links* links);
+nw_links* nw_links_ref(nw_links* links);
+nw_links* nw_links_unref(nw_links* links);
 
-int nw_links_add_link(struct nw_links* links, struct nw_link* link);
-void nw_links_drop_link(struct nw_links* links, struct nw_link* link);
+int nw_links_add_link(nw_links* links, nw_link* link);
+void nw_links_drop_link(nw_links* links, nw_link* link);
 
-int nw_links_enumerate(struct nw_links* links);
+int nw_links_enumerate(nw_links* links);
 
-struct nw_link* nw_links_get_by_ifindex(struct nw_links* links, int ifindex);
-struct nw_link* nw_links_get_by_name(struct nw_links* links, const char* name);
+nw_link* nw_links_get_by_ifindex(nw_links* links, int ifindex);
+nw_link* nw_links_get_by_name(nw_links* links, const char* name);
 
 #endif /* NETWORKD_LINKS_H */
index 9a0fd74d744238b074d558fb58ccbb3b16461834..d3afc2aa199d87e50b31ed097f2d23ced4e7f01b 100644 (file)
@@ -212,7 +212,7 @@ static int drop_privileges(const char* user) {
 }
 
 int main(int argc, char** argv) {
-       struct nw_daemon* daemon = NULL;
+       nw_daemon* daemon = NULL;
        int r;
 
        // Drop privileges
index 1a486554e56ea6913f64e4a1413df475cabc6dbc..996be9205fbb9ede154f9920f0180da6fe1bdad1 100644 (file)
@@ -36,10 +36,10 @@ static int nw_port_node_enumerator(sd_bus* bus, const char* path, void* data,
        DEBUG("Enumerating ports...\n");
 
        // Fetch a reference to the daemon
-       struct nw_daemon* daemon = (struct nw_daemon*)data;
+       nw_daemon* daemon = (nw_daemon*)data;
 
        // Fetch ports
-       struct nw_ports* ports = nw_daemon_ports(daemon);
+       nw_ports* ports = nw_daemon_ports(daemon);
 
        // Make bus paths for all ports
        r = nw_ports_bus_paths(ports, nodes);
@@ -58,7 +58,7 @@ static int nw_port_object_find(sd_bus* bus, const char* path, const char* interf
        int r;
 
        // Fetch a reference to the daemon
-       struct nw_daemon* daemon = (struct nw_daemon*)data;
+       nw_daemon* daemon = (nw_daemon*)data;
 
        // Decode the path of the requested object
        r = sd_bus_path_decode(path, "/org/ipfire/network1/port", &name);
@@ -66,7 +66,7 @@ static int nw_port_object_find(sd_bus* bus, const char* path, const char* interf
                return 0;
 
        // Find the port
-       struct nw_port* port = nw_daemon_get_port_by_name(daemon, name);
+       nw_port* port = nw_daemon_get_port_by_name(daemon, name);
        if (!port)
                return 0;
 
@@ -80,7 +80,7 @@ static int nw_port_object_find(sd_bus* bus, const char* path, const char* interf
 
 static int nw_port_bus_get_address(sd_bus* bus, const char* path, const char* interface,
                const char* property, sd_bus_message* reply, void* data, sd_bus_error* error) {
-       struct nw_port* port = (struct nw_port*)data;
+       nw_port* port = (nw_port*)data;
        int r;
 
        // Fetch the address
@@ -115,7 +115,7 @@ static const sd_bus_vtable port_vtable[] = {
        SD_BUS_VTABLE_END
 };
 
-const struct nw_bus_implementation port_bus_impl = {
+const nw_bus_implementation port_bus_impl = {
        "/org/ipfire/network1/port",
        "org.ipfire.network1.Port",
        .fallback_vtables = BUS_FALLBACK_VTABLES({port_vtable, nw_port_object_find}),
index 95e49a89cbdaf1c1dc5f548215b4a1768b2add2a..373c281218bb1f9aa8c9dbccb37dd6c35a6309ec 100644 (file)
@@ -23,6 +23,6 @@
 
 #include "bus.h"
 
-extern const struct nw_bus_implementation port_bus_impl;
+extern const nw_bus_implementation port_bus_impl;
 
 #endif /* NETWORKD_PORT_BUS_H */
index 33e75d70b4245ce801d82cc203d02245a2057d60..41b8b2426bb79f310fb8fa56aa7258b06872b8a3 100644 (file)
 #include "port.h"
 
 struct nw_port {
-       struct nw_daemon* daemon;
+       nw_daemon* daemon;
        int nrefs;
 
        char name[IF_NAMESIZE];
        nw_port_type_t type;
 
        // Configuration
-       struct nw_config *config;
+       nw_config *config;
 
        // Common attributes
        nw_address_t address;
@@ -65,7 +65,7 @@ static nw_port_type_t nw_port_type_from_string(const char* s) {
        return NW_PORT_UNKNOWN;
 }
 
-static void nw_port_free(struct nw_port* port) {
+static void nw_port_free(nw_port* port) {
        if (port->config)
                nw_config_unref(port->config);
        if (port->daemon)
@@ -74,7 +74,7 @@ static void nw_port_free(struct nw_port* port) {
        free(port);
 }
 
-static int nw_port_setup_address(struct nw_port* port) {
+static int nw_port_setup_address(nw_port* port) {
        int r;
 
        // Read ADDRESS from configuration
@@ -111,7 +111,7 @@ ERROR:
        return 0;
 }
 
-static int nw_port_setup_common(struct nw_port* port) {
+static int nw_port_setup_common(nw_port* port) {
        int r;
 
        // Address
@@ -122,7 +122,7 @@ static int nw_port_setup_common(struct nw_port* port) {
        return 0;
 }
 
-static nw_port_type_t nw_port_setup_type(struct nw_port* port) {
+static nw_port_type_t nw_port_setup_type(nw_port* port) {
        const char* type = nw_config_get(port->config, "TYPE");
        if (!type)
                return NW_PORT_UNKNOWN;
@@ -130,7 +130,7 @@ static nw_port_type_t nw_port_setup_type(struct nw_port* port) {
        return nw_port_type_from_string(type);
 }
 
-static int nw_port_setup(struct nw_port* port) {
+static int nw_port_setup(nw_port* port) {
        char path[PATH_MAX];
        int r;
 
@@ -167,11 +167,11 @@ static int nw_port_setup(struct nw_port* port) {
        return 0;
 }
 
-int nw_port_create(struct nw_port** port, struct nw_daemon* daemon, const char* name) {
+int nw_port_create(nw_port** port, nw_daemon* daemon, const char* name) {
        int r;
 
        // Allocate a new object
-       struct nw_port* p = calloc(1, sizeof(*p));
+       nw_port* p = calloc(1, sizeof(*p));
        if (!p)
                return 1;
 
@@ -199,13 +199,13 @@ ERROR:
        return r;
 }
 
-struct nw_port* nw_port_ref(struct nw_port* port) {
+nw_port* nw_port_ref(nw_port* port) {
        port->nrefs++;
 
        return port;
 }
 
-struct nw_port* nw_port_unref(struct nw_port* port) {
+nw_port* nw_port_unref(nw_port* port) {
        if (--port->nrefs > 0)
                return port;
 
@@ -213,11 +213,11 @@ struct nw_port* nw_port_unref(struct nw_port* port) {
        return NULL;
 }
 
-const char* nw_port_name(struct nw_port* port) {
+const char* nw_port_name(nw_port* port) {
        return port->name;
 }
 
-char* nw_port_bus_path(struct nw_port* port) {
+char* nw_port_bus_path(nw_port* port) {
        char* p = NULL;
        int r;
 
@@ -229,10 +229,10 @@ char* nw_port_bus_path(struct nw_port* port) {
        return p;
 }
 
-static struct nw_link* nw_port_get_link(struct nw_port* port) {
+static nw_link* nw_port_get_link(nw_port* port) {
        return nw_daemon_get_link_by_name(port->daemon, port->name);
 }
 
-const nw_address_t* nw_port_get_address(struct nw_port* port) {
+const nw_address_t* nw_port_get_address(nw_port* port) {
        return &port->address;
 }
index 92d60b291cbc822c2b22835d0bb2788ab3ca6454..9881846d002614455813a6d88f8f1f6ba23bf4d9 100644 (file)
@@ -28,20 +28,20 @@ typedef enum nw_port_type {
        NW_PORT_DUMMY,
 } nw_port_type_t;
 
-struct nw_port;
+typedef struct nw_port nw_port;
 
 #include "address.h"
 #include "daemon.h"
 
-int nw_port_create(struct nw_port** port, struct nw_daemon* daemon, const char* name);
+int nw_port_create(nw_port** port, nw_daemon* daemon, const char* name);
 
-struct nw_port* nw_port_ref(struct nw_port* port);
-struct nw_port* nw_port_unref(struct nw_port* port);
+nw_port* nw_port_ref(nw_port* port);
+nw_port* nw_port_unref(nw_port* port);
 
-const char* nw_port_name(struct nw_port* port);
+const char* nw_port_name(nw_port* port);
 
-char* nw_port_bus_path(struct nw_port* port);
+char* nw_port_bus_path(nw_port* port);
 
-const nw_address_t* nw_port_get_address(struct nw_port* port);
+const nw_address_t* nw_port_get_address(nw_port* port);
 
 #endif /* NETWORKD_PORT_H */
index 9cec111532ed117fb70a7528a4a2f648b08049ed..35ed04810f90c8d111d684e17a2ce12913760375 100644 (file)
 #include "util.h"
 
 struct nw_ports_entry {
-       struct nw_port* port;
+       nw_port* port;
 
        // Link to the other entries
        STAILQ_ENTRY(nw_ports_entry) nodes;
 };
 
 struct nw_ports {
-       struct nw_daemon* daemon;
+       nw_daemon* daemon;
        int nrefs;
 
        // Port Entries
@@ -47,8 +47,8 @@ struct nw_ports {
        unsigned int num;
 };
 
-int nw_ports_create(struct nw_ports** ports, struct nw_daemon* daemon) {
-       struct nw_ports* p = calloc(1, sizeof(*p));
+int nw_ports_create(nw_ports** ports, nw_daemon* daemon) {
+       nw_ports* p = calloc(1, sizeof(*p));
        if (!p)
                return 1;
 
@@ -67,7 +67,7 @@ int nw_ports_create(struct nw_ports** ports, struct nw_daemon* daemon) {
        return 0;
 }
 
-static void nw_ports_free(struct nw_ports* ports) {
+static void nw_ports_free(nw_ports* ports) {
        struct nw_ports_entry* entry = NULL;
 
        while (!STAILQ_EMPTY(&ports->entries)) {
@@ -84,13 +84,13 @@ static void nw_ports_free(struct nw_ports* ports) {
        }
 }
 
-struct nw_ports* nw_ports_ref(struct nw_ports* ports) {
+nw_ports* nw_ports_ref(nw_ports* ports) {
        ports->nrefs++;
 
        return ports;
 }
 
-struct nw_ports* nw_ports_unref(struct nw_ports* ports) {
+nw_ports* nw_ports_unref(nw_ports* ports) {
        if (--ports->nrefs > 0)
                return ports;
 
@@ -98,7 +98,7 @@ struct nw_ports* nw_ports_unref(struct nw_ports* ports) {
        return NULL;
 }
 
-static int nw_ports_add_port(struct nw_ports* ports, struct nw_port* port) {
+static int nw_ports_add_port(nw_ports* ports, nw_port* port) {
        // Allocate a new entry
        struct nw_ports_entry* entry = calloc(1, sizeof(*entry));
        if (!entry)
@@ -117,10 +117,10 @@ static int nw_ports_add_port(struct nw_ports* ports, struct nw_port* port) {
 }
 
 static int __nw_ports_enumerate(const char* path, const struct stat* s, void* data) {
-       struct nw_port* port = NULL;
+       nw_port* port = NULL;
        int r;
 
-       struct nw_ports* ports = (struct nw_ports*)data;
+       nw_ports* ports = (nw_ports*)data;
 
        // Skip anything that isn't a regular file
        if (!S_ISREG(s->st_mode))
@@ -154,11 +154,11 @@ ERROR:
        return r;
 }
 
-int nw_ports_enumerate(struct nw_ports* ports) {
+int nw_ports_enumerate(nw_ports* ports) {
        return nw_ftw(PORT_CONFIG_DIR, PORT_CONFIG_DIR "/*", __nw_ports_enumerate, ports);
 }
 
-struct nw_port* nw_ports_get_by_name(struct nw_ports* ports, const char* name) {
+nw_port* nw_ports_get_by_name(nw_ports* ports, const char* name) {
        struct nw_ports_entry* entry = NULL;
 
        STAILQ_FOREACH(entry, &ports->entries, nodes) {
@@ -173,7 +173,7 @@ struct nw_port* nw_ports_get_by_name(struct nw_ports* ports, const char* name) {
        return NULL;
 }
 
-int nw_ports_bus_paths(struct nw_ports* ports, char*** paths) {
+int nw_ports_bus_paths(nw_ports* ports, char*** paths) {
        struct nw_ports_entry* entry = NULL;
        char* path = NULL;
 
index e807e25bae4de5c28ef57651bc3db14c2ac306ea..f58c3a4babe31ac3329da37b3feae93ad8744900 100644 (file)
 #ifndef NETWORKD_PORTS_H
 #define NETWORKD_PORTS_H
 
-struct nw_ports;
+typedef struct nw_ports nw_ports;
 
 #include "daemon.h"
 
-int nw_ports_create(struct nw_ports** ports, struct nw_daemon* daemon);
+int nw_ports_create(nw_ports** ports, nw_daemon* daemon);
 
-struct nw_ports* nw_ports_ref(struct nw_ports* ports);
-struct nw_ports* nw_ports_unref(struct nw_ports* ports);
+nw_ports* nw_ports_ref(nw_ports* ports);
+nw_ports* nw_ports_unref(nw_ports* ports);
 
-int nw_ports_enumerate(struct nw_ports* ports);
+int nw_ports_enumerate(nw_ports* ports);
 
-struct nw_port* nw_ports_get_by_name(struct nw_ports* ports, const char* name);
+struct nw_port* nw_ports_get_by_name(nw_ports* ports, const char* name);
 
-int nw_ports_bus_paths(struct nw_ports* ports, char*** paths);
+int nw_ports_bus_paths(nw_ports* ports, char*** paths);
 
 #endif /* NETWORKD_PORTS_H */
index e9c2ecc2c06a28c344437bf4484a9fae7dd6a508..a06deb5beee1c446c8c048549b6a3d198ce185c9 100644 (file)
@@ -34,10 +34,10 @@ static int nw_zone_node_enumerator(sd_bus* bus, const char* path, void* data,
        DEBUG("Enumerating zones...\n");
 
        // Fetch a reference to the daemon
-       struct nw_daemon* daemon = (struct nw_daemon*)data;
+       nw_daemon* daemon = (nw_daemon*)data;
 
        // Fetch zones
-       struct nw_zones* zones = nw_daemon_zones(daemon);
+       nw_zones* zones = nw_daemon_zones(daemon);
 
        // Make bus paths for all zones
        r = nw_zones_bus_paths(zones, nodes);
@@ -56,7 +56,7 @@ static int nw_zone_object_find(sd_bus* bus, const char* path, const char* interf
        int r;
 
        // Fetch a reference to the daemon
-       struct nw_daemon* daemon = (struct nw_daemon*)data;
+       nw_daemon* daemon = (nw_daemon*)data;
 
        // Decode the path of the requested object
        r = sd_bus_path_decode(path, "/org/ipfire/network1/zone", &name);
@@ -64,7 +64,7 @@ static int nw_zone_object_find(sd_bus* bus, const char* path, const char* interf
                return 0;
 
        // Find the zone
-       struct nw_zone* zone = nw_daemon_get_zone_by_name(daemon, name);
+       nw_zone* zone = nw_daemon_get_zone_by_name(daemon, name);
        if (!zone)
                return 0;
 
@@ -81,7 +81,7 @@ static int nw_zone_object_find(sd_bus* bus, const char* path, const char* interf
 */
 static int nw_zone_bus_get_mtu(sd_bus* bus, const char *path, const char *interface,
                const char* property, sd_bus_message* reply, void* data, sd_bus_error *error) {
-       struct nw_zone* zone = (struct nw_zone*)data;
+       nw_zone* zone = (nw_zone*)data;
 
        return sd_bus_message_append(reply, "u", nw_zone_mtu(zone));
 }
@@ -91,7 +91,7 @@ static int nw_zone_bus_set_mtu(sd_bus* bus, const char* path, const char* interf
        unsigned int mtu = 0;
        int r;
 
-       struct nw_zone* zone = (struct nw_zone*)data;
+       nw_zone* zone = (nw_zone*)data;
 
        // Parse the value
        r = sd_bus_message_read(value, "u", &mtu);
@@ -114,7 +114,7 @@ static const sd_bus_vtable zone_vtable[] = {
        SD_BUS_VTABLE_END
 };
 
-const struct nw_bus_implementation zone_bus_impl = {
+const nw_bus_implementation zone_bus_impl = {
        "/org/ipfire/network1/zone",
        "org.ipfire.network1.Zone",
        .fallback_vtables = BUS_FALLBACK_VTABLES({zone_vtable, nw_zone_object_find}),
index 0d5583ed0510d731fb6c5c20a2a924e5388d6a0a..db257f73e4ff44cd424ca9ac49b4be559ccf8b86 100644 (file)
@@ -23,6 +23,6 @@
 
 #include "bus.h"
 
-extern const struct nw_bus_implementation zone_bus_impl;
+extern const nw_bus_implementation zone_bus_impl;
 
 #endif /* NETWORKD_ZONE_BUS_H */
index c64706fcc1657bc9a14ef565bbfc9bb0213d2c8d..b6fa65d256b795358dab0e9f5708c4e4afa63222 100644 (file)
@@ -34,13 +34,13 @@ struct nw_zone {
        char name[NETWORK_ZONE_NAME_MAX_LENGTH];
 
        // Configuration
-       struct nw_config *config;
+       nw_config *config;
 };
 
 #define nw_zone_path(zone, path, format, ...) \
        __nw_zone_path(zone, path, sizeof(path), format, __VA_ARGS__)
 
-static int __nw_zone_path(struct nw_zone* zone, char* p, const size_t length,
+static int __nw_zone_path(nw_zone* zone, char* p, const size_t length,
                const char* format, ...) {
        char prefix[NAME_MAX];
        char suffix[NAME_MAX];
@@ -63,14 +63,14 @@ static int __nw_zone_path(struct nw_zone* zone, char* p, const size_t length,
        return __nw_path_join(p, length, prefix, suffix);
 }
 
-static void nw_zone_free(struct nw_zone* zone) {
+static void nw_zone_free(nw_zone* zone) {
        if (zone->config)
                nw_config_unref(zone->config);
 
        free(zone);
 }
 
-static int nw_zone_setup(struct nw_zone* zone) {
+static int nw_zone_setup(nw_zone* zone) {
        char path[PATH_MAX];
        int r;
 
@@ -87,11 +87,11 @@ static int nw_zone_setup(struct nw_zone* zone) {
        return 0;
 }
 
-int nw_zone_create(struct nw_zone** zone, const char* name) {
+int nw_zone_create(nw_zone** zone, const char* name) {
        int r;
 
        // Allocate a new object
-       struct nw_zone* z = calloc(1, sizeof(*z));
+       nw_zone* z = calloc(1, sizeof(*z));
        if (!z)
                return 1;
 
@@ -116,13 +116,13 @@ ERROR:
        return r;
 }
 
-struct nw_zone* nw_zone_ref(struct nw_zone* zone) {
+nw_zone* nw_zone_ref(nw_zone* zone) {
        zone->nrefs++;
 
        return zone;
 }
 
-struct nw_zone* nw_zone_unref(struct nw_zone* zone) {
+nw_zone* nw_zone_unref(nw_zone* zone) {
        if (--zone->nrefs > 0)
                return zone;
 
@@ -130,11 +130,11 @@ struct nw_zone* nw_zone_unref(struct nw_zone* zone) {
        return NULL;
 }
 
-const char* nw_zone_name(struct nw_zone* zone) {
+const char* nw_zone_name(nw_zone* zone) {
        return zone->name;
 }
 
-char* nw_zone_bus_path(struct nw_zone* zone) {
+char* nw_zone_bus_path(nw_zone* zone) {
        char* p = NULL;
        int r;
 
@@ -149,11 +149,11 @@ char* nw_zone_bus_path(struct nw_zone* zone) {
 /*
        MTU
 */
-unsigned int nw_zone_mtu(struct nw_zone* zone) {
+unsigned int nw_zone_mtu(nw_zone* zone) {
        return nw_config_get_int(zone->config, "MTU", NETWORK_ZONE_DEFAULT_MTU);
 }
 
-int nw_zone_set_mtu(struct nw_zone* zone, unsigned int mtu) {
+int nw_zone_set_mtu(nw_zone* zone, unsigned int mtu) {
        DEBUG("Change MTU of %s to %u\n", zone->name, mtu);
 
        return nw_config_set_int(zone->config, "MTU", mtu);
index 4a00412503ac096736c2b2046918b837d0828a06..1c8e6b65430bfbd2eb15dce11978df3b8908e6c8 100644 (file)
 #define NETWORK_ZONE_NAME_MAX_LENGTH           16
 #define NETWORK_ZONE_DEFAULT_MTU                       1500
 
-struct nw_zone;
+typedef struct nw_zone nw_zone;
 
-int nw_zone_create(struct nw_zone** zone, const char* name);
+int nw_zone_create(nw_zone** zone, const char* name);
 
-struct nw_zone* nw_zone_ref(struct nw_zone* zone);
-struct nw_zone* nw_zone_unref(struct nw_zone* zone);
+nw_zone* nw_zone_ref(nw_zone* zone);
+nw_zone* nw_zone_unref(nw_zone* zone);
 
-const char* nw_zone_name(struct nw_zone* zone);
+const char* nw_zone_name(nw_zone* zone);
 
-char* nw_zone_bus_path(struct nw_zone* zone);
+char* nw_zone_bus_path(nw_zone* zone);
 
 /*
        MTU
 */
-unsigned int nw_zone_mtu(struct nw_zone* zone);
-int nw_zone_set_mtu(struct nw_zone* zone, unsigned int mtu);
+unsigned int nw_zone_mtu(nw_zone* zone);
+int nw_zone_set_mtu(nw_zone* zone, unsigned int mtu);
 
 #endif /* NETWORKD_ZONE_H */
index 4f739f52069756a84b3c9b8deebe13f20dc7cc4a..779bbe1081f82b141469b36f2d8aaa2978ccf9ff 100644 (file)
@@ -28,7 +28,7 @@
 #include "zones.h"
 
 struct nw_zones_entry {
-       struct nw_zone* zone;
+       nw_zone* zone;
 
        // Link to the other entries
        STAILQ_ENTRY(nw_zones_entry) nodes;
@@ -44,8 +44,8 @@ struct nw_zones {
        unsigned int num;
 };
 
-static int nw_zones_create(struct nw_zones** zones) {
-       struct nw_zones* z = calloc(1, sizeof(*z));
+static int nw_zones_create(nw_zones** zones) {
+       nw_zones* z = calloc(1, sizeof(*z));
        if (!z)
                return 1;
 
@@ -61,7 +61,7 @@ static int nw_zones_create(struct nw_zones** zones) {
        return 0;
 }
 
-static void nw_zones_free(struct nw_zones* zones) {
+static void nw_zones_free(nw_zones* zones) {
        struct nw_zones_entry* entry = NULL;
 
        while (!STAILQ_EMPTY(&zones->entries)) {
@@ -78,13 +78,13 @@ static void nw_zones_free(struct nw_zones* zones) {
        }
 }
 
-struct nw_zones* nw_zones_ref(struct nw_zones* zones) {
+nw_zones* nw_zones_ref(nw_zones* zones) {
        zones->nrefs++;
 
        return zones;
 }
 
-struct nw_zones* nw_zones_unref(struct nw_zones* zones) {
+nw_zones* nw_zones_unref(nw_zones* zones) {
        if (--zones->nrefs > 0)
                return zones;
 
@@ -92,7 +92,7 @@ struct nw_zones* nw_zones_unref(struct nw_zones* zones) {
        return NULL;
 }
 
-static int nw_zones_add_zone(struct nw_zones* zones, struct nw_zone* zone) {
+static int nw_zones_add_zone(nw_zones* zones, nw_zone* zone) {
        // Allocate a new entry
        struct nw_zones_entry* entry = calloc(1, sizeof(*entry));
        if (!entry)
@@ -124,12 +124,12 @@ static int nw_zones_load_filter(const struct dirent* path) {
        return 1;
 }
 
-static int __nw_zones_load(struct nw_zones* zones) {
+static int __nw_zones_load(nw_zones* zones) {
        struct dirent** paths = NULL;
        int n;
        int r = 0;
 
-       struct nw_zone* zone = NULL;
+       nw_zone* zone = NULL;
 
        // Scan the zones directory
        n = scandir(CONFIG_DIR "/zones", &paths, nw_zones_load_filter, alphasort);
@@ -173,7 +173,7 @@ ERROR:
        return r;
 }
 
-int nw_zones_load(struct nw_zones** zones) {
+int nw_zones_load(nw_zones** zones) {
        int r;
 
        // Create a new zones object
@@ -193,7 +193,7 @@ ERROR:
        return r;
 }
 
-size_t nw_zones_num(struct nw_zones* zones) {
+size_t nw_zones_num(nw_zones* zones) {
        struct nw_zones_entry* entry = NULL;
        size_t length = 0;
 
@@ -204,7 +204,7 @@ size_t nw_zones_num(struct nw_zones* zones) {
        return length;
 }
 
-struct nw_zone* nw_zones_get_by_name(struct nw_zones* zones, const char* name) {
+nw_zone* nw_zones_get_by_name(nw_zones* zones, const char* name) {
        struct nw_zones_entry* entry = NULL;
 
        STAILQ_FOREACH(entry, &zones->entries, nodes) {
@@ -219,7 +219,7 @@ struct nw_zone* nw_zones_get_by_name(struct nw_zones* zones, const char* name) {
        return NULL;
 }
 
-int nw_zones_bus_paths(struct nw_zones* zones, char*** paths) {
+int nw_zones_bus_paths(nw_zones* zones, char*** paths) {
        struct nw_zones_entry* entry = NULL;
        char* path = NULL;
 
index 6e2686d0493e992aa83801fee4f050d7af7c944d..e41c74fd53b67bac8ede2f48c75b8ed90e3096cb 100644 (file)
 #ifndef NETWORKD_ZONES_H
 #define NETWORKD_ZONES_H
 
-struct nw_zones;
+typedef struct nw_zones nw_zones;
 
-struct nw_zones* nw_zones_ref(struct nw_zones* zones);
-struct nw_zones* nw_zones_unref(struct nw_zones* zones);
+nw_zones* nw_zones_ref(nw_zones* zones);
+nw_zones* nw_zones_unref(nw_zones* zones);
 
-int nw_zones_load(struct nw_zones** zones);
+int nw_zones_load(nw_zones** zones);
 
-size_t nw_zones_num(struct nw_zones* zones);
+size_t nw_zones_num(nw_zones* zones);
 
-struct nw_zone* nw_zones_get_by_name(struct nw_zones* zones, const char* name);
+nw_zone* nw_zones_get_by_name(nw_zones* zones, const char* name);
 
-int nw_zones_bus_paths(struct nw_zones* zones, char*** paths);
+int nw_zones_bus_paths(nw_zones* zones, char*** paths);
 
 #endif /* NETWORKD_ZONES_H */