Commit 5d4b8602 authored by Phil Blundell's avatar Phil Blundell

Crusade against bogus AF specifics. Make it work (mostly)

to build without AF_INET.
parent cbd46240
......@@ -3,7 +3,7 @@
* that either displays or sets the characteristics of
* one or more of the system's networking interfaces.
*
* Version: $Id: ifconfig.c,v 1.27 1999/01/17 21:20:25 philip Exp $
* Version: $Id: ifconfig.c,v 1.28 1999/03/03 19:40:28 philip Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* and others. Copyright 1993 MicroWalt Corporation
......@@ -140,9 +140,6 @@ void ife_print(struct interface *ptr)
int plen, scope, dad_status, if_idx;
extern struct aftype inet6_aftype;
char addr6p[8][5];
if (!strncmp(ptr->name, "sit", 3))
ptr->addr.sa_family = AF_INET6; /* fix this up properly one day */
#endif
ap = get_afntype(ptr->addr.sa_family);
......@@ -163,20 +160,22 @@ void ife_print(struct interface *ptr)
printf(_("%-9.9s Link encap:%s "), ptr->name, hw->title);
/* Don't print the hardware address for ATM or Ash if it's null. */
/* FIXME. Make this an option in struct hwtype. */
if (hw->sprint != NULL && ((strncmp(ptr->name, "atm", 3) &&
strncmp(ptr->name, "ash", 3)) ||
(ptr->hwaddr[0] || ptr->hwaddr[1] || ptr->hwaddr[2] || ptr->hwaddr[3] ||
ptr->hwaddr[4] || ptr->hwaddr[5])))
(! hw_null_address(hw, ptr->hwaddr))))
printf(_("HWaddr %s "), hw->print(ptr->hwaddr));
#ifdef IFF_PORTSEL
if (ptr->flags & IFF_PORTSEL)
printf(_("Media:%s%s"), if_port_text[ptr->map.port][0],
(ptr->flags & IFF_AUTOMEDIA) ? _("(auto)") : "");
if (ptr->flags & IFF_PORTSEL) {
printf(_("Media:%s"), if_port_text[ptr->map.port][0]);
if (ptr->flags & IFF_AUTOMEDIA)
printf(_("(auto)"));
}
#endif
printf("\n");
#if HAVE_AFINET6
if (ap->af != AF_INET6) {
#endif
#if HAVE_AFINET
if (ptr->has_ip) {
printf(_(" %s addr:%s "), ap->name,
ap->sprint(&ptr->addr, 1));
if (ptr->flags & IFF_POINTOPOINT) {
......@@ -186,8 +185,10 @@ void ife_print(struct interface *ptr)
printf(_(" Bcast:%s "), ap->sprint(&ptr->broadaddr, 1));
}
printf(_(" Mask:%s\n"), ap->sprint(&ptr->netmask, 1));
#if HAVE_AFINET6
}
#endif
#if HAVE_AFINET6
/* FIXME: should be integrated into interface.c. */
if ((f = fopen(_PATH_PROCNET_IFINET6, "r")) != NULL) {
......
......@@ -2,7 +2,7 @@
* lib/hw.c This file contains the top-level part of the hardware
* support functions module.
*
* Version: $Id: hw.c,v 1.10 1999/01/05 20:53:31 philip Exp $
* Version: $Id: hw.c,v 1.11 1999/03/03 19:40:38 philip Exp $
*
* Maintainer: Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
*
......@@ -237,3 +237,14 @@ void print_hwlist(int type) {
}
fprintf(stderr,"\n");
}
/* return 1 if address is all zeros */
int hw_null_address(struct hwtype *hw, void *ap)
{
unsigned int i;
unsigned char *address = (unsigned char *)ap;
for (i = 0; i < hw->alen; i++)
if (address[i])
return 0;
return 1;
}
......@@ -3,7 +3,7 @@
* support functions for the net-tools.
* (NET-3 base distribution).
*
* Version: $Id: inet.c,v 1.9 1999/03/02 21:09:14 philip Exp $
* Version: $Id: inet.c,v 1.10 1999/03/03 19:40:41 philip Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
......@@ -26,10 +26,13 @@
*/
#include "config.h"
#if HAVE_AFINET
/* FIXME. Split this file into inet4.c for the IPv4 specific parts
and inet.c for those shared between IPv4 and IPv6. */
#if HAVE_AFINET || HAVE_AFINET6
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <ctype.h>
......@@ -45,6 +48,7 @@
#include "pathnames.h"
#include "intl.h"
#include "util.h"
#endif
extern int h_errno; /* some netdb.h versions don't export this */
......@@ -63,6 +67,8 @@ struct service {
static struct service *tcp_name = NULL, *udp_name = NULL, *raw_name = NULL;
#if HAVE_AFINET
static struct addr *INET_nn = NULL; /* addr-to-name cache */
......
......@@ -4,7 +4,7 @@
10/1998 partly rewriten by Andi Kleen to support an interface list.
I don't claim that the list operations are efficient @).
$Id: interface.c,v 1.1 1999/01/09 14:36:36 philip Exp $
$Id: interface.c,v 1.2 1999/03/03 19:40:42 philip Exp $
*/
#include "config.h"
......@@ -113,6 +113,9 @@ static int if_readconf(void)
if (skfd < 0) {
fprintf(stderr, _("warning: no inet socket available: %s\n"),
strerror(errno));
/* Try to soldier on with whatever socket we can get hold of. */
skfd = sockets_open(0);
if (skfd < 0)
return -1;
}
......@@ -394,8 +397,13 @@ int if_fetch(struct interface *ife)
#endif
#if HAVE_AFINET
/* IPv4 address? */
fd = get_socket_for_af(AF_INET);
if (fd >= 0) {
strcpy(ifr.ifr_name, ifname);
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
ife->has_ip = 1;
ife->addr = ifr.ifr_addr;
strcpy(ifr.ifr_name, ifname);
if (ioctl(fd, SIOCGIFDSTADDR, &ifr) < 0)
memset(&ife->dstaddr, 0, sizeof(struct sockaddr));
......@@ -413,12 +421,8 @@ int if_fetch(struct interface *ife)
memset(&ife->netmask, 0, sizeof(struct sockaddr));
else
ife->netmask = ifr.ifr_netmask;
strcpy(ifr.ifr_name, ifname);
if (ioctl(fd, SIOCGIFADDR, &ifr) < 0)
} else
memset(&ife->addr, 0, sizeof(struct sockaddr));
else
ife->addr = ifr.ifr_addr;
}
#endif
......
......@@ -73,6 +73,7 @@ extern void print_hwlist(int type);
extern struct aftype *get_aftype(const char *name);
extern struct aftype *get_afntype(int type);
extern void print_aflist(int type);
extern int hw_null_address(struct hwtype *hw, void *addr);
extern int getargs(char *string, char *arguments[]);
......
......@@ -6,7 +6,7 @@
* NET-3 Networking Distribution for the LINUX operating
* system.
*
* Version: $Id: netstat.c,v 1.20 1999/03/02 09:20:44 ralf Exp $
* Version: $Id: netstat.c,v 1.21 1999/03/03 19:40:32 philip Exp $
*
* Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
......@@ -257,7 +257,7 @@ static int netrom_info(void)
#endif
#if HAVE_AFINET
#if HAVE_AFINET || HAVE_AFINET6
enum {
TCP_ESTABLISHED = 1,
......
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