summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>1999-07-28 15:43:55 +0000
committerErik Troan <ewt@redhat.com>1999-07-28 15:43:55 +0000
commit48ec2f269f43be0f3f76879f04aa4739ab2909e2 (patch)
tree82a5db2a4e1723eb338074d64bb432dd35b8ca89
parent8f1e79d9ae735005a5d1825ac4c3cc7523c76bf2 (diff)
downloadanaconda-48ec2f269f43be0f3f76879f04aa4739ab2909e2.tar.gz
anaconda-48ec2f269f43be0f3f76879f04aa4739ab2909e2.tar.xz
anaconda-48ec2f269f43be0f3f76879f04aa4739ab2909e2.zip
added addDefualtRoute()
-rw-r--r--isys/inet.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/isys/inet.c b/isys/inet.c
index b31dbc3cb..03dd92147 100644
--- a/isys/inet.c
+++ b/isys/inet.c
@@ -104,3 +104,43 @@ int configureNetDevice(struct intfInfo * intf) {
return 0;
}
+
+int addDefaultRoute(struct intfInfo * net) {
+ int s;
+ struct rtentry route;
+ struct sockaddr_in addr;
+
+ /* It should be okay to try and setup a machine w/o a default gateway */
+ /* XXX
+ if (!(net->set & NETINFO_HAS_GATEWAY)) return 0;
+ */
+
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ close(s);
+ perror("socket:");
+ return 1;
+ }
+
+ memset(&route, 0, sizeof(route));
+
+ addr.sin_family = AF_INET;
+ addr.sin_port = 0;
+ addr.sin_addr = net->gateway;
+ memcpy(&route.rt_gateway, &addr, sizeof(addr));
+
+ addr.sin_addr.s_addr = INADDR_ANY;
+ memcpy(&route.rt_dst, &addr, sizeof(addr));
+ memcpy(&route.rt_genmask, &addr, sizeof(addr));
+
+ route.rt_flags = RTF_UP | RTF_GATEWAY;
+ route.rt_metric = 0;
+
+ if (ioctl(s, SIOCADDRT, &route)) {
+ close(s);
+ perror("SIOCADDRT");
+ return 1;
+ }
+
+ return 0;
+}