diff -Nur net-tools-1.60/ifconfig.c net-tools-1.60-ifgrp/ifconfig.c --- net-tools-1.60/ifconfig.c Fri Apr 13 20:25:18 2001 +++ net-tools-1.60-ifgrp/ifconfig.c Mon Dec 1 23:41:23 2003 @@ -105,7 +105,7 @@ int res; if (ife_short) - printf(_("Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n")); + printf(_("Iface Groups MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n")); if (!ifname) { res = for_all_interfaces(do_if_print, &opt_a); @@ -120,6 +120,26 @@ return res; } +static int if_group(char *ifname) +{ + int res; + + printf(_("Groups: | 4| 0|\n")); + printf(_("Iface +----+----+\n")); + + if (!ifname) { + res = for_all_interfaces(do_if_group, &opt_a); + } else { + struct interface *ife; + + ife = lookup_interface(ifname); + res = do_if_fetch(ife); + if (res >= 0) + ife_group(ife); + } + return res; +} + /* Set a certain interface flag. */ static int set_flag(char *ifname, short flag) { @@ -174,7 +194,7 @@ static void usage(void) { - fprintf(stderr, _("Usage:\n ifconfig [-a] [-i] [-v] [-s] [[]
]\n")); + fprintf(stderr, _("Usage:\n ifconfig [-a] [-i] [-v] [-s] [-g] [[]
]\n")); #if HAVE_AFINET fprintf(stderr, _(" [add
[/]]\n")); fprintf(stderr, _(" [del
[/]]\n")); @@ -188,6 +208,8 @@ fprintf(stderr, _(" [[-]trailers] [[-]arp] [[-]allmulti]\n")); fprintf(stderr, _(" [multicast] [[-]promisc]\n")); fprintf(stderr, _(" [mem_start ] [io_addr ] [irq ] [media ]\n")); + fprintf(stderr, _(" [grp_add ]\n")); + fprintf(stderr, _(" [grp_rm ]\n")); #ifdef HAVE_TXQUEUELEN fprintf(stderr, _(" [txqueuelen ]\n")); #endif @@ -263,6 +285,9 @@ else if (!strcmp(*argv, "-s")) ife_short = 1; + else if (!strcmp(*argv, "-g")) + ife_grp = 1; + else if (!strcmp(*argv, "-v")) opt_v = 1; @@ -293,7 +318,11 @@ /* Do we have to show the current setup? */ if (argc == 0) { - int err = if_print((char *) NULL); + int err; + if (ife_grp) + err = if_group((char *) NULL); + else + err = if_print((char *) NULL); (void) close(skfd); exit(err < 0); } @@ -301,7 +330,11 @@ spp = argv; safe_strncpy(ifr.ifr_name, *spp++, IFNAMSIZ); if (*spp == (char *) NULL) { - int err = if_print(ifr.ifr_name); + int err; + if (ife_grp) + err = if_group(ifr.ifr_name); + else + err = if_print(ifr.ifr_name); (void) close(skfd); exit(err < 0); } @@ -558,7 +591,28 @@ continue; } #endif - + if (!strcmp(*spp, "grp_add")) { + if (*++spp == NULL) + usage(); + ifr.ifr_qlen = strtoul(*spp, NULL, 0); + if (ioctl(skfd, SIOCAIFGROUP, &ifr) < 0) { + fprintf(stderr, "SIOCAIFGROUP: %s\n", strerror(errno)); + goterr = 1; + } + spp++; + continue; + } + if (!strcmp(*spp, "grp_rm")) { + if (*++spp == NULL) + usage(); + ifr.ifr_qlen = strtoul(*spp, NULL, 0); + if (ioctl(skfd, SIOCRIFGROUP, &ifr) < 0) { + fprintf(stderr, "SIOCRIFGROUP: %s\n", strerror(errno)); + goterr = 1; + } + spp++; + continue; + } if (!strcmp(*spp, "mem_start")) { if (*++spp == NULL) usage(); diff -Nur net-tools-1.60/include/interface.h net-tools-1.60-ifgrp/include/interface.h --- net-tools-1.60/include/interface.h Sat Feb 10 20:24:25 2001 +++ net-tools-1.60-ifgrp/include/interface.h Mon Dec 1 23:12:27 2003 @@ -35,6 +35,7 @@ int metric; /* routing metric */ int mtu; /* MTU value */ int tx_queue_len; /* transmit queue length */ + int ifgroup; /* interface group number*/ struct ifmap map; /* hardware setup */ struct sockaddr addr; /* IP address */ struct sockaddr dstaddr; /* P-P IP address */ @@ -70,10 +71,13 @@ extern int do_if_fetch(struct interface *ife); extern int do_if_print(struct interface *ife, void *cookie); +extern int do_if_group(struct interface *ife, void *cookie); extern void ife_print(struct interface *ptr); +extern void ife_group(struct interface *ptr); extern int ife_short; +extern int ife_grp; extern const char *if_port_text[][4]; diff -Nur net-tools-1.60/lib/interface.c net-tools-1.60-ifgrp/lib/interface.c --- net-tools-1.60/lib/interface.c Sat Feb 10 20:31:15 2001 +++ net-tools-1.60-ifgrp/lib/interface.c Mon Dec 1 23:18:46 2003 @@ -86,6 +86,7 @@ int procnetdev_vsn = 1; int ife_short; +int ife_grp = 0; static struct interface *int_list, *int_last; @@ -462,6 +463,12 @@ ife->tx_queue_len = -1; /* unknown value */ #endif + strcpy(ifr.ifr_name, ifname); + if (ioctl(skfd, SIOCGIFGROUP, &ifr) < 0) + ife->ifgroup= -1; /* unknown value */ + else + ife->ifgroup = ifr.ifr_group; + #if HAVE_AFINET /* IPv4 address? */ fd = get_socket_for_af(AF_INET); @@ -577,9 +584,23 @@ return res; } +int do_if_group(struct interface *ife, void *cookie) +{ + int *opt_a = (int *) cookie; + int res; + + res = do_if_fetch(ife); + if (res >= 0) { + if ((ife->flags & IFF_UP) || *opt_a) + ife_group(ife); + } + return res; +} + void ife_print_short(struct interface *ptr) { printf("%-5.5s ", ptr->name); + printf(" %.8x ", ptr->ifgroup); printf("%5d %3d", ptr->mtu, ptr->metric); /* If needed, display the interface statistics. */ if (ptr->statistics_valid) { @@ -670,7 +691,11 @@ if (hw == NULL) hw = get_hwntype(-1); - printf(_("%-9.9s Link encap:%s "), ptr->name, hw->title); + if (ptr->ifgroup != -1) + printf(_("%-9.9s Groups:%.8x "), ptr->name, ptr->ifgroup); + printf("\n"); + + printf(_(" Link encap:%s "), hw->title); /* For some hardware types (eg Ash, ATM) we don't print the hardware address if it's null. */ if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) && @@ -891,3 +916,22 @@ else ife_print_long(i); } + +void ife_group(struct interface *ptr) +{ + int i; + unsigned int mask = 0x80; + + printf("%-5.5s |", ptr->name); + for (i = 7; i >= 0; i--) { + if (ptr->ifgroup & mask) + printf("x"); + else + printf(" "); + mask >>= 1; + if (!(i % 4)) + printf("|"); + } + printf("\n"); +} +