[PATCH v2 1/8] rmnet: Add skeleton

Denis Kenzior <[email protected]>
Newsgroups dev.linux.lists.ofono
Message-ID <[email protected]>
Add skeleton of the RMNet interface management module.  Implement the
basic API structure and register the module with oFono core.
---
 Makefile.am |  2 ++
 src/rmnet.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/rmnet.h | 25 +++++++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 src/rmnet.c
 create mode 100644 src/rmnet.h

diff --git a/Makefile.am b/Makefile.am
index d379201d362b..d107dc410fd2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -353,6 +353,8 @@ builtin_sources += plugins/u8500.c
 endif
 
 if QMIMODEM
+builtin_sources += src/rmnet.h src/rmnet.c
+
 qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
 					drivers/qmimodem/ctl.h \
 					drivers/qmimodem/dms.h \
diff --git a/src/rmnet.c b/src/rmnet.c
new file mode 100644
index 000000000000..58f841a49a59
--- /dev/null
+++ b/src/rmnet.c
@@ -0,0 +1,59 @@
+/*
+ *  oFono - Open Source Telephony
+ *  Copyright (C) 2024  Cruise, LLC
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+#include <linux/rtnetlink.h>
+#include <net/if.h>
+
+#include <ell/ell.h>
+
+#include "ofono.h"
+#include "rmnet.h"
+
+static struct l_netlink *rtnl;
+
+int rmnet_get_interfaces(uint32_t parent_ifindex, unsigned int n_interfaces,
+				rmnet_new_interfaces_func_t cb,
+				void *user_data, rmnet_destroy_func_t destroy)
+{
+	return -ENOTSUP;
+}
+
+int rmnet_del_interfaces(unsigned int n_interfaces,
+					const struct rmnet_ifinfo *interfaces)
+{
+	return -ENOTSUP;
+}
+
+int rmnet_cancel(int id)
+{
+	return -ENOTSUP;
+}
+
+static int rmnet_init(void)
+{
+	DBG("");
+
+	rtnl = l_netlink_new(NETLINK_ROUTE);
+	if (!rtnl)
+		return -EIO;
+
+	return 0;
+}
+
+static void rmnet_exit(void)
+{
+	l_netlink_destroy(rtnl);
+}
+
+OFONO_MODULE(rmnet, rmnet_init, rmnet_exit)
diff --git a/src/rmnet.h b/src/rmnet.h
new file mode 100644
index 000000000000..dc416e0d5d51
--- /dev/null
+++ b/src/rmnet.h
@@ -0,0 +1,25 @@
+/*
+ *  oFono - Open Source Telephony
+ *  Copyright (C) 2024  Cruise, LLC
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+struct rmnet_ifinfo {
+	uint32_t ifindex;
+	uint16_t mux_id;
+	char ifname[IF_NAMESIZE];
+};
+
+typedef void (*rmnet_new_interfaces_func_t)(int error,
+					unsigned int n_interfaces,
+					const struct rmnet_ifinfo *interfaces,
+					void *user_data);
+typedef void (*rmnet_destroy_func_t)(void *user_data);
+
+int rmnet_get_interfaces(uint32_t parent_ifindex, unsigned int n_interfaces,
+				rmnet_new_interfaces_func_t cb,
+				void *user_data, rmnet_destroy_func_t destroy);
+int rmnet_del_interfaces(unsigned int n_interfaces,
+					const struct rmnet_ifinfo *interfaces);
+int rmnet_cancel(int id);
-- 
2.47.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.