From: Daniel Wagner <daniel.wag...@bmw-carit.de>

---
 src/connman.h |  6 +++---
 src/inet.c    | 24 ++++--------------------
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 548f987..208678f 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -191,9 +191,9 @@ int __connman_inet_rtnl_addattr_l(struct nlmsghdr *n, 
size_t max_length,
                        int type, const void *data, size_t data_length);
 int __connman_inet_rtnl_addattr32(struct nlmsghdr *n, size_t maxlen,
                        int type, __u32 data);
-int __connman_inet_add_fwmark_rule(int ifindex, int family, uint32_t fwmark);
-int __connman_inet_del_fwmark_rule(int ifindex, int family, uint32_t fwmark);
-int __connman_inet_add_default_to_table(int ifindex, const char *gateway);
+int __connman_inet_add_fwmark_rule(uint32_t table_id, int family, uint32_t 
fwmark);
+int __connman_inet_del_fwmark_rule(uint32_t table_id, int family, uint32_t 
fwmark);
+int __connman_inet_add_default_to_table(uint32_t table_id, int ifindex, const 
char *gateway);
 
 #include <connman/resolver.h>
 
diff --git a/src/inet.c b/src/inet.c
index eb586e3..8b043ba 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -2427,40 +2427,25 @@ done:
        return ret;
 }
 
-/*
- * Tie the table number to interface index number, substract 1 because
- * indexes are > 0
- */
-static uint32_t get_table_id(int ifindex)
-{
-       const uint32_t value = ('c' << 24) | ('m' << 16) | ('a' << 8) | 'n';
-
-       return value + ifindex - 1;
-}
-
-int __connman_inet_add_fwmark_rule(int ifindex, int family, uint32_t fwmark)
+int __connman_inet_add_fwmark_rule(uint32_t table_id, int family, uint32_t 
fwmark)
 {
        /* ip rule add fwmark 9876 table 1234 */
 
-       uint32_t table_id = get_table_id(ifindex);
-
        return iprule_modify(RTM_NEWRULE, family, table_id, fwmark);
 }
 
-int __connman_inet_del_fwmark_rule(int ifindex, int family, uint32_t fwmark)
+int __connman_inet_del_fwmark_rule(uint32_t table_id, int family, uint32_t 
fwmark)
 {
-       uint32_t table_id = get_table_id(ifindex);
-
        return iprule_modify(RTM_DELRULE, family, table_id, fwmark);
 }
 
-int __connman_inet_add_default_to_table(int ifindex, const char *gateway)
+int __connman_inet_add_default_to_table(uint32_t table_id, int ifindex,
+                                               const char *gateway)
 {
        /* ip route add default via 1.2.3.4 dev wlan0 table 1234 */
 
        struct __connman_inet_rtnl_handle rth;
        unsigned char buf[sizeof(struct in6_addr)];
-       uint32_t table_id;
        int ret, len;
        int family = connman_inet_check_ipaddress(gateway);
 
@@ -2493,7 +2478,6 @@ int __connman_inet_add_default_to_table(int ifindex, 
const char *gateway)
 
        __connman_inet_rtnl_addattr_l(&rth.req.n, sizeof(rth.req), RTA_GATEWAY,
                                                                buf, len);
-       table_id = get_table_id(ifindex);
        if (table_id < 256) {
                rth.req.u.r.rt.rtm_table = table_id;
        } else {
-- 
1.8.1.3.566.gaa39828

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to