From 9607771add0107b7e93bdccc8e3a994e968aad4a Mon Sep 17 00:00:00 2001 From: ms Date: Tue, 28 Nov 2006 20:05:18 +0000 Subject: [PATCH] PXE Boot integriert. Installerarbeit fortgesetzt. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@351 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/kernel/kernel.config.i586 | 7 +- config/kernel/kernel.config.i586.smp | 7 +- config/uClibc/busybox.config | 44 +- langs/de/install/lang_de.c | 2 + langs/en/install/lang_en.c | 2 + lfs/installer | 3 +- lfs/pxe | 64 ++ make.sh | 4 +- src/install+setup/install/install.h | 8 +- src/install+setup/install/main.c | 115 ++- src/install+setup/install/net.c | 20 +- src/install+setup/install/probecntrl.sh | 13 + src/install+setup/install/probenic.sh | 12 + src/install+setup/libsmooth/netstuff.c | 1259 +++++++++++------------ 14 files changed, 825 insertions(+), 735 deletions(-) create mode 100644 lfs/pxe create mode 100644 src/install+setup/install/probecntrl.sh create mode 100644 src/install+setup/install/probenic.sh diff --git a/config/kernel/kernel.config.i586 b/config/kernel/kernel.config.i586 index c357a8a33d..80df797794 100644 --- a/config/kernel/kernel.config.i586 +++ b/config/kernel/kernel.config.i586 @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Linux kernel version: 2.6.16 -# Wed Nov 15 11:02:15 2006 +# Wed Nov 15 12:49:42 2006 # CONFIG_X86_32=y CONFIG_SEMAPHORE_SLEEPERS=y @@ -1493,7 +1493,7 @@ CONFIG_SENSORS_HDAPS=m # # Graphics support # -CONFIG_FB=m +CONFIG_FB=y # CONFIG_FB_CFB_FILLRECT is not set # CONFIG_FB_CFB_COPYAREA is not set # CONFIG_FB_CFB_IMAGEBLIT is not set @@ -1504,7 +1504,10 @@ CONFIG_FB=m # CONFIG_FB_PM2 is not set # CONFIG_FB_CYBER2000 is not set # CONFIG_FB_ARC is not set +# CONFIG_FB_ASILIANT is not set +# CONFIG_FB_IMSTT is not set # CONFIG_FB_VGA16 is not set +# CONFIG_FB_VESA is not set CONFIG_VIDEO_SELECT=y # CONFIG_FB_HGA is not set # CONFIG_FB_S1D13XXX is not set diff --git a/config/kernel/kernel.config.i586.smp b/config/kernel/kernel.config.i586.smp index a33a9f565b..e71c682ce6 100644 --- a/config/kernel/kernel.config.i586.smp +++ b/config/kernel/kernel.config.i586.smp @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Linux kernel version: 2.6.16 -# Wed Nov 15 11:45:07 2006 +# Wed Nov 15 12:49:54 2006 # CONFIG_X86_32=y CONFIG_SEMAPHORE_SLEEPERS=y @@ -1488,7 +1488,7 @@ CONFIG_SENSORS_HDAPS=m # # Graphics support # -CONFIG_FB=m +CONFIG_FB=y # CONFIG_FB_CFB_FILLRECT is not set # CONFIG_FB_CFB_COPYAREA is not set # CONFIG_FB_CFB_IMAGEBLIT is not set @@ -1499,7 +1499,10 @@ CONFIG_FB=m # CONFIG_FB_PM2 is not set # CONFIG_FB_CYBER2000 is not set # CONFIG_FB_ARC is not set +# CONFIG_FB_ASILIANT is not set +# CONFIG_FB_IMSTT is not set # CONFIG_FB_VGA16 is not set +# CONFIG_FB_VESA is not set CONFIG_VIDEO_SELECT=y # CONFIG_FB_HGA is not set # CONFIG_FB_S1D13XXX is not set diff --git a/config/uClibc/busybox.config b/config/uClibc/busybox.config index 1025da9ba6..4d09475494 100644 --- a/config/uClibc/busybox.config +++ b/config/uClibc/busybox.config @@ -145,7 +145,7 @@ CONFIG_FEATURE_FANCY_ECHO=y # CONFIG_EXPR_MATH_SUPPORT_64 is not set # CONFIG_FALSE is not set # CONFIG_FOLD is not set -# CONFIG_HEAD is not set +CONFIG_HEAD=y # CONFIG_FEATURE_FANCY_HEAD is not set # CONFIG_HOSTID is not set # CONFIG_ID is not set @@ -168,8 +168,8 @@ CONFIG_MKDIR=y # CONFIG_FEATURE_MKDIR_LONG_OPTIONS is not set CONFIG_MKFIFO=y CONFIG_MKNOD=y -# CONFIG_MV is not set -# CONFIG_FEATURE_MV_LONG_OPTIONS is not set +CONFIG_MV=y +CONFIG_FEATURE_MV_LONG_OPTIONS=y CONFIG_NICE=y # CONFIG_NOHUP is not set # CONFIG_OD is not set @@ -177,9 +177,9 @@ CONFIG_NICE=y # CONFIG_PRINTF is not set # CONFIG_PWD is not set # CONFIG_REALPATH is not set -# CONFIG_RM is not set +CONFIG_RM=y # CONFIG_RMDIR is not set -# CONFIG_SEQ is not set +CONFIG_SEQ=y # CONFIG_SHA1SUM is not set CONFIG_SLEEP=y # CONFIG_FEATURE_FANCY_SLEEP is not set @@ -197,10 +197,10 @@ CONFIG_TEE=y CONFIG_TEST=y # CONFIG_FEATURE_TEST_64 is not set CONFIG_TOUCH=y -# CONFIG_TR is not set -# CONFIG_FEATURE_TR_CLASSES is not set -# CONFIG_FEATURE_TR_EQUIV is not set -# CONFIG_TRUE is not set +CONFIG_TR=y +CONFIG_FEATURE_TR_CLASSES=y +CONFIG_FEATURE_TR_EQUIV=y +CONFIG_TRUE=y # CONFIG_TTY is not set CONFIG_UNAME=y CONFIG_UNIQ=y @@ -208,10 +208,10 @@ CONFIG_UNIQ=y # CONFIG_UUDECODE is not set # CONFIG_UUENCODE is not set # CONFIG_WATCH is not set -# CONFIG_WC is not set +CONFIG_WC=y # CONFIG_WHO is not set # CONFIG_WHOAMI is not set -# CONFIG_YES is not set +CONFIG_YES=y # # Common options for cp and mv @@ -271,17 +271,17 @@ CONFIG_FEATURE_HUMAN_READABLE=y # CONFIG_ED is not set # CONFIG_PATCH is not set CONFIG_SED=y -# CONFIG_VI is not set -# CONFIG_FEATURE_VI_COLON is not set -# CONFIG_FEATURE_VI_YANKMARK is not set -# CONFIG_FEATURE_VI_SEARCH is not set -# CONFIG_FEATURE_VI_USE_SIGNALS is not set -# CONFIG_FEATURE_VI_DOT_CMD is not set -# CONFIG_FEATURE_VI_READONLY is not set -# CONFIG_FEATURE_VI_SETOPTS is not set -# CONFIG_FEATURE_VI_SET is not set -# CONFIG_FEATURE_VI_WIN_RESIZE is not set -# CONFIG_FEATURE_VI_OPTIMIZE_CURSOR is not set +CONFIG_VI=y +CONFIG_FEATURE_VI_COLON=y +CONFIG_FEATURE_VI_YANKMARK=y +CONFIG_FEATURE_VI_SEARCH=y +CONFIG_FEATURE_VI_USE_SIGNALS=y +CONFIG_FEATURE_VI_DOT_CMD=y +CONFIG_FEATURE_VI_READONLY=y +CONFIG_FEATURE_VI_SETOPTS=y +CONFIG_FEATURE_VI_SET=y +CONFIG_FEATURE_VI_WIN_RESIZE=y +CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y # # Finding Utilities diff --git a/langs/de/install/lang_de.c b/langs/de/install/lang_de.c index 2d5c7e4e91..5027e3a70a 100644 --- a/langs/de/install/lang_de.c +++ b/langs/de/install/lang_de.c @@ -327,6 +327,8 @@ char *de_tr[] = { "Automatische Erkennung fehlgeschlagen.", /* TR_PROBING_HARDWARE */ "Hardwareerkennung läuft...", +/* TR_PROBING_FOR_NICS */ +"Netzwerkkartenerkennung läuft...", /* TR_PROBLEM_SETTING_ADMIN_PASSWORD */ "Problem beim Setzen des %s Administrator-Passworts.", /* TR_PROBLEM_SETTING_ROOT_PASSWORD */ diff --git a/langs/en/install/lang_en.c b/langs/en/install/lang_en.c index c154a2aead..d7c3231ac0 100644 --- a/langs/en/install/lang_en.c +++ b/langs/en/install/lang_en.c @@ -323,6 +323,8 @@ char *en_tr[] = { "Auto detecting failed.", /* TR_PROBING_HARDWARE */ "Probing hardware...", +/* TR_PROBING_FOR_NICS */ +"Probing for NICs...", /* TR_PROBLEM_SETTING_ADMIN_PASSWORD */ "Problem setting %s 'admin' user password.", /* TR_PROBLEM_SETTING_ROOT_PASSWORD */ diff --git a/lfs/installer b/lfs/installer index 3e2b836b23..1f0f89fcf3 100644 --- a/lfs/installer +++ b/lfs/installer @@ -61,6 +61,7 @@ $(TARGET) : cd $(DIR_APP)/install && make CFLAGS="-Os -fomit-frame-pointer -Wall \ -DNAME='\"$(NAME)\"' -DSNAME='\"$(SNAME)\"' -DVERSION='\"$(VERSION)\"' \ -DSLOGAN='\"$(SLOGAN)\"' -DCONFIG_ROOT='\"$(CONFIG_ROOT)\"' -DKERNEL_VERSION='\"$(KVER)\"'" - cd $(DIR_APP)/install && install -v -m 0755 install probehw.sh installbootsplash.sh mountsource.sh /install/initrd/bin + cd $(DIR_APP)/install && install -v -m 0755 install probenic.sh \ + probecntrl.sh probehw.sh installbootsplash.sh mountsource.sh /install/initrd/bin @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/pxe b/lfs/pxe new file mode 100644 index 0000000000..2949db6885 --- /dev/null +++ b/lfs/pxe @@ -0,0 +1,64 @@ +############################################################################### +# This file is part of the IPCop Firewall. # +# # +# IPCop is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPCop is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPCop; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Makefiles are based on LFSMake, which is # +# Copyright (C) 2002 Rod Roard # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = ipfire + +THISAPP = pxe +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +install : $(TARGET) + +check : + +download : + +md5 : + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : + # Create install pxe package as an alternate way to boot during install + rm -rf /tmp/* + mkdir -p /tmp/$(VERSION) /tmp/pxelinux.cfg + cp /usr/lib/syslinux/pxelinux.0 /tmp + cp /install/cdrom/boot/isolinux/{instroot.gz,message,vmlinuz} /tmp/$(VERSION) + sed -e "s|message|$(VERSION)/message|" \ + -e "s|vmlinuz|$(VERSION)/vmlinuz|" \ + -e "s|instroot|$(VERSION)/instroot|" \ + /install/cdrom/boot/isolinux/isolinux.cfg \ + > /tmp/pxelinux.cfg/$(SNAME)-pxe-$(VERSION).model + chmod 444 /tmp/$(VERSION)/instroot.gz + cd /tmp && tar cvzf \ + /install/images/$(SNAME)-$(VERSION)-pxe-$(MACHINE).tgz * + rm -rf /tmp/* diff --git a/make.sh b/make.sh index 04186ee596..1a66343bd2 100644 --- a/make.sh +++ b/make.sh @@ -596,9 +596,9 @@ buildpackages() { # packages-list.txt is ready to be displayed for wiki page beautify message DONE - # Create ISO for CDROM + # Create images for install + ipfiremake pxe ipfiremake cdrom - rm -f $LFS/install/images/*usb* cp $LFS/install/images/{*.iso,*.tgz} $BASEDIR >> $LOGFILE 2>&1 # ipfirepackages diff --git a/src/install+setup/install/install.h b/src/install+setup/install/install.h index 1b004bc373..ecf122ddf3 100644 --- a/src/install+setup/install/install.h +++ b/src/install+setup/install/install.h @@ -37,7 +37,7 @@ int ejectcdrom(char *dev); int networkmenu(struct keyvalue *ethernetkv); /* net.c */ -int checktarball(char *); +int checktarball(char *, char *message); /* config.c */ int write_disk_configs(struct devparams *dp); @@ -47,12 +47,6 @@ int write_ethernet_configs(struct keyvalue *ethernetkv); /* pcmcia.c */ char * initialize_pcmcia (void); -/* upgrade_v12_v13.c */ -int upgrade_v12_v13(); - -/* upgrade_v130_v131.c */ -int upgrade_v130_v140(); - /* usb.c */ int initialize_usb(); int write_usb_modules_conf(); diff --git a/src/install+setup/install/main.c b/src/install+setup/install/main.c index e87ebb7e23..2756f3e720 100644 --- a/src/install+setup/install/main.c +++ b/src/install+setup/install/main.c @@ -394,31 +394,48 @@ int main(int argc, char *argv[]) // Starting hardware detection runcommandwithstatus("/bin/probehw.sh", ctr[TR_PROBING_HARDWARE]); - switch (mysystem("/bin/mountsource.sh")) { - case 0: - installtype = CDROM_INSTALL; - cdmounted = 1; - break; - case 1: - installtype = DISK_INSTALL; - break; - case 10: - errorbox(ctr[TR_NO_CDROM]); - goto EXIT; - } + /* CDROM INSTALL */ + if (installtype == CDROM_INSTALL) { - /* read source drive letter */ - if ((handle = fopen("/source_device", "r")) == NULL) { - errorbox("ERROR reading source_device"); + switch (mysystem("/bin/mountsource.sh")) { + case 0: + installtype = CDROM_INSTALL; + cdmounted = 1; + break; + case 1: + installtype = DISK_INSTALL; + break; + case 10: + errorbox(ctr[TR_NO_CDROM]); + goto EXIT; + } + + /* read source drive letter */ + if ((handle = fopen("/source_device", "r")) == NULL) { + errorbox("ERROR reading source_device"); + } + fgets(sourcedrive, 5, handle); + fprintf(flog, "Source drive: %s\n", sourcedrive); + fclose(handle); + + snprintf(cdromparams.devnode, STRING_SIZE, "/dev/%s", sourcedrive); + cdromparams.module = 0; + fprintf(flog, "Source device: %s\n", cdromparams.devnode); } - fgets(sourcedrive, 5, handle); - fprintf(flog, "Source drive: %s\n", sourcedrive); - fclose(handle); - - if (installtype == CDROM_INSTALL) { - snprintf(cdromparams.devnode, STRING_SIZE, "/dev/%s", sourcedrive); - cdromparams.module = 0; - fprintf(flog, "Source device: %s\n", cdromparams.devnode); + + /* Configure the network now! */ + if (installtype == URL_INSTALL) { + /* Network driver and params. */ + if (!(networkmenu(ethernetkv))) { + errorbox(ctr[TR_NETWORK_SETUP_FAILED]); + goto EXIT; + } + + /* Check for ipcop-.tbz2 */ + if (checktarball(SNAME "-" VERSION ".tbz2", ctr[TR_ENTER_URL])) { + errorbox(ctr[TR_NO_IPCOP_TARBALL_FOUND]); + goto EXIT; + } } /* Get device for the HD. This has to succeed. */ @@ -467,6 +484,7 @@ int main(int argc, char *argv[]) } else sprintf(harddrive, "hd%c", hdletter); + fprintf(flog, "Destination drive: %s\n", harddrive); /* load unattended configuration */ if (unattended) { @@ -571,13 +589,12 @@ int main(int argc, char *argv[]) handle = fopen("/tmp/partitiontable", "w"); - /* Make swapfile */ if (swap_file) { - fprintf(handle, ",%ld,L,*\n,%ld,S,\n,%ld,L,\n", + fprintf(handle, ",%ld,L,*\n,%ld,S,\n,%ld,L,\n,,L,\n", boot_partition, swap_file, root_partition); } else { - fprintf(handle, ",%ld,L,*\n,0,0,\n,%ld,L,\n", + fprintf(handle, ",%ld,L,*\n,0,0,\n,%ld,L,\n,,L,\n", boot_partition, root_partition); } @@ -625,7 +642,7 @@ int main(int argc, char *argv[]) goto EXIT; } -/* if (raid_disk) + if (raid_disk) snprintf(commandstring, STRING_SIZE, "/bin/mkreiserfs -f %sp4", hdparams.devnode); else snprintf(commandstring, STRING_SIZE, "/bin/mkreiserfs -f %s4", hdparams.devnode); @@ -634,7 +651,7 @@ int main(int argc, char *argv[]) { errorbox(ctr[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM]); goto EXIT; - } */ + } /* Mount harddisk. */ if (raid_disk) @@ -672,7 +689,7 @@ int main(int argc, char *argv[]) goto EXIT; } } -/* if (raid_disk) + if (raid_disk) snprintf(commandstring, STRING_SIZE, "/sbin/mount %sp4 /harddisk/var", hdparams.devnode); else snprintf(commandstring, STRING_SIZE, "/sbin/mount %s4 /harddisk/var", hdparams.devnode); @@ -680,7 +697,7 @@ int main(int argc, char *argv[]) { errorbox(ctr[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM]); goto EXIT; - } */ + } snprintf(commandstring, STRING_SIZE, "/bin/tar -C /harddisk -xvjf /cdrom/" SNAME "-" VERSION ".tbz2"); @@ -737,8 +754,14 @@ int main(int argc, char *argv[]) goto EXIT; } + /* mount proc filesystem */ + mysystem("mkdir /harddisk/proc"); + mysystem("/bin/mount -t proc none /harddisk/proc"); + mysystem("/bin/mount --bind /dev /harddisk/dev"); + /* if we detected SCSI then fixup */ - if ((handle = fopen("/scsidriver", "r"))) + mysystem("/bin/probecntrl.sh"); + if ((handle = fopen("/cntrldriver", "r"))) { char *driver; fgets(line, STRING_SIZE-1, handle); @@ -750,22 +773,21 @@ int main(int argc, char *argv[]) fprintf(flog, "Fixing up ipfirerd.img\n"); mysystem("/bin/chroot /harddisk /sbin/modprobe loop"); mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO); - snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata --with=ataraid /boot/ipfirerd.img %s", driver, KERNEL_VERSION); + snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata /boot/ipfirerd.img %s", driver, KERNEL_VERSION); runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]); - snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata --with=ataraid /boot/ipfirerd-smp.img %s-smp", driver, KERNEL_VERSION); + snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata /boot/ipfirerd-smp.img %s-smp", driver, KERNEL_VERSION); runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]); mysystem("/bin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf"); - } - } - + } + } - /* Build cache lang file */ - snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\""); - if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_LANG_CACHE])) - { - errorbox(ctr[TR_UNABLE_TO_INSTALL_LANG_CACHE]); - goto EXIT; - } + /* Build cache lang file */ + snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\""); + if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_LANG_CACHE])) + { + errorbox(ctr[TR_UNABLE_TO_INSTALL_LANG_CACHE]); + goto EXIT; + } if (raid_disk) sprintf(string, "root=%sp3", hdparams.devnode); @@ -778,11 +800,6 @@ int main(int argc, char *argv[]) /* restore permissions */ chmod("/harddisk/boot/grub/grubbatch", S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH); - /* mount proc filesystem */ - mysystem("mkdir /harddisk/proc"); - mysystem("/bin/mount -t proc none /harddisk/proc"); - mysystem("/bin/mount --bind /dev /harddisk/dev"); - snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /boot/grub/grubbatch"); if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_GRUB])) { @@ -833,7 +850,7 @@ EXIT: fcloseall(); system("/bin/swapoff /harddisk/swapfile"); - system("/sbin/umount /harddisk/var/log"); + system("/sbin/umount /harddisk/var"); system("/sbin/umount /harddisk/boot"); system("/sbin/umount /harddisk"); diff --git a/src/install+setup/install/net.c b/src/install+setup/install/net.c index 2aa84d5d1e..86d11dae17 100644 --- a/src/install+setup/install/net.c +++ b/src/install+setup/install/net.c @@ -6,8 +6,6 @@ * (c) Lawrence Manning, 2001 * Stuff for downloading the smoothwall tarball using wget. * - * $Id: net.c,v 1.8.2.2 2004/04/14 22:05:40 gespinasse Exp $ - * */ #include "install.h" @@ -19,11 +17,11 @@ extern char **ctr; static int got_url = 0; -char url[STRING_SIZE]; +char url[STRING_SIZE] = "http://";; -static int gettarballurl(); +static int gettarballurl(char *url, char *message); -int checktarball(char *file) +int checktarball(char *file, char *message) { int done; int tries = 0; @@ -32,7 +30,7 @@ int checktarball(char *file) done = 0; while (!done) { - if (!got_url && gettarballurl() != 1) + if (!got_url && gettarballurl(url, message) != 1) return 0; /* remove any successive /'s */ @@ -49,24 +47,22 @@ int checktarball(char *file) errorbox(ctr[TR_FAILED_TO_FIND]); got_url = 0; if (tries == 3) - return 0; + return 1; /* failure */ } tries++; } - return 1; + return 0; } -static int gettarballurl() +static int gettarballurl(char *url, char *message) { - char *values[] = { NULL, NULL }; /* pointers for the values. */ + char *values[] = { url, NULL }; /* pointers for the values. */ struct newtWinEntry entries[] = { { "", &values[0], 0,}, { NULL, NULL, 0 } }; char title[STRING_SIZE]; - char message[1000]; int rc; - sprintf(message, ctr[TR_ENTER_URL]); sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN); rc = newtWinEntries(title, message, 60, 5, 5, 50, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL); diff --git a/src/install+setup/install/probecntrl.sh b/src/install+setup/install/probecntrl.sh new file mode 100644 index 0000000000..1cfc23a348 --- /dev/null +++ b/src/install+setup/install/probecntrl.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +echo "Probing for SCSI controllers" +MODULE=`/bin/kudzu -qps -t 30 -c SCSI | grep driver | cut -d ' ' -f 2 | sort | uniq` + +if [ "$?" == "0" ]; then + echo $MODULE > /cntrldriver; + echo "Your controller is: $MODULE" + exit 0 +fi + +echo "No SCSI controller found" +exit 1 diff --git a/src/install+setup/install/probenic.sh b/src/install+setup/install/probenic.sh new file mode 100644 index 0000000000..a79309068f --- /dev/null +++ b/src/install+setup/install/probenic.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +NUMBER=$1 +MODULES=`/bin/kudzu -qps -t 30 -c NETWORK | grep driver | cut -d ' ' -f 2 | sort | uniq` + +if [ "$NUMBER" ]; then + NICS=`echo $MODULES | head -$NUMBER` +else + NICS=$MODULES +fi + +echo "$NICS" > /nicdriver diff --git a/src/install+setup/libsmooth/netstuff.c b/src/install+setup/libsmooth/netstuff.c index 090d0259fa..81ea3df568 100644 --- a/src/install+setup/libsmooth/netstuff.c +++ b/src/install+setup/libsmooth/netstuff.c @@ -1,638 +1,621 @@ -/* SmoothWall libsmooth. - * - * This program is distributed under the terms of the GNU General Public - * Licence. See the file COPYING for details. - * - * (c) Lawrence Manning, 2001 - * Contains network library functions. - * - * $Id: netstuff.c,v 1.19.2.7 2004/11/05 23:40:17 alanh Exp $ - * - */ - -#include "libsmooth.h" -#include - -extern FILE *flog; -extern char *mylog; - -extern char **ctr; - -newtComponent networkform; -newtComponent addressentry; -newtComponent netmaskentry; -newtComponent statictyperadio; -newtComponent dhcptyperadio; -newtComponent pppoetyperadio; -newtComponent pptptyperadio; -newtComponent dhcphostnameentry; - -/* acceptable character filter for IP and netmaks entry boxes */ -static int ip_input_filter(newtComponent entry, void * data, int ch, int cursor) -{ - if ((ch >= '0' && ch <= '9') || ch == '.' || ch == '\r' || ch >= NEWT_KEY_EXTRA_BASE) - return ch; - return 0; -} - -/* This is a groovie dialog for showing network info. Takes a keyvalue list, - * a colour and a dhcp flag. Shows the current settings, and rewrites them - * if necessary. DHCP flag sets wether to show the dhcp checkbox. */ -int changeaddress(struct keyvalue *kv, char *colour, int typeflag, - char *defaultdhcphostname) -{ - char *addressresult; - char *netmaskresult; - char *dhcphostnameresult; - struct newtExitStruct es; - newtComponent header; - newtComponent addresslabel; - newtComponent netmasklabel; - newtComponent dhcphostnamelabel; - newtComponent ok, cancel; - char message[1000]; - char temp[STRING_SIZE]; - char addressfield[STRING_SIZE]; - char netmaskfield[STRING_SIZE]; - char typefield[STRING_SIZE]; - char dhcphostnamefield[STRING_SIZE]; - int error; - int result = 0; - char type[STRING_SIZE]; - int startstatictype = 0; - int startdhcptype = 0; - int startpppoetype = 0; - int startpptptype = 0; - - /* Build some key strings. */ - sprintf(addressfield, "%s_ADDRESS", colour); - sprintf(netmaskfield, "%s_NETMASK", colour); - sprintf(typefield, "%s_TYPE", colour); - sprintf(dhcphostnamefield, "%s_DHCP_HOSTNAME", colour); - - sprintf(message, ctr[TR_INTERFACE], colour); - newtCenteredWindow(44, (typeflag ? 18 : 12), message); - - networkform = newtForm(NULL, NULL, 0); - - sprintf(message, ctr[TR_ENTER_THE_IP_ADDRESS_INFORMATION], colour); - header = newtTextboxReflowed(1, 1, message, 42, 0, 0, 0); - newtFormAddComponent(networkform, header); - - /* See if we need a dhcp checkbox. If we do, then we shift the contents - * of the window down two rows to make room. */ - if (typeflag) - { - strcpy(temp, "STATIC"); findkey(kv, typefield, temp); - if (strcmp(temp, "STATIC") == 0) startstatictype = 1; - if (strcmp(temp, "DHCP") == 0) startdhcptype = 1; - if (strcmp(temp, "PPPOE") == 0) startpppoetype = 1; - if (strcmp(temp, "PPTP") == 0) startpptptype = 1; - statictyperadio = newtRadiobutton(2, 4, ctr[TR_STATIC], startstatictype, NULL); - dhcptyperadio = newtRadiobutton(2, 5, "DHCP", startdhcptype, statictyperadio); - pppoetyperadio = newtRadiobutton(2, 6, "PPPOE", startpppoetype, dhcptyperadio); - pptptyperadio = newtRadiobutton(2, 7, "PPTP", startpptptype, pppoetyperadio); - newtFormAddComponents(networkform, statictyperadio, dhcptyperadio, - pppoetyperadio, pptptyperadio, NULL); - newtComponentAddCallback(statictyperadio, networkdialogcallbacktype, NULL); - newtComponentAddCallback(dhcptyperadio, networkdialogcallbacktype, NULL); - newtComponentAddCallback(pppoetyperadio, networkdialogcallbacktype, NULL); - newtComponentAddCallback(pptptyperadio, networkdialogcallbacktype, NULL); - dhcphostnamelabel = newtTextbox(2, 9, 18, 1, 0); - newtTextboxSetText(dhcphostnamelabel, ctr[TR_DHCP_HOSTNAME]); - strcpy(temp, defaultdhcphostname); - findkey(kv, dhcphostnamefield, temp); - dhcphostnameentry = newtEntry(20, 9, temp, 20, &dhcphostnameresult, 0); - newtFormAddComponent(networkform, dhcphostnamelabel); - newtFormAddComponent(networkform, dhcphostnameentry); - if (startdhcptype == 0) - newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); - } - /* Address */ - addresslabel = newtTextbox(2, (typeflag ? 11 : 4) + 0, 18, 1, 0); - newtTextboxSetText(addresslabel, ctr[TR_IP_ADDRESS_PROMPT]); - strcpy(temp, ""); - findkey(kv, addressfield, temp); - addressentry = newtEntry(20, (typeflag ? 11 : 4) + 0, temp, 20, &addressresult, 0); - newtEntrySetFilter(addressentry, ip_input_filter, NULL); - if (typeflag == 1 && startstatictype == 0 && startpptptype == 0 ) - newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); - newtFormAddComponent(networkform, addresslabel); - newtFormAddComponent(networkform, addressentry); - - /* Netmask */ - netmasklabel = newtTextbox(2, (typeflag ? 11 : 4) + 1, 18, 1, 0); - newtTextboxSetText(netmasklabel, ctr[TR_NETMASK_PROMPT]); - strcpy(temp, "255.255.255.0"); findkey(kv, netmaskfield, temp); - netmaskentry = newtEntry(20, (typeflag ? 11 : 4) + 1, temp, 20, &netmaskresult, 0); - newtEntrySetFilter(netmaskentry, ip_input_filter, NULL); - if (typeflag == 1 && startstatictype == 0 && startpptptype == 0 ) - newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); - - newtFormAddComponent(networkform, netmasklabel); - newtFormAddComponent(networkform, netmaskentry); - - /* Buttons. */ - ok = newtButton(8, (typeflag ? 14 : 7), ctr[TR_OK]); - cancel = newtButton(26, (typeflag ? 14 : 7), ctr[TR_CANCEL]); - - newtFormAddComponents(networkform, ok, cancel, NULL); - - newtRefresh(); - newtDrawForm(networkform); - - do - { - error = 0; - newtFormRun(networkform, &es); - - if (es.u.co == ok) - { - /* OK was pressed; verify the contents of each entry. */ - strcpy(message, ctr[TR_INVALID_FIELDS]); - - strcpy(type, "STATIC"); - if (typeflag) - gettype(type); - if (strcmp(type, "STATIC") == 0 || strcmp(type, "PPTP") == 0 ) - { - if (inet_addr(addressresult) == INADDR_NONE) - { - strcat(message, ctr[TR_IP_ADDRESS_CR]); - error = 1; - } - if (inet_addr(netmaskresult) == INADDR_NONE) - { - strcat(message, ctr[TR_NETWORK_MASK_CR]); - error = 1; - } - } - if (strcmp(type, "DHCP") == 0) - { - if (!strlen(dhcphostnameresult)) - { - strcat(message, ctr[TR_DHCP_HOSTNAME_CR]); - error = 1; - } - } - if (error) - errorbox(message); - else - { - /* No errors! Set new values, depending on dhcp flag etc. */ - if (typeflag) - { - replacekeyvalue(kv, dhcphostnamefield, dhcphostnameresult); - if (strcmp(type, "STATIC") != 0 && strcmp(type, "PPTP") != 0) - { - replacekeyvalue(kv, addressfield, "0.0.0.0"); - replacekeyvalue(kv, netmaskfield, "0.0.0.0"); - } - else - { - replacekeyvalue(kv, addressfield, addressresult); - replacekeyvalue(kv, netmaskfield, netmaskresult); - } - replacekeyvalue(kv, typefield, type); - } - else - { - replacekeyvalue(kv, addressfield, addressresult); - replacekeyvalue(kv, netmaskfield, netmaskresult); - } - - setnetaddress(kv, colour); - result = 1; - } - } - } - while (error); - - newtFormDestroy(networkform); - newtPopWindow(); - - return result; -} - -/* for pppoe: return string thats type STATIC, DHCP or PPPOE */ -int gettype(char *type) -{ - newtComponent selected = newtRadioGetCurrent(statictyperadio); - - if (selected == statictyperadio) - strcpy(type, "STATIC"); - else if (selected == dhcptyperadio) - strcpy(type, "DHCP"); - else if (selected == pppoetyperadio) - strcpy(type, "PPPOE"); - else if (selected == pptptyperadio) - strcpy(type, "PPTP"); - else - strcpy(type, "ERROR"); - - return 0; -} - -/* 0.9.9: calculates broadcast too. */ -int setnetaddress(struct keyvalue *kv, char *colour) -{ - char addressfield[STRING_SIZE]; - char netaddressfield[STRING_SIZE]; - char netmaskfield[STRING_SIZE]; - char broadcastfield[STRING_SIZE]; - char address[STRING_SIZE]; - char netmask[STRING_SIZE]; - unsigned long int intaddress; - unsigned long int intnetaddress; - unsigned long int intnetmask; - unsigned long int intbroadcast; - struct in_addr temp; - char *netaddress; - char *broadcast; - - /* Build some key strings. */ - sprintf(addressfield, "%s_ADDRESS", colour); - sprintf(netaddressfield, "%s_NETADDRESS", colour); - sprintf(netmaskfield, "%s_NETMASK", colour); - sprintf(broadcastfield, "%s_BROADCAST", colour); - - strcpy(address, ""); findkey(kv, addressfield, address); - strcpy(netmask, ""); findkey(kv, netmaskfield, netmask); - - /* Calculate netaddress. Messy.. */ - intaddress = inet_addr(address); - intnetmask = inet_addr(netmask); - - intnetaddress = intaddress & intnetmask; - temp.s_addr = intnetaddress; - netaddress = inet_ntoa(temp); - - replacekeyvalue(kv, netaddressfield, netaddress); - - intbroadcast = intnetaddress | ~intnetmask; - temp.s_addr = intbroadcast; - broadcast = inet_ntoa(temp); - - replacekeyvalue(kv, broadcastfield, broadcast); - - return 1; -} - -/* Called when dhcp flag is toggled. Toggle disabled state of other 3 - * controls. */ -void networkdialogcallbacktype(newtComponent cm, void *data) -{ - char type[STRING_SIZE]; - - gettype(type); - - if (strcmp(type, "STATIC") != 0 && strcmp(type, "PPTP") != 0 ) - { - newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); - newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); - } - else - { - newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET); - newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET); - } - if (strcmp(type, "DHCP") == 0) - newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET); - else - newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); - - newtRefresh(); - newtDrawForm(networkform); -} - -int interfacecheck(struct keyvalue *kv, char *colour) -{ - char temp[STRING_SIZE]; - char colourfields[NETCHANGE_TOTAL][STRING_SIZE]; - int c; - - sprintf(colourfields[ADDRESS], "%s_ADDRESS", colour); - sprintf(colourfields[NETADDRESS], "%s_NETADDRESS", colour); - sprintf(colourfields[NETMASK], "%s_NETMASK", colour); - - for (c = 0; c < 3; c++) - { - strcpy(temp, ""); findkey(kv, colourfields[c], temp); - if (!(strlen(temp))) return 0; - } - return 1; -} - -/* Network probing! */ -struct nic nics[] = { - { "100VG-AnyLan Network Adapters, HP J2585B, J2585A, etc", "hp100" }, - { "3Com EtherLink III", "3c509" }, - { "3Com 3c501", "3c501" }, - { "3Com ISA EtherLink XL", "3c515" }, - { "3Com 3c503 and 3c503/16", "3c503" }, - { "3Com EtherLink MC (3c523)", "3c523" }, - { "3Com EtherLink MC/32 (3c527)", "3c527" }, - { "3Com EtherLink Plus (3c505)", "3c505" }, - { "3Com EtherLink 16", "3c507" }, - { "3Com \"Corkscrew\" EtherLink PCI III/XL, etc.", "3c59x" }, - { "3Com Typhoon Family (3C990, 3CR990, and variants)", "typhoon" }, - { "Adaptec Starfire/DuraLAN", "starfire" }, - { "Alteon AceNIC/3Com 3C985/Netgear GA620 Gigabit", "acenic" }, - { "AMD8111 based 10/100 Ethernet Controller", "amd8111e" }, - { "AMD LANCE/PCnetAllied Telesis AT1500, J2405A, etc", "lance" }, - { "AMD PCnet32 and AMD PCnetPCI", "pcnet32" }, - { "Ansel Communications EISA 3200", "ac3200" }, - { "Apricot 680x0 VME, 82596 chipset", "82596" }, - { "AT1700/1720", "at1700" }, - { "Broadcom 4400", "b44" }, - { "Broadcom Tigon3", "tg3" }, - { "Cabletron E2100 series ethercards", "e2100" }, - { "CATC USB NetMate-based Ethernet", "catc" }, - { "CDC USB Ethernet", "CDCEther" }, - { "Crystal LAN CS8900/CS8920", "cs89x0" }, - { "Compaq Netelligent 10/100 TX PCI UTP, etc", "tlan" }, - { "D-Link DL2000-based Gigabit Ethernet", "dl2k" }, - { "Digi Intl. RightSwitch SE-X EISA and PCI", "dgrs" }, - { "Digital 21x4x Tulip PCI ethernet cards, etc.", "tulip" }, - { "Digital DEPCA & EtherWORKS,DEPCA, DE100, etc", "depca" }, - { "DM9102 PCI Fast Ethernet Adapter", "dmfe", }, - { "Dummy Network Card (testing)", "dummy", }, - { "EtherWORKS DE425 TP/COAX EISA, DE434 TP PCI, etc.", "de4x5" }, - { "EtherWORKS 3 (DE203, DE204 and DE205)", "ewrk3" }, - { "HP PCLAN/plus", "hp-plus" }, - { "HP LAN ethernet", "hp" }, - { "IBM LANA", "ibmlana" }, - { "ICL EtherTeam 16i/32" ,"eth16i" }, - { "Intel i82557/i82558 PCI EtherExpressPro", "e100" }, - { "Intel EtherExpress Cardbus Ethernet", "eepro100_cb" }, - { "Intel i82595 ISA EtherExpressPro10/10+ driver" ,"eepro" }, - { "Intel EtherExpress 16 (i82586)", "eexpress" }, - { "Intel Panther onboard i82596 driver", "lp486e" }, - { "Intel PRO/1000 Gigabit Ethernet", "e1000" }, - { "KLSI USB KL5USB101-based", "kaweth" }, - { "MiCom-Interlan NI5010 ethercard", "ni5010" }, - { "Mylex EISA LNE390A/B", "lne390", }, - { "Myson MTD-8xx PCI Ethernet", "fealnx" }, - { "National Semiconductor DP8381x" , "natsemi" }, - { "National Semiconductor DP83820" , "ns83820" }, - { "NE/2 MCA", "ne2" }, - { "NE2000 PCI cards, RealTEk RTL-8029, etc", "ne2k-pci" }, - { "NE1000 / NE2000 (non-pci)", "ne" }, - { "NI50 card (i82586 Ethernet chip)", "ni52" }, - { "NI6510, ni6510 EtherBlaster", "ni65" }, - { "Novell/Eagle/Microdyne NE3210 EISA", "ne3210" }, - { "NVidia Nforce2 Driver", "forcedeth" }, - { "Packet Engines Hamachi GNIC-II", "hamachi" }, - { "Packet Engines Yellowfin Gigabit-NIC", "yellowfin" }, - { "Pegasus/Pegasus-II USB ethernet", "pegasus" }, - { "PureData PDUC8028,WD8003 and WD8013 compatibles", "wd" }, - { "Racal-Interlan EISA ES3210", "es3210" }, - { "RealTek RTL-8139 Fast Ethernet", "8139too" }, - { "RealTek RTL-8139C+ series 10/100 PCI Ethernet", "8139cp" }, - { "RealTek RTL-8150 USB ethernet", "rtl8150" }, - { "RealTek RTL-8169 Gigabit Ethernet", "r8169" }, - { "SiS 900 PCI", "sis900" }, - { "SKnet MCA", "sk_mca" }, - { "SMC 9000 series of ethernet cards", "smc9194" }, - { "SMC EtherPower II", "epic100" }, - { "SMC Ultra/EtherEZ ISA/PnP Ethernet", "smc-ultra" }, - { "SMC Ultra32 EISA Ethernet", "smc-ultra32" }, - { "SMC Ultra MCA Ethernet", "smc-mca" }, - { "Sundance Alta", "sundance" }, - { "SysKonnect SK-98xx", "sk98lin" }, - { "Toshiba TC35815 Ethernet", "tc35815" }, - { "Tulip chipset Cardbus Ethernet", "tulip_cb" }, - { "USB Ethernet", "usbnet" }, - { "VIA Rhine PCI Fast Ethernet, etc", "via-rhine" }, - { "Winbond W89c840 Ethernet", "winbond-840" }, - { "Xircom Cardbus Ethernet", "xircom_cb" }, - { "Xircom (tulip-like) Cardbus Ethernet", "xircom_tulip_cb" }, - { NULL, NULL } -}; - -/* Funky routine for loading all drivers (cept those are already loaded.). */ -int probecards(char *driver, char *driveroptions) -{ - int c = 0; - int n = 0; - char message[1000]; - char commandstring[STRING_SIZE]; - - n = countcards(); - - /* PCMCIA Detection */ - runcommandwithstatus("cardmgr -o", - ctr[TR_LOADING_PCMCIA]); - - if (countcards() > n) - { - strcpy(driver, "pcmcia"); - strcpy(driveroptions,""); - return 1; - } - - /* Regular module detection */ - while (nics[c].modulename) - { - /* Skip dummy driver during autoprobe as it always succeeds */ - if (strncmp(nics[c].modulename, "dummy", strlen("dummy"))) - { - if (!checkformodule(nics[c].modulename)) { - sprintf(commandstring, "/sbin/modprobe %s", nics[c].modulename); - sprintf(message, ctr[TR_LOOKING_FOR_NIC], nics[c].description); - if (runcommandwithstatus(commandstring, message) == 0) - { - if (countcards() > n) { - strcpy(driver, nics[c].modulename); - strcpy(driveroptions, ""); - return 1; - } - } - } - } - c++; - } - strcpy(driver, ""); - strcpy(driveroptions, ""); - - return 0; -} - -/* A listbox for selected the card... with a * MANUAL * entry at top for - * manual module names. */ -int choosecards(char *driver, char *driveroptions) -{ - int c; - char **sections; - int drivercount; - int rc; - int choice; - char commandstring[STRING_SIZE]; - char message[STRING_SIZE]; - int done = 0; - - /* Count 'em */ - c = 0; drivercount = 0; - while (nics[c].modulename) - { - drivercount++; - c++; - } - drivercount++; - sections = malloc((drivercount + 1) * sizeof(char *)); - - /* Copy 'em. */ - c = 0; - sections[c] = ctr[TR_MANUAL]; - c++; - while (nics[c - 1].modulename) - { - sections[c] = nics[c - 1].description; - c++; - } - sections[c] = NULL; - - strcpy(driver, ""); - strcpy(driveroptions, ""); - - done = 0; choice = 1; - while (!done) - { - rc = newtWinMenu(ctr[TR_SELECT_NETWORK_DRIVER], - ctr[TR_SELECT_NETWORK_DRIVER_LONG], 50, 5, 5, 6, - sections, &choice, ctr[TR_OK], ctr[TR_CANCEL], NULL); - if (rc == 0 || rc == 1) - { - if (choice > 0) - { - /* Find module number, load module. */ - c = choice - 1; - - if (!checkformodule(nics[c].modulename)) - { - sprintf(commandstring, "/sbin/modprobe %s", nics[c].modulename); - sprintf(message, ctr[TR_LOOKING_FOR_NIC], nics[c].description); - if (runcommandwithstatus(commandstring, message) == 0) - { - strcpy(driver, nics[c].modulename); - strcpy(driveroptions, ""); - done = 1; - } - else - errorbox(ctr[TR_UNABLE_TO_LOAD_DRIVER_MODULE]); - } - else - errorbox(ctr[TR_THIS_DRIVER_MODULE_IS_ALREADY_LOADED]); - } - else - { - manualdriver(driver, driveroptions); - if (strlen(driver)) - done = 1; - } - } - else - done = 1; - } - - return 1; -} - -/* Manual entry for gurus. */ -int manualdriver(char *driver, char *driveroptions) -{ - char *values[] = { NULL, NULL }; /* pointers for the values. */ - struct newtWinEntry entries[] = - { { "", &values[0], 0,}, { NULL, NULL, 0 } }; - int rc; - char commandstring[STRING_SIZE]; - char *driverend; - - strcpy(driver, ""); - strcpy(driveroptions, ""); - - rc = newtWinEntries(ctr[TR_SELECT_NETWORK_DRIVER], - ctr[TR_MODULE_PARAMETERS], 50, 5, 5, 40, entries, - ctr[TR_OK], ctr[TR_CANCEL], NULL); - if (rc == 0 || rc == 1) - { - if (strlen(values[0])) - { - sprintf(commandstring, "/sbin/modprobe %s", values[0]); - if (runcommandwithstatus(commandstring, ctr[TR_LOADING_MODULE]) == 0) - { - if ((driverend = strchr(values[0], ' '))) - { - *driverend = '\0'; - strcpy(driver, values[0]); - strcpy(driveroptions, driverend + 1); - } - else - { - strcpy(driver, values[0]); - strcpy(driveroptions, ""); - } - } - else - errorbox(ctr[TR_UNABLE_TO_LOAD_DRIVER_MODULE]); - } - else - errorbox(ctr[TR_MODULE_NAME_CANNOT_BE_BLANK]); - } - free(values[0]); - - return 1; -} - -/* Returns the total number of nics current available as ethX devices. */ -int countcards(void) -{ - FILE *file; - char buffer[STRING_SIZE]; - char *start; - int niccount = 0; - - if (!(file = fopen("/proc/net/dev", "r"))) - { - fprintf(flog, "Unable to open /proc/net/dev in countnics()\n"); - return 0; - } - - while (fgets(buffer, STRING_SIZE, file)) - { - start = buffer; - while (*start == ' ') start++; - if (strncmp(start, "eth", strlen("eth")) == 0) - niccount++; - if (strncmp(start, "dummy", strlen("dummy")) == 0) - niccount++; - } - - fclose(file); - - return niccount; -} - -/* Finds the listed module name and copies the card description back. */ -int findnicdescription(char *modulename, char *description) -{ - int c = 0; - - if (strcmp(modulename, "pcmcia") == 0) { - strcpy(description, "PCMCIA Ethernet card"); - return 0; - } - - while (nics[c].description) - { - if (strcmp(nics[c].modulename, modulename) == 0) - { - strcpy(description, nics[c].description); - return 1; - } - c++; - } - - strcpy(description, "UNKNOWN"); - return 0; -} +/* SmoothWall libsmooth. + * + * This program is distributed under the terms of the GNU General Public + * Licence. See the file COPYING for details. + * + * (c) Lawrence Manning, 2001 + * Contains network library functions. + * + * $Id: netstuff.c,v 1.19.2.7 2004/11/05 23:40:17 alanh Exp $ + * + */ + +#include "libsmooth.h" +#include + +extern FILE *flog; +extern char *mylog; + +extern char **ctr; + +newtComponent networkform; +newtComponent addressentry; +newtComponent netmaskentry; +newtComponent statictyperadio; +newtComponent dhcptyperadio; +newtComponent pppoetyperadio; +newtComponent pptptyperadio; +newtComponent dhcphostnameentry; + +/* acceptable character filter for IP and netmaks entry boxes */ +static int ip_input_filter(newtComponent entry, void * data, int ch, int cursor) +{ + if ((ch >= '0' && ch <= '9') || ch == '.' || ch == '\r' || ch >= NEWT_KEY_EXTRA_BASE) + return ch; + return 0; +} + +/* This is a groovie dialog for showing network info. Takes a keyvalue list, + * a colour and a dhcp flag. Shows the current settings, and rewrites them + * if necessary. DHCP flag sets wether to show the dhcp checkbox. */ +int changeaddress(struct keyvalue *kv, char *colour, int typeflag, + char *defaultdhcphostname) +{ + char *addressresult; + char *netmaskresult; + char *dhcphostnameresult; + struct newtExitStruct es; + newtComponent header; + newtComponent addresslabel; + newtComponent netmasklabel; + newtComponent dhcphostnamelabel; + newtComponent ok, cancel; + char message[1000]; + char temp[STRING_SIZE]; + char addressfield[STRING_SIZE]; + char netmaskfield[STRING_SIZE]; + char typefield[STRING_SIZE]; + char dhcphostnamefield[STRING_SIZE]; + int error; + int result = 0; + char type[STRING_SIZE]; + int startstatictype = 0; + int startdhcptype = 0; + int startpppoetype = 0; + int startpptptype = 0; + + /* Build some key strings. */ + sprintf(addressfield, "%s_ADDRESS", colour); + sprintf(netmaskfield, "%s_NETMASK", colour); + sprintf(typefield, "%s_TYPE", colour); + sprintf(dhcphostnamefield, "%s_DHCP_HOSTNAME", colour); + + sprintf(message, ctr[TR_INTERFACE], colour); + newtCenteredWindow(44, (typeflag ? 18 : 12), message); + + networkform = newtForm(NULL, NULL, 0); + + sprintf(message, ctr[TR_ENTER_THE_IP_ADDRESS_INFORMATION], colour); + header = newtTextboxReflowed(1, 1, message, 42, 0, 0, 0); + newtFormAddComponent(networkform, header); + + /* See if we need a dhcp checkbox. If we do, then we shift the contents + * of the window down two rows to make room. */ + if (typeflag) + { + strcpy(temp, "STATIC"); findkey(kv, typefield, temp); + if (strcmp(temp, "STATIC") == 0) startstatictype = 1; + if (strcmp(temp, "DHCP") == 0) startdhcptype = 1; + if (strcmp(temp, "PPPOE") == 0) startpppoetype = 1; + if (strcmp(temp, "PPTP") == 0) startpptptype = 1; + statictyperadio = newtRadiobutton(2, 4, ctr[TR_STATIC], startstatictype, NULL); + dhcptyperadio = newtRadiobutton(2, 5, "DHCP", startdhcptype, statictyperadio); + pppoetyperadio = newtRadiobutton(2, 6, "PPPOE", startpppoetype, dhcptyperadio); + pptptyperadio = newtRadiobutton(2, 7, "PPTP", startpptptype, pppoetyperadio); + newtFormAddComponents(networkform, statictyperadio, dhcptyperadio, + pppoetyperadio, pptptyperadio, NULL); + newtComponentAddCallback(statictyperadio, networkdialogcallbacktype, NULL); + newtComponentAddCallback(dhcptyperadio, networkdialogcallbacktype, NULL); + newtComponentAddCallback(pppoetyperadio, networkdialogcallbacktype, NULL); + newtComponentAddCallback(pptptyperadio, networkdialogcallbacktype, NULL); + dhcphostnamelabel = newtTextbox(2, 9, 18, 1, 0); + newtTextboxSetText(dhcphostnamelabel, ctr[TR_DHCP_HOSTNAME]); + strcpy(temp, defaultdhcphostname); + findkey(kv, dhcphostnamefield, temp); + dhcphostnameentry = newtEntry(20, 9, temp, 20, &dhcphostnameresult, 0); + newtFormAddComponent(networkform, dhcphostnamelabel); + newtFormAddComponent(networkform, dhcphostnameentry); + if (startdhcptype == 0) + newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); + } + /* Address */ + addresslabel = newtTextbox(2, (typeflag ? 11 : 4) + 0, 18, 1, 0); + newtTextboxSetText(addresslabel, ctr[TR_IP_ADDRESS_PROMPT]); + strcpy(temp, ""); + findkey(kv, addressfield, temp); + addressentry = newtEntry(20, (typeflag ? 11 : 4) + 0, temp, 20, &addressresult, 0); + newtEntrySetFilter(addressentry, ip_input_filter, NULL); + if (typeflag == 1 && startstatictype == 0 && startpptptype == 0 ) + newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); + newtFormAddComponent(networkform, addresslabel); + newtFormAddComponent(networkform, addressentry); + + /* Netmask */ + netmasklabel = newtTextbox(2, (typeflag ? 11 : 4) + 1, 18, 1, 0); + newtTextboxSetText(netmasklabel, ctr[TR_NETMASK_PROMPT]); + strcpy(temp, "255.255.255.0"); findkey(kv, netmaskfield, temp); + netmaskentry = newtEntry(20, (typeflag ? 11 : 4) + 1, temp, 20, &netmaskresult, 0); + newtEntrySetFilter(netmaskentry, ip_input_filter, NULL); + if (typeflag == 1 && startstatictype == 0 && startpptptype == 0 ) + newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); + + newtFormAddComponent(networkform, netmasklabel); + newtFormAddComponent(networkform, netmaskentry); + + /* Buttons. */ + ok = newtButton(8, (typeflag ? 14 : 7), ctr[TR_OK]); + cancel = newtButton(26, (typeflag ? 14 : 7), ctr[TR_CANCEL]); + + newtFormAddComponents(networkform, ok, cancel, NULL); + + newtRefresh(); + newtDrawForm(networkform); + + do + { + error = 0; + newtFormRun(networkform, &es); + + if (es.u.co == ok) + { + /* OK was pressed; verify the contents of each entry. */ + strcpy(message, ctr[TR_INVALID_FIELDS]); + + strcpy(type, "STATIC"); + if (typeflag) + gettype(type); + if (strcmp(type, "STATIC") == 0 || strcmp(type, "PPTP") == 0 ) + { + if (inet_addr(addressresult) == INADDR_NONE) + { + strcat(message, ctr[TR_IP_ADDRESS_CR]); + error = 1; + } + if (inet_addr(netmaskresult) == INADDR_NONE) + { + strcat(message, ctr[TR_NETWORK_MASK_CR]); + error = 1; + } + } + if (strcmp(type, "DHCP") == 0) + { + if (!strlen(dhcphostnameresult)) + { + strcat(message, ctr[TR_DHCP_HOSTNAME_CR]); + error = 1; + } + } + if (error) + errorbox(message); + else + { + /* No errors! Set new values, depending on dhcp flag etc. */ + if (typeflag) + { + replacekeyvalue(kv, dhcphostnamefield, dhcphostnameresult); + if (strcmp(type, "STATIC") != 0 && strcmp(type, "PPTP") != 0) + { + replacekeyvalue(kv, addressfield, "0.0.0.0"); + replacekeyvalue(kv, netmaskfield, "0.0.0.0"); + } + else + { + replacekeyvalue(kv, addressfield, addressresult); + replacekeyvalue(kv, netmaskfield, netmaskresult); + } + replacekeyvalue(kv, typefield, type); + } + else + { + replacekeyvalue(kv, addressfield, addressresult); + replacekeyvalue(kv, netmaskfield, netmaskresult); + } + + setnetaddress(kv, colour); + result = 1; + } + } + } + while (error); + + newtFormDestroy(networkform); + newtPopWindow(); + + return result; +} + +/* for pppoe: return string thats type STATIC, DHCP or PPPOE */ +int gettype(char *type) +{ + newtComponent selected = newtRadioGetCurrent(statictyperadio); + + if (selected == statictyperadio) + strcpy(type, "STATIC"); + else if (selected == dhcptyperadio) + strcpy(type, "DHCP"); + else if (selected == pppoetyperadio) + strcpy(type, "PPPOE"); + else if (selected == pptptyperadio) + strcpy(type, "PPTP"); + else + strcpy(type, "ERROR"); + + return 0; +} + +/* 0.9.9: calculates broadcast too. */ +int setnetaddress(struct keyvalue *kv, char *colour) +{ + char addressfield[STRING_SIZE]; + char netaddressfield[STRING_SIZE]; + char netmaskfield[STRING_SIZE]; + char broadcastfield[STRING_SIZE]; + char address[STRING_SIZE]; + char netmask[STRING_SIZE]; + unsigned long int intaddress; + unsigned long int intnetaddress; + unsigned long int intnetmask; + unsigned long int intbroadcast; + struct in_addr temp; + char *netaddress; + char *broadcast; + + /* Build some key strings. */ + sprintf(addressfield, "%s_ADDRESS", colour); + sprintf(netaddressfield, "%s_NETADDRESS", colour); + sprintf(netmaskfield, "%s_NETMASK", colour); + sprintf(broadcastfield, "%s_BROADCAST", colour); + + strcpy(address, ""); findkey(kv, addressfield, address); + strcpy(netmask, ""); findkey(kv, netmaskfield, netmask); + + /* Calculate netaddress. Messy.. */ + intaddress = inet_addr(address); + intnetmask = inet_addr(netmask); + + intnetaddress = intaddress & intnetmask; + temp.s_addr = intnetaddress; + netaddress = inet_ntoa(temp); + + replacekeyvalue(kv, netaddressfield, netaddress); + + intbroadcast = intnetaddress | ~intnetmask; + temp.s_addr = intbroadcast; + broadcast = inet_ntoa(temp); + + replacekeyvalue(kv, broadcastfield, broadcast); + + return 1; +} + +/* Called when dhcp flag is toggled. Toggle disabled state of other 3 + * controls. */ +void networkdialogcallbacktype(newtComponent cm, void *data) +{ + char type[STRING_SIZE]; + + gettype(type); + + if (strcmp(type, "STATIC") != 0 && strcmp(type, "PPTP") != 0 ) + { + newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); + newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); + } + else + { + newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET); + newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET); + } + if (strcmp(type, "DHCP") == 0) + newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET); + else + newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); + + newtRefresh(); + newtDrawForm(networkform); +} + +int interfacecheck(struct keyvalue *kv, char *colour) +{ + char temp[STRING_SIZE]; + char colourfields[NETCHANGE_TOTAL][STRING_SIZE]; + int c; + + sprintf(colourfields[ADDRESS], "%s_ADDRESS", colour); + sprintf(colourfields[NETADDRESS], "%s_NETADDRESS", colour); + sprintf(colourfields[NETMASK], "%s_NETMASK", colour); + + for (c = 0; c < 3; c++) + { + strcpy(temp, ""); findkey(kv, colourfields[c], temp); + if (!(strlen(temp))) return 0; + } + return 1; +} + +/* Network probing! */ +struct nic nics[] = { + { "100VG-AnyLan Network Adapters, HP J2585B, J2585A, etc", "hp100" }, + { "3Com EtherLink III", "3c509" }, + { "3Com 3c501", "3c501" }, + { "3Com ISA EtherLink XL", "3c515" }, + { "3Com 3c503 and 3c503/16", "3c503" }, + { "3Com EtherLink MC (3c523)", "3c523" }, + { "3Com EtherLink MC/32 (3c527)", "3c527" }, + { "3Com EtherLink Plus (3c505)", "3c505" }, + { "3Com EtherLink 16", "3c507" }, + { "3Com \"Corkscrew\" EtherLink PCI III/XL, etc.", "3c59x" }, + { "3Com Typhoon Family (3C990, 3CR990, and variants)", "typhoon" }, + { "Adaptec Starfire/DuraLAN", "starfire" }, + { "Alteon AceNIC/3Com 3C985/Netgear GA620 Gigabit", "acenic" }, + { "AMD8111 based 10/100 Ethernet Controller", "amd8111e" }, + { "AMD LANCE/PCnetAllied Telesis AT1500, J2405A, etc", "lance" }, + { "AMD PCnet32 and AMD PCnetPCI", "pcnet32" }, + { "Ansel Communications EISA 3200", "ac3200" }, + { "Apricot 680x0 VME, 82596 chipset", "82596" }, + { "AT1700/1720", "at1700" }, + { "Broadcom 4400", "b44" }, + { "Broadcom Tigon3", "tg3" }, + { "Cabletron E2100 series ethercards", "e2100" }, + { "CATC USB NetMate-based Ethernet", "catc" }, + { "CDC USB Ethernet", "CDCEther" }, + { "Crystal LAN CS8900/CS8920", "cs89x0" }, + { "Compaq Netelligent 10/100 TX PCI UTP, etc", "tlan" }, + { "D-Link DL2000-based Gigabit Ethernet", "dl2k" }, + { "Digi Intl. RightSwitch SE-X EISA and PCI", "dgrs" }, + { "Digital 21x4x Tulip PCI ethernet cards, etc.", "tulip" }, + { "Digital DEPCA & EtherWORKS,DEPCA, DE100, etc", "depca" }, + { "DM9102 PCI Fast Ethernet Adapter", "dmfe", }, + { "Dummy Network Card (testing)", "dummy", }, + { "EtherWORKS DE425 TP/COAX EISA, DE434 TP PCI, etc.", "de4x5" }, + { "EtherWORKS 3 (DE203, DE204 and DE205)", "ewrk3" }, + { "HP PCLAN/plus", "hp-plus" }, + { "HP LAN ethernet", "hp" }, + { "IBM LANA", "ibmlana" }, + { "ICL EtherTeam 16i/32" ,"eth16i" }, + { "Intel i82557/i82558 PCI EtherExpressPro", "e100" }, + { "Intel EtherExpress Cardbus Ethernet", "eepro100_cb" }, + { "Intel i82595 ISA EtherExpressPro10/10+ driver" ,"eepro" }, + { "Intel EtherExpress 16 (i82586)", "eexpress" }, + { "Intel Panther onboard i82596 driver", "lp486e" }, + { "Intel PRO/1000 Gigabit Ethernet", "e1000" }, + { "KLSI USB KL5USB101-based", "kaweth" }, + { "MiCom-Interlan NI5010 ethercard", "ni5010" }, + { "Mylex EISA LNE390A/B", "lne390", }, + { "Myson MTD-8xx PCI Ethernet", "fealnx" }, + { "National Semiconductor DP8381x" , "natsemi" }, + { "National Semiconductor DP83820" , "ns83820" }, + { "NE/2 MCA", "ne2" }, + { "NE2000 PCI cards, RealTEk RTL-8029, etc", "ne2k-pci" }, + { "NE1000 / NE2000 (non-pci)", "ne" }, + { "NI50 card (i82586 Ethernet chip)", "ni52" }, + { "NI6510, ni6510 EtherBlaster", "ni65" }, + { "Novell/Eagle/Microdyne NE3210 EISA", "ne3210" }, + { "NVidia Nforce2 Driver", "forcedeth" }, + { "Packet Engines Hamachi GNIC-II", "hamachi" }, + { "Packet Engines Yellowfin Gigabit-NIC", "yellowfin" }, + { "Pegasus/Pegasus-II USB ethernet", "pegasus" }, + { "PureData PDUC8028,WD8003 and WD8013 compatibles", "wd" }, + { "Racal-Interlan EISA ES3210", "es3210" }, + { "RealTek RTL-8139 Fast Ethernet", "8139too" }, + { "RealTek RTL-8139C+ series 10/100 PCI Ethernet", "8139cp" }, + { "RealTek RTL-8150 USB ethernet", "rtl8150" }, + { "RealTek RTL-8169 Gigabit Ethernet", "r8169" }, + { "SiS 900 PCI", "sis900" }, + { "SKnet MCA", "sk_mca" }, + { "SMC 9000 series of ethernet cards", "smc9194" }, + { "SMC EtherPower II", "epic100" }, + { "SMC Ultra/EtherEZ ISA/PnP Ethernet", "smc-ultra" }, + { "SMC Ultra32 EISA Ethernet", "smc-ultra32" }, + { "SMC Ultra MCA Ethernet", "smc-mca" }, + { "Sundance Alta", "sundance" }, + { "SysKonnect SK-98xx", "sk98lin" }, + { "Toshiba TC35815 Ethernet", "tc35815" }, + { "Tulip chipset Cardbus Ethernet", "tulip_cb" }, + { "USB Ethernet", "usbnet" }, + { "VIA Rhine PCI Fast Ethernet, etc", "via-rhine" }, + { "Winbond W89c840 Ethernet", "winbond-840" }, + { "Xircom Cardbus Ethernet", "xircom_cb" }, + { "Xircom (tulip-like) Cardbus Ethernet", "xircom_tulip_cb" }, + { NULL, NULL } +}; + +/* Funky routine for loading all drivers (cept those are already loaded.). */ +int probecards(char *driver, char *driveroptions) +{ + char message[1000]; + char commandstring[STRING_SIZE]; + FILE *handle; + char line[STRING_SIZE]; + + sprintf(commandstring, "/bin/probenic.sh 1"); + sprintf(message, ctr[TR_PROBING_FOR_NICS]); + runcommandwithstatus(commandstring, message); + + if ((handle = fopen("/nicdriver", "r"))) + { + char *driver; + fgets(line, STRING_SIZE-1, handle); + fclose(handle); + line[strlen(line) - 1] = 0; + driver = strtok(line, "."); + fprintf(flog, "Detected NIC driver %s\n",driver); + if (strlen(driver) > 1) { + strcpy(driveroptions, ""); + return 1; + } + } + strcpy(driver, ""); + strcpy(driveroptions, ""); + + return 0; +} + +/* A listbox for selected the card... with a * MANUAL * entry at top for + * manual module names. */ +int choosecards(char *driver, char *driveroptions) +{ + int c; + char **sections; + int drivercount; + int rc; + int choice; + char commandstring[STRING_SIZE]; + char message[STRING_SIZE]; + int done = 0; + + /* Count 'em */ + c = 0; drivercount = 0; + while (nics[c].modulename) + { + drivercount++; + c++; + } + drivercount++; + sections = malloc((drivercount + 1) * sizeof(char *)); + + /* Copy 'em. */ + c = 0; + sections[c] = ctr[TR_MANUAL]; + c++; + while (nics[c - 1].modulename) + { + sections[c] = nics[c - 1].description; + c++; + } + sections[c] = NULL; + + strcpy(driver, ""); + strcpy(driveroptions, ""); + + done = 0; choice = 1; + while (!done) + { + rc = newtWinMenu(ctr[TR_SELECT_NETWORK_DRIVER], + ctr[TR_SELECT_NETWORK_DRIVER_LONG], 50, 5, 5, 6, + sections, &choice, ctr[TR_OK], ctr[TR_CANCEL], NULL); + if (rc == 0 || rc == 1) + { + if (choice > 0) + { + /* Find module number, load module. */ + c = choice - 1; + + if (!checkformodule(nics[c].modulename)) + { + sprintf(commandstring, "/sbin/modprobe %s", nics[c].modulename); + sprintf(message, ctr[TR_LOOKING_FOR_NIC], nics[c].description); + if (runcommandwithstatus(commandstring, message) == 0) + { + strcpy(driver, nics[c].modulename); + strcpy(driveroptions, ""); + done = 1; + } + else + errorbox(ctr[TR_UNABLE_TO_LOAD_DRIVER_MODULE]); + } + else + errorbox(ctr[TR_THIS_DRIVER_MODULE_IS_ALREADY_LOADED]); + } + else + { + manualdriver(driver, driveroptions); + if (strlen(driver)) + done = 1; + } + } + else + done = 1; + } + + return 1; +} + +/* Manual entry for gurus. */ +int manualdriver(char *driver, char *driveroptions) +{ + char *values[] = { NULL, NULL }; /* pointers for the values. */ + struct newtWinEntry entries[] = + { { "", &values[0], 0,}, { NULL, NULL, 0 } }; + int rc; + char commandstring[STRING_SIZE]; + char *driverend; + + strcpy(driver, ""); + strcpy(driveroptions, ""); + + rc = newtWinEntries(ctr[TR_SELECT_NETWORK_DRIVER], + ctr[TR_MODULE_PARAMETERS], 50, 5, 5, 40, entries, + ctr[TR_OK], ctr[TR_CANCEL], NULL); + if (rc == 0 || rc == 1) + { + if (strlen(values[0])) + { + sprintf(commandstring, "/sbin/modprobe %s", values[0]); + if (runcommandwithstatus(commandstring, ctr[TR_LOADING_MODULE]) == 0) + { + if ((driverend = strchr(values[0], ' '))) + { + *driverend = '\0'; + strcpy(driver, values[0]); + strcpy(driveroptions, driverend + 1); + } + else + { + strcpy(driver, values[0]); + strcpy(driveroptions, ""); + } + } + else + errorbox(ctr[TR_UNABLE_TO_LOAD_DRIVER_MODULE]); + } + else + errorbox(ctr[TR_MODULE_NAME_CANNOT_BE_BLANK]); + } + free(values[0]); + + return 1; +} + +/* Returns the total number of nics current available as ethX devices. */ +int countcards(void) +{ + FILE *file; + char buffer[STRING_SIZE]; + char *start; + int niccount = 0; + + if (!(file = fopen("/proc/net/dev", "r"))) + { + fprintf(flog, "Unable to open /proc/net/dev in countnics()\n"); + return 0; + } + + while (fgets(buffer, STRING_SIZE, file)) + { + start = buffer; + while (*start == ' ') start++; + if (strncmp(start, "eth", strlen("eth")) == 0) + niccount++; + if (strncmp(start, "dummy", strlen("dummy")) == 0) + niccount++; + } + + fclose(file); + + return niccount; +} + +/* Finds the listed module name and copies the card description back. */ +int findnicdescription(char *modulename, char *description) +{ + int c = 0; + + if (strcmp(modulename, "pcmcia") == 0) { + strcpy(description, "PCMCIA Ethernet card"); + return 0; + } + + while (nics[c].description) + { + if (strcmp(nics[c].modulename, modulename) == 0) + { + strcpy(description, nics[c].description); + return 1; + } + c++; + } + + strcpy(description, "UNKNOWN"); + return 0; +} -- 2.39.2