]> git.ipfire.org Git - people/ms/network.git/commitdiff
ports: Create scaffolding for operations struct
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Jun 2023 14:28:35 +0000 (14:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Jun 2023 14:28:35 +0000 (14:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/networkd/port-dummy.c [new file with mode: 0644]
src/networkd/port-dummy.h [new file with mode: 0644]
src/networkd/port.c
src/networkd/port.h

index 22d90d48ee73ca353b0b11005f2cd23dac7c5f2e..15e9fa0ad08a6761ad2e267fda12c5625735e677 100644 (file)
@@ -332,6 +332,8 @@ dist_networkd_SOURCES = \
        src/networkd/port.h \
        src/networkd/port-bus.c \
        src/networkd/port-bus.h \
+       src/networkd/port-dummy.c \
+       src/networkd/port-dummy.h \
        src/networkd/stats-collector.c \
        src/networkd/stats-collector.h \
        src/networkd/string.h \
diff --git a/src/networkd/port-dummy.c b/src/networkd/port-dummy.c
new file mode 100644 (file)
index 0000000..cc4b649
--- /dev/null
@@ -0,0 +1,28 @@
+/*#############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2023 IPFire Network Development Team                          #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program 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 General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include "port.h"
+#include "port-dummy.h"
+
+nw_port_ops_t nw_port_ops_dummy = {
+       // There is no special configuration
+       .config_read = NULL,
+       .config_write = NULL,
+};
diff --git a/src/networkd/port-dummy.h b/src/networkd/port-dummy.h
new file mode 100644 (file)
index 0000000..0a29c84
--- /dev/null
@@ -0,0 +1,28 @@
+/*#############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2023 IPFire Network Development Team                          #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program 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 General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#ifndef NETWORKD_PORT_DUMMY_H
+#define NETWORKD_PORT_DUMMY_H
+
+#include "port.h"
+
+extern nw_port_ops_t nw_port_ops_dummy;
+
+#endif /* NETWORKD_PORT_DUMMY_H */
index 23ffd0bd59c3e6feacd27368f278feeeef0660d7..6ba48757e13d4b130c22e5a7c1ebf4a7d0ccc6ab 100644 (file)
@@ -30,6 +30,7 @@
 #include "link.h"
 #include "logging.h"
 #include "port.h"
+#include "port-dummy.h"
 #include "stats-collector.h"
 #include "string.h"
 
@@ -49,6 +50,9 @@ struct nw_port {
        // Common attributes
        nw_address_t address;
 
+       // Type Operations
+       nw_port_ops_t ops;
+
        // VLAN settings
        struct nw_port_vlan {
                nw_port* parent;
@@ -252,6 +256,13 @@ int nw_port_create(nw_port** port, nw_daemon* daemon, nw_port_type_t type, const
        // Store the type
        p->type = type;
 
+       // Set operations
+       switch (p->type) {
+               case NW_PORT_DUMMY:
+                       p->ops = nw_port_ops_dummy;
+                       break;
+       }
+
        // Store the name
        r = nw_string_set(p->name, name);
        if (r)
index 032d82c7f9cf31bc3b237770e4af0144704476ee..76df7a77e01dcfc328ad64e720c8b9dea861a4de 100644 (file)
@@ -37,8 +37,15 @@ typedef enum nw_port_type {
 typedef struct nw_port nw_port;
 
 #include "address.h"
+#include "config.h"
 #include "daemon.h"
 
+typedef struct nw_port_ops {
+       // Configuration
+       int (*config_read)(nw_port* port, nw_config* config);
+       int (*config_write)(nw_port* port, nw_config* config);
+} nw_port_ops_t;
+
 int nw_port_create(nw_port** port, nw_daemon* daemon,
        nw_port_type_t type, const char* name);
 int nw_port_create_from_config(nw_port** port, nw_daemon* daemon,