From: David van Moolenbroek Date: Tue, 14 Feb 2017 17:08:55 +0000 (+0000) Subject: Retire MINIX ifconfig(8) X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=refs%2Fchanges%2F34%2F3434%2F1;p=minix.git Retire MINIX ifconfig(8) Change-Id: I26f3ceff01bbd31e4c009752c7454a58e8a72abf --- diff --git a/distrib/sets/lists/minix-base/mi b/distrib/sets/lists/minix-base/mi index 0d94a8b31..9c618f631 100644 --- a/distrib/sets/lists/minix-base/mi +++ b/distrib/sets/lists/minix-base/mi @@ -377,7 +377,7 @@ ./usr/bin/host minix-base ./usr/bin/hostaddr minix-base ./usr/bin/id minix-base -./usr/bin/ifconfig minix-base +./usr/bin/ifconfig minix-base obsolete ./usr/bin/ifdef minix-base ./usr/bin/in.rshd minix-base obsolete ./usr/bin/in.telnetd minix-base diff --git a/distrib/sets/lists/minix-debug/mi b/distrib/sets/lists/minix-debug/mi index 866978bf7..6882a5fca 100644 --- a/distrib/sets/lists/minix-debug/mi +++ b/distrib/sets/lists/minix-debug/mi @@ -294,7 +294,7 @@ ./usr/libdata/debug/usr/bin/host.debug minix-debug debug ./usr/libdata/debug/usr/bin/hostaddr.debug minix-debug debug ./usr/libdata/debug/usr/bin/id.debug minix-debug debug -./usr/libdata/debug/usr/bin/ifconfig.debug minix-debug debug +./usr/libdata/debug/usr/bin/ifconfig.debug minix-debug debug,obsolete ./usr/libdata/debug/usr/bin/ifdef.debug minix-debug debug ./usr/libdata/debug/usr/bin/in.telnetd.debug minix-debug debug ./usr/libdata/debug/usr/bin/indent.debug minix-debug debug diff --git a/distrib/sets/lists/minix-man/mi b/distrib/sets/lists/minix-man/mi index 38fbc48f0..943654a11 100644 --- a/distrib/sets/lists/minix-man/mi +++ b/distrib/sets/lists/minix-man/mi @@ -3400,7 +3400,7 @@ ./usr/man/man8/halt.8 minix-man ./usr/man/man8/httpd.8 minix-man obsolete ./usr/man/man8/i2cscan.8 minix-man -./usr/man/man8/ifconfig.8 minix-man +./usr/man/man8/ifconfig.8 minix-man obsolete ./usr/man/man8/in.httpd.8 minix-man obsolete ./usr/man/man8/inet.8 minix-man obsolete ./usr/man/man8/init.8 minix-man diff --git a/minix/commands/Makefile b/minix/commands/Makefile index b9d62ef8f..115811adb 100644 --- a/minix/commands/Makefile +++ b/minix/commands/Makefile @@ -11,7 +11,7 @@ SUBDIR= add_route arp at backup \ eject \ fix format fsck.mfs \ gcov-pull host \ - hostaddr ifconfig ifdef \ + hostaddr ifdef \ intr irdpd isoread \ loadkeys loadramdisk logger look lp \ lpd lspci mail MAKEDEV \ diff --git a/minix/commands/ifconfig/Makefile b/minix/commands/ifconfig/Makefile deleted file mode 100644 index 03f0f3c9e..000000000 --- a/minix/commands/ifconfig/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -PROG= ifconfig -MAN= ifconfig.8 - -.include diff --git a/minix/commands/ifconfig/ifconfig.8 b/minix/commands/ifconfig/ifconfig.8 deleted file mode 100644 index 176450fe4..000000000 --- a/minix/commands/ifconfig/ifconfig.8 +++ /dev/null @@ -1,50 +0,0 @@ -.TH IFCONFIG 8 -.SH NAME -ifconfig \- configure a TCP/IP device -.SH SYNOPSIS -.B ifconfig -.RB [ \-I -.IR ip-device ] -.RB [ \-h -.IR ipaddr ] -.RB [ \-n -.IR netmask ] -.RB [ \-m -.IR mtu ] -.RB [ \-iva ] -.SH DESCRIPTION -.B Ifconfig -initializes a TCP/IP device setting the IP address and/or netmask. It will -report the address and netmask set. This command may be used if the system -has not been configured properly yet. It is only used at boot time to set a -fixed address for a system without a physical ethernet. Normally the -.B inet -task will find it out by itself from the RARP server. -.SH OPTIONS -.TP -.B \-h -The decimal TCP/IP address to set. -.TP -.B \-n -The netmask to set. -.TP -.B \-m -The mtu to set. (Minix-vmd only.) -.TP -.B \-i -Don't set the IP address or netmask if already set. This way ifconfig cannot -interfere if the numbers have been found out by RARP. -.TP -.B \-v -Report IP address and netmask. This is the default action if there are no -other options. -.TP -.B \-a -Report the IP addresses and netmasks of all configured interfaces. -.SH "SEE ALSO" -.BR hostaddr (1), -.BR rarpd (8), -.BR inet (8), -.BR boot (8). -.SH AUTHOR -Kees J. Bot (kjb@cs.vu.nl) diff --git a/minix/commands/ifconfig/ifconfig.c b/minix/commands/ifconfig/ifconfig.c deleted file mode 100644 index 4b3f3f513..000000000 --- a/minix/commands/ifconfig/ifconfig.c +++ /dev/null @@ -1,356 +0,0 @@ -/* -ifconfig.c -*/ - -#define _POSIX_C_SOURCE 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if __STDC__ -#define PROTO(x,y) x y -#else -#define PROTO(x,y) x() -#endif - -static PROTO (void usage, (void) ); -static PROTO (void set_hostaddr, (int ip_fd, char *host_s, int ins) ); -static PROTO (void set_netmask, (int ip_fd, char *net_s, int ins) ); -static PROTO (void set_mtu, (int ip_fd, char *mtu_s) ); -static PROTO (int check_ipaddrset, (int ip_fd) ); -static PROTO (int check_netmaskset, (int ip_fd) ); -static PROTO (int get_ipconf, (int ip_fd, - struct nwio_ipconf *ref_ipconf) ); -PROTO (int main, (int argc, char *argv[]) ); - -char *prog_name; - -int -main(argc, argv) -int argc; -char *argv[]; -{ - char *device_s, *hostaddr_s, *mtu_s, *netmask_s, **arg_s; - int ins; - int c, ip_fd, ifno; - struct nwio_ipconf ipconf; - int i_flag, v_flag, a_flag, modify; - char *d_arg, *h_arg, *m_arg, *n_arg; - - prog_name= argv[0]; - - d_arg= NULL; - h_arg= NULL; - m_arg= NULL; - n_arg= NULL; - i_flag= 0; - v_flag= 0; - a_flag= 0; - while ((c= getopt(argc, argv, "?I:h:m:n:iva")) != -1) - { - switch(c) - { - case '?': - usage(); - case 'I': - if (d_arg) - usage(); - d_arg= optarg; - break; - case 'h': - if (h_arg) - usage(); - h_arg= optarg; - break; - case 'm': - if (m_arg) - usage(); - m_arg= optarg; - break; - case 'n': - if (n_arg) - usage(); - n_arg= optarg; - break; - case 'i': - if (i_flag) - usage(); - i_flag= 1; - break; - case 'v': - if (v_flag) - usage(); - v_flag= 1; - break; - case 'a': - if (a_flag) - usage(); - a_flag= 1; - break; - default: - fprintf(stderr, "%s: getopt failed: '%c'\n", - prog_name, c); - exit(1); - } - } - modify = (h_arg != NULL || n_arg != NULL || m_arg != NULL); - if (a_flag && modify) usage(); - if (!modify) v_flag= 1; - - if (modify) setuid(getuid()); - - if (optind != argc) - usage(); - - hostaddr_s= h_arg; - mtu_s= m_arg; - netmask_s= n_arg; - ins= i_flag; - - ifno= 0; - do - { - if (!a_flag) { - device_s= d_arg; - if (device_s == NULL) - device_s= getenv("IP_DEVICE"); - if (device_s == NULL) - device_s= IP_DEVICE; - } else { - static char device[sizeof("/dev/ip99")]; - - sprintf(device, "/dev/ip%d", ifno); - device_s= device; - } - - ip_fd= open (device_s, O_RDWR); - if (ip_fd<0) - { - if (a_flag && (errno == ENOENT || errno == ENXIO)) - continue; - - fprintf(stderr, "%s: Unable to open '%s': %s\n", - prog_name, device_s, strerror(errno)); - exit(1); - } - - if (hostaddr_s) - set_hostaddr(ip_fd, hostaddr_s, ins); - - if (netmask_s) - set_netmask(ip_fd, netmask_s, ins); - - if (mtu_s) - set_mtu(ip_fd, mtu_s); - - if (v_flag) { - if (!get_ipconf(ip_fd, &ipconf)) - { - if (!a_flag) - { - fprintf(stderr, - "%s: %s: Host address not set\n", - prog_name, device_s); - exit(1); - } - } - else - { - printf("%s: address %s", device_s, - inet_ntoa(*(struct in_addr *) - &ipconf.nwic_ipaddr)); - - if (ipconf.nwic_flags & NWIC_NETMASK_SET) - { - printf(" netmask %s", - inet_ntoa(*(struct in_addr *) - &ipconf.nwic_netmask)); - } -#ifdef NWIC_MTU_SET - if (ipconf.nwic_mtu) - printf(" mtu %u", ipconf.nwic_mtu); -#endif - fputc('\n', stdout); - } - } - close(ip_fd); - } while (a_flag && ++ifno < 32); - exit(0); -} - -static void set_hostaddr (ip_fd, hostaddr_s, ins) -int ip_fd; -char *hostaddr_s; -int ins; -{ - ipaddr_t ipaddr; - struct nwio_ipconf ipconf; - int result; - - ipaddr= inet_addr (hostaddr_s); - if (ipaddr == (ipaddr_t)(-1)) - { - fprintf(stderr, "%s: Invalid host address (%s)\n", - prog_name, hostaddr_s); - exit(1); - } - if (ins && check_ipaddrset(ip_fd)) - return; - - ipconf.nwic_flags= NWIC_IPADDR_SET; - ipconf.nwic_ipaddr= ipaddr; - - result= ioctl(ip_fd, NWIOSIPCONF, &ipconf); - if (result<0) - { - fprintf(stderr, "%s: Unable to set IP configuration: %s\n", - prog_name, strerror(errno)); - exit(1); - } -} - -static int check_ipaddrset (ip_fd) -int ip_fd; -{ - struct nwio_ipconf ipconf; - - if (!get_ipconf(ip_fd, &ipconf)) - return 0; - - assert (ipconf.nwic_flags & NWIC_IPADDR_SET); - - return 1; -} - -static int get_ipconf (ip_fd, ref_ipaddr) -int ip_fd; -struct nwio_ipconf *ref_ipaddr; -{ - int flags; - int error, result; - nwio_ipconf_t ipconf; - - flags= fcntl(ip_fd, F_GETFL); - fcntl(ip_fd, F_SETFL, flags | O_NONBLOCK); - - result= ioctl (ip_fd, NWIOGIPCONF, &ipconf); - error= errno; - - fcntl(ip_fd, F_SETFL, flags); - - if (result <0 && error != EAGAIN) - { - errno= error; - fprintf(stderr, "%s: Unable to get IP configuration: %s\n", - prog_name, strerror(errno)); - exit(1); - } - if (result == 0) - { - *ref_ipaddr = ipconf; - } - return result>=0; -} - -static void usage() -{ - fprintf(stderr, - "Usage: %s [-I ip-device] [-h ipaddr] [-n netmask] [-m mtu] [-iva]\n", - prog_name); - exit(1); -} - -static void set_netmask (ip_fd, netmask_s, ins) -int ip_fd; -char *netmask_s; -int ins; -{ - ipaddr_t netmask; - struct nwio_ipconf ipconf; - int result; - - netmask= inet_addr (netmask_s); - if (netmask == (ipaddr_t)(-1)) - { - fprintf(stderr, "%s: Invalid netmask (%s)\n", - prog_name, netmask_s); - exit(1); - } - if (ins && check_netmaskset(ip_fd)) - return; - - ipconf.nwic_flags= NWIC_NETMASK_SET; - ipconf.nwic_netmask= netmask; - - result= ioctl(ip_fd, NWIOSIPCONF, &ipconf); - if (result<0) - { - fprintf(stderr, "%s: Unable to set IP configuration: %s\n", - prog_name, strerror(errno)); - exit(1); - } -} - -static void set_mtu (ip_fd, mtu_s) -int ip_fd; -char *mtu_s; -{ - ipaddr_t netmask; - int result; - long mtu; - char *check; - struct nwio_ipconf ipconf; - - mtu= strtol (mtu_s, &check, 0); - if (check[0] != '\0') - { - fprintf(stderr, "%s: Invalid mtu (%s)\n", - prog_name, mtu_s); - exit(1); - } - -#ifdef NWIC_MTU_SET - ipconf.nwic_flags= NWIC_MTU_SET; - ipconf.nwic_mtu= mtu; - - result= ioctl(ip_fd, NWIOSIPCONF, &ipconf); - if (result<0) - { - fprintf(stderr, "%s: Unable to set IP configuration: %s\n", - prog_name, strerror(errno)); - exit(1); - } -#endif -} - -static int check_netmaskset (ip_fd) -int ip_fd; -{ - struct nwio_ipconf ipconf; - - if (!get_ipconf(ip_fd, &ipconf)) - { - fprintf(stderr, -"%s: Unable to determine if netmask is set, please set IP address first\n", - prog_name); - exit(1); - } - - return (ipconf.nwic_flags & NWIC_NETMASK_SET); -} - -/* - * $PchId: ifconfig.c,v 1.7 2001/02/21 09:19:52 philip Exp $ - */