Commit 7f083685 authored by Phil Blundell's avatar Phil Blundell

Merge various changes from my private tree.

 - ROSE and FDDI support is in now
 - `route' ignores routes that are deleted, to avoid confusing users.
 - `ifconfig' no longer even tries to use SIOCGIFCOUNT.  Even old ifconfigs
   will work correctly without it though, so let's delete this ioctl now
   before 2.2 is released.  It was only added in the mid 2.1 series so no code
   should rely on it yet.

Also the usual round of tidying up.

I need to check whether Bernd has any outstanding changes, and then I want
to release net-tools 1.50 in the fairly near future.
parent f90b7ae5
Sun Jan 25 13:00:00 1998 Philip Blundell <Philip.Blundell@pobox.com>
* lib/inet6_gr.c, lib/inet_gr.c: Don't display inactive routes
(ie those without RTF_UP).
* rarp.c: Add support for /etc/ethers. Patch from haardt@gmd.de
(Michael Haardt).
* config.in, lib/hw.c: Tidy up. Add support for Rose and FDDI.
* lib/fddi.c, lib/rose.c, lib/rose_gr.c: New files, copied from
Bernd's net-tools-pre-1.34.
* ifconfig.c: Try to use AF_ROSE sockets.
* ifconfig.c: Don't use SIOCGIFCOUNT to work out how many
interfaces to display; use SIOCGIFCONF with a null buffer
instead.
Tue Sep 23 20:58:27 1997 Philip Blundell <Philip.Blundell@pobox.com>
* ifconfig.c (if_getstats): use _PATH_PROCNET_DEV rather than
......@@ -23,4 +41,4 @@ Sun Sep 21 18:26:24 1997 Philip Blundell <Philip.Blundell@pobox.com>
* netstat.c: include <net/route.h> for net-features. Patch by
Roderich Schupp <rsch@ExperTeam.de>
* route.c: likewise.
\ No newline at end of file
......@@ -8,19 +8,13 @@
# NET-3 Networking Distribution for the LINUX operating
# system.
#
# Version: config.in 1.04 (96-04-24)
# Version: config.in 1.20 (98-01-25)
#
# Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
# Copyright 1988-1993 MicroWalt Corporation
#
# Bernd 'eckes' Eckenfels <net-tools@lina.inka.de>
#
# Modified:
# {1.01} Bernd Eckenfels: generates more verbose config.h file
#960125 {1.02} Bernd Eckenfels: reordered
#960215 {1.03} Bernd Eckenfels: NET/ROM (Jonathan)
#960424 {1.04} Bernd Eckenfels: NLS disabled, FR added
#
# This program 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
......@@ -36,7 +30,6 @@
= *
= * DO NOT EDIT DIRECTLY
= *
= * Version: Generated from "config.in 1.04 (96-04-24)"
= */
#*
#*
......@@ -67,6 +60,7 @@ bool 'Novell IPX/SPX protocol family' HAVE_AFIPX y
bool 'Appletalk DDP protocol family' HAVE_AFATALK y
bool 'AX25 (Packet Radio) protocol family' HAVE_AFAX25 y
bool 'NET/ROM (Packet Radio) protocol family' HAVE_AFNETROM y
bool 'Rose (packet radio) protocol family' HAVE_AFROSE n
*
*
* Device Hardware types.
......@@ -81,5 +75,7 @@ bool 'AX25 (Packet Radio) support' HAVE_HWAX25 y
bool 'NET/ROM (Packet Radio) support' HAVE_HWNETROM y
bool 'DLCI/FRAD (Frame Relay) support' HAVE_HWFR y
bool 'SIT (IPv6-in-IPv4) support' HAVE_HWSIT n
bool 'FDDI (generic) support' HAVE_HWFDDI n
bool 'Rose (packet radio) support' HAVE_HWROSE n
bool 'Ash support' HAVE_HWASH y
......@@ -3,7 +3,7 @@
* that either displays or sets the characteristics of
* one or more of the system's networking interfaces.
*
* Version: ifconfig 1.30 (1998-01-02)
* Version: ifconfig 1.31 (1998-01-25)
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* and others. Copyright 1993 MicroWalt Corporation
......@@ -155,9 +155,6 @@ static const char *if_port_text[][4] = {
#ifndef SIOGIFNAME
#define SIOGIFNAME 0x8934 /* if_index -> name mapping */
#endif
#ifndef SIOCGIFCOUNT
#define SIOCGIFCOUNT 0x8935 /* get number of interfaces */
#endif
#ifndef SIOCDIFADDR
#define SIOCDIFADDR 0x8936 /* delete PA address */
#endif
......@@ -184,6 +181,9 @@ int ipx_sock = -1; /* IPX socket */
#if HAVE_AFAX25
int ax25_sock = -1; /* AX.25 socket */
#endif
#if HAVE_AFROSE
int rose_sock = -1; /* Rose socket */
#endif
#if HAVE_AFINET
int inet_sock = -1; /* INET socket */
#endif
......@@ -591,7 +591,10 @@ if_print(char *ifname)
int i;
struct ifconf ifc;
struct ifreq *ifr;
if (ioctl(skfd, SIOCGIFCOUNT, &i) < 0) {
ifc.ifc_buf = NULL;
ifc.ifc_len = 0;
if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) {
/* Can this ever happen? */
int n = 2, s;
ifc.ifc_buf = NULL;
do {
......@@ -609,7 +612,7 @@ if_print(char *ifname)
}
} while (ifc.ifc_len == s);
} else {
ifc.ifc_buf = malloc(ifc.ifc_len = i*sizeof(struct ifreq));
ifc.ifc_buf = malloc(ifc.ifc_len);
if (ifc.ifc_buf == NULL) {
fprintf(stderr, "Out of memory.\n");
exit(1);
......@@ -740,6 +743,10 @@ static int sockets_open()
ax25_sock = socket(AF_AX25, SOCK_DGRAM, 0);
#endif
#if HAVE_ROSE
rose_sock = socket(AF_ROSE, SOCK_DGRAM, 0);
#endif
#if HAVE_AFATALK
ddp_sock = socket(AF_APPLETALK, SOCK_DGRAM, 0);
#endif
......@@ -764,6 +771,10 @@ static int sockets_open()
if (ax25_sock != -1) return ax25_sock;
#endif
#if HAVE_AFROSE
if (rose_sock != -1) return rose_sock;
#endif
#if HAVE_AFATALK
if (ddp_sock != -1) return ddp_sock;
#endif
......
/*
* lib/fddi.c This file contains an implementation of the "FDDI"
* support functions for the NET-2 base distribution.
*
* Version: @(#)fddi.c 1.00 08/13/96
*
* Author: Lawrence V. Stefani, <stefani@lkg.dec.com>
*
* This program 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.
*/
#include "config.h"
#if HAVE_HWFDDI
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_arp.h>
#ifndef ARPHRD_FDDI
#error "No FDDI Support in your current Kernelsource Tree."
#error "Disable HW Type FDDI"
#endif
#include <linux/if_fddi.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include "net-support.h"
#include "pathnames.h"
#define EXTERN
#include "net-locale.h"
extern struct hwtype fddi_hwtype;
/* Display an FDDI address in readable format. */
static char *
pr_fddi(unsigned char *ptr)
{
static char buff[64];
sprintf(buff, "%02X-%02X-%02X-%02X-%02X-%02X",
(ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
(ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
);
return(buff);
}
/* Display an FDDI socket address. */
static char *
pr_sfddi(struct sockaddr *sap)
{
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
return(NLS_CATBUFF (catfd, fddiSet, fddi_none, "[NONE SET]", buf, 64));
return(pr_fddi(sap->sa_data));
}
/* Input an FDDI address and convert to binary. */
static int
in_fddi(char *bufp, struct sockaddr *sap)
{
unsigned char *ptr;
char c, *orig;
int i, val;
sap->sa_family = fddi_hwtype.type;
ptr = sap->sa_data;
i = 0;
orig = bufp;
while((*bufp != '\0') && (i < FDDI_K_ALEN)) {
val = 0;
c = *bufp++;
if (isdigit(c)) val = c - '0';
else if (c >= 'a' && c <= 'f') val = c - 'a' + 10;
else if (c >= 'A' && c <= 'F') val = c - 'A' + 10;
else {
#ifdef DEBUG
fprintf(stderr, NLS_CATGETS(catfd, fddiSet, fddi_debug1,
"in_fddi(%s): invalid fddi address!\n"), orig);
#endif
errno = EINVAL;
return(-1);
}
val <<= 4;
c = *bufp++;
if (isdigit(c)) val |= c - '0';
else if (c >= 'a' && c <= 'f') val |= c - 'a' + 10;
else if (c >= 'A' && c <= 'F') val |= c - 'A' + 10;
else {
#ifdef DEBUG
fprintf(stderr, NLS_CATGETS(catfd, fddiSet, fddi_debug2,
"in_fddi(%s): invalid fddi address!\n"), orig);
#endif
errno = EINVAL;
return(-1);
}
*ptr++ = (unsigned char) (val & 0377);
i++;
/* We might get a semicolon here - not required. */
if (*bufp == ':') {
if (i == FDDI_K_ALEN) {
#ifdef DEBUG
fprintf(stderr, NLS_CATGETS(catfd, fddiSet, fddi_debug3,
"in_fddi(%s): trailing : ignored!\n"),
orig)
#endif
; /* nothing */
}
bufp++;
}
}
/* That's it. Any trailing junk? */
if ((i == FDDI_K_ALEN) && (*bufp != '\0')) {
#ifdef DEBUG
fprintf(stderr, NLS_CATGETS(catfd, fddiSet, fddi_debug4, "in_fddi(%s): trailing junk!\n"), orig);
errno = EINVAL;
return(-1);
#endif
}
#ifdef DEBUG
fprintf(stderr, "in_fddi(%s): %s\n", orig, pr_fddi(sap->sa_data));
#endif
return(0);
}
struct hwtype fddi_hwtype = {
"fddi", NULL, /*"Fiber Distributed Data Interface (FDDI)",*/ ARPHRD_FDDI, FDDI_K_ALEN,
pr_fddi, pr_sfddi, in_fddi, NULL
};
#endif /* HAVE_HWFDDI */
......@@ -2,16 +2,13 @@
* lib/hw.c This file contains the top-level part of the hardware
* support functions module for the NET-2 base distribution.
*
* Version: lib/hw.c 1.13 (1996-04-13)
* Version: lib/hw.c 1.20 (1998-01-25)
*
* Maintainer: Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
*
* Changes:
*960413 {1.13} Mike Mclagan : DLCI/FRAD support
*
* This program 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
......@@ -43,21 +40,24 @@ extern struct hwtype cslip6_hwtype;
extern struct hwtype adaptive_hwtype;
extern struct hwtype ether_hwtype;
extern struct hwtype fddi_hwtype;
extern struct hwtype tr_hwtype;
extern struct hwtype ax25_hwtype;
extern struct hwtype rose_hwtype;
extern struct hwtype netrom_hwtype;
extern struct hwtype tunnel_hwtype;
extern struct hwtype ash_hwtype;
extern struct hwtype ppp_hwtype;
extern struct hwtype ppp_hwtype;
extern struct hwtype arcnet_hwtype;
extern struct hwtype arcnet_hwtype;
extern struct hwtype dlci_hwtype;
extern struct hwtype frad_hwtype;
extern struct hwtype dlci_hwtype;
extern struct hwtype frad_hwtype;
extern struct hwtype sit_hwtype;
extern struct hwtype sit_hwtype;
static struct hwtype *hwtypes[] = {
......@@ -100,6 +100,12 @@ static struct hwtype *hwtypes[] = {
#endif
#if HAVE_HWSIT
&sit_hwtype,
#endif
#if HAVE_HWROSE
&rose_hwtype,
#endif
#if HAVE_HWFDDI
&fddi_hwtype,
#endif
&unspec_hwtype,
NULL
......@@ -110,6 +116,7 @@ static short sVhwinit = 0;
void hwinit ()
{
loop_hwtype.title = NLS_CATSAVE (catfd, loopbackSet, loopback_loop, "Local Loopback");
unspec_hwtype.title = NLS_CATSAVE (catfd, loopbackSet, loopback_unspec, "UNSPEC");
#if HAVE_HWSLIP
slip_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_slip, "Serial Line IP");
cslip_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_cslip, "VJ Serial Line IP");
......@@ -117,16 +124,21 @@ void hwinit ()
cslip6_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_cslip6, "VJ 6-bit Serial Line IP");
adaptive_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_adaptive, "Adaptive Serial Line IP");
#endif
unspec_hwtype.title = NLS_CATSAVE (catfd, loopbackSet, loopback_unspec, "UNSPEC");
#if HAVE_HWETHER
ether_hwtype.title = NLS_CATSAVE (catfd, etherSet, ether_ether, "Ethernet");
#endif
#if HAVE_HWASH
ash_hwtype.title = NLS_CATSAVE (catfd, ashSet, ash_hw, "64Mbps ASH");
ash_hwtype.title = NLS_CATSAVE (catfd, ashSet, ash_hw, "64Mbps Ash");
#endif
#if HAVE_HWFDDI
fddi_hwtype.title = NLS_CATSAVE (catfd, fddiSet, fddi_fddi, "Fiber Distributed Data Interface");
#endif
#if HAVE_HWAX25
ax25_hwtype.title = NLS_CATSAVE (catfd, ax25Set, ax25_hw, "AMPR AX.25");
#endif
#if HAVE_HWROSE
rose_hwtype.title = NLS_CATSAVE (catfd, roseSet, rose_hw, "AMPR ROSE");
#endif
#if HAVE_HWNETROM
netrom_hwtype.title = NLS_CATSAVE (catfd, netromSet, netrom_hw, "AMPR NET/ROM");
#endif
......@@ -140,13 +152,13 @@ void hwinit ()
arcnet_hwtype.title = NLS_CATSAVE (catfd, arcnetSet, arcnet_arcnet, "1.5Mbps ARCnet");
#endif
#if HAVE_HWFR
dlci_hwtype.title = NLS_CATSAVE(catfd, dlciSet, dlci_hw, "Frame Relay DLCI");
frad_hwtype.title = NLS_CATSAVE(catfd, fradSet, frad_hw, "Frame Relay Access Device");
dlci_hwtype.title = NLS_CATSAVE(catfd, dlciSet, dlci_hw, "Frame Relay DLCI");
frad_hwtype.title = NLS_CATSAVE(catfd, fradSet, frad_hw, "Frame Relay Access Device");
#endif
#if HAVE_HWSIT
sit_hwtype.title = NLS_CATSAVE(catfd, sitSet, sit_hw, "IPv6-in-IPv4");
sit_hwtype.title = NLS_CATSAVE(catfd, sitSet, sit_hw, "IPv6-in-IPv4");
#endif
sVhwinit = 1;
sVhwinit = 1;
}
/* Check our hardware type table for this type. */
......
......@@ -97,6 +97,7 @@ int rprint_fib6(int ext, int numeric)
#if 0
if (num < 23) continue;
#endif
if (!(iflags & RTF_UP)) continue;
/* Fetch and resolve the target address. */
sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",
addr6p[0], addr6p[1], addr6p[2], addr6p[3],
......@@ -116,7 +117,6 @@ int rprint_fib6(int ext, int numeric)
/* Decode the flags. */
flags[0] = '\0';
if (iflags & RTF_UP) strcat(flags, "U");
if (iflags & RTF_GATEWAY) strcat(flags, "G");
if (iflags & RTF_HOST) strcat(flags, "H");
if (iflags & RTF_DEFAULT) strcat(flags, "D");
......
......@@ -65,7 +65,7 @@ int rprint_fib(int ext, int numeric)
iface, net_addr, gate_addr,
&iflags, &refcnt, &use, &metric, mask_addr,
&mss,&window,&irtt);
if (num < 10) continue;
if (num < 10 || !(iflags & RTF_UP)) continue;
/* Fetch and resolve the target address. */
(void)inet_aftype.input(1, net_addr, &snet);
......@@ -84,7 +84,6 @@ int rprint_fib(int ext, int numeric)
/* Decode the flags. */
flags[0] = '\0';
if (iflags & RTF_UP) strcat(flags, "U");
if (iflags & RTF_GATEWAY) strcat(flags, "G");
#if HAVE_RTF_REJECT
if (iflags & RTF_REJECT) strcpy(flags,"!");
......
/*
* lib/rose.c This file contains an implementation of the "ROSE"
* support functions for the NET-2 base distribution.
*
* Version: @(#)rose.c 1.00 03/08/97
*
* Author: Terry Dawson, VK2KTJ, <terry@perf.no.itg.telstra.com.au>
* based on ax25.c by:
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
*
* This program 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.
*/
#include "config.h"
#if HAVE_AFROSE || HAVE_HWROSE
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if_arp.h> /* ARPHRD_ROSE */
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include "net-support.h"
#include "pathnames.h"
#define EXTERN
#include "net-locale.h"
static char ROSE_errmsg[128];
extern struct aftype rose_aftype;
static char *
ROSE_print(unsigned char *ptr)
{
static char buff[12];
sprintf(buff,"%02x%02x%02x%02x%02x",ptr[0],ptr[1],ptr[2],ptr[3],ptr[4]);
buff[10] = '\0';
return(buff);
}
/* Display a ROSE socket address. */
static char *
ROSE_sprint(struct sockaddr *sap, int numeric)
{
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
return(NLS_CATBUFF (catfd, roseSet, rose_none, "[NONE SET]", buf, 64));
return(ROSE_print(((struct sockaddr_rose *)sap)->srose_addr.rose_addr));
}
static int
ROSE_input(int type, char *bufp, struct sockaddr *sap)
{
char *ptr;
int i,o;
sap->sa_family = rose_aftype.af;
ptr = ((struct sockaddr_rose *)sap)->srose_addr.rose_addr;
/* Node address the correct length ? */
if (strlen(bufp)!=10) {
strcpy(ROSE_errmsg, NLS_CATGETS (catfd, roseSet, rose_debug2, "Node address must be ten digits"));
#ifdef DEBUG
fprintf(stderr, "rose_input(%s): %s !\n", ROSE_errmsg, orig);
#endif
errno = EINVAL;
return(-1);
}
/* Ok, lets set it */
for (i=0, o=0; i<5; i++) {
o=i*2;
ptr[i]=(((bufp[o]-'0')<<4) | (bufp[o+1]-'0'));
}
/* All done. */
#ifdef DEBUG
fprintf(stderr, "rose_input(%s): ", orig);
for (i = 0; i < sizeof(rose_address); i++)
fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
fprintf(stderr, "\n");
#endif
return(0);
}
/* Display an error message. */
static void
ROSE_herror(char *text)
{
if (text == NULL) fprintf(stderr, "%s\n", ROSE_errmsg);
else fprintf(stderr, "%s: %s\n", text, ROSE_errmsg);
}
static char *
ROSE_hprint(struct sockaddr *sap)
{
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
return(NLS_CATBUFF (catfd, roseSet, rose_none, "[NONE SET]", buf, 64));
return(ROSE_print(((struct sockaddr_rose *)sap)->srose_addr.rose_addr));
}
static int
ROSE_hinput(char *bufp, struct sockaddr *sap)
{
if (ROSE_input(0, bufp, sap) < 0) return(-1);
sap->sa_family = ARPHRD_ROSE;
return(0);
}
struct hwtype rose_hwtype = {
"rose", NULL, /*"AMPR ROSE",*/ ARPHRD_ROSE, 10,
ROSE_print, ROSE_hprint, ROSE_hinput, NULL
};
struct aftype rose_aftype = {
"rose", NULL, /*"AMPR ROSE",*/ AF_ROSE, 10,
ROSE_print, ROSE_sprint, ROSE_input, ROSE_herror,
NULL
};
#endif /* HAVE_xxROSE */
/*
* lib/rose_gr.c This file contains an implementation of the "ROSE"
* route print support functions.
*
* Version: lib/rose_gr.c 1.00 03/08/97
*
* Author: Terry Dawson, VK2KTJ, <terry@perf.no.itg.telstra.com.au>
* based on ax25_gr.c by:
* Bernd Eckenfels, <ecki@lina.inka.de>
* Copyright 1999 Bernd Eckenfels, Germany
* base on Code from Jonathan Naylor <jsn@Cs.Nott.AC.UK>
*
* This program 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.
*/
#include "config.h"
#if HAVE_AFROSE
#if 0
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/rose.h>
#include <sys/socket.h>
#include <net/if_arp.h> /* ARPHRD_ROSE */
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "net-support.h"
#include "pathnames.h"
#define EXTERN
#include "net-locale.h"
int ROSE_rprint(int options)
{
FILE *f=fopen(_PATH_PROCNET_ROSE_ROUTE, "r");
char buffer[256];
int use;
if(f==NULL)
{
printf(NLS_CATGETS(catfd, netstatSet, netstat_norose, "ROSE not configured in this system.\n")); /* xxx */
return 1;
}
printf(NLS_CATGETS(catfd, netstatSet, netstat_rose, "Kernel ROSE routing table\n")); /* xxx */
printf(NLS_CATGETS(catfd, netstatSet, netstat_header_rose, "Destination Iface Use\n")); /* xxx */
fgets(buffer,256,f);
while(fgets(buffer,256,f))
{
buffer[9]=0;
buffer[14]=0;
use=atoi(buffer+15);
printf("%-9s %-5s %5d\n",
buffer,buffer+10,use);
}
fclose(f);
return 0;
}
#endif /* HAVE_AFROSE */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment