diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2010-12-17 15:52:00 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-12-21 01:30:31 +0100 |
commit | c6dc58620400f2f21e157144253b9ed20e49539f (patch) | |
tree | 8ea5c124196fa41f5523c8a57a92e0ef67cee111 | |
parent | 44098150b1db9cce6baedb242285b6c1a8c440bf (diff) | |
download | connman-c6dc58620400f2f21e157144253b9ed20e49539f.tar.gz connman-c6dc58620400f2f21e157144253b9ed20e49539f.tar.bz2 connman-c6dc58620400f2f21e157144253b9ed20e49539f.zip |
inet: Add connman_inet_[add|del]_network_route()
connman_inet_[add|del]_host_route() are now wrappers
around connman_inet_[add|del]_network_route()
-rw-r--r-- | include/inet.h | 3 | ||||
-rw-r--r-- | src/inet.c | 25 |
2 files changed, 25 insertions, 3 deletions
diff --git a/include/inet.h b/include/inet.h index 7b349000..5fb3a53f 100644 --- a/include/inet.h +++ b/include/inet.h @@ -48,6 +48,9 @@ int connman_inet_set_address(int index, struct connman_ipaddress *ipaddress); int connman_inet_clear_address(int index, struct connman_ipaddress *ipaddress); int connman_inet_add_host_route(int index, const char *host, const char *gateway); int connman_inet_del_host_route(int index, const char *host); +int connman_inet_add_network_route(int index, const char *host, const char *gateway, + const char *netmask); +int connman_inet_del_network_route(int index, const char *host); int connman_inet_set_gateway_address(int index, const char *gateway); int connman_inet_clear_gateway_address(int index, const char *gateway); int connman_inet_set_gateway_interface(int index); @@ -616,7 +616,20 @@ int connman_inet_clear_address(int index, struct connman_ipaddress *ipaddress) return 0; } -int connman_inet_add_host_route(int index, const char *host, const char *gateway) +int connman_inet_add_host_route(int index, const char *host, + const char *gateway) +{ + return connman_inet_add_network_route(index, host, gateway, NULL); +} + +int connman_inet_del_host_route(int index, const char *host) +{ + return connman_inet_del_network_route(index, host); +} + +int connman_inet_add_network_route(int index, const char *host, + const char *gateway, + const char *netmask) { struct ifreq ifr; struct rtentry rt; @@ -638,9 +651,11 @@ int connman_inet_add_host_route(int index, const char *host, const char *gateway DBG("ifname %s", ifr.ifr_name); memset(&rt, 0, sizeof(rt)); - rt.rt_flags = RTF_UP | RTF_HOST; + rt.rt_flags = RTF_UP; if (gateway != NULL) rt.rt_flags |= RTF_GATEWAY; + if (netmask == NULL) + rt.rt_flags |= RTF_HOST; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; @@ -658,6 +673,10 @@ int connman_inet_add_host_route(int index, const char *host, const char *gateway memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; + if (netmask != NULL) + addr.sin_addr.s_addr = inet_addr(netmask); + else + addr.sin_addr.s_addr = INADDR_ANY; memcpy(&rt.rt_genmask, &addr, sizeof(rt.rt_genmask)); rt.rt_dev = ifr.ifr_name; @@ -672,7 +691,7 @@ int connman_inet_add_host_route(int index, const char *host, const char *gateway return err; } -int connman_inet_del_host_route(int index, const char *host) +int connman_inet_del_network_route(int index, const char *host) { struct ifreq ifr; struct rtentry rt; |