Commit 49d6a000 authored by Klaas Freitag's avatar Klaas Freitag

Yow. This is net-tools completely reindented.

Some other cleanups:
- lib/net-string.c removed because it was not used and had a copyright notice
that conflicted with the GPL.
- Minor cleanups.
- Fix an potential buffer overflow in ax25.
- Switch to CVS $Id$ for versioning consistently
parent 72c29c95
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Sanitised ipx.h for net-tools. */
#ifndef _IPX_H_
#ifndef _IPX_H_
#define _IPX_H_
#define IPX_NODE_LEN 6
#define IPX_MTU 576
struct sockaddr_ipx
{
#if LINUX_VERSION_CODE > 131328 /* 2.1.0 or later */
sa_family_t sipx_family;
struct sockaddr_ipx {
#if LINUX_VERSION_CODE > 131328 /* 2.1.0 or later */
sa_family_t sipx_family;
#else
short sipx_family;
#endif
unsigned short sipx_port;
unsigned long sipx_network;
unsigned char sipx_node[IPX_NODE_LEN];
unsigned char sipx_type;
unsigned char sipx_zero; /* 16 byte fill */
};
unsigned short sipx_port;
unsigned long sipx_network;
unsigned char sipx_node[IPX_NODE_LEN];
unsigned char sipx_type;
unsigned char sipx_zero; /* 16 byte fill */
};
#define IPX_FRAME_NONE 0
#define IPX_FRAME_SNAP 1
......
This diff is collapsed.
struct user_net_device_stats
{
unsigned long rx_packets; /* total packets received */
unsigned long tx_packets; /* total packets transmitted */
unsigned long rx_bytes; /* total bytes received */
unsigned long tx_bytes; /* total bytes transmitted */
unsigned long rx_errors; /* bad packets received */
unsigned long tx_errors; /* packet transmit problems */
unsigned long rx_dropped; /* no space in linux buffers */
unsigned long tx_dropped; /* no space available in linux */
unsigned long rx_multicast; /* multicast packets received */
unsigned long rx_compressed;
unsigned long tx_compressed;
unsigned long collisions;
struct user_net_device_stats {
unsigned long rx_packets; /* total packets received */
unsigned long tx_packets; /* total packets transmitted */
unsigned long rx_bytes; /* total bytes received */
unsigned long tx_bytes; /* total bytes transmitted */
unsigned long rx_errors; /* bad packets received */
unsigned long tx_errors; /* packet transmit problems */
unsigned long rx_dropped; /* no space in linux buffers */
unsigned long tx_dropped; /* no space available in linux */
unsigned long rx_multicast; /* multicast packets received */
unsigned long rx_compressed;
unsigned long tx_compressed;
unsigned long collisions;
/* detailed rx_errors: */
unsigned long rx_length_errors;
unsigned long rx_over_errors; /* receiver ring buff overflow */
unsigned long rx_crc_errors; /* recved pkt with crc error */
unsigned long rx_frame_errors; /* recv'd frame alignment error */
unsigned long rx_fifo_errors; /* recv'r fifo overrun */
unsigned long rx_missed_errors; /* receiver missed packet */
/* detailed tx_errors */
unsigned long tx_aborted_errors;
unsigned long tx_carrier_errors;
unsigned long tx_fifo_errors;
unsigned long tx_heartbeat_errors;
unsigned long tx_window_errors;
/* detailed rx_errors: */
unsigned long rx_length_errors;
unsigned long rx_over_errors; /* receiver ring buff overflow */
unsigned long rx_crc_errors; /* recved pkt with crc error */
unsigned long rx_frame_errors; /* recv'd frame alignment error */
unsigned long rx_fifo_errors; /* recv'r fifo overrun */
unsigned long rx_missed_errors; /* receiver missed packet */
/* detailed tx_errors */
unsigned long tx_aborted_errors;
unsigned long tx_carrier_errors;
unsigned long tx_fifo_errors;
unsigned long tx_heartbeat_errors;
unsigned long tx_window_errors;
};
struct interface {
struct interface *next;
struct interface *next;
char name[IFNAMSIZ]; /* interface name */
short type; /* if type */
short flags; /* various flags */
int metric; /* routing metric */
int mtu; /* MTU value */
int tx_queue_len; /* transmit queue length */
struct ifmap map; /* hardware setup */
struct sockaddr addr; /* IP address */
struct sockaddr dstaddr; /* P-P IP address */
struct sockaddr broadaddr; /* IP broadcast address */
struct sockaddr netmask; /* IP network mask */
struct sockaddr ipxaddr_bb; /* IPX network address */
struct sockaddr ipxaddr_sn; /* IPX network address */
struct sockaddr ipxaddr_e3; /* IPX network address */
struct sockaddr ipxaddr_e2; /* IPX network address */
struct sockaddr ddpaddr; /* Appletalk DDP address */
struct sockaddr ecaddr; /* Econet address */
int has_ip;
int has_ipx_bb;
int has_ipx_sn;
int has_ipx_e3;
int has_ipx_e2;
int has_ax25;
int has_ddp;
int has_econet;
char hwaddr[32]; /* HW address */
int statistics_valid;
struct user_net_device_stats stats; /* statistics */
int keepalive; /* keepalive value for SLIP */
int outfill; /* outfill value for SLIP */
char name[IFNAMSIZ]; /* interface name */
short type; /* if type */
short flags; /* various flags */
int metric; /* routing metric */
int mtu; /* MTU value */
int tx_queue_len; /* transmit queue length */
struct ifmap map; /* hardware setup */
struct sockaddr addr; /* IP address */
struct sockaddr dstaddr; /* P-P IP address */
struct sockaddr broadaddr; /* IP broadcast address */
struct sockaddr netmask; /* IP network mask */
struct sockaddr ipxaddr_bb; /* IPX network address */
struct sockaddr ipxaddr_sn; /* IPX network address */
struct sockaddr ipxaddr_e3; /* IPX network address */
struct sockaddr ipxaddr_e2; /* IPX network address */
struct sockaddr ddpaddr; /* Appletalk DDP address */
struct sockaddr ecaddr; /* Econet address */
int has_ip;
int has_ipx_bb;
int has_ipx_sn;
int has_ipx_e3;
int has_ipx_e2;
int has_ax25;
int has_ddp;
int has_econet;
char hwaddr[32]; /* HW address */
int statistics_valid;
struct user_net_device_stats stats; /* statistics */
int keepalive; /* keepalive value for SLIP */
int outfill; /* outfill value for SLIP */
};
extern int if_fetch(char *ifname, struct interface *ife);
extern int for_all_interfaces(int (*)(struct interface *, void *), void *);
extern int for_all_interfaces(int (*)(struct interface *, void *), void *);
extern struct interface *lookup_interface(char *name);
extern int if_readlist(void);
/* Define for poor glibc2.0 users, the feature check is done at runtime */
/* Define for poor glibc2.0 users, the feature check is done at runtime */
#if !defined(SIOCSIFTXQLEN)
#define SIOCSIFTXQLEN 0x8943
#define SIOCGIFTXQLEN 0x8942
#define SIOCSIFTXQLEN 0x8943
#define SIOCGIFTXQLEN 0x8942
#endif
#if !defined(ifr_qlen)
......@@ -83,5 +82,5 @@ extern int if_readlist(void);
#define HAVE_DYNAMIC
#ifndef IFF_DYNAMIC
#define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/
#define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses */
#endif
......@@ -22,9 +22,8 @@ AFGROBJS = inet_gr.o inet6_gr.o ipx_gr.o ddp_gr.o netrom_gr.o ax25_gr.o rose_gr.
AFSROBJS = inet_sr.o inet6_sr.o netrom_sr.o ipx_sr.o setroute.o
ACTOBJS = slip_ac.o ppp_ac.o activate.o
VARIA = getargs.o masq_info.o proc.o util.o nstrcmp.o
NLSMISC = net-string.o
OBJS = $(NLSMISC) $(VARIA) $(AFOBJS) $(HWOBJS) \
OBJS = $(VARIA) $(AFOBJS) $(HWOBJS) \
$(AFGROBJS) $(AFSROBJS) $(ACTOBJS)
......
/*
* lib/activate.c This file contains a small interface function to
* use the HW specific activate routines for line
* disciplines
* lib/activate.c This file contains a small interface function to
* use the HW specific activate routines for line
* disciplines
*
* NET-LIB A collection of functions used from the base set of the
* NET-3 Networking Distribution for the LINUX operating
* system. (net-tools, net-drivers)
* NET-LIB A collection of functions used from the base set of the
* NET-3 Networking Distribution for the LINUX operating
* system. (net-tools, net-drivers)
*
* Version: lib/activate.c 0.01 (1996-03-22)
* Version: $Id: activate.c,v 1.3 1998/11/15 20:08:55 freitag Exp $
*
* Author: Bernd 'eckes' Eckenfels <net-tools@lina.inka.de>
* Copyright 1996 Bernd Eckenfels, Germany
* Author: Bernd 'eckes' Eckenfels <net-tools@lina.inka.de>
* Copyright 1996 Bernd Eckenfels, Germany
*
* Modifications:
*
*960322 {0.01} Bernd Eckenfels: creation
*960322 {0.01} Bernd Eckenfels: creation
*980411 {0.01i} Arnaldo Carvalho: i18n: now uses gettext
*
* 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.
* 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 <stdio.h>
#include <string.h>
......@@ -31,12 +31,12 @@
#include "config.h"
#include "intl.h"
extern struct hwtype slip_hwtype;
extern struct hwtype cslip_hwtype;
extern struct hwtype slip6_hwtype;
extern struct hwtype cslip6_hwtype;
extern struct hwtype adaptive_hwtype;
extern struct hwtype ppp_hwtype;
extern struct hwtype slip_hwtype;
extern struct hwtype cslip_hwtype;
extern struct hwtype slip6_hwtype;
extern struct hwtype cslip6_hwtype;
extern struct hwtype adaptive_hwtype;
extern struct hwtype ppp_hwtype;
extern int SLIP_activate(int fd);
extern int CSLIP_activate(int fd);
......@@ -45,34 +45,33 @@ extern int CSLIP6_activate(int fd);
extern int ADAPTIVE_activate(int fd);
extern int PPP_activate(int fd);
void
activate_init(void)
void activate_init(void)
{
#if HAVE_HWSLIP
slip_hwtype.activate = SLIP_activate;
cslip_hwtype.activate = CSLIP_activate;
slip6_hwtype.activate = SLIP6_activate;
cslip6_hwtype.activate = CSLIP6_activate;
adaptive_hwtype.activate = ADAPTIVE_activate;
slip_hwtype.activate = SLIP_activate;
cslip_hwtype.activate = CSLIP_activate;
slip6_hwtype.activate = SLIP6_activate;
cslip6_hwtype.activate = CSLIP6_activate;
adaptive_hwtype.activate = ADAPTIVE_activate;
#endif
#if HAVE_HWPPP
ppp_hwtype.activate = PPP_activate;
ppp_hwtype.activate = PPP_activate;
#endif
}
int activate_ld(const char *hwname, int fd)
{
struct hwtype *hw;
hw = get_hwtype(hwname);
if (!hw) {
fprintf(stderr,_("Hardware type `%s' not supported.\n"),hwname);
return(E_NOSUPP);
}
if (!hw->activate) {
fprintf(stderr,_("Cannot change line discipline to `%s'.\n"),hw->name);
return(E_OPTERR);
}
return(hw->activate(fd));
struct hwtype *hw;
hw = get_hwtype(hwname);
if (!hw) {
fprintf(stderr, _("Hardware type `%s' not supported.\n"), hwname);
return (E_NOSUPP);
}
if (!hw->activate) {
fprintf(stderr, _("Cannot change line discipline to `%s'.\n"), hw->name);
return (E_OPTERR);
}
return (hw->activate(fd));
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -18,7 +18,7 @@
int DDP_rprint(int options)
{
fprintf(stderr, _("Routing table for `ddp' not yet supported.\n"));
return(1);
fprintf(stderr, _("Routing table for `ddp' not yet supported.\n"));
return (1);
}
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -23,23 +23,14 @@
#include "net-features.h"
extern struct aftype ipx_aftype;
extern struct aftype ipx_aftype;
/* static int skfd = -1; */
/*
static int usage(void)
{
fprintf(stderr,"IPX usage\n");
return(E_USAGE);
}
*/
int IPX_rinput(int action, int ext, char **args)
{
fprintf(stderr,_("IPX: this needs to be written\n"));
return(0);
fprintf(stderr, _("IPX: this needs to be written\n"));
return (0);
}
#endif /* HAVE_AFIPX */
#endif /* HAVE_AFIPX */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Generate a suitable scanf format for a column title line */
char *proc_gen_fmt(char *name, int more, FILE *fh, ...);
/* Generate a suitable scanf format for a column title line */
char *proc_gen_fmt(char *name, int more, FILE * fh,...);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include <stddef.h>
void *xmalloc(size_t sz);
void *xrealloc(void *p, size_t sz);
void *xmalloc(size_t sz);
void *xrealloc(void *p, size_t sz);
#define new(p) ((p) = xmalloc(sizeof(*(p))))
int kernel_version(void);
#define KRELEASE(maj,min,patch) ((maj) * 10000 + (min)*1000 + (patch))
int kernel_version(void);
#define KRELEASE(maj,min,patch) ((maj) * 10000 + (min)*1000 + (patch))
int nstrcmp(const char *, const char *);
int nstrcmp(const char *, const char *);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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