diff -Naur .config.orig .config --- .config.orig 1970-01-01 03:00:00.000000000 +0300 +++ .config 2007-01-02 10:25:58.000000000 +0200 @@ -0,0 +1,431 @@ +# +# Automatically generated make config: don't edit +# +HAVE_DOT_CONFIG=y + +# +# General Configuration +# +# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set +CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y +# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set +# CONFIG_FEATURE_VERBOSE_USAGE is not set +# CONFIG_FEATURE_INSTALLER is not set +# CONFIG_LOCALE_SUPPORT is not set +# CONFIG_FEATURE_DEVFS is not set +# CONFIG_FEATURE_DEVPTS is not set +# CONFIG_FEATURE_CLEAN_UP is not set +CONFIG_FEATURE_SUID=y +# CONFIG_FEATURE_SUID_CONFIG is not set +# CONFIG_SELINUX is not set + +# +# Build Options +# +# CONFIG_STATIC is not set +CONFIG_LFS=y +USING_CROSS_COMPILER=y +CROSS_COMPILER_PREFIX="powerpc-linux-uclibc-" +EXTRA_CFLAGS_OPTIONS="-Os" + +# +# Installation Options +# +CONFIG_INSTALL_NO_USR=y +PREFIX="./_install" + +# +# Archival Utilities +# +# CONFIG_AR is not set +# CONFIG_BUNZIP2 is not set +# CONFIG_CPIO is not set +# CONFIG_DPKG is not set +# CONFIG_DPKG_DEB is not set +CONFIG_GUNZIP=y +CONFIG_FEATURE_GUNZIP_UNCOMPRESS=y +CONFIG_GZIP=y +# CONFIG_RPM2CPIO is not set +# CONFIG_RPM is not set +CONFIG_TAR=y +CONFIG_FEATURE_TAR_CREATE=y +# CONFIG_FEATURE_TAR_BZIP2 is not set +# CONFIG_FEATURE_TAR_FROM is not set +CONFIG_FEATURE_TAR_GZIP=y +# CONFIG_FEATURE_TAR_COMPRESS is not set +# CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY is not set +CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y +# CONFIG_FEATURE_TAR_LONG_OPTIONS is not set +# CONFIG_UNCOMPRESS is not set +# CONFIG_UNZIP is not set + +# +# Common options for cpio and tar +# +# CONFIG_FEATURE_UNARCHIVE_TAPE is not set + +# +# Coreutils +# +CONFIG_BASENAME=y +# CONFIG_CAL is not set +CONFIG_CAT=y +CONFIG_CHGRP=y +CONFIG_CHMOD=y +CONFIG_CHOWN=y +CONFIG_CHROOT=y +CONFIG_CMP=y +CONFIG_CP=y +# CONFIG_CUT is not set +CONFIG_DATE=y +CONFIG_FEATURE_DATE_ISOFMT=y +# CONFIG_DD is not set +CONFIG_DF=y +# CONFIG_DIRNAME is not set +# CONFIG_DOS2UNIX is not set +# CONFIG_DU is not set +CONFIG_ECHO=y +CONFIG_FEATURE_FANCY_ECHO=y +CONFIG_ENV=y +CONFIG_EXPR=y +CONFIG_FALSE=y +# CONFIG_FOLD is not set +CONFIG_HEAD=y +# CONFIG_FEATURE_FANCY_HEAD is not set +# CONFIG_HOSTID is not set +CONFIG_ID=y +# CONFIG_INSTALL is not set +# CONFIG_LENGTH is not set +CONFIG_LN=y +# CONFIG_LOGNAME is not set +CONFIG_LS=y +CONFIG_FEATURE_LS_FILETYPES=y +CONFIG_FEATURE_LS_FOLLOWLINKS=y +# CONFIG_FEATURE_LS_RECURSIVE is not set +CONFIG_FEATURE_LS_SORTFILES=y +CONFIG_FEATURE_LS_TIMESTAMPS=y +CONFIG_FEATURE_LS_USERNAME=y +# CONFIG_FEATURE_LS_COLOR is not set +# CONFIG_MD5SUM is not set +CONFIG_MKDIR=y +# CONFIG_MKFIFO is not set +CONFIG_MKNOD=y +CONFIG_MV=y +# CONFIG_OD is not set +# CONFIG_PRINTF is not set +CONFIG_PWD=y +# CONFIG_REALPATH is not set +CONFIG_RM=y +# CONFIG_RMDIR is not set +# CONFIG_SEQ is not set +# CONFIG_SHA1SUM is not set +CONFIG_SLEEP=y +# CONFIG_FEATURE_FANCY_SLEEP is not set +# CONFIG_SORT is not set +# CONFIG_STTY is not set +CONFIG_SYNC=y +CONFIG_TAIL=y +# CONFIG_FEATURE_FANCY_TAIL is not set +# CONFIG_TEE is not set +CONFIG_TEST=y + +# +# test (forced enabled for use with shell) +# +# CONFIG_FEATURE_TEST_64 is not set +CONFIG_TOUCH=y +# CONFIG_TR is not set +CONFIG_TRUE=y +# CONFIG_TTY is not set +CONFIG_UNAME=y +# CONFIG_UNIQ is not set +# CONFIG_USLEEP is not set +# CONFIG_UUDECODE is not set +# CONFIG_UUENCODE is not set +# CONFIG_WATCH is not set +# CONFIG_WC is not set +# CONFIG_WHO is not set +# CONFIG_WHOAMI is not set +# CONFIG_YES is not set + +# +# Common options for cp and mv +# +# CONFIG_FEATURE_PRESERVE_HARDLINKS is not set + +# +# Common options for ls and more +# +CONFIG_FEATURE_AUTOWIDTH=y + +# +# Common options for df, du, ls +# +CONFIG_FEATURE_HUMAN_READABLE=y + +# +# Console Utilities +# +# CONFIG_CHVT is not set +# CONFIG_CLEAR is not set +# CONFIG_DEALLOCVT is not set +# CONFIG_DUMPKMAP is not set +# CONFIG_LOADFONT is not set +# CONFIG_LOADKMAP is not set +# CONFIG_OPENVT is not set +# CONFIG_RESET is not set +# CONFIG_SETKEYCODES is not set + +# +# Debian Utilities +# +# CONFIG_MKTEMP is not set +CONFIG_PIPE_PROGRESS=y +# CONFIG_READLINK is not set +# CONFIG_RUN_PARTS is not set +# CONFIG_START_STOP_DAEMON is not set +# CONFIG_WHICH is not set + +# +# Editors +# +# CONFIG_AWK is not set +# CONFIG_PATCH is not set +# CONFIG_SED 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 +# +CONFIG_FIND=y +CONFIG_FEATURE_FIND_MTIME=y +CONFIG_FEATURE_FIND_PERM=y +CONFIG_FEATURE_FIND_TYPE=y +CONFIG_FEATURE_FIND_XDEV=y +CONFIG_FEATURE_FIND_NEWER=y +CONFIG_FEATURE_FIND_INUM=y +CONFIG_GREP=y +CONFIG_FEATURE_GREP_EGREP_ALIAS=y +CONFIG_FEATURE_GREP_FGREP_ALIAS=y +CONFIG_FEATURE_GREP_CONTEXT=y +# CONFIG_XARGS is not set + +# +# Init Utilities +# +CONFIG_INIT=y +CONFIG_FEATURE_USE_INITTAB=y +# CONFIG_FEATURE_INITRD is not set +# CONFIG_FEATURE_INIT_COREDUMPS is not set +# CONFIG_FEATURE_EXTRA_QUIET is not set +# CONFIG_HALT is not set +CONFIG_POWEROFF=y +CONFIG_REBOOT=y +# CONFIG_MESG is not set + +# +# Login/Password Management Utilities +# +# CONFIG_USE_BB_PWD_GRP is not set +# CONFIG_ADDGROUP is not set +# CONFIG_DELGROUP is not set +# CONFIG_ADDUSER is not set +# CONFIG_DELUSER is not set +# CONFIG_GETTY is not set +# CONFIG_FEATURE_U_W_TMP is not set +CONFIG_LOGIN=y +CONFIG_FEATURE_SECURETTY=y +# CONFIG_PASSWD is not set +# CONFIG_SU is not set +# CONFIG_SULOGIN is not set +# CONFIG_VLOCK is not set + +# +# Common options for adduser, deluser, login, su +# +CONFIG_FEATURE_SHADOWPASSWDS=y + +# +# Miscellaneous Utilities +# +# CONFIG_ADJTIMEX is not set +CONFIG_CROND=y +# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set +CONFIG_CRONTAB=y +# CONFIG_DC is not set +# CONFIG_DEVFSD is not set +# CONFIG_LAST is not set +# CONFIG_HDPARM is not set +# CONFIG_MAKEDEVS is not set +# CONFIG_MT is not set +# CONFIG_RX is not set +# CONFIG_STRINGS is not set +# CONFIG_TIME is not set +# CONFIG_WATCHDOG is not set + +# +# Linux Module Utilities +# +CONFIG_INSMOD=y +CONFIG_FEATURE_2_4_MODULES=y +# CONFIG_FEATURE_2_6_MODULES is not set +CONFIG_FEATURE_INSMOD_VERSION_CHECKING=y +CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS=y +# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set +# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set +CONFIG_LSMOD=y +CONFIG_FEATURE_QUERY_MODULE_INTERFACE=y +CONFIG_MODPROBE=y +CONFIG_RMMOD=y +CONFIG_FEATURE_CHECK_TAINTED_MODULE=y + +# +# Networking Utilities +# +CONFIG_GOWEB=y +CONFIG_AUTOIP=y +# CONFIG_FEATURE_IPV6 is not set +CONFIG_ARPING=y +# CONFIG_FTPGET is not set +# CONFIG_FTPPUT is not set +CONFIG_HOSTNAME=y +# CONFIG_HTTPD is not set +CONFIG_IFCONFIG=y +CONFIG_FEATURE_IFCONFIG_STATUS=y +CONFIG_FEATURE_IFCONFIG_SLIP=y +CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y +CONFIG_FEATURE_IFCONFIG_HW=y +# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set +# CONFIG_IFUPDOWN is not set +# CONFIG_INETD is not set +# CONFIG_IP is not set +# CONFIG_IPCALC is not set +# CONFIG_IPADDR is not set +# CONFIG_IPLINK is not set +# CONFIG_IPROUTE is not set +# CONFIG_IPTUNNEL is not set +# CONFIG_NAMEIF is not set +# CONFIG_NC is not set +# CONFIG_NETSTAT is not set +# CONFIG_NSLOOKUP is not set +CONFIG_PING=y +CONFIG_FEATURE_FANCY_PING=y +CONFIG_ROUTE=y +# CONFIG_TELNET is not set +CONFIG_TELNETD=y +# CONFIG_FEATURE_TELNETD_INETD is not set +# CONFIG_TFTP is not set +# CONFIG_TRACEROUTE is not set +# CONFIG_VCONFIG is not set +# CONFIG_WGET is not set + +# +# udhcp Server/Client +# +# CONFIG_UDHCPD is not set +CONFIG_UDHCPC=y +# CONFIG_FEATURE_UDHCP_SYSLOG is not set +# CONFIG_FEATURE_UDHCP_DEBUG is not set + +# +# Process Utilities +# +CONFIG_FREE=y +CONFIG_KILL=y +# CONFIG_KILLALL is not set +CONFIG_PIDOF=y +CONFIG_PS=y +# CONFIG_RENICE is not set +# CONFIG_TOP is not set +# CONFIG_UPTIME is not set +# CONFIG_SYSCTL is not set + +# +# Another Bourne-like Shell +# +CONFIG_FEATURE_SH_IS_ASH=y +# CONFIG_FEATURE_SH_IS_HUSH is not set +# CONFIG_FEATURE_SH_IS_LASH is not set +# CONFIG_FEATURE_SH_IS_MSH is not set +# CONFIG_FEATURE_SH_IS_NONE is not set +CONFIG_ASH=y + +# +# Ash Shell Options +# +CONFIG_ASH_JOB_CONTROL=y +CONFIG_ASH_ALIAS=y +CONFIG_ASH_MATH_SUPPORT=y +# CONFIG_ASH_MATH_SUPPORT_64 is not set +# CONFIG_ASH_GETOPTS is not set +# CONFIG_ASH_CMDCMD is not set +CONFIG_ASH_MAIL=y +CONFIG_ASH_OPTIMIZE_FOR_SIZE=y +# CONFIG_ASH_RANDOM_SUPPORT is not set +# CONFIG_HUSH is not set +# CONFIG_LASH is not set +# CONFIG_MSH is not set + +# +# Bourne Shell Options +# +# CONFIG_FEATURE_SH_EXTRA_QUIET is not set +# CONFIG_FEATURE_SH_STANDALONE_SHELL is not set +CONFIG_FEATURE_COMMAND_EDITING=y +CONFIG_FEATURE_COMMAND_HISTORY=15 +# CONFIG_FEATURE_COMMAND_SAVEHISTORY is not set +CONFIG_FEATURE_COMMAND_TAB_COMPLETION=y +# CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION is not set +# CONFIG_FEATURE_SH_FANCY_PROMPT is not set + +# +# System Logging Utilities +# +# CONFIG_SYSLOGD is not set +# CONFIG_LOGGER is not set + +# +# Linux System Utilities +# +CONFIG_DMESG=y +# CONFIG_FBSET is not set +# CONFIG_FDFLUSH is not set +# CONFIG_FDFORMAT is not set +# CONFIG_FDISK is not set +FDISK_SUPPORT_LARGE_DISKS=y +CONFIG_FREERAMDISK=y +CONFIG_FSCK_MINIX=y +CONFIG_MKFS_MINIX=y + +# +# Minix filesystem support +# +CONFIG_FEATURE_MINIX2=y +# CONFIG_GETOPT is not set +CONFIG_HEXDUMP=y +CONFIG_HWCLOCK=y +# CONFIG_FEATURE_HWCLOCK_LONGOPTIONS is not set +CONFIG_LOSETUP=y +CONFIG_MKSWAP=y +CONFIG_MORE=y +CONFIG_FEATURE_USE_TERMIOS=y +CONFIG_PIVOT_ROOT=y +CONFIG_RDATE=y +CONFIG_SWAPONOFF=y +# CONFIG_MOUNT is not set +# CONFIG_UMOUNT is not set + +# +# Debugging Options +# +# CONFIG_DEBUG is not set diff -Naur Makefile.orig Makefile --- Makefile.orig 2004-10-08 10:45:08.000000000 +0300 +++ Makefile 2007-01-02 09:09:23.000000000 +0200 @@ -125,7 +125,7 @@ busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y) $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group - $(STRIPCMD) $@ + $(STRIPCMD) $@ -s busybox.links: $(top_srcdir)/applets/busybox.mkll include/config.h $(top_srcdir)/include/applets.h - $(SHELL) $^ >$@ diff -Naur include/applets.h.orig include/applets.h --- include/applets.h.orig 2004-08-27 02:01:34.000000000 +0300 +++ include/applets.h 2007-01-02 09:11:13.000000000 +0200 @@ -69,6 +69,9 @@ #ifdef CONFIG_ASH APPLET_NOUSAGE("ash", ash_main, _BB_DIR_BIN, _BB_SUID_NEVER) #endif +#ifdef CONFIG_AUTOIP + APPLET(autoip, autoip_main, _BB_DIR_BIN, _BB_SUID_NEVER) +#endif #ifdef CONFIG_AWK APPLET(awk, awk_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) #endif @@ -229,6 +232,9 @@ #ifdef CONFIG_GETTY APPLET(getty, getty_main, _BB_DIR_SBIN, _BB_SUID_NEVER) #endif +#ifdef CONFIG_GOWEB + APPLET(goweb, goweb_main, _BB_DIR_BIN, _BB_SUID_NEVER) +#endif #ifdef CONFIG_GREP APPLET(grep, grep_main, _BB_DIR_BIN, _BB_SUID_NEVER) #endif diff -Naur include/usage.h.orig include/usage.h --- include/usage.h.orig 2004-09-14 19:23:56.000000000 +0300 +++ include/usage.h 2007-01-02 09:13:22.000000000 +0200 @@ -2882,4 +2882,14 @@ #define zcat_full_usage \ "Uncompress to stdout." +#define autoip_trivial_usage \ + "[interface]" +#define autoip_full_usage \ + "autoip interface" + +#define goweb_trivial_usage \ + "[file]" +#define goweb_full_usage \ + "goweb file" + #endif /* __BB_USAGE_H__ */ diff -Naur init/init.c.orig init/init.c --- init/init.c.orig 2004-10-08 11:21:54.000000000 +0300 +++ init/init.c 2007-01-02 09:14:11.000000000 +0200 @@ -593,6 +593,9 @@ bb_full_write(1, press_enter, sizeof(press_enter) - 1); while(read(0, &c, 1) == 1 && c != '\n') ; + { + + } } #endif diff -Naur libbb/interface.c.orig libbb/interface.c --- libbb/interface.c.orig 2004-08-27 00:45:21.000000000 +0300 +++ libbb/interface.c 2007-01-02 09:15:42.000000000 +0200 @@ -2081,3 +2081,45 @@ close(skfd); exit(status < 0); } + +char* get_hw_info(char *ifname) +{ + int hf; + int res; + struct hwtype *hw; + struct interface *ife; + + if ((skfd = sockets_open(0)) < 0) { + bb_perror_msg_and_die("socket"); + } + + ife = lookup_interface(ifname); + res = do_if_fetch(ife); + + hf = ife->type; + + hw = get_hwntype(hf); + //printf(_("HWaddr %s "), hw->print(ife->hwaddr)); + + close(skfd); + return (hw->print(ife->hwaddr)); +} + +void get_ip_info(char *ifname, char *ip_str) +{ + int hf; + int res; + struct interface *ife; + struct aftype *ap; + + if ((skfd = sockets_open(0)) < 0) { + bb_perror_msg_and_die("socket"); + } + + ife = lookup_interface(ifname); + res = do_if_fetch(ife); + + ap = get_afntype(ife->addr.sa_family); + + strcpy(ip_str, ap->sprint(&ife->addr, 1) ); +} diff -Naur loginutils/passwd.c.orig loginutils/passwd.c --- loginutils/passwd.c.orig 2004-09-15 05:39:09.000000000 +0300 +++ loginutils/passwd.c 2007-01-02 09:21:25.000000000 +0200 @@ -336,7 +336,7 @@ pw->pw_name); time(&start); now = start; - while (difftime(now, start) < FAIL_DELAY) { + while ((now-start) < FAIL_DELAY) { sleep(FAIL_DELAY); time(&now); } diff -Naur networking/Config.in.orig networking/Config.in --- networking/Config.in.orig 2004-09-23 23:08:46.000000000 +0300 +++ networking/Config.in 2007-01-02 09:22:19.000000000 +0200 @@ -5,6 +5,18 @@ menu "Networking Utilities" +config CONFIG_GOWEB + bool "goweb -- by roy (used in samba project)" + default n + help + Redirect to our WEB Page + +config CONFIG_AUTOIP + bool "autoip -- by roy (used in samba project)" + default n + help + Autoip support + config CONFIG_FEATURE_IPV6 bool "Enable IPv6 support" default n diff -Naur networking/Makefile.in.orig networking/Makefile.in --- networking/Makefile.in.orig 2004-10-08 10:45:43.000000000 +0300 +++ networking/Makefile.in 2007-01-02 09:23:08.000000000 +0200 @@ -23,6 +23,8 @@ endif srcdir=$(top_srcdir)/networking NETWORKING-y:= +NETWORKING-$(CONFIG_AUTOIP) += autoip.o +NETWORKING-$(CONFIG_GOWEB) += goweb.o NETWORKING-$(CONFIG_ARPING) += arping.o NETWORKING-$(CONFIG_FTPGET) += ftpgetput.o NETWORKING-$(CONFIG_FTPPUT) += ftpgetput.o diff -Naur networking/arping.c.orig networking/arping.c --- networking/arping.c.orig 2003-09-26 03:33:18.000000000 +0300 +++ networking/arping.c 2007-01-02 09:26:40.000000000 +0200 @@ -497,3 +497,266 @@ sigprocmask(SIG_SETMASK, &osset, NULL); } } + +int my_arping_main(char* ifname, char* ifip) +{ + int socket_errno; + uid_t uid = getuid(); + char *device = "eth0"; + int ifindex = 0; + char *source = NULL; + char *target; + + s = socket(PF_PACKET, SOCK_DGRAM, 0); + socket_errno = errno; + +#if 0 + quit_on_reply = 0; + count = -1; +#endif + + setuid(uid); + + //parse parameter + dad++; + quit_on_reply=1; + device = ifname; + quiet = 0; + count = 2; + +#if 0 + while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:")) != EOF) + { + switch (ch) + { + case 'b': + broadcast_only = 1; + break; + case 'D': + dad++; + quit_on_reply = 1; + break; + case 'U': + unsolicited++; + break; + case 'A': + advert++; + unsolicited++; + break; + case 'q': + quiet++; + break; + case 'c': + count = atoi(optarg); + break; + case 'w': + timeout = atoi(optarg); + break; + case 'I': + if (optarg == NULL) + bb_show_usage(); + if (bb_strlen(optarg) > IF_NAMESIZE) { + bb_error_msg("Interface name `%s' must be less than %d", optarg, + IF_NAMESIZE); + exit(2); + } + device = optarg; + break; + case 'f': + quit_on_reply = 1; + break; + case 's': + source = optarg; + break; + case 'h': + case '?': + default: + bb_show_usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 1) + bb_show_usage(); +#endif + + target = ifip; + if( !quiet ) + { + printf("target = %s\n", target); + } + + if (s < 0) + { + bb_error_msg("socket"); + exit(socket_errno); + } + + { + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, device, IFNAMSIZ - 1); + if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { + bb_error_msg("Interface %s not found", device); + exit(-1); + } + ifindex = ifr.ifr_ifindex; + + if (ioctl(s, SIOCGIFFLAGS, (char *) &ifr)) { + bb_error_msg("SIOCGIFFLAGS"); + exit(-1); + } + if (!(ifr.ifr_flags & IFF_UP)) { + bb_error_msg("Interface %s is down", device); + exit(-1); + } + if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { + bb_error_msg("Interface %s is not ARPable", device); + exit(dad ? 0 : -1); + } + } + + if (!inet_aton(target, &dst)) { + struct hostent *hp; + + hp = gethostbyname2(target, AF_INET); + if (!hp) { + bb_error_msg("invalid or unknown target %s", target); + exit(-1); + } + memcpy(&dst, hp->h_addr, 4); + } + + if (source && !inet_aton(source, &src)) { + bb_error_msg("invalid source address %s", source); + exit(-1); + } + + if (!dad && unsolicited && src.s_addr == 0) + src = dst; + + if (!dad || src.s_addr) { + struct sockaddr_in saddr; + int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); + + if (probe_fd < 0) { + bb_error_msg("socket"); + exit(-1); + } + if (device) { + if (setsockopt + (probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, + strlen(device) + 1) == -1) + bb_error_msg("WARNING: interface %s is ignored", device); + } + memset(&saddr, 0, sizeof(saddr)); + saddr.sin_family = AF_INET; + if (src.s_addr) { + saddr.sin_addr = src; + if (bind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) { + bb_error_msg("bind"); + exit(-1); + } + } else if (!dad) { + int on = 1; + int alen = sizeof(saddr); + + saddr.sin_port = htons(1025); + saddr.sin_addr = dst; + + if (setsockopt + (probe_fd, SOL_SOCKET, SO_DONTROUTE, (char *) &on, + sizeof(on)) == -1) + perror("WARNING: setsockopt(SO_DONTROUTE)"); + if (connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) + == -1) { + bb_error_msg("connect"); + exit(-1); + } + if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == + -1) { + bb_error_msg("getsockname"); + exit(-1); + } + src = saddr.sin_addr; + } + close(probe_fd); + }; + + me.sll_family = AF_PACKET; + me.sll_ifindex = ifindex; + me.sll_protocol = htons(ETH_P_ARP); + if (bind(s, (struct sockaddr *) &me, sizeof(me)) == -1) { + bb_error_msg("bind"); + exit(-1); + } + + { + int alen = sizeof(me); + + if (getsockname(s, (struct sockaddr *) &me, &alen) == -1) { + bb_error_msg("getsockname"); + exit(-1); + } + } + if (me.sll_halen == 0) { + bb_error_msg("Interface \"%s\" is not ARPable (no ll address)", device); + exit(dad ? 0 : 2); + } + he = me; + memset(he.sll_addr, -1, he.sll_halen); + + if (!quiet) { + printf("ARPING to %s", inet_ntoa(dst)); + printf(" from %s via %s\n", inet_ntoa(src), + device ? device : "unknown"); + } + + if (!src.s_addr && !dad) { + bb_error_msg("no src address in the non-DAD mode"); + exit(-1); + } + + + { + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); + sa.sa_flags = SA_RESTART; + + sa.sa_handler = (void (*)(int)) finish; + sigaction(SIGINT, &sa, NULL); + + sa.sa_handler = (void (*)(int)) catcher; + sigaction(SIGALRM, &sa, NULL); + } + + catcher(); + + + while (1) + { + sigset_t sset, osset; + char packet[4096]; + struct sockaddr_ll from; + int alen = sizeof(from); + int cc; + + if ((cc = recvfrom(s, packet, sizeof(packet), 0, + (struct sockaddr *) &from, &alen)) < 0) { + perror("recvfrom"); + continue; + } + sigemptyset(&sset); + sigaddset(&sset, SIGALRM); + sigaddset(&sset, SIGINT); + sigprocmask(SIG_BLOCK, &sset, &osset); + + recv_pack(packet, cc, &from); + + sigprocmask(SIG_SETMASK, &osset, NULL); + } + return 0; +} diff -Naur networking/autoip.c.orig networking/autoip.c --- networking/autoip.c.orig 1970-01-01 03:00:00.000000000 +0300 +++ networking/autoip.c 2006-12-15 10:45:34.000000000 +0200 @@ -0,0 +1,159 @@ +//royc create this file for auto ip function +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AUTO_IP_DBG + +extern void bb_show_usage(void); +extern char* get_hw_info(char *ifname); +extern int my_arping_main(char* ifname, char* ifip); +extern int my_ifconfig_main(char*, char*); + +int autoip_main(int argc, char *argv[]) +{ + int status, i; + char ifname[16]; + char *hw_mac; + char *p; + char *set_ip; + char set_ip_1[4], set_ip_2[4]; + unsigned int to_int_1, to_int_2; + struct in_addr int_addr; + + + if( argc != 2 ) + { + bb_show_usage(); + } + + //copy network interface name + strcpy(ifname, argv[1]); + + //get hardware mac address + hw_mac = get_hw_info(ifname); + +#ifdef AUTO_IP_DBG + printf("\n%s HWaddr %s \n", ifname, hw_mac); +#endif + + //determine a IP for this interface + p = strtok(hw_mac, ":"); + for(i=0 ; i<5; i++) + { + p = strtok(NULL, ":"); + if(i==3) + { + strcpy(set_ip_1, p); + } + else if(i == 4) + { + strcpy(set_ip_2, p); + } + } + +#ifdef AUTO_IP_DBG + printf("get last 2 items from MAC = %s %s \n", set_ip_1, set_ip_2); +#endif + + //convert from string(hex) to int(dec) + to_int_1 = (unsigned int)strtol(set_ip_1, NULL, 16); + to_int_2 = (unsigned int)strtol(set_ip_2, NULL, 16); + + if(to_int_1 == 0 && to_int_2 == 0) + { + to_int_2 = 1; + } + + while(1) + { + p = (char*)&int_addr; + *p = 169; + *(p+1) = 254; + *(p+2) = to_int_1; + *(p+3) = to_int_2; + + set_ip = inet_ntoa(int_addr); + +#ifdef AUTO_IP_DBG + printf("IP Now = %s\n", set_ip); +#endif + + //ARP Ping function + if( fork() == 0 ) + { + +#ifdef AUTO_IP_DBG + printf("\n"); +#endif + + //start send arp ping + my_arping_main(ifname, set_ip); + } + else + { + wait(&status); + + i = WEXITSTATUS(status); + +#ifdef AUTO_IP_DBG + printf("ARPING return value = %d\n", i); +#endif + + //if i == 0 means that ARP Probe not get any reply + if(i == 0) + { + break; + } + else if(i == -1) + { + printf("Ohhh! System someting wrong!\n"); + return -1; + } + else + { + //increase IP + if(to_int_1 == 255 && to_int_2 == 255) + { + to_int_1 = 0; + to_int_2 = 1; + } + else if(to_int_2 == 255) + { + to_int_1 ++; + to_int_2 = 1; //royc 20040826 + } + else + { + to_int_2 ++; + } + continue; + } + } + } + + strcat(ifname, ":0"); + +#ifdef AUTO_IP_DBG + printf("\nifconfig: set interface %s to %s\n\n", ifname, set_ip); +#endif + + my_ifconfig_main(ifname, set_ip); + + return 0; +} + diff -Naur networking/goweb.c.orig networking/goweb.c --- networking/goweb.c.orig 1970-01-01 03:00:00.000000000 +0300 +++ networking/goweb.c 2006-12-15 10:45:34.000000000 +0200 @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern void get_ip_info(char *ifname, char *ip_str); +extern void bb_show_usage(void); + +int goweb_main(int argc, char *argv[]) +{ + char my_ip[16]; + FILE *fp; + char buf[80]; + + if( argc != 3 ) + { + bb_show_usage(); + } + + get_ip_info(argv[1], my_ip); + printf("get IP = %s\n", my_ip); + + fp = fopen(argv[2], "w+"); + if ( fp == NULL ) + { + return 0; + } + + fputs("", fp); + + fclose(fp); + + return 0; +} + diff -Naur networking/ifconfig.c.orig networking/ifconfig.c --- networking/ifconfig.c.orig 2004-03-31 14:30:08.000000000 +0300 +++ networking/ifconfig.c 2007-01-02 09:31:05.000000000 +0200 @@ -603,3 +603,308 @@ return (int) (*bufp); /* Error if we don't end at end of string. */ } #endif + +int my_ifconfig_main(char *ifname, char *ifip) +{ + int argc = 8; + char argv[9][16]; + char *cmd_end = "endcmd"; + + struct ifreq ifr; + struct sockaddr_in sai; +#ifdef CONFIG_FEATURE_IPV6 + struct sockaddr_in6 sai6; +#endif +#ifdef CONFIG_FEATURE_IFCONFIG_HW + struct sockaddr sa; +#endif + const struct arg1opt *a1op; + const struct options *op; + int sockfd; /* socket fd we use to manipulate stuff with */ + int goterr; + int selector; +#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS + unsigned int mask; + unsigned int did_flags; + unsigned int sai_hostname, sai_netmask; +#else + unsigned char mask; + unsigned char did_flags; +#endif + char *p; + char host[128]; + int ii=0; + + goterr = 0; + did_flags = 0; +#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS + sai_hostname = 0; + sai_netmask = 0; +#endif + + strcpy(argv[0], "ifconfig"); + strcpy(argv[1], ifname); + strcpy(argv[2], ifip); + strcpy(argv[3], "netmask"); + strcpy(argv[4], "255.255.0.0"); + strcpy(argv[5], "broadcast"); + strcpy(argv[6], "169.254.255.255"); + strcpy(argv[7], "up"); + strcpy(argv[8], cmd_end); + + + /* skip argv[0] */ + //++argv; + ++ii; + --argc; + +#ifdef CONFIG_FEATURE_IFCONFIG_STATUS + if ((argc > 0) && (((*argv)[1] == '-') && ((*argv)[2] == 'a') && !(*argv)[3])) + { + interface_opt_a = 1; + --argc; + //++argv; + ++ii; + } +#endif + + if (argc <= 1) { +#ifdef CONFIG_FEATURE_IFCONFIG_STATUS + return display_interfaces(argc ? *argv : NULL); +#else + bb_error_msg_and_die + ("ifconfig was not compiled with interface status display support."); +#endif + } + + /* Create a channel to the NET kernel. */ + if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + bb_perror_msg_and_die("socket"); + } + + /* get interface name */ + safe_strncpy(ifr.ifr_name, argv[ii], IFNAMSIZ); + + /* Process the remaining arguments. */ + //while (*++argv != (char *) NULL) + //while (argv[++ii] != (char *) NULL) + while( strcmp(argv[++ii], cmd_end) != 0) + { + p = argv[ii]; + mask = N_MASK; + if (*p == '-') { /* If the arg starts with '-'... */ + ++p; /* advance past it and */ + mask = M_MASK; /* set the appropriate mask. */ + } + for (op = OptArray; op->name; op++) { /* Find table entry. */ + if (strcmp(p, op->name) == 0) { /* If name matches... */ + if ((mask &= op->flags)) { /* set the mask and go. */ + goto FOUND_ARG;; + } + /* If we get here, there was a valid arg with an */ + /* invalid '-' prefix. */ + ++goterr; + goto LOOP; + } + } + + /* We fell through, so treat as possible hostname. */ + a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1; + mask = op->arg_flags; + goto HOSTNAME; + + FOUND_ARG: + if (mask & ARG_MASK) { + mask = op->arg_flags; + a1op = Arg1Opt + (op - OptArray); + if (mask & A_NETMASK & did_flags) { + bb_show_usage(); + } + //if (*++argv == NULL) + //if (argv[++ii] == NULL) + if( strcmp(argv[++ii], cmd_end) == 0 ) + { + if (mask & A_ARG_REQ) { + bb_show_usage(); + } else { + //--argv; + --ii; + mask &= A_SET_AFTER; /* just for broadcast */ + } + } else { /* got an arg so process it */ + HOSTNAME: + did_flags |= (mask & (A_NETMASK|A_HOSTNAME)); + if (mask & A_CAST_HOST_COPY) { +#ifdef CONFIG_FEATURE_IFCONFIG_HW + if (mask & A_CAST_RESOLVE) { +#endif +#ifdef CONFIG_FEATURE_IPV6 + char *prefix; + int prefix_len = 0; +#endif + + safe_strncpy(host, argv[ii], (sizeof host)); +#ifdef CONFIG_FEATURE_IPV6 + if ((prefix = strchr(host, '/'))) { + prefix_len = atol(prefix + 1); + if ((prefix_len < 0) || (prefix_len > 128)) { + ++goterr; + goto LOOP; + } + *prefix = 0; + } +#endif + + sai.sin_family = AF_INET; + sai.sin_port = 0; + if (!strcmp(host, bb_INET_default)) { + /* Default is special, meaning 0.0.0.0. */ + sai.sin_addr.s_addr = INADDR_ANY; +#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS + } else if (((host[0] == '+') && !host[1]) && (mask & A_BROADCAST) && + (did_flags & (A_NETMASK|A_HOSTNAME)) == (A_NETMASK|A_HOSTNAME)) { + /* + is special, meaning broadcast is derived. */ + sai.sin_addr.s_addr = (~sai_netmask) | (sai_hostname & sai_netmask); +#endif +#ifdef CONFIG_FEATURE_IPV6 + } else if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > 0) { + int sockfd6; + struct in6_ifreq ifr6; + + memcpy((char *) &ifr6.ifr6_addr, + (char *) &sai6.sin6_addr, + sizeof(struct in6_addr)); + + /* Create a channel to the NET kernel. */ + if ((sockfd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { + bb_perror_msg_and_die("socket6"); + } + if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { + perror("SIOGIFINDEX"); + ++goterr; + continue; + } + ifr6.ifr6_ifindex = ifr.ifr_ifindex; + ifr6.ifr6_prefixlen = prefix_len; + if (ioctl(sockfd6, a1op->selector, &ifr6) < 0) { + perror(a1op->name); + ++goterr; + } + continue; +#endif + } else if (inet_aton(host, &sai.sin_addr) == 0) { + /* It's not a dotted quad. */ + ++goterr; + continue; + } +#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS + if (mask & A_HOSTNAME) { + sai_hostname = sai.sin_addr.s_addr; + } + if (mask & A_NETMASK) { + sai_netmask = sai.sin_addr.s_addr; + } +#endif + p = (char *) &sai; +#ifdef CONFIG_FEATURE_IFCONFIG_HW + } else { /* A_CAST_HOST_COPY_IN_ETHER */ + /* This is the "hw" arg case. */ + //if (strcmp("ether", *argv) || (*++argv == NULL)) + //if (strcmp("ether", argv[ii]) || (argv[++ii] == NULL)) + if (strcmp("ether", argv[ii]) || (strcmp(argv[++ii], cmd_end) == 0)) + { + bb_show_usage(); + } + safe_strncpy(host, argv[ii], (sizeof host)); + if (in_ether(host, &sa)) { + bb_error_msg("invalid hw-addr %s", host); + ++goterr; + continue; + } + p = (char *) &sa; + } +#endif + memcpy((((char *) (&ifr)) + a1op->ifr_offset), + p, sizeof(struct sockaddr)); + } else { + unsigned int i = strtoul(argv[ii], NULL, 0); + + p = ((char *) (&ifr)) + a1op->ifr_offset; +#ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ + if (mask & A_MAP_TYPE) { + if (ioctl(sockfd, SIOCGIFMAP, &ifr) < 0) { + ++goterr; + continue; + } + if ((mask & A_MAP_UCHAR) == A_MAP_UCHAR) { + *((unsigned char *) p) = i; + } else if (mask & A_MAP_USHORT) { + *((unsigned short *) p) = i; + } else { + *((unsigned long *) p) = i; + } + } else +#endif + if (mask & A_CAST_CHAR_PTR) { + *((caddr_t *) p) = (caddr_t) i; + } else { /* A_CAST_INT */ + *((int *) p) = i; + } + } + + if (ioctl(sockfd, a1op->selector, &ifr) < 0) { + perror(a1op->name); + ++goterr; + continue; + } +#ifdef QUESTIONABLE_ALIAS_CASE + if (mask & A_COLON_CHK) { + /* + * Don't do the set_flag() if the address is an alias with + * a - at the end, since it's deleted already! - Roman + * + * Should really use regex.h here, not sure though how well + * it'll go with the cross-platform support etc. + */ + char *ptr; + short int found_colon = 0; + + for (ptr = ifr.ifr_name; *ptr; ptr++) { + if (*ptr == ':') { + found_colon++; + } + } + + if (found_colon && *(ptr - 1) == '-') { + continue; + } + } +#endif + } + if (!(mask & A_SET_AFTER)) { + continue; + } + mask = N_SET; + } + + if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { + perror("SIOCGIFFLAGS"); + ++goterr; + } else { + selector = op->selector; + if (mask & SET_MASK) { + ifr.ifr_flags |= selector; + } else { + ifr.ifr_flags &= ~selector; + } + if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) { + perror("SIOCSIFFLAGS"); + ++goterr; + } + } + LOOP: + continue; + } /* end of while-loop */ + + return goterr; +} diff -Naur networking/udhcp/dhcpc.c.orig networking/udhcp/dhcpc.c --- networking/udhcp/dhcpc.c.orig 2004-05-19 11:29:05.000000000 +0300 +++ networking/udhcp/dhcpc.c 2007-01-02 09:37:50.000000000 +0200 @@ -68,6 +68,7 @@ clientid: NULL, hostname: NULL, ifindex: 0, + def_ip: "192.168.1.2", arp: "\0\0\0\0\0\0", /* appease gcc-3.0 */ }; @@ -191,6 +192,7 @@ long now; int max_fd; int sig; + char buf[256]; static const struct option arg_options[] = { {"clientid", required_argument, 0, 'c'}, @@ -205,13 +207,14 @@ {"request", required_argument, 0, 'r'}, {"script", required_argument, 0, 's'}, {"version", no_argument, 0, 'v'}, + {"defaultip", required_argument, 0, 'x'}, {0, 0, 0, 0} }; /* get options */ while (1) { int option_index = 0; - c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index); + c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:vx:", arg_options, &option_index); if (c == -1) break; switch (c) { @@ -261,6 +264,9 @@ printf("udhcpcd, version %s\n\n", VERSION); return 0; break; + case 'x': + client_config.def_ip = optarg; + break; default: show_usage(); } @@ -328,6 +334,8 @@ run_script(NULL, "leasefail"); if (client_config.background_if_no_lease) { LOG(LOG_INFO, "No lease, forking to background."); + sprintf(buf, "ifconfig br0 %s", client_config.def_ip); + system(buf); client_background(); } else if (client_config.abort_if_no_lease) { LOG(LOG_INFO, "No lease, failing."); @@ -335,7 +343,7 @@ } /* wait to try again */ packet_num = 0; - timeout = now + 60; + timeout = now + 30; } break; case RENEW_REQUESTED: diff -Naur networking/udhcp/dhcpc.h.orig networking/udhcp/dhcpc.h --- networking/udhcp/dhcpc.h.orig 2004-01-31 01:45:12.000000000 +0200 +++ networking/udhcp/dhcpc.h 2007-01-02 09:38:25.000000000 +0200 @@ -28,6 +28,7 @@ uint8_t *clientid; /* Optional client id to use */ uint8_t *hostname; /* Optional hostname to use */ int ifindex; /* Index number of the interface to use */ + char *def_ip; uint8_t arp[6]; /* Our arp address */ }; diff -Naur util-linux/rdate.c.orig util-linux/rdate.c --- util-linux/rdate.c.orig 2004-01-18 20:18:33.000000000 +0200 +++ util-linux/rdate.c 2007-01-02 09:49:38.000000000 +0200 @@ -78,20 +78,31 @@ int rdate_main(int argc, char **argv) { time_t remote_time; + struct tm *p; int opt; int setdate = 1; int printdate = 1; + int setzone = 1; + int zone = 0; /* Interpret command line args */ - while ((opt = getopt(argc, argv, "sp")) > 0) { + while ((opt = getopt(argc, argv, "spz:")) > 0) { switch (opt) { case 's': printdate = 0; setdate = 1; + setzone = 0; break; case 'p': printdate = 1; setdate = 0; + setzone = 0; + break; + case 'z': + printdate = 0; + setdate = 1; + setzone = 1; + zone = atoi(optarg); break; default: bb_show_usage(); @@ -107,6 +118,12 @@ time_t current_time; time(¤t_time); + if(setzone) + { + p=localtime(&remote_time); + p->tm_hour += zone; + remote_time=mktime(p); + } if (current_time == remote_time) bb_error_msg("Current time matches remote time."); else