diff mbox series

[35/90] inet: Add '__connman_inet_table2string'.

Message ID 20231206235056.322578-36-gerickson@nuovations.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Add Gateway Low-priority Default Routes for Non-default Services | expand

Commit Message

Grant Erickson Dec. 6, 2023, 11:49 p.m. UTC
This adds the function '__connman_inet_table2string', which returns a
null-terminated C string describing a Linux Routing Netlink (rtnl)
routing table identifier.
---
 src/connman.h |  2 ++
 src/inet.c    | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/src/connman.h b/src/connman.h
index 6b86be6f5ab3..19de86346565 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -174,6 +174,8 @@  int __connman_inet_get_interface_mac_address(int index, uint8_t *mac_address);
 
 bool __connman_inet_is_any_addr(const char *address, int family);
 
+const char *__connman_inet_table2string(uint32_t table_id);
+
 #include <netinet/ip6.h>
 #include <netinet/icmp6.h>
 
diff --git a/src/inet.c b/src/inet.c
index 3465d50cc84b..3d40f8d09e82 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -256,6 +256,24 @@  out:
 	return ret;
 }
 
+const char *__connman_inet_table2string(uint32_t table_id)
+{
+	switch (table_id) {
+	case RT_TABLE_UNSPEC:
+		return "unspecified";
+	case RT_TABLE_COMPAT:
+		return "compat";
+	case RT_TABLE_DEFAULT:
+		return "default";
+	case RT_TABLE_MAIN:
+		return "main";
+	case RT_TABLE_LOCAL:
+		return "local";
+	}
+
+	return "";
+}
+
 int connman_inet_ifindex(const char *name)
 {
 	struct ifreq ifr;