Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From a9243f13d6e1aadd69bfcc27f75f69c38be51677 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jian Liang <jianliang@tycoint.com> |
| 3 | Date: Wed, 4 Oct 2017 17:30:17 +0100 |
| 4 | Subject: [PATCH 3/4] inet: Implement APIs for creating and deleting subnet |
| 5 | route |
| 6 | To: connman@lists.01.org |
| 7 | Cc: wagi@monom.org |
| 8 | |
| 9 | Signed-off-by: Jian Liang <jianliang@tycoint.com> |
| 10 | |
| 11 | --- |
| 12 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=3a15b0b7fccd053aff91da2cc68585509d0c509b] |
| 13 | Signed-off-by: André Draszik <andre.draszik@jci.com> |
| 14 | src/connman.h | 4 ++++ |
| 15 | src/inet.c | 14 ++++++++++++++ |
| 16 | 2 files changed, 18 insertions(+) |
| 17 | |
| 18 | diff --git a/src/connman.h b/src/connman.h |
| 19 | index 21b7080..da4446a 100644 |
| 20 | --- a/src/connman.h |
| 21 | +++ b/src/connman.h |
| 22 | @@ -240,7 +240,11 @@ int __connman_inet_rtnl_addattr32(struct nlmsghdr *n, size_t maxlen, |
| 23 | int __connman_inet_add_fwmark_rule(uint32_t table_id, int family, uint32_t fwmark); |
| 24 | int __connman_inet_del_fwmark_rule(uint32_t table_id, int family, uint32_t fwmark); |
| 25 | int __connman_inet_add_default_to_table(uint32_t table_id, int ifindex, const char *gateway); |
| 26 | +int __connman_inet_add_subnet_to_table(uint32_t table_id, int ifindex, |
| 27 | + const char *gateway, unsigned char prefixlen); |
| 28 | int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex, const char *gateway); |
| 29 | +int __connman_inet_del_subnet_from_table(uint32_t table_id, int ifindex, |
| 30 | + const char *gateway, unsigned char prefixlen); |
| 31 | int __connman_inet_get_address_netmask(int ifindex, |
| 32 | struct sockaddr_in *address, struct sockaddr_in *netmask); |
| 33 | |
| 34 | diff --git a/src/inet.c b/src/inet.c |
| 35 | index 0ddb030..dcd1ab2 100644 |
| 36 | --- a/src/inet.c |
| 37 | +++ b/src/inet.c |
| 38 | @@ -2880,6 +2880,13 @@ int __connman_inet_add_default_to_table(uint32_t table_id, int ifindex, |
| 39 | return iproute_default_modify(RTM_NEWROUTE, table_id, ifindex, gateway, 0); |
| 40 | } |
| 41 | |
| 42 | +int __connman_inet_add_subnet_to_table(uint32_t table_id, int ifindex, |
| 43 | + const char *gateway, unsigned char prefixlen) |
| 44 | +{ |
| 45 | + /* ip route add 1.2.3.4/24 dev eth0 table 1234 */ |
| 46 | + return iproute_default_modify(RTM_NEWROUTE, table_id, ifindex, gateway, prefixlen); |
| 47 | +} |
| 48 | + |
| 49 | int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex, |
| 50 | const char *gateway) |
| 51 | { |
| 52 | @@ -2888,6 +2895,13 @@ int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex, |
| 53 | return iproute_default_modify(RTM_DELROUTE, table_id, ifindex, gateway, 0); |
| 54 | } |
| 55 | |
| 56 | +int __connman_inet_del_subnet_from_table(uint32_t table_id, int ifindex, |
| 57 | + const char *gateway, unsigned char prefixlen) |
| 58 | +{ |
| 59 | + /* ip route del 1.2.3.4/24 dev eth0 table 1234 */ |
| 60 | + return iproute_default_modify(RTM_DELROUTE, table_id, ifindex, gateway, prefixlen); |
| 61 | +} |
| 62 | + |
| 63 | int __connman_inet_get_interface_ll_address(int index, int family, |
| 64 | void *address) |
| 65 | { |
| 66 | -- |
| 67 | 2.7.4 |
| 68 | |