summaryrefslogtreecommitdiff
path: root/src/inet.c
diff options
context:
space:
mode:
authorKalle Valo <kalle.valo@canonical.com>2010-06-15 01:17:36 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-06-16 00:11:07 +0200
commit11281de04f7707ebcaf4050ae6ad5d48907b956a (patch)
treee51a31af617de0640059931c85b8602fd939811f /src/inet.c
parent460513c7edcbd14e830cb9f0dd9da3a7ee79f3db (diff)
downloadconnman-11281de04f7707ebcaf4050ae6ad5d48907b956a.tar.gz
connman-11281de04f7707ebcaf4050ae6ad5d48907b956a.tar.bz2
connman-11281de04f7707ebcaf4050ae6ad5d48907b956a.zip
Support for ppp default route setting
When gateway is NULL, we need to properly set our connection and element string to 0.0.0.0 so that the interface is the default route.
Diffstat (limited to 'src/inet.c')
-rw-r--r--src/inet.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/inet.c b/src/inet.c
index ec0850a4..980bd481 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -899,3 +899,48 @@ int connman_inet_clear_gateway_address(int index, const char *gateway)
return err;
}
+
+int connman_inet_clear_gateway_interface(int index)
+{
+ struct ifreq ifr;
+ struct rtentry rt;
+ struct sockaddr_in addr;
+ int sk, err;
+
+ DBG("");
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0)
+ return -1;
+
+ memset(&ifr, 0, sizeof(ifr));
+ ifr.ifr_ifindex = index;
+
+ if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
+ close(sk);
+ return -1;
+ }
+
+ DBG("ifname %s", ifr.ifr_name);
+
+ memset(&rt, 0, sizeof(rt));
+ rt.rt_flags = RTF_UP;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = INADDR_ANY;
+
+ memcpy(&rt.rt_genmask, &addr, sizeof(rt.rt_genmask));
+ memcpy(&rt.rt_dst, &addr, sizeof(rt.rt_dst));
+ memcpy(&rt.rt_gateway, &addr, sizeof(rt.rt_gateway));
+
+ rt.rt_dev = ifr.ifr_name;
+
+ err = ioctl(sk, SIOCDELRT, &rt);
+ if (err < 0)
+ connman_error("Removing default interface route failed (%s)",
+ strerror(errno));
+ close(sk);
+
+ return err;
+}