diff options
| author | Matt Wilson <msw@redhat.com> | 1999-06-25 02:13:21 +0000 |
|---|---|---|
| committer | Matt Wilson <msw@redhat.com> | 1999-06-25 02:13:21 +0000 |
| commit | 79babd8fb43cfd0f73633a42f175398fedf5f7a5 (patch) | |
| tree | 3cff7ef981549fe3c7454b7bcd81fba16ddf57d9 | |
| parent | e5805f48c6d95f77afedbce04d1cab6b88d4f05b (diff) | |
added networking calls to isys
added some newt status stuff to the loader
| -rw-r--r-- | isys/Makefile | 4 | ||||
| -rw-r--r-- | isys/isys.c | 29 | ||||
| -rw-r--r-- | loader/Makefile | 4 | ||||
| -rw-r--r-- | loader/loader.c | 145 | ||||
| -rw-r--r-- | text.py | 2 |
5 files changed, 51 insertions, 133 deletions
diff --git a/isys/Makefile b/isys/Makefile index e86117fc1..997866f6a 100644 --- a/isys/Makefile +++ b/isys/Makefile @@ -1,8 +1,8 @@ DESTDIR = $(TOPDIR)/RedHat/instimage/usr/lib/python1.5/site-packages CFLAGS = -I/usr/include/python1.5 -g -OBJECTS = isys.o nfsmount.o dns.o mount_clnt.o mount_xdr.o imount.o smp.o \ - moduleinfo.o devnodes.o otherinsmod.o cpio.o +OBJECTS = isys.o nfsmount.o dns.o mount_clnt.o mount_xdr.o imount.o \ + inet.o smp.o moduleinfo.o devnodes.o otherinsmod.o cpio.o STATICLIBS = pci/libpciprobe.a modutils/insmod/libmodutils.a \ modutils/obj/libobj.a modutils/util/libutil.a LOADLIBES = -lrpm -lresolv -lz diff --git a/isys/isys.c b/isys/isys.c index 0861c4d9e..ac8925c2c 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -7,6 +7,7 @@ #include "Python.h" #include "imount.h" +#include "inet.h" #include "isys.h" #include "pci/pciprobe.h" #include "smp.h" @@ -21,6 +22,7 @@ static PyObject * getModuleList(PyObject * s, PyObject * args); static PyObject * makeDevInode(PyObject * s, PyObject * args); static PyObject * pciProbe(PyObject * s, PyObject * args); static PyObject * smpAvailable(PyObject * s, PyObject * args); +static PyObject * doConfigNetDevice(PyObject * s, PyObject * args); static PyMethodDef isysModuleMethods[] = { { "findmoduleinfo", (PyCFunction) doFindModInfo, METH_VARARGS, NULL }, @@ -33,6 +35,7 @@ static PyMethodDef isysModuleMethods[] = { { "mount", (PyCFunction) doMount, METH_VARARGS, NULL }, { "smpavailable", (PyCFunction) smpAvailable, METH_VARARGS, NULL }, { "umount", (PyCFunction) doUMount, METH_VARARGS, NULL }, + { "confignetdevice", (PyCFunction) doConfigNetDevice, METH_VARARGS, NULL }, { NULL } } ; @@ -280,3 +283,29 @@ void init_isys(void) { static void emptyDestructor(PyObject * s) { } +static PyObject * doConfigNetDevice(PyObject * s, PyObject * args) { + char * dev, * ip, * netmask, * broadcast, * network; + int * isPtp, rc; + struct intfInfo device; + + if (!PyArg_ParseTuple(args, "sssssd", &dev, &ip, &netmask, &broadcast, + &network, &isPtp)) return NULL; + + strncpy(device.device, dev, sizeof(device.device) - 1); + device.ip.s_addr = inet_addr(ip); + device.netmask.s_addr = inet_addr(netmask); + device.broadcast.s_addr = inet_addr(broadcast); + device.network.s_addr = inet_addr(network); + device.isPtp = 0; + device.isUp = 0; + + rc = configureNetDevice(&device); + + if (rc == INET_ERR_ERRNO) + PyErr_SetFromErrno(PyExc_SystemError); + else if (rc) + PyErr_SetString(PyExc_SystemError, "net configure failed"); + + Py_INCREF(Py_None); + return Py_None; +} diff --git a/loader/Makefile b/loader/Makefile index 496da72a8..393581760 100644 --- a/loader/Makefile +++ b/loader/Makefile @@ -1,6 +1,6 @@ DESTDIR = ../../trees/initrd -OBJS = loader.o +OBJS = loader.o log.o windows.o SOURCES = $(subst .o,.c,$(OBJS)) BINS = loader init @@ -46,7 +46,7 @@ loader: $(OBJS) ../isys/modutils/insmod/libmodutils.a \ ../isys/modutils/util/libutil.a \ ../isys/modutils/obj/libobj.a \ - -lrpm -lz -lresolv + -lrpm -lz -lresolv -lnewt -lslang init: init.o $(MINILIBC) $(CC) $(STATIC) -g $(LDFLAGS) -o $@ init.o $(MINILIBC) diff --git a/loader/loader.c b/loader/loader.c index 40d20a02e..83fd99b71 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -23,131 +23,17 @@ #include <unistd.h> #include <popt.h> #include <newt.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <net/if.h> -#include <net/route.h> -#include <sys/ioctl.h> #include <fcntl.h> +#include <arpa/inet.h> #include "isys/imount.h" +#include "isys/inet.h" #include "isys/isys.h" #include "isys/pci/pciprobe.h" -#define _(x) x - -struct intfInfo { - char device[10]; - int isPtp, isUp; - int set, manuallySet; - struct in_addr ip, netmask, broadcast, network; - struct in_addr bootServer; - char * bootFile; - int bootProto; -}; - -static int configureNetDevice(struct intfInfo * intf) { - struct ifreq req; - int s; - struct sockaddr_in addr; - struct in_addr ia; - char ip[20], nm[20], nw[20], bc[20]; -#if 0 /* 2.0 kernels only */ - struct rtentry route; -#endif - - addr.sin_family = AF_INET; - addr.sin_port = 0; - - memcpy(&ia, &intf->ip, sizeof(intf->ip)); - strcpy(ip, inet_ntoa(ia)); - - memcpy(&ia, &intf->netmask, sizeof(intf->netmask)); - strcpy(nm, inet_ntoa(ia)); - - memcpy(&ia, &intf->broadcast, sizeof(intf->broadcast)); - strcpy(bc, inet_ntoa(ia)); - - memcpy(&ia, &intf->network, sizeof(intf->network)); - strcpy(nw, inet_ntoa(ia)); - - printf("configuring %s ip: %s nm: %s nw: %s bc: %s\n", intf->device, - ip, nm, nw, bc); - - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - perror("socket"); - return 1; - } - - strcpy(req.ifr_name, intf->device); - req.ifr_flags &= ~(IFF_UP | IFF_RUNNING); /* Take down iface */ - if (ioctl(s, SIOCSIFFLAGS, &req)) { - perror("SIOCSIFFLAGS"); - close(s); - return 1; - } - - addr.sin_port = 0; - memcpy(&addr.sin_addr, &intf->ip, sizeof(intf->ip)); - memcpy(&req.ifr_addr, &addr, sizeof(addr)); - if (ioctl(s, SIOCSIFADDR, &req)) { - perror("SIOCSIFADDR"); - close(s); - return 1; - } - - memcpy(&addr.sin_addr, &intf->broadcast, sizeof(intf->broadcast)); - memcpy(&req.ifr_broadaddr, &addr, sizeof(addr)); - if (ioctl(s, SIOCSIFBRDADDR, &req)) { - perror("SIOCSIFNETMASK"); - close(s); - return 1; - } - - memcpy(&addr.sin_addr, &intf->netmask, sizeof(intf->netmask)); - memcpy(&req.ifr_netmask, &addr, sizeof(addr)); - if (ioctl(s, SIOCSIFNETMASK, &req)) { - perror("SIOCSIFNETMASK\n"); - close(s); - return 1; - } - - if (intf->isPtp) - req.ifr_flags = IFF_UP | IFF_RUNNING | IFF_POINTOPOINT | IFF_NOARP; - else - req.ifr_flags = IFF_UP | IFF_RUNNING | IFF_BROADCAST; - - if (ioctl(s, SIOCSIFFLAGS, &req)) { - perror("SIOCSIFFLAGS"); - close(s); - return 1; - } - -#if 0 /* kernel 2.0 only */ - memset(&route, 0, sizeof(route)); - route.rt_dev = intf->device; - route.rt_flags = RTF_UP; - - memcpy(&addr.sin_addr, &intf->network, sizeof(intf->netmask)); - memcpy(&route.rt_dst, &addr, sizeof(addr)); - - memcpy(&addr.sin_addr, &intf->netmask, sizeof(intf->netmask)); - memcpy(&route.rt_genmask, &addr, sizeof(addr)); - - if (ioctl(s, SIOCADDRT, &route)) { - perror("SIOCADDRT"); - close(s); - return 1; - - } -#endif - - intf->isUp = 1; - - return 0; -} +#include "windows.h" +#include "log.h" +#include "lang.h" int main(int argc, char ** argv) { char ** argptr; @@ -184,6 +70,13 @@ int main(int argc, char ** argv) { return 1; } + openLog(testing); + + newtInit(); + newtDrawRootText(0, 0, _("Welcome to Red Hat Linux")); + + newtPushHelpLine(_(" <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen ")); + if (!testing) { modules = probePciDriverList(); if (modules == NULL) { @@ -191,8 +84,10 @@ int main(int argc, char ** argv) { } else { while ((module = *modules++)) { if (!testing) { - printf("Inserting module %s\n", module); + winStatus(60, 5, "Module Insertion", + "Inserting module %s"); insmod(module, NULL); + newtPopWindow(); } else { printf("Test mode: I would run insmod(%s, args);\n", module); @@ -200,14 +95,6 @@ int main(int argc, char ** argv) { } } - /* - newtInit(); - newtDrawRootText(0, 0, _("Welcome to Red Hat Linux")); - - newtPushHelpLine(_(" <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen ")); - - newtFinished(); - */ strcpy(eth0.device, "eth0"); eth0.isPtp=0; @@ -242,6 +129,8 @@ int main(int argc, char ** argv) { *argptr++ = "-p"; *argptr++ = "/mnt/source"; + newtFinished(); + printf("Launching anaconda (%s), please wait...\n", anacondaArgs[0]); execv(anacondaArgs[0], anacondaArgs); @@ -7,7 +7,7 @@ import os class WelcomeWindow: def run(self, screen): ButtonChoiceWindow(screen, "Red Hat Linux", - "Welcome to Red Hat Linux!\n\n" + "Welcome to Red Hat Linux!\n\n" "This installation process is outlined in detail in the " "Official Red Hat Linux Installation Guide available from " "Red Hat Software. If you have access to this manual, you " |
