Commit b12c3ada authored by Linus Torvalds's avatar Linus Torvalds

Import 1.1.4

parent 7450aa7e
VERSION = 1
PATCHLEVEL = 1
SUBLEVEL = 3
SUBLEVEL = 4
all: Version zImage
......
......@@ -65,7 +65,7 @@ fi
#bool 'PPP (point-to-point) support' CONFIG_PPP n
bool 'PLIP (parallel port) support' CONFIG_PLIP n
bool 'NE2000/NE1000 support' CONFIG_NE2000 n
bool 'WD80E3 support' CONFIG_WD80x3 y
bool 'WD80*3 support' CONFIG_WD80x3 y
bool 'SMC Ultra support' CONFIG_ULTRA n
bool '3c501 support' CONFIG_EL1 n
bool '3c503 support' CONFIG_EL2 n
......
......@@ -37,10 +37,9 @@ static char *version =
#include <asm/io.h>
#include <errno.h>
#include "dev.h"
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#ifndef HAVE_AUTOIRQ
/* From auto_irq.c, should be in a *.h file. */
......@@ -49,11 +48,6 @@ extern int autoirq_report(int waittime);
extern struct device *irq2dev_map[16];
#endif
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#define kfree_skbmem(addr, size) kfree_s(addr,size);
#endif
/* Index to functions. */
int el1_probe(struct device *dev);
......@@ -64,9 +58,7 @@ static void el_receive(struct device *dev);
static void el_reset(struct device *dev);
static int el1_close(struct device *dev);
static struct enet_statistics *el1_get_stats(struct device *dev);
#ifdef HAVE_MULTICAST
static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
#endif
#define EL_NAME "EtherLink 3c501"
......@@ -202,35 +194,9 @@ el1_probe(struct device *dev)
dev->hard_start_xmit = &el_start_xmit;
dev->stop = &el1_close;
dev->get_stats = &el1_get_stats;
#ifdef HAVE_MULTICAST
dev->set_multicast_list = &set_multicast_list;
#endif
/* Fill in the generic field of the device structure. */
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
/* Setup the generic properties */
ether_setup(dev);
return 0;
}
......@@ -291,14 +257,6 @@ el_start_xmit(struct sk_buff *skb, struct device *dev)
return 0;
}
/* Fill in the ethernet header. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
if (skb->len <= 0)
return 0;
......@@ -431,7 +389,7 @@ el_interrupt(int reg_ptr)
static void
el_receive(struct device *dev)
{
int sksize, pkt_len;
int pkt_len;
struct sk_buff *skb;
pkt_len = inw(RX_LOW);
......@@ -447,31 +405,19 @@ el_receive(struct device *dev)
}
outb(AX_SYS, AX_CMD);
sksize = sizeof(struct sk_buff) + pkt_len;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
outw(0x00, GP_LOW);
if (skb == NULL) {
printk("%s: Memory squeeze, dropping packet.\n", dev->name);
el_status.stats.rx_dropped++;
return;
} else {
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
insb(DATAPORT, skb->data, pkt_len);
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_skbmem(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
netif_rx(skb);
el_status.stats.rx_packets++;
}
return;
......@@ -526,7 +472,6 @@ el1_get_stats(struct device *dev)
return &el_status.stats;
}
#ifdef HAVE_MULTICAST
/* Set or clear the multicast filter for this adaptor.
num_addrs == -1 Promiscuous mode, receive all packets
num_addrs == 0 Normal mode, clear multicast list
......@@ -547,7 +492,6 @@ set_multicast_list(struct device *dev, int num_addrs, void *addrs)
inb(RX_STATUS);
}
}
#endif
/*
* Local variables:
......
......@@ -26,7 +26,7 @@ static char *version =
#include <asm/io.h>
#include <asm/system.h>
#include "dev.h"
#include <linux/netdevice.h>
#include "8390.h"
#include "3c503.h"
......
......@@ -51,17 +51,10 @@ static char *version =
#include <asm/dma.h>
#include <linux/errno.h>
#include "dev.h"
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#define kfree_skbmem(addr, size) kfree_s(addr,size);
#else
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/malloc.h>
#endif
/* use 0 for production, 1 for verification, 2..7 for debug */
#ifndef NET_DEBUG
......@@ -409,32 +402,7 @@ int el16_probe1(struct device *dev, short ioaddr)
dev->hard_start_xmit = el16_send_packet;
dev->get_stats = el16_get_stats;
/* Fill in the fields of the device structure with ethernet-generic values.
This should be in a common file instead of per-driver. */
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
ether_setup(dev); /* Generic ethernet behaviour */
return 0;
}
......@@ -496,15 +464,6 @@ el16_send_packet(struct sk_buff *skb, struct device *dev)
return 0;
}
/* For ethernet, fill in the header. This should really be done by a
higher level, rather than duplicated for each ethernet adaptor. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
/* Block a timer-based transmit from overlapping. */
if (set_bit(0, (void*)&dev->tbusy) != 0)
printk("%s: Transmitter access conflict.\n", dev->name);
......@@ -855,35 +814,22 @@ el16_rx(struct device *dev)
if (frame_status & 0x0080) lp->stats.rx_length_errors++;
} else {
/* Malloc up new buffer. */
int sksize;
struct sk_buff *skb;
pkt_len &= 0x3fff;
sksize = sizeof(struct sk_buff) + pkt_len;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) {
printk("%s: Memory squeeze, dropping packet.\n", dev->name);
lp->stats.rx_dropped++;
break;
}
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
/* 'skb->data' points to the start of sk_buff data area. */
memcpy(skb->data, data_frame + 5, pkt_len);
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_skbmem(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
lp->stats.rx_packets++;
}
......
......@@ -28,14 +28,10 @@ static char *version = "3c509.c:pl15k 3/5/94 becker@super.org\n";
#include <asm/bitops.h>
#include <asm/io.h>
#include "dev.h"
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#endif
#ifdef EL3_DEBUG
......@@ -95,20 +91,17 @@ int el3_probe(struct device *dev)
/* First check for a board on the EISA bus. */
if (EISA_bus) {
for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
/* Check the standard EISA ID register for an encoded '3Com'. */
if (inw(ioaddr + 0xC80) != 0x6d50)
if (inw(ioaddr) != 0x6d50)
continue;
/* Change the register set to the configuration window 0. */
outw(0x0800, ioaddr + 0xC80 + EL3_CMD);
irq = inw(ioaddr + 8) >> 12;
if_port = inw(ioaddr + 6)>>14;
for (i = 0; i < 3; i++)
phys_addr[i] = htons(read_eeprom(ioaddr, i));
/* Restore the "Product ID" to the EEPROM read register. */
read_eeprom(ioaddr, 3);
/* Restore the "Manufacturer ID" to the EEPROM read register. */
/* The manual says to restore "Product ID" (reg. 3). !???! */
read_eeprom(ioaddr, 7);
/* Was the EISA code an add-on hack? Nahhhhh... */
goto found;
......@@ -219,31 +212,7 @@ int el3_probe(struct device *dev)
#endif
/* Fill in the generic fields of the device structure. */
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
ether_setup(dev);
return 0;
}
......@@ -368,14 +337,6 @@ el3_start_xmit(struct sk_buff *skb, struct device *dev)
return 0;
}
/* Fill in the ethernet header. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
if (skb->len <= 0)
return 0;
......@@ -480,7 +441,7 @@ el3_interrupt(int reg_ptr)
if (++i > 10) {
printk("%s: Infinite loop in interrupt, status %4.4x.\n",
dev->name, status);
/* Clear all interrupts we have handled. */
/* Clear all interrupts we have handled */
outw(0x68FF, ioaddr + EL3_CMD);
break;
}
......@@ -568,16 +529,13 @@ el3_rx(struct device *dev)
if ( (! (rx_status & 0x4000))
|| ! (rx_status & 0x1000)) { /* Dribble bits are OK. */
short pkt_len = rx_status & 0x7ff;
int sksize = sizeof(struct sk_buff) + pkt_len + 3;
struct sk_buff *skb;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len+3, GFP_ATOMIC);
if (el3_debug > 4)
printk(" Receiving packet size %d status %4.4x.\n",
printk("Receiving packet size %d status %4.4x.\n",
pkt_len, rx_status);
if (skb != NULL) {
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
......@@ -606,12 +564,12 @@ el3_rx(struct device *dev)
continue;
} else {
printk("%s: receive buffers full.\n", dev->name);
kfree_s(skb, sksize);
kfree_s(skb, FREE_READ);
}
#endif
} else if (el3_debug)
printk("%s: Couldn't allocate a sk_buff of size %d.\n",
dev->name, sksize);
dev->name, pkt_len);
}
lp->stats.rx_dropped++;
outw(0x4000, ioaddr + EL3_CMD); /* Rx discard */
......
......@@ -47,14 +47,9 @@ static char *version =
#include <linux/in.h>
#include <linux/interrupt.h>
#include "dev.h"
#include "eth.h"
#include "ip.h"
#include "protocol.h"
#include "tcp.h"
#include "skbuff.h"
#include "sock.h"
#include "arp.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include "8390.h"
......@@ -153,8 +148,8 @@ static int ei_start_xmit(struct sk_buff *skb, struct device *dev)
else {
/* The 8390 probably hasn't gotten on the cable yet. */
printk(KERN_DEBUG "%s: Possible network cable problem?\n", dev->name);
if (ei_local->stat.tx_packets == 0)
ei_local->interface_num ^= 1; /* Try a different xcvr. */
if(ei_local->stat.tx_packets==0)
ei_local->interface_num ^= 1; /* Try a different xcvr. */
}
/* Try to restart the card. Perhaps the user has fixed something. */
ei_reset_8390(dev);
......@@ -169,13 +164,6 @@ static int ei_start_xmit(struct sk_buff *skb, struct device *dev)
dev_tint(dev);
return 0;
}
/* Fill in the ethernet header. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
length = skb->len;
if (skb->len <= 0)
......@@ -449,19 +437,16 @@ static void ei_receive(struct device *dev)
rx_frame.next);
ei_local->stat.rx_errors++;
} else if ((rx_frame.status & 0x0F) == ENRSR_RXOK) {
int sksize = sizeof(struct sk_buff) + pkt_len;
struct sk_buff *skb;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) {
if (ei_debug > 1)
printk("%s: Couldn't allocate a sk_buff of size %d.\n",
dev->name, sksize);
dev->name, pkt_len);
ei_local->stat.rx_dropped++;
break;
} else {
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
......@@ -580,8 +565,6 @@ static void set_multicast_list(struct device *dev, int num_addrs, void *addrs)
/* Initialize the rest of the 8390 device structure. */
int ethdev_init(struct device *dev)
{
int i;
if (ei_debug > 1)
printk(version);
......@@ -605,32 +588,9 @@ int ethdev_init(struct device *dev)
#ifdef HAVE_MULTICAST
dev->set_multicast_list = &set_multicast_list;
#endif
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
ether_setup(dev);
return 0;
}
......
......@@ -7,7 +7,7 @@
# are difficult for users to deal with.
include CONFIG
NETDRV_OBJS := net.a(Space.o) net.a(auto_irq.o) net.a(net_init.o)
NETDRV_OBJS := net.a(Space.o) net.a(auto_irq.o) net.a(net_init.o) net.a(loopback.o)
CFLAGS := $(CFLAGS) -I../../net/inet
CPP := $(CPP) -I../../net/inet
......
......@@ -26,7 +26,7 @@
*/
#include <linux/config.h>
#include <linux/ddi.h>
#include "dev.h"
#include <linux/netdevice.h>
#define LOOPBACK /* always present, right? */
......
......@@ -40,10 +40,9 @@ static char *version =
#include <asm/dma.h>
#include <errno.h>
#include "dev.h"
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#ifndef HAVE_AUTOIRQ
/* From auto_irq.c, in ioport.h for later versions. */
......@@ -54,11 +53,6 @@ extern int autoirq_report(int waittime);
extern struct device *irq2dev_map[16];
#endif
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#define kfree_skbmem(addr, size) kfree_s(addr,size);
#endif
/* use 0 for production, 1 for verification, >2 for debug */
#ifndef NET_DEBUG
#define NET_DEBUG 2
......@@ -121,9 +115,7 @@ static void net_interrupt(int reg_ptr);
static void net_rx(struct device *dev);
static int net_close(struct device *dev);
static struct enet_statistics *net_get_stats(struct device *dev);
#ifdef HAVE_MULTICAST
static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
#endif
/* Check for a network adaptor of this type, and return '0' iff one exists.
......@@ -258,37 +250,11 @@ int at1700_probe1(struct device *dev, short ioaddr)
dev->stop = net_close;
dev->hard_start_xmit = net_send_packet;
dev->get_stats = net_get_stats;
#ifdef HAVE_MULTICAST
dev->set_multicast_list = &set_multicast_list;
#endif
/* Fill in the fields of the device structure with ethernet-generic values.
This should be in a common file instead of per-driver. */
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
/* Fill in the fields of the device structure with ethernet-generic values. */
ether_setup(dev);
return 0;
}
......@@ -410,15 +376,6 @@ net_send_packet(struct sk_buff *skb, struct device *dev)
return 0;
}
/* For ethernet, fill in the header. This should really be done by a
higher level, rather than duplicated for each ethernet adaptor. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
/* Block a timer-based transmit from overlapping. This could better be
done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
if (set_bit(0, (void*)&dev->tbusy) != 0)
......@@ -534,7 +491,6 @@ net_rx(struct device *dev)
} else {
ushort pkt_len = inw(ioaddr + DATAPORT);
/* Malloc up new buffer. */
int sksize = sizeof(struct sk_buff) + pkt_len;
struct sk_buff *skb;
if (pkt_len > 1550) {
......@@ -544,7 +500,7 @@ net_rx(struct device *dev)
lp->stats.rx_errors++;
break;
}
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) {
printk("%s: Memory squeeze, dropping packet (len %d).\n",
dev->name, pkt_len);
......@@ -552,8 +508,6 @@ net_rx(struct device *dev)
lp->stats.rx_dropped++;
break;
}
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
......@@ -567,16 +521,7 @@ net_rx(struct device *dev)
printk(".\n");
}
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_s(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
lp->stats.rx_packets++;
}
if (--boguscount <= 0)
......@@ -637,7 +582,6 @@ net_get_stats(struct device *dev)
return &lp->stats;
}
#ifdef HAVE_MULTICAST
/* Set or clear the multicast filter for this adaptor.
num_addrs == -1 Promiscuous mode, receive all packets
num_addrs == 0 Normal mode, clear multicast list
......@@ -653,7 +597,6 @@ set_multicast_list(struct device *dev, int num_addrs, void *addrs)
} else
outw(2, ioaddr + RX_MODE); /* Disable promiscuous, use normal mode */
}
#endif
/*
* Local variables:
......
......@@ -91,10 +91,9 @@ static char *version =
#include <asm/dma.h>
#include <errno.h>
#include "dev.h"
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include "atp.h"
......@@ -132,7 +131,6 @@ static unsigned int net_debug = NET_DEBUG;
extern int atp_probe(struct device *dev);
static int atp_probe1(struct device *dev, short ioaddr);
static void init_dev(struct device *dev);
static void get_node_ID(struct device *dev);
static unsigned short eeprom_op(short ioaddr, unsigned int cmd);
static int net_open(struct device *dev);
......@@ -145,9 +143,7 @@ static void net_rx(struct device *dev);
static void read_block(short ioaddr, int length, unsigned char *buffer, int data_mode);
static int net_close(struct device *dev);
static struct enet_statistics *net_get_stats(struct device *dev);
#ifdef HAVE_MULTICAST
static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
#endif
/* Check for a network adaptor of this type, and return '0' iff one exists.
......@@ -232,7 +228,7 @@ static int atp_probe1(struct device *dev, short ioaddr)
printk(version);
/* Initialize the device structure. */
init_dev(dev);
ether_setup(dev);
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
memset(dev->priv, 0, sizeof(struct net_local));
......@@ -251,45 +247,11 @@ static int atp_probe1(struct device *dev, short ioaddr)
dev->stop = net_close;
dev->hard_start_xmit = net_send_packet;
dev->get_stats = net_get_stats;
#ifdef HAVE_MULTICAST
dev->set_multicast_list = &set_multicast_list;
#endif
return 0;
}
/* Fill in the fields of the device structure with ethernet-generic values.
This should be in a common file instead of per-driver. */
static void init_dev(struct device *dev)
{
int i;
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
}
/* Read the station address PROM, usually a word-wide EEPROM. */
static void get_node_ID(struct device *dev)
{
......@@ -475,15 +437,6 @@ net_send_packet(struct sk_buff *skb, struct device *dev)
return 0;
}
/* For ethernet, fill in the header. This should really be done by a
higher level, rather than duplicated for each ethernet adaptor. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
/* Block a timer-based transmit from overlapping. This could better be
done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
if (set_bit(0, (void*)&dev->tbusy) != 0)
......@@ -674,17 +627,14 @@ static void net_rx(struct device *dev)
} else {
/* Malloc up new buffer. */
int pkt_len = (rx_head.rx_count & 0x7ff) - 4; /* The "-4" is omits the FCS (CRC). */
int sksize = sizeof(struct sk_buff) + pkt_len;
struct sk_buff *skb;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) {
printk("%s: Memory squeeze, dropping packet.\n", dev->name);
lp->stats.rx_dropped++;
goto done;
}
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
......@@ -699,16 +649,7 @@ static void net_rx(struct device *dev)
data[12], data[13]);
}
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_s(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
lp->stats.rx_packets++;
}
done:
......@@ -770,7 +711,6 @@ net_get_stats(struct device *dev)
return &lp->stats;
}
#ifdef HAVE_MULTICAST
/* Set or clear the multicast filter for this adaptor.
num_addrs == -1 Promiscuous mode, receive all packets
num_addrs == 0 Normal mode, clear multicast list
......@@ -785,7 +725,6 @@ set_multicast_list(struct device *dev, int num_addrs, void *addrs)
lp->addr_mode = num_addrs ? CMR2h_PROMISC : CMR2h_Normal;
write_reg_high(ioaddr, CMR2, lp->addr_mode);
}
#endif
/*
* Local variables:
......
......@@ -35,7 +35,7 @@ static char *version="auto_irq.c:v0.02 1993 Donald Becker (becker@super.org)";
#include <linux/sched.h>
#include <asm/bitops.h>
#include <asm/io.h>
#include "dev.h"
#include <linux/netdevice.h>
/*#include <asm/system.h>*/
struct device *irq2dev_map[16] = {0, 0, /* ... zeroed */};
......
......@@ -76,23 +76,13 @@ static unsigned int d_link_debug = D_LINK_DEBUG;
#include <asm/system.h>
#include <errno.h>
#include "inet.h"
#include "dev.h"
#include "eth.h"
#include "ip.h"
#include "route.h"
#include "protocol.h"
#include "tcp.h"
#include "skbuff.h"
#include "sock.h"
#include "arp.h"
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#define netstats enet_statistics
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size,pri) (struct sk_buff *)kmalloc(size,pri)
#endif
/**************************************************
* *
* Definition of D-Link Ethernet Pocket adapter *
......@@ -334,7 +324,10 @@ d_link_open(struct device *dev)
*
* This fix is better than changing in tcp.h IMHO
*/
#if 0
tcp_prot.rspace = d_link_rspace; /* was: sock_rspace */
#endif
return 0;
}
......@@ -355,8 +348,9 @@ d_link_close(struct device *dev)
free_irq(D_LINK_IRQ);
irq2dev_map[D_LINK_IRQ] = NULL;
dev->start = 0;
#if 0
tcp_prot.rspace = sock_rspace; /* see comment above! */
#endif
return 0;
}
......@@ -399,15 +393,6 @@ d_link_start_xmit(struct sk_buff *skb, struct device *dev)
return 0;
}
/* For ethernet, fill in the header (hardware addresses) with an arp. */
if (!skb->arp)
if(dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp = 1;
if (free_tx_pages <= 0) { /* Do timeouts, to avoid hangs. */
tickssofar = jiffies - dev->trans_start;
......@@ -559,7 +544,6 @@ d_link_rx_intr(struct device *dev)
int i;
int read_from;
int size;
int sksize;
register unsigned char *buffer;
cli();
......@@ -577,19 +561,16 @@ d_link_rx_intr(struct device *dev)
if ((size < 32) || (size > 1535))
printk("%s: Bogus packet size %d.\n", dev->name, size);
sksize = sizeof(struct sk_buff) + size;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(size, GFP_ATOMIC);
sti();
if (skb == NULL) {
printk("%s: Couldn't allocate a sk_buff of size %d.\n",
dev->name, sksize);
dev->name, size);
return;
}
/* else */
skb->lock = 0;
skb->mem_len = sksize;
skb->mem_addr = skb;
/* 'skb->data' points to the start of sk_buff data area. */
buffer = skb->data;
......@@ -663,35 +644,14 @@ d_link_init(struct device *dev)
/* Initialize the device structure. */
dev->priv = kmalloc(sizeof(struct netstats), GFP_KERNEL);
memset(dev->priv, 0, sizeof(struct netstats));
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->get_stats = get_stats;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->open = d_link_open;
dev->stop = d_link_close;
dev->hard_start_xmit = &d_link_start_xmit;
/* These are ethernet specific. */
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
ether_setup(dev);
select_prn();
return 0;
}
......
......@@ -147,11 +147,10 @@ static char *version = "depca.c:v0.35 3/8/94 davies@wanton.lkg.dec.com\n";
#include <asm/io.h>
#include <asm/dma.h>
#include "dev.h"
#include <linux/netdevice.h>
#include "iow.h" /* left in for pl13/14 compatibility... */
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include "depca.h"
#ifdef DEPCA_DEBUG
......@@ -216,11 +215,6 @@ static short mem_chkd = 0; /* holds which base addrs have been */
#endif /* CRC_POLYNOMIAL */
#endif /* HAVE_MULTICAST */
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#define kfree_skbmem(buff, size) kfree_s(buff,size)
#endif /* HAVE_ALLOC_SKB */
/*
** The DEPCA Rx and Tx ring descriptors.
*/
......@@ -1066,17 +1060,14 @@ depca_rx(struct device *dev)
if (status & R_BUFF) lp->stats.rx_fifo_errors++;
} else { /* Malloc up new buffer, compatible with net-2e. */
short pkt_len = lp->rx_ring[entry].msg_length;
int sksize = sizeof(struct sk_buff) + pkt_len;
struct sk_buff *skb;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) {
printk("%s: Memory squeeze, deferring packet.\n", dev->name);
lp->stats.rx_dropped++; /* Really, deferred. */
break;
}
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
memcpy(skb->data,
......@@ -1086,16 +1077,7 @@ depca_rx(struct device *dev)
** Notify the upper protocol layers that there is another
** packet to handle
*/
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_skbmem(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
lp->stats.rx_packets++;
}
......
/* eexpress.c: Intel EtherExpress device driver for Linux. */
/*
Written 1993 by Donald Becker.
......@@ -41,25 +42,19 @@ static char *version =
#include <linux/interrupt.h>
#include <linux/ptrace.h>
#include <linux/ioport.h>
#include <linux/in.h>
#include <linux/string.h>
#include <linux/in.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include <asm/io.h>
#include <asm/dma.h>
#include <linux/errno.h>
#include "dev.h"
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#else
/* This isn't quite right, but it's the best version define I can find right now. */
#include <linux/malloc.h>
#endif
/* use 0 for production, 1 for verification, 2..7 for debug */
#ifndef NET_DEBUG
......@@ -292,9 +287,7 @@ static void eexp_interrupt(int reg_ptr);
static void eexp_rx(struct device *dev);
static int eexp_close(struct device *dev);
static struct enet_statistics *eexp_get_stats(struct device *dev);
#ifdef HAVE_MULTICAST
static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
#endif
static int read_eeprom(int ioaddr, int location);
static void hardware_send_packet(struct device *dev, void *buf, short length);
......@@ -405,37 +398,12 @@ int eexp_probe1(struct device *dev, short ioaddr)
dev->stop = eexp_close;
dev->hard_start_xmit = eexp_send_packet;
dev->get_stats = eexp_get_stats;
#ifdef HAVE_MULTICAST
dev->set_multicast_list = &set_multicast_list;
#endif
/* Fill in the fields of the device structure with ethernet-generic values.
This should be in a common file instead of per-driver. */
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
/* Fill in the fields of the device structure with ethernet-generic values. */
ether_setup(dev);
return 0;
}
......@@ -511,15 +479,6 @@ eexp_send_packet(struct sk_buff *skb, struct device *dev)
return 0;
}
/* For ethernet, fill in the header. This should really be done by a
higher level, rather than duplicated for each ethernet adaptor. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
/* Block a timer-based transmit from overlapping. */
if (set_bit(0, (void*)&dev->tbusy) != 0)
printk("%s: Transmitter access conflict.\n", dev->name);
......@@ -704,7 +663,6 @@ eexp_get_stats(struct device *dev)
return &lp->stats;
}
#ifdef HAVE_MULTICAST
/* Set or clear the multicast filter for this adaptor.
num_addrs == -1 Promiscuous mode, receive all packets
num_addrs == 0 Normal mode, clear multicast list
......@@ -731,7 +689,6 @@ set_multicast_list(struct device *dev, int num_addrs, void *addrs)
outw(99, ioaddr); /* Disable promiscuous mode, use normal mode */
}
}
#endif
/* The horrible routine to read a word from the serial EEPROM. */
......@@ -964,19 +921,15 @@ eexp_rx(struct device *dev)
if (frame_status & 0x0080) lp->stats.rx_length_errors++;
} else {
/* Malloc up new buffer. */
int sksize;
struct sk_buff *skb;
pkt_len &= 0x3fff;
sksize = sizeof(struct sk_buff) + pkt_len;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) {
printk("%s: Memory squeeze, dropping packet.\n", dev->name);
lp->stats.rx_dropped++;
break;
}
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
......@@ -984,16 +937,7 @@ eexp_rx(struct device *dev)
insw(ioaddr, skb->data, (pkt_len + 1) >> 1);
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_s(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
lp->stats.rx_packets++;
}
......
......@@ -23,7 +23,7 @@ static char *version =
#include <asm/system.h>
#include <asm/io.h>
#include "dev.h"
#include <linux/netdevice.h>
#include "8390.h"
#ifndef HAVE_PORTRESERVE
......
......@@ -29,21 +29,15 @@ static char *version = "lance.c:v0.14g 12/21/93 becker@super.org\n";
#include <asm/io.h>
#include <asm/dma.h>
#include "dev.h"
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#ifndef HAVE_PORTRESERVE
#define check_region(addr, size) 0
#define snarf_region(addr, size) do ; while(0)
#endif
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#define kfree_skbmem(buff, size) kfree_s(buff,size)
#endif
struct device *init_etherdev(struct device *dev, int sizeof_private,
unsigned long *mem_startp);
......@@ -359,9 +353,7 @@ unsigned long lance_probe1(short ioaddr, unsigned long mem_start)
dev->hard_start_xmit = &lance_start_xmit;
dev->stop = &lance_close;
dev->get_stats = &lance_get_stats;
#ifdef HAVE_MULTICAST
dev->set_multicast_list = &set_multicast_list;
#endif
return mem_start;
}
......@@ -511,14 +503,6 @@ lance_start_xmit(struct sk_buff *skb, struct device *dev)
return 0;
}
/* Fill in the ethernet header. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
if (skb->len <= 0)
return 0;
......@@ -720,32 +704,20 @@ lance_rx(struct device *dev)
} else {
/* Malloc up new buffer, compatible with net-2e. */
short pkt_len = lp->rx_ring[entry].msg_length;
int sksize = sizeof(struct sk_buff) + pkt_len;
struct sk_buff *skb;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) {
printk("%s: Memory squeeze, deferring packet.\n", dev->name);
lp->stats.rx_dropped++; /* Really, deferred. */
break;
}
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
memcpy(skb->data,
(unsigned char *)(lp->rx_ring[entry].base & 0x00ffffff),
pkt_len);
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_skbmem(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
lp->stats.rx_packets++;
}
......@@ -808,7 +780,6 @@ lance_get_stats(struct device *dev)
return &lp->stats;
}
#ifdef HAVE_MULTICAST
/* Set or clear the multicast filter for this adaptor.
num_addrs == -1 Promiscuous mode, receive all packets
num_addrs == 0 Normal mode, clear multicast list
......@@ -842,7 +813,6 @@ set_multicast_list(struct device *dev, int num_addrs, void *addrs)
outw(0, ioaddr+LANCE_ADDR);
outw(0x0142, ioaddr+LANCE_DATA); /* Resume normal operation. */
}
#endif
#ifdef HAVE_DEVLIST
static unsigned int lance_portlist[] = {0x300, 0x320, 0x340, 0x360, 0};
......
......@@ -32,15 +32,10 @@
#include <asm/segment.h>
#include <asm/io.h>
#include "inet.h"
#include "dev.h"
#include "eth.h"
#include "ip.h"
#include "protocol.h"
#include "tcp.h"
#include "skbuff.h"
#include "sock.h"
#include "arp.h"
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
static int
......@@ -55,17 +50,23 @@ loopback_xmit(struct sk_buff *skb, struct device *dev)
cli();
if (dev->tbusy != 0) {
sti();
printk("loopback error: called by %08lx\n",
((unsigned long *)&skb)[-1]);
stats->tx_errors++;
return(1);
}
dev->tbusy = 1;
sti();
start_bh_atomic();
done = dev_rint(skb->data, skb->len, 0, dev);
if (skb->free) kfree_skb(skb, FREE_WRITE);
end_bh_atomic();
while (done != 1) {
start_bh_atomic();
done = dev_rint(NULL, 0, 0, dev);
end_bh_atomic();
}
stats->tx_packets++;
......@@ -99,13 +100,14 @@ get_stats(struct device *dev)
int
loopback_init(struct device *dev)
{
int i;
dev->mtu = 2000; /* MTU */
dev->tbusy = 0;
dev->hard_start_xmit = loopback_xmit;
dev->open = NULL;
#if 1
dev->hard_header = eth_header;
dev->add_arp = NULL;
dev->hard_header_len = ETH_HLEN; /* 14 */
dev->addr_len = ETH_ALEN; /* 6 */
dev->type = ARPHRD_ETHER; /* 0x0001 */
......@@ -113,14 +115,12 @@ loopback_init(struct device *dev)
dev->rebuild_header = eth_rebuild_header;
#else
dev->hard_header_length = 0;
dev->add_arp = NULL;
dev->addr_len = 0;
dev->type = 0; /* loopback_type (0) */
dev->hard_header = NULL;
dev->type_trans = NULL;
dev->rebuild_header = NULL;
#endif
dev->queue_xmit = dev_queue_xmit;
/* New-style flags. */
dev->flags = IFF_LOOPBACK;
......@@ -132,6 +132,10 @@ loopback_init(struct device *dev)
dev->priv = kmalloc(sizeof(struct enet_statistics), GFP_KERNEL);
memset(dev->priv, 0, sizeof(struct enet_statistics));
dev->get_stats = get_stats;
/* Fill in the generic fields of the device structure. */
for (i = 0; i < DEV_NUMBUFFS; i++)
skb_queue_head_init(&dev->buffs[i]);
return(0);
};
......@@ -26,7 +26,7 @@ static char *version =
#include <asm/system.h>
#include <asm/io.h>
#include "dev.h"
#include <linux/netdevice.h>
#include "8390.h"
#define NE_BASE (dev->base_addr)
......
......@@ -24,8 +24,8 @@
#include <linux/malloc.h>
#include <linux/if_ether.h>
#include <linux/string.h>
#include "dev.h"
#include "eth.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
/* The network devices currently exist only in the socket namespace, so these
entries are unused. The only ones that make sense are
......@@ -38,26 +38,14 @@
Given that almost all of these functions are handled in the current
socket-based scheme, putting ethercard devices in /dev/ seems pointless.
[Removed all support for /dev network devices. When someone adds streams then
by magic we get them, but otherwise they are un-needed and a space waste]
*/
/* The next device number/name to assign: "eth0", "eth1", etc. */
static int next_ethdev_number = 0;
#ifdef NET_MAJOR_NUM
static struct file_operations netcard_fops = {
NULL, /* lseek */
NULL, /* read */
NULL, /* write */
NULL, /* readdir */
NULL, /* select */
NULL, /* ioctl */
NULL, /* mmap */
NULL, /* open */
NULL, /* release */
NULL /* fsync */
};
#endif
unsigned long lance_init(unsigned long mem_start, unsigned long mem_end);
/*
......@@ -69,12 +57,6 @@ unsigned long lance_init(unsigned long mem_start, unsigned long mem_end);
unsigned long net_dev_init (unsigned long mem_start, unsigned long mem_end)
{
#ifdef NET_MAJOR_NUM
if (register_chrdev(NET_MAJOR_NUM, "network",&netcard_fops))
printk("WARNING: Unable to get major %d for the network devices.\n",
NET_MAJOR_NUM);
#endif
#if defined(CONFIG_LANCE) /* Note this is _not_ CONFIG_AT1500. */
mem_start = lance_init(mem_start, mem_end);
#endif
......@@ -117,11 +99,9 @@ struct device *init_etherdev(struct device *dev, int sizeof_private,
sprintf(dev->name, "eth%d", next_ethdev_number++);
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
skb_queue_head_init(&dev->buffs[i]);
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
......@@ -152,6 +132,36 @@ struct device *init_etherdev(struct device *dev, int sizeof_private,
return dev;
}
void ether_setup(struct device *dev)
{
int i;
/* Fill in the fields of the device structure with ethernet-generic values.
This should be in a common file instead of per-driver. */
for (i = 0; i < DEV_NUMBUFFS; i++)
skb_queue_head_init(&dev->buffs[i]);
dev->hard_header = eth_header;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
}
/*
* Local variables:
......
This diff is collapsed.
......@@ -56,10 +56,9 @@ static char *version =
#include <asm/dma.h>
#include <errno.h>
#include "dev.h"
#include "eth.h"
#include "skbuff.h"
#include "arp.h"
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#ifndef HAVE_AUTOIRQ
/* From auto_irq.c, in ioport.h for later versions. */
......@@ -70,11 +69,6 @@ extern int autoirq_report(int waittime);
extern struct device *irq2dev_map[16];
#endif
#ifndef HAVE_ALLOC_SKB
#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
#define kfree_skbmem(addr, size) kfree_s(addr,size);
#endif
#ifndef HAVE_PORTRESERVE
#define check_region(ioaddr, size) 0
#define snarf_region(ioaddr, size); do ; while (0)
......@@ -111,9 +105,7 @@ static void net_interrupt(int reg_ptr);
static void net_rx(struct device *dev);
static int net_close(struct device *dev);
static struct enet_statistics *net_get_stats(struct device *dev);
#ifdef HAVE_MULTICAST
static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
#endif
/* Example routines you must write ;->. */
#define tx_done(dev) 1
......@@ -213,36 +205,11 @@ int netcard_probe1(struct device *dev, short ioaddr)
dev->stop = net_close;
dev->hard_start_xmit = net_send_packet;
dev->get_stats = net_get_stats;
#ifdef HAVE_MULTICAST
dev->set_multicast_list = &set_multicast_list;
#endif
/* Fill in the fields of the device structure with ethernet-generic values.
This should be in a common file instead of per-driver. */
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
dev->hard_header = eth_header;
dev->add_arp = eth_add_arp;
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = eth_rebuild_header;
dev->type_trans = eth_type_trans;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = 1500; /* eth_mtu */
dev->addr_len = ETH_ALEN;
for (i = 0; i < ETH_ALEN; i++) {
dev->broadcast[i]=0xff;
}
/* New-style flags. */
dev->flags = IFF_BROADCAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
dev->pa_mask = 0;
dev->pa_alen = sizeof(unsigned long);
/* Fill in the fields of the device structure with ethernet-generic values. */
ether_setup(dev);
return 0;
}
......@@ -314,15 +281,6 @@ net_send_packet(struct sk_buff *skb, struct device *dev)
return 0;
}
/* For ethernet, fill in the header. This should really be done by a
higher level, rather than duplicated for each ethernet adaptor. */
if (!skb->arp && dev->rebuild_header(skb->data, dev)) {
skb->dev = dev;
arp_queue (skb);
return 0;
}
skb->arp=1;
/* Block a timer-based transmit from overlapping. This could better be
done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
if (set_bit(0, (void*)&dev->tbusy) != 0)
......@@ -406,17 +364,14 @@ net_rx(struct device *dev)
if (status & 0x04) lp->stats.rx_fifo_errors++;
} else {
/* Malloc up new buffer. */
int sksize = sizeof(struct sk_buff) + pkt_len;
struct sk_buff *skb;
skb = alloc_skb(sksize, GFP_ATOMIC);
skb = alloc_skb(pkt_len, GFP_ATOMIC);
if (skb == NULL) {
printk("%s: Memory squeeze, dropping packet.\n", dev->name);
lp->stats.rx_dropped++;
break;
}
skb->mem_len = sksize;
skb->mem_addr = skb;
skb->len = pkt_len;
skb->dev = dev;
......@@ -426,16 +381,7 @@ net_rx(struct device *dev)
/* or */
insw(ioaddr, skb->data, (pkt_len + 1) >> 1);
#ifdef HAVE_NETIF_RX
netif_rx(skb);
#else
skb->lock = 0;
if (dev_rint((unsigned char*)skb, pkt_len, IN_SKBUFF, dev) != 0) {
kfree_s(skb, sksize);
lp->stats.rx_dropped++;
break;
}
#endif
lp->stats.rx_packets++;
}
} while (--boguscount);
......@@ -492,7 +438,6 @@ net_get_stats(struct device *dev)
return &lp->stats;
}
#ifdef HAVE_MULTICAST
/* Set or clear the multicast filter for this adaptor.
num_addrs == -1 Promiscuous mode, receive all packets
num_addrs == 0 Normal mode, clear multicast list
......@@ -508,7 +453,6 @@ set_multicast_list(struct device *dev, int num_addrs, void *addrs)
} else
outw(99, ioaddr); /* Disable promiscuous mode, use normal mode */
}
#endif
/*
* Local variables:
......
......@@ -36,8 +36,15 @@
* allow zero or one slots
* separate routines
* status display
*
*
* This module is a difficult issue. Its clearly inet code but its also clearly
* driver code belonging close to PPP and SLIP
*/
#include <linux/config.h>
#ifdef CONFIG_INET
/* Entire module is for IP only */
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/mm.h>
......@@ -47,15 +54,14 @@
#include <linux/termios.h>
#include <linux/in.h>
#include <linux/fcntl.h>
#include "inet.h"
#include "dev.h"
#include <linux/inet.h>
#include <linux/netdevice.h>
#include "ip.h"
#include "protocol.h"
#include "icmp.h"
#include "tcp.h"
#include "skbuff.h"
#include <linux/skbuff.h>
#include "sock.h"
#include "arp.h"
#include <linux/errno.h>
#include <linux/timer.h>
#include <asm/system.h>
......@@ -723,3 +729,4 @@ void slhc_o_status(struct slcompress *comp)
}
}
#endif /* CONFIG_INET */
......@@ -21,6 +21,10 @@
* Michael Riepe : Automatic CSLIP recognition added
* Charles Hedrick : CSLIP header length problem fix.
* Alan Cox : Corrected non-IP cases of the above.
*
*
* FIXME: This driver still makes some IP'ish assumptions. It should build cleanly KISS TNC only without
* CONFIG_INET defined.
*/
#include <asm/segment.h>
......@@ -39,21 +43,24 @@
#include <linux/errno.h>
#include <linux/stat.h>
#include <linux/in.h>
#include "inet.h"
#include "dev.h"
#include <linux/inet.h>
#include <linux/netdevice.h>
#ifdef CONFIG_AX25
#include "ax25.h"
#endif
#include "eth.h"
#include <linux/etherdevice.h>
#ifdef CONFIG_INET
#include "ip.h"
#include "route.h"
#include "protocol.h"
#include "tcp.h"
#include "skbuff.h"
#endif
#include <linux/skbuff.h>
#include "sock.h"
#include "arp.h"
#include "slip.h"
#ifdef CONFIG_INET
#include "slhc.h"
#endif
#define SLIP_VERSION "0.7.5"
......@@ -363,6 +370,7 @@ sl_bump(struct slip *sl)
int count;
count = sl->rcount;
#ifdef CONFIG_INET
if (sl->mode & (SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) {
if ((c = sl->rbuff[0]) & SL_TYPE_COMPRESSED_TCP) {
#if 1
......@@ -408,7 +416,7 @@ sl_bump(struct slip *sl)
DPRINTF((DBG_SLIP, "<< \"%s\" recv:\r\n", sl->dev->name));
ip_dump(sl->rbuff, sl->rcount);
#endif
/* Bump the datagram to the upper layers... */
do {
DPRINTF((DBG_SLIP, "SLIP: packet is %d at 0x%X\n",
......@@ -454,49 +462,14 @@ sl_encaps(struct slip *sl, unsigned char *icp, int len)
}
p = icp;
#ifdef CONFIG_INET
if(sl->mode & SL_MODE_CSLIP)
len = slhc_compress(sl->slcomp, p, len, sl->cbuff, &p, 1);
#ifdef OLD
/*
* Send an initial END character to flush out any
* data that may have accumulated in the receiver
* due to line noise.
*/
bp = sl->xbuff;
*bp++ = END;
count = 1;
/*
* For each byte in the packet, send the appropriate
* character sequence, according to the SLIP protocol.
*/
while(len-- > 0) {
c = *p++;
switch(c) {
case END:
*bp++ = ESC;
*bp++ = ESC_END;
count += 2;
break;
case ESC:
*bp++ = ESC;
*bp++ = ESC_ESC;
count += 2;
break;
default:
*bp++ = c;
count++;
}
}
*bp++ = END;
count++;
#else
#endif
if(sl->mode & SL_MODE_SLIP6)
count=slip_esc6(p, (unsigned char *)sl->xbuff,len);
else
count=slip_esc(p, (unsigned char *)sl->xbuff,len);
#endif
sl->spacket++;
bp = sl->xbuff;
......@@ -552,36 +525,45 @@ sl_xmit(struct sk_buff *skb, struct device *dev)
/* We were not, so we are now... :-) */
if (skb != NULL) {
#ifdef CONFIG_AX25
if(sl->mode & SL_MODE_AX25)
{
if(!skb->arp && dev->rebuild_header(skb->data,dev))
{
skb->dev=dev;
arp_queue(skb);
return 0;
}
skb->arp=1;
}
#if 0
#ifdef CONFIG_AX25
if(sl->mode & SL_MODE_AX25)
{
if(!skb->arp && dev->rebuild_header(skb->data,dev))
{
skb->dev=dev;
arp_queue(skb);
return 0;
}
skb->arp=1;
}
#endif
#endif
sl_lock(sl);
size = skb->len;
if (!(sl->mode & SL_MODE_AX25)) {
if (size < sizeof(struct iphdr)) {
size=skb->len;
if(!(sl->mode&SL_MODE_AX25))
{
if(size<sizeof(struct iphdr))
{
printk("Runt IP frame fed to slip!\n");
} else {
size = ((struct iphdr *)(skb->data))->tot_len;
size = ntohs(size);
}
else
{
size=((struct iphdr *)(skb->data))->tot_len;
size=ntohs(size);
/* sl_hex_dump(skb->data,skb->len);*/
}
}
/* sl_hex_dump(skb->data,skb->len);*/
sl_encaps(sl, skb->data, size);
if (skb->free)
if (skb->free)
kfree_skb(skb, FREE_WRITE);
}
return(0);
}
/* Return the frame type ID. This is normally IP but maybe be AX.25. */
static unsigned short
sl_type_trans (struct sk_buff *skb, struct device *dev)
......@@ -589,49 +571,37 @@ sl_type_trans (struct sk_buff *skb, struct device *dev)
#ifdef CONFIG_AX25
struct slip *sl=&sl_ctrl[dev->base_addr];
if(sl->mode&SL_MODE_AX25)
return(NET16(ETH_P_AX25));
return htons(ETH_P_AX25);
#endif
return(NET16(ETH_P_IP));
return htons(ETH_P_IP);
}
/* Fill in the MAC-level header. Not used by SLIP. */
static int
sl_header(unsigned char *buff, struct device *dev, unsigned short type,
unsigned long daddr, unsigned long saddr, unsigned len)
void *daddr, void *saddr, unsigned len, struct sk_buff *skb)
{
#ifdef CONFIG_AX25
struct slip *sl=&sl_ctrl[dev->base_addr];
if((sl->mode&SL_MODE_AX25) && type!=NET16(ETH_P_AX25))
return ax25_encapsulate_ip(buff,dev,type,daddr,saddr,len);
if((sl->mode&SL_MODE_AX25) && type!=htons(ETH_P_AX25))
return ax25_encapsulate(buff,dev,type,daddr,saddr,len,skb);
#endif
return(0);
}
/* Add an ARP-entry for this device's broadcast address. Not used. */
static void
sl_add_arp(unsigned long addr, struct sk_buff *skb, struct device *dev)
{
#ifdef CONFIG_AX25
struct slip *sl=&sl_ctrl[dev->base_addr];
if(sl->mode&SL_MODE_AX25)
arp_add(addr,((char *) skb->data)+8,dev);
#endif
}
/* Rebuild the MAC-level header. Not used by SLIP. */
static int
sl_rebuild_header(void *buff, struct device *dev)
sl_rebuild_header(void *buff, struct device *dev, unsigned long raddr,
struct sk_buff *skb)
{
#ifdef CONFIG_AX25
struct slip *sl=&sl_ctrl[dev->base_addr];
if(sl->mode&SL_MODE_AX25)
return ax25_rebuild_header(buff,dev);
return ax25_rebuild_header(buff,dev,raddr, skb);
#endif
return(0);
}
......@@ -779,33 +749,10 @@ slip_recv(struct tty_struct *tty)
break;
}
p = buff;
#ifdef OLD
while (count--) {
c = *p++;
if (sl->escape) {
if (c == ESC_ESC)
sl_enqueue(sl, ESC);
else if (c == ESC_END)
sl_enqueue(sl, END);
else
printk ("SLIP: received wrong character\n");
sl->escape = 0;
} else {
if (c == ESC)
sl->escape = 1;
else if (c == END) {
if (sl->rcount > 2) sl_bump(sl);
sl_dequeue(sl, sl->rcount);
sl->rcount = 0;
} else sl_enqueue(sl, c);
}
}
#else
if(sl->mode & SL_MODE_SLIP6)
slip_unesc6(sl,buff,count,error);
else
slip_unesc(sl,buff,count,error);
#endif
} while(1);
}
......@@ -1102,9 +1049,9 @@ slip_ioctl(struct tty_struct *tty, void *file, int cmd, void *arg)
DPRINTF((DBG_SLIP, "SLIP: ioctl(%d, 0x%X, 0x%X)\n", tty->line, cmd, arg));
switch(cmd) {
case SIOCGIFNAME:
err=verify_area(VERIFY_WRITE, arg, strlen(sl->dev->name) + 1);
err=verify_area(VERIFY_WRITE, arg, 16);
if(err)
return err;
return -err;
memcpy_tofs(arg, sl->dev->name, strlen(sl->dev->name) + 1);
return(0);
case SIOCGIFENCAP:
......@@ -1156,7 +1103,9 @@ slip_init(struct device *dev)
if (already++ == 0) {
printk("SLIP: version %s (%d channels)\n",
SLIP_VERSION, SL_NRUNIT);
#ifdef CONFIG_INET
printk("CSLIP: code copyright 1989 Regents of the University of California\n");
#endif
#ifdef CONFIG_AX25
printk("AX25: KISS encapsulation enabled\n");
#endif
......@@ -1191,7 +1140,6 @@ slip_init(struct device *dev)
dev->open = sl_open;
dev->stop = sl_close;
dev->hard_header = sl_header;
dev->add_arp = sl_add_arp;
dev->type_trans = sl_type_trans;
dev->get_stats = sl_get_stats;
#ifdef HAVE_SET_MAC_ADDR
......@@ -1206,10 +1154,9 @@ slip_init(struct device *dev)
memcpy(dev->broadcast,ax25_bcast,7); /* Only activated in AX.25 mode */
memcpy(dev->dev_addr,ax25_test,7); /* "" "" "" "" */
#endif
dev->queue_xmit = dev_queue_xmit;
dev->rebuild_header = sl_rebuild_header;
for (i = 0; i < DEV_NUMBUFFS; i++)
dev->buffs[i] = NULL;
skb_queue_head_init(&dev->buffs[i]);
/* New-style flags. */
dev->flags = 0;
......
......@@ -24,7 +24,7 @@ static char *version =
#include <asm/io.h>
#include <asm/system.h>
#include "dev.h"
#include <linux/netdevice.h>
#include "8390.h"
/* Compatibility definitions for earlier kernel versions. */
......
......@@ -25,7 +25,7 @@ static char *version =
#include <asm/io.h>
#include <asm/system.h>
#include "dev.h"
#include <linux/netdevice.h>
#include "8390.h"
/* Compatibility definitions for earlier kernel versions. */
......
......@@ -632,12 +632,12 @@ static void requeue_sd_request (Scsi_Cmnd * SCpnt)
printk("Use sg, count %d %x %d\n", SCpnt->use_sg, count, dma_free_sectors);
printk("maxsg = %x, counted = %d this_count = %d\n", max_sg, counted, this_count);
while(bh){
printk("[%8.8x %x] ", bh->b_data, bh->b_size);
printk("[%p %lx] ", bh->b_data, bh->b_size);
bh = bh->b_reqnext;
};
if(SCpnt->use_sg < 16)
for(count=0; count<SCpnt->use_sg; count++)
printk("{%d:%8.8x %8.8x %d} ", count,
printk("{%d:%p %p %d} ", count,
sgpnt[count].address,
sgpnt[count].alt_address,
sgpnt[count].length);
......
......@@ -193,10 +193,9 @@ static int sync_buffers(dev_t dev, int wait)
/* If an unlocked buffer is not uptodate, there has
been an IO error. Skip it. */
if (wait && bh->b_req && !bh->b_lock &&
!bh->b_dirt && !bh->b_uptodate)
{
!bh->b_dirt && !bh->b_uptodate) {
err = 1;
printk("Weird - unlocked, clean and not uptodate buffer on %d list %d\n", nlist);
printk("Weird - unlocked, clean and not uptodate buffer on list %d\n", nlist);
continue;
}
/* Don't write clean buffers. Don't write ANY buffers
......@@ -208,7 +207,7 @@ static int sync_buffers(dev_t dev, int wait)
ll_rw_block(WRITE, 1, &bh);
if(nlist != BUF_DIRTY) {
printk("[%d %x %d] ", nlist, bh->b_dev, bh->b_blocknr);
printk("[%d %x %ld] ", nlist, bh->b_dev, bh->b_blocknr);
ncount++;
};
bh->b_count--;
......@@ -596,7 +595,8 @@ void refill_freelist(int size)
to request some blocks in a filesystem that we know that we will
be needing ahead of time. */
if(nr_free[isize] > 100) return 0;
if (nr_free[isize] > 100)
return;
/* If there are too many dirty buffers, we wake up the update process
now so as to ensure that there are still clean buffers available
......
......@@ -15,6 +15,8 @@
* quite a bit, modularized the code.
* fvk 4/'93 waltje@uwalt.nl.mugnet.org (Fred N. van Kempen)
* Renamed "route_get_info()" to "rt_get_info()" for consistency.
* Alan Cox (gw4pts@gw4pts.ampr.org) 4/94
* Dusted off the code and added IPX. Fixed the 4K limit.
*
* proc net directory handling functions
*/
......@@ -36,16 +38,19 @@ static int proc_lookupnet(struct inode *,const char *,int,struct inode **);
/* the get_*_info() functions are in the net code, and are configured
in via the standard mechanism... */
extern int unix_get_info(char *);
extern int unix_get_info(char *, char **, off_t, int);
#ifdef CONFIG_INET
extern int tcp_get_info(char *);
extern int udp_get_info(char *);
extern int raw_get_info(char *);
extern int arp_get_info(char *);
extern int dev_get_info(char *);
extern int rt_get_info(char *);
extern int tcp_get_info(char *, char **, off_t, int);
extern int udp_get_info(char *, char **, off_t, int);
extern int raw_get_info(char *, char **, off_t, int);
extern int arp_get_info(char *, char **, off_t, int);
extern int dev_get_info(char *, char **, off_t, int);
extern int rt_get_info(char *, char **, off_t, int);
#endif /* CONFIG_INET */
#ifdef CONFIG_IPX
extern int ipx_get_info(char *, char **, off_t, int);
extern int ipx_rt_get_info(char *, char **, off_t, int);
#endif /* CONFIG_IPX */
static struct file_operations proc_net_operations = {
NULL, /* lseek - default */
......@@ -93,6 +98,10 @@ static struct proc_dir_entry net_dir[] = {
{ 133,3,"tcp" },
{ 134,3,"udp" }
#endif /* CONFIG_INET */
#ifdef CONFIG_IPX
,{ 135,9,"ipx_route" },
{ 136,3,"ipx" }
#endif /* CONFIG_IPX */
};
#define NR_NET_DIRENTRY ((sizeof (net_dir))/(sizeof (net_dir[0])))
......@@ -154,57 +163,86 @@ static int proc_readnetdir(struct inode * inode, struct file * filp,
}
#define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */
static int proc_readnet(struct inode * inode, struct file * file,
char * buf, int count)
{
char * page;
int length;
int end;
unsigned int ino;
int bytes=count;
int thistime;
int copied=0;
char *start;
if (count < 0)
return -EINVAL;
if (!(page = (char*) __get_free_page(GFP_KERNEL)))
return -ENOMEM;
ino = inode->i_ino;
switch (ino) {
case 128:
length = unix_get_info(page);
break;
while(bytes>0)
{
thistime=bytes;
if(bytes>PROC_BLOCK_SIZE)
thistime=PROC_BLOCK_SIZE;
switch (ino)
{
case 128:
length = unix_get_info(page,&start,file->f_pos,thistime);
break;
#ifdef CONFIG_INET
case 129:
length = arp_get_info(page);
break;
case 130:
length = rt_get_info(page);
break;
case 131:
length = dev_get_info(page);
break;
case 132:
length = raw_get_info(page);
break;
case 133:
length = tcp_get_info(page);
break;
case 134:
length = udp_get_info(page);
break;
case 129:
length = arp_get_info(page,&start,file->f_pos,thistime);
break;
case 130:
length = rt_get_info(page,&start,file->f_pos,thistime);
break;
case 131:
length = dev_get_info(page,&start,file->f_pos,thistime);
break;
case 132:
length = raw_get_info(page,&start,file->f_pos,thistime);
break;
case 133:
length = tcp_get_info(page,&start,file->f_pos,thistime);
break;
case 134:
length = udp_get_info(page,&start,file->f_pos,thistime);
break;
#endif /* CONFIG_INET */
default:
free_page((unsigned long) page);
return -EBADF;
}
if (file->f_pos >= length) {
free_page((unsigned long) page);
return 0;
#ifdef CONFIG_IPX
case 135:
length = ipx_rt_get_info(page,&start,file->f_pos,thistime);
break;
case 136:
length = ipx_get_info(page,&start,file->f_pos,thistime);
break;
#endif /* CONFIG_IPX */
default:
free_page((unsigned long) page);
return -EBADF;
}
/*
* We have been given a non page aligned block of
* the data we asked for + a bit. We have been given
* the start pointer and we know the length..
*/
/*
* Copy the bytes
*/
memcpy_tofs(buf+copied, start, length);
file->f_pos+=length; /* Move down the file */
bytes-=length;
copied+=length;
if(length<thistime)
break; /* End of file */
}
if (count + file->f_pos > length)
count = length - file->f_pos;
end = count + file->f_pos;
memcpy_tofs(buf, page + file->f_pos, count);
free_page((unsigned long) page);
file->f_pos = end;
return count;
return copied;
}
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. NET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Definitions for the Ethernet handlers.
*
* Version: @(#)eth.h 1.0.4 05/13/93
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
*
* Relocated to include/linux where it belongs by Alan Cox
* <gw4pts@gw4pts.ampr.org>
*
* 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.
*
* WARNING: This move may well be temporary. This file will get merged with others RSN.
*
*/
#ifndef _LINUX_ETHERDEVICE_H
#define _LINUX_ETHERDEVICE_H
#include <linux/if_ether.h>
#ifdef __KERNEL__
extern int eth_header(unsigned char *buff, struct device *dev,
unsigned short type, void *daddr,
void *saddr, unsigned len,
struct sk_buff *skb);
extern int eth_rebuild_header(void *buff, struct device *dev,
unsigned long raddr, struct sk_buff *skb);
extern unsigned short eth_type_trans(struct sk_buff *skb, struct device *dev);
#endif
#endif /* _LINUX_ETHERDEVICE_H */
......@@ -22,44 +22,6 @@
#include <linux/types.h> /* for "caddr_t" et al */
#include <linux/socket.h> /* for "struct sockaddr" et al */
/* Structure defining a queue for a network interface. */
#ifdef not_yet_in_linux
struct ifnet {
char *if_name; /* name, e.g. ``en'' or ``lo'' */
short if_unit; /* sub-unit for device driver */
short if_mtu; /* maximum transmission unit */
short if_flags; /* up/down, broadcast, etc. */
short if_timer; /* time 'til if_watchdog called */
int if_metric; /* routing metric (not used) */
struct ifaddr *if_addrlist; /* linked list of addrs per if */
struct ifqueue {
struct mbuf *ifq_head;
struct mbuf *ifq_tail;
int ifq_len;
int ifq_maxlen;
int ifq_drops;
} if_snd; /* output queue */
/* Procedure handles. */
int (*if_init)(); /* init routine */
int (*if_output)(); /* output routine */
int (*if_ioctl)(); /* ioctl routine */
int (*if_reset)(); /* bus reset routine */
int (*if_watchdog)(); /* timer routine */
/* Generic interface statistics. */
int if_ipackets; /* packets recv'd on interface */
int if_ierrors; /* input errors on interface */
int if_opackets; /* packets sent on interface */
int if_oerrors; /* output errors on interface */
int if_collisions; /* collisions on CSMA i'faces */
/* Linked list: pointer to next interface. */
struct ifnet *if_next;
};
#endif
/* Standard interface flags. */
#define IFF_UP 0x1 /* interface is up */
#define IFF_BROADCAST 0x2 /* broadcast address valid */
......@@ -106,7 +68,7 @@ struct ifreq {
union
{
char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
char ifrn_hwaddr[IFHWADDRLEN];
char ifrn_hwaddr[IFHWADDRLEN]; /* Obsolete */
} ifr_ifrn;
union {
......@@ -114,6 +76,7 @@ struct ifreq {
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
struct sockaddr ifru_netmask;
struct sockaddr ifru_hwaddr;
short ifru_flags;
int ifru_metric;
int ifru_mtu;
......@@ -122,7 +85,8 @@ struct ifreq {
};
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
#define ifr_hwaddr ifr_ifrn.ifrn_hwaddr /* interface hardware */
#define old_ifr_hwaddr ifr_ifrn.ifrn_hwaddr /* interface hardware */
#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
......
......@@ -38,33 +38,6 @@
#define ARPOP_RREPLY 4 /* RARP reply */
/*
* Address Resolution Protocol.
*
* See RFC 826 for protocol description. ARP packets are variable
* in size; the arphdr structure defines the fixed-length portion.
* Protocol type values are the same as those for 10 Mb/s Ethernet.
* It is followed by the variable-sized fields ar_sha, arp_spa,
* arp_tha and arp_tpa in that order, according to the lengths
* specified. Field names used correspond to RFC 826.
*/
struct arphdr {
unsigned short ar_hrd; /* format of hardware address */
unsigned short ar_pro; /* format of protocol address */
unsigned char ar_hln; /* length of hardware address */
unsigned char ar_pln; /* length of protocol address */
unsigned short ar_op; /* ARP opcode (command) */
/* The rest is variable in size, according to the sizes above. */
#if 0
unsigned char ar_sha[]; /* sender hardware address */
unsigned char ar_spa[]; /* sender protocol address */
unsigned char ar_tha[]; /* target hardware address */
unsigned char ar_tpa[]; /* target protocol address */
#endif /* not actually included! */
};
/* ARP ioctl request. */
struct arpreq {
struct sockaddr arp_pa; /* protocol address */
......@@ -73,7 +46,6 @@ struct arpreq {
};
/* ARP Flag values. */
#define ATF_INUSE 0x01 /* entry in use */
#define ATF_COM 0x02 /* completed entry (ha valid) */
#define ATF_PERM 0x04 /* permanent entry */
#define ATF_PUBL 0x08 /* publish entry */
......
/*
* Swansea University Computer Society NET3
*
* This work is derived from NET2Debugged, which is in turn derived
* from NET2D which was written by:
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
*
* This work was derived friom Ross Biro's inspirational work
* for the LINUX operating system. His version numbers were:
*
* $Id: Space.c,v 0.8.4.5 1992/12/12 19:25:04 bir7 Exp $
* $Id: arp.c,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $
* $Id: arp.h,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $
* $Id: dev.c,v 0.8.4.13 1993/01/23 18:00:11 bir7 Exp $
* $Id: dev.h,v 0.8.4.7 1993/01/23 18:00:11 bir7 Exp $
* $Id: eth.c,v 0.8.4.4 1993/01/22 23:21:38 bir7 Exp $
* $Id: eth.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $
* $Id: icmp.c,v 0.8.4.9 1993/01/23 18:00:11 bir7 Exp $
* $Id: icmp.h,v 0.8.4.2 1992/11/15 14:55:30 bir7 Exp $
* $Id: ip.c,v 0.8.4.8 1992/12/12 19:25:04 bir7 Exp $
* $Id: ip.h,v 0.8.4.2 1993/01/23 18:00:11 bir7 Exp $
* $Id: loopback.c,v 0.8.4.8 1993/01/23 18:00:11 bir7 Exp $
* $Id: packet.c,v 0.8.4.7 1993/01/26 22:04:00 bir7 Exp $
* $Id: protocols.c,v 0.8.4.3 1992/11/15 14:55:30 bir7 Exp $
* $Id: raw.c,v 0.8.4.12 1993/01/26 22:04:00 bir7 Exp $
* $Id: sock.c,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $
* $Id: sock.h,v 0.8.4.7 1993/01/26 22:04:00 bir7 Exp $
* $Id: tcp.c,v 0.8.4.16 1993/01/26 22:04:00 bir7 Exp $
* $Id: tcp.h,v 0.8.4.7 1993/01/22 22:58:08 bir7 Exp $
* $Id: timer.c,v 0.8.4.8 1993/01/23 18:00:11 bir7 Exp $
* $Id: timer.h,v 0.8.4.2 1993/01/23 18:00:11 bir7 Exp $
* $Id: udp.c,v 0.8.4.12 1993/01/26 22:04:00 bir7 Exp $
* $Id: udp.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $
* $Id: we.c,v 0.8.4.10 1993/01/23 18:00:11 bir7 Exp $
* $Id: wereg.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $
*
* 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.
*/
#ifndef _LINUX_INET_H
#define _LINUX_INET_H
#include <linux/ddi.h>
#undef INET_DEBUG
#ifdef INET_DEBUG
# define DPRINTF(x) dprintf x
#else
# define DPRINTF(x) do ; while (0)
#endif
/* Debug levels. One per module. */
#define DBG_OFF 0 /* no debugging */
#define DBG_INET 1 /* sock.c */
#define DBG_RT 2 /* route.c */
#define DBG_DEV 3 /* dev.c */
#define DBG_ETH 4 /* eth.c */
#define DBG_PROTO 5 /* protocol.c */
#define DBG_TMR 6 /* timer.c */
#define DBG_PKT 7 /* packet.c */
#define DBG_RAW 8 /* raw.c */
#define DBG_LOOPB 10 /* loopback.c */
#define DBG_SLIP 11 /* slip.c */
#define DBG_ARP 20 /* arp.c */
#define DBG_IP 21 /* ip.c */
#define DBG_ICMP 22 /* icmp.c */
#define DBG_TCP 23 /* tcp.c */
#define DBG_UDP 24 /* udp.c */
#ifdef __KERNEL__
extern int inet_debug;
extern void inet_proto_init(struct ddi_proto *pro);
extern char *in_ntoa(unsigned long in);
extern unsigned long in_aton(char *str);
extern void dprintf(int level, char *fmt, ...);
extern int dbg_ioctl(void *arg, int level);
#endif
#endif /* _LINUX_INET_H */
struct sockaddr_ipx
{
short sipx_family;
unsigned long sipx_network;
unsigned char sipx_node[6];
short sipx_port;
};
struct ipx_route_def
{
unsigned long ipx_network;
unsigned long ipx_router_network;
#define IPX_ROUTE_NO_ROUTER 0
unsigned char ipx_router_node[6];
unsigned char ipx_device[16];
unsigned short ipx_flags;
#define IPX_RT_BLUEBOOK 2
#define IPX_RT_ROUTED 1
};
#define IPX_MTU 576
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Definitions for the Interfaces handler.
*
* Version: @(#)dev.h 1.0.10 08/12/93
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Corey Minyard <wf-rch!minyard@relay.EU.net>
* Donald J. Becker, <becker@super.org>
*
* 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.
*
* Moved to /usr/include/linux for NET3
*/
#ifndef _LINUX_NETDEVICE_H
#define _LINUX_NETDEVICE_H
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/skbuff.h>
/* for future expansion when we will have different priorities. */
#define DEV_NUMBUFFS 3
#define MAX_ADDR_LEN 7
#define MAX_HEADER 18
#define IS_MYADDR 1 /* address is (one of) our own */
#define IS_LOOPBACK 2 /* address is for LOOPBACK */
#define IS_BROADCAST 3 /* address is a valid broadcast */
#define IS_INVBCAST 4 /* Wrong netmask bcast not for us */
/*
* The DEVICE structure.
* Actually, this whole structure is a big mistake. It mixes I/O
* data with strictly "high-level" data, and it has to know about
* almost every data structure used in the INET module.
*/
struct device
{
/*
* This is the first field of the "visible" part of this structure
* (i.e. as seen by users in the "Space.c" file). It is the name
* the interface.
*/
char *name;
/* I/O specific fields. These will be moved to DDI soon. */
unsigned long rmem_end; /* shmem "recv" end */
unsigned long rmem_start; /* shmem "recv" start */
unsigned long mem_end; /* sahared mem end */
unsigned long mem_start; /* shared mem start */
unsigned short base_addr; /* device I/O address */
unsigned char irq; /* device IRQ number */
/* Low-level status flags. */
volatile unsigned char start, /* start an operation */
tbusy, /* transmitter busy */
interrupt; /* interrupt arrived */
/*
* Another mistake.
* This points to the next device in the "dev" chain. It will
* be moved to the "invisible" part of the structure as soon as
* it has been cleaned up. -FvK
*/
struct device *next;
/* The device initialization function. Called only once. */
int (*init)(struct device *dev);
/* Some hardware also needs these fields, but they are not part of the
usual set specified in Space.c. */
unsigned char if_port; /* Selectable AUI, TP,..*/
unsigned char dma; /* DMA channel */
struct enet_statistics* (*get_stats)(struct device *dev);
/*
* This marks the end of the "visible" part of the structure. All
* fields hereafter are internal to the system, and may change at
* will (read: may be cleaned up at will).
*/
/* These may be needed for future network-power-down code. */
unsigned long trans_start; /* Time (in jiffies) of last Tx */
unsigned long last_rx; /* Time of last Rx */
unsigned short flags; /* interface flags (a la BSD) */
unsigned short family; /* address family ID (AF_INET) */
unsigned short metric; /* routing metric (not used) */
unsigned short mtu; /* interface MTU value */
unsigned short type; /* interface hardware type */
unsigned short hard_header_len; /* hardware hdr length */
void *priv; /* pointer to private data */
/* Interface address info. */
unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address */
unsigned char addr_len; /* harfware address length */
unsigned long pa_addr; /* protocol address */
unsigned long pa_brdaddr; /* protocol broadcast addr */
unsigned long pa_dstaddr; /* protocol P-P other side addr */
unsigned long pa_mask; /* protocol netmask */
unsigned short pa_alen; /* protocol address length */
/* Pointer to the interface buffers. */
struct sk_buff_head buffs[DEV_NUMBUFFS];
/* Pointers to interface service routines. */
int (*open)(struct device *dev);
int (*stop)(struct device *dev);
int (*hard_start_xmit) (struct sk_buff *skb,
struct device *dev);
int (*hard_header) (unsigned char *buff,
struct device *dev,
unsigned short type,
void *daddr,
void *saddr,
unsigned len,
struct sk_buff *skb);
int (*rebuild_header)(void *eth, struct device *dev,
unsigned long raddr, struct sk_buff *skb);
unsigned short (*type_trans) (struct sk_buff *skb,
struct device *dev);
#define HAVE_MULTICAST
void (*set_multicast_list)(struct device *dev,
int num_addrs, void *addrs);
#define HAVE_SET_MAC_ADDR
int (*set_mac_address)(struct device *dev, void *addr);
};
struct packet_type {
unsigned short type; /* This is really htons(ether_type). */
unsigned short copy:1;
int (*func) (struct sk_buff *, struct device *,
struct packet_type *);
void *data;
struct packet_type *next;
};
#ifdef __KERNEL__
/* Used by dev_rint */
#define IN_SKBUFF 1
extern volatile char in_bh;
extern struct device *dev_base;
extern struct packet_type *ptype_base;
extern int ip_addr_match(unsigned long addr1, unsigned long addr2);
extern int ip_chk_addr(unsigned long addr);
extern struct device *ip_dev_check(unsigned long daddr);
extern unsigned long ip_my_addr(void);
extern unsigned long ip_get_mask(unsigned long addr);
extern void dev_add_pack(struct packet_type *pt);
extern void dev_remove_pack(struct packet_type *pt);
extern struct device *dev_get(char *name);
extern int dev_open(struct device *dev);
extern int dev_close(struct device *dev);
extern void dev_queue_xmit(struct sk_buff *skb, struct device *dev,
int pri);
#define HAVE_NETIF_RX 1
extern void netif_rx(struct sk_buff *skb);
/* The old interface to netif_rx(). */
extern int dev_rint(unsigned char *buff, long len, int flags,
struct device * dev);
extern void dev_transmit(void);
extern int in_inet_bh(void);
extern void inet_bh(void *tmp);
extern void dev_tint(struct device *dev);
extern int dev_get_info(char *buffer, char **start, off_t offset, int length);
extern int dev_ioctl(unsigned int cmd, void *);
extern void dev_init(void);
/* This function lives elsewhere (drivers/net/net_init.c but is related) */
extern void ether_setup(struct device *dev);
#endif /* __KERNEL__ */
#endif /* _LINUX_DEV_H */
......@@ -23,6 +23,12 @@ extern int wp_works_ok;
extern unsigned long intr_count;
#define start_bh_atomic() \
__asm__ __volatile__("incl _intr_count")
#define end_bh_atomic() \
__asm__ __volatile__("decl _intr_count")
/*
* Bus types (default is ISA, but people can check others with these..)
* MCA_bus hardcoded to 0 for now.
......
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
* Definitions for the 'struct sk_buff' memory handlers.
*
* Definitions for the 'struct sk_buff' memory handlers.
* Authors:
* Alan Cox, <gw4pts@gw4pts.ampr.org>
* Florian La Roche, <rzsfl@rz.uni-sb.de>
*
* Version: @(#)skbuff.h 1.0.4 05/20/93
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Corey Minyard <wf-rch!minyard@relay.EU.net>
*
* Fixes:
* Alan Cox : Volatiles (this makes me unhappy - we want proper asm linked list stuff)
* Alan Cox : Declaration for new primitives
* Alan Cox : Fraglist support (idea by Donald Becker)
* Alan Cox : 'users' counter. Combines with datagram changes to avoid skb_peek_copy
* being used.
*
* 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.
*/
#ifndef _SKBUFF_H
#define _SKBUFF_H
#ifndef _LINUX_SKBUFF_H
#define _LINUX_SKBUFF_H
#include <linux/malloc.h>
#include <linux/wait.h>
#include <linux/time.h>
#ifdef CONFIG_IPX
#include "ipx.h"
#endif
#define CONFIG_SKB_CHECK 1
#define HAVE_ALLOC_SKB /* For the drivers to know */
......@@ -38,14 +26,25 @@
#define FREE_WRITE 0
struct sk_buff_head {
struct sk_buff * volatile next;
struct sk_buff * volatile prev;
#if CONFIG_SKB_CHECK
int magic_debug_cookie;
#endif
};
struct sk_buff {
unsigned long magic_debug_cookie;
struct sk_buff *volatile next;
struct sk_buff *volatile prev;
struct sk_buff *volatile link3;
struct sk_buff *volatile* list;
struct sk_buff * volatile next;
struct sk_buff * volatile prev;
#if CONFIG_SKB_CHECK
int magic_debug_cookie;
#endif
struct sk_buff * volatile link3;
struct sock *sk;
volatile unsigned long when; /* used to compute rtt's */
struct timeval stamp;
struct device *dev;
void *mem_addr;
union {
......@@ -53,12 +52,8 @@ struct sk_buff {
struct ethhdr *eth;
struct iphdr *iph;
struct udphdr *uh;
struct arphdr *arp;
unsigned char *raw;
unsigned long seq;
#ifdef CONFIG_IPX
ipx_packet *ipx;
#endif
} h;
struct iphdr *ip_hdr; /* For IPPROTO_RAW */
unsigned long mem_len;
......@@ -68,12 +63,12 @@ struct sk_buff {
unsigned long truesize;
unsigned long saddr;
unsigned long daddr;
int magic;
unsigned long raddr; /* next hop addr */
volatile char acked,
used,
free,
arp;
unsigned char tries,lock; /* Lock is now unused */
unsigned char tries,lock;
unsigned short users; /* User count - see datagram.c (and soon seqpacket.c/stream.c) */
unsigned long padding[0];
unsigned char data[0];
......@@ -82,30 +77,61 @@ struct sk_buff {
#define SK_WMEM_MAX 32767
#define SK_RMEM_MAX 32767
#ifdef CONFIG_SKB_CHECK
#define SK_FREED_SKB 0x0DE2C0DE
#define SK_GOOD_SKB 0xDEC0DED1
#define SK_HEAD_SKB 0x12231298
#endif
#ifdef __KERNEL__
/*
* Handling routines are only of interest to the kernel
*/
#if 0
extern void print_skb(struct sk_buff *);
#endif
extern void kfree_skb(struct sk_buff *skb, int rw);
extern void skb_queue_head(struct sk_buff * volatile *list,struct sk_buff *buf);
extern void skb_queue_tail(struct sk_buff * volatile *list,struct sk_buff *buf);
extern struct sk_buff * skb_dequeue(struct sk_buff * volatile *list);
extern void skb_queue_head_init(struct sk_buff_head *list);
extern void skb_queue_head(struct sk_buff_head *list,struct sk_buff *buf);
extern void skb_queue_tail(struct sk_buff_head *list,struct sk_buff *buf);
extern struct sk_buff * skb_dequeue(struct sk_buff_head *list);
extern void skb_insert(struct sk_buff *old,struct sk_buff *newsk);
extern void skb_append(struct sk_buff *old,struct sk_buff *newsk);
extern void skb_unlink(struct sk_buff *buf);
extern void skb_new_list_head(struct sk_buff *volatile* list);
extern struct sk_buff * skb_peek(struct sk_buff * volatile *list);
extern struct sk_buff * skb_peek_copy(struct sk_buff * volatile *list);
extern struct sk_buff * skb_peek_copy(struct sk_buff_head *list);
extern struct sk_buff * alloc_skb(unsigned int size, int priority);
extern void kfree_skbmem(void *mem, unsigned size);
extern struct sk_buff * skb_clone(struct sk_buff *skb, int priority);
extern void skb_kept_by_device(struct sk_buff *skb);
extern void skb_device_release(struct sk_buff *skb, int mode);
extern void skb_device_release(struct sk_buff *skb,
int mode);
extern int skb_device_locked(struct sk_buff *skb);
extern void skb_check(struct sk_buff *skb,int, char *);
#define IS_SKB(skb) skb_check((skb),__LINE__,__FILE__)
/*
* Peek an sk_buff. Unlike most other operations you _MUST_
* be careful with this one. A peek leaves the buffer on the
* list and someone else may run off with it. For an interrupt
* type system cli() peek the buffer copy the data and sti();
*/
static __inline__ struct sk_buff *skb_peek(struct sk_buff_head *list_)
{
struct sk_buff *list = (struct sk_buff *)list_;
return (list->next != list)? list->next : NULL;
}
#if CONFIG_SKB_CHECK
extern int skb_check(struct sk_buff *skb,int,int, char *);
#define IS_SKB(skb) skb_check((skb), 0, __LINE__,__FILE__)
#define IS_SKB_HEAD(skb) skb_check((skb), 1, __LINE__,__FILE__)
#else
#define IS_SKB(skb) 0
#define IS_SKB_HEAD(skb) 0
#endif
extern struct sk_buff * skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err);
extern int datagram_select(struct sock *sk, int sel_type, select_table *wait);
extern void skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size);
extern void skb_free_datagram(struct sk_buff *skb);
#endif /* _SKBUFF_H */
#endif /* __KERNEL__ */
#endif /* _LINUX_SKBUFF_H */
......@@ -19,18 +19,6 @@
#define _LINUX_SOCKIOS_H
/* This section will go away soon! */
#if 1 /* FIXME: */
#define MAX_IP_NAME 20
#define IP_SET_DEV 0x2401
struct ip_config {
char name[MAX_IP_NAME];
unsigned long paddr;
unsigned long router;
unsigned long net;
unsigned up:1,destroy:1;
};
#endif /* FIXME: */
/* Socket-level I/O control calls. */
#define FIOSETOWN 0x8901
......@@ -38,6 +26,7 @@ struct ip_config {
#define FIOGETOWN 0x8903
#define SIOCGPGRP 0x8904
#define SIOCATMARK 0x8905
#define SIOCGSTAMP 0x8096 /* Get stamp */
/* Routing table calls. */
#define SIOCADDRT 0x890B /* add routing table entry */
......@@ -63,10 +52,11 @@ struct ip_config {
#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */
#define SIOCGIFMTU 0x8921 /* get MTU size */
#define SIOCSIFMTU 0x8922 /* set MTU size */
#define SIOCGIFHWADDR 0x8923 /* get hardware address */
#define OLD_SIOCGIFHWADDR 0x8923 /* get hardware address */
#define SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */
#define SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */
#define SIOCSIFENCAP 0x8926
#define SIOCGIFHWADDR 0x8927 /* Get hardware address */
/* Routing table calls (oldrtent - don't use) */
#define SIOCADDRTOLD 0x8940 /* add routing table entry */
......
......@@ -7,7 +7,11 @@
* Version: @(#)Space.c 1.0.2 04/22/93
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
*
* Please see the comments in ddi.c - Alan
*
*/
#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
......@@ -27,7 +31,7 @@
# include "unix/unix.h"
#endif
#ifdef CONFIG_INET
# include "inet/inet.h"
# include <linux/inet.h>
#endif
#ifdef CONFIG_IPX
#include "inet/ipxcall.h"
......@@ -53,43 +57,3 @@ struct ddi_proto protocols[] = {
};
/*
* Section B: Device Driver Modules.
* This section defines which network device drivers
* get linked into the Linux kernel. It is currently
* only used by the INET protocol. Any takers for the
* other protocols like XNS or Novell?
*
* WARNING: THIS SECTION IS NOT YET USED BY THE DRIVERS !!!!!
*/
/*#include "drv/we8003/we8003.h" Western Digital WD-80[01]3 */
/*#include "drv/dp8390/dp8390.h" Donald Becker's DP8390 kit */
/*#inclde "drv/slip/slip.h" Laurence Culhane's SLIP kit */
struct ddi_device devices[] = {
#if CONF_WE8003
{ "WD80x3[EBT]",
"", 0, 1, we8003_init, NULL,
19, 0, DDI_FCHRDEV,
{ 0x280, 0, 15, 0, 32768, 0xD0000 } },
#endif
#if CONF_DP8390
{ "DP8390/WD80x3",
"", 0, 1, dpwd8003_init, NULL,
20, 0, DDI_FCHRDEV,
{ 0, 0, 0, 0, 0, 0, } },
{ "DP8390/NE-x000",
"", 0, 1, dpne2000_init, NULL,
20, 8, DDI_FCHRDEV,
{ 0, 0, 0, 0, 0, 0, } },
{ "DP8390/3C50x",
"", 0, 1, dpec503_init, NULL,
20, 16, DDI_FCHRDEV,
{ 0, 0, 0, 0, 0, 0, } },
#endif
{ NULL,
"", 0, 0, NULL, NULL,
0, 0, 0,
{ 0, 0, 0, 0, 0, 0 } }
};
......@@ -7,6 +7,14 @@
* Version: @(#)ddi.c 1.0.5 04/22/93
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
*
*
* For the moment I'm classifying DDI as 'dead'. However if/when Fred
* produces a masterpiece of design DDI may get resurrected. With the
* current kernel as modules work by Peter MacDonald they might be
* redundant anyway. Thus I've removed all but the protocol initialise.
*
* We will end up with protocol initialisers and socket family initialisers.
*/
#include <asm/segment.h>
#include <asm/system.h>
......@@ -28,38 +36,9 @@
#endif
extern struct ddi_device devices[]; /* device driver map */
extern struct ddi_proto protocols[]; /* network protocols */
/*
* This function gets called with an ASCII string representing the
* ID of some DDI driver. We loop through the DDI Devices table
* and return the address of the control block that has a matching
* "name" field. It is used by upper-level layers that want to
* dynamically bind some UNIX-domain "/dev/XXXX" file name to a
* DDI device driver. The "iflink(8)" program is an example of
* this behaviour.
*/
struct ddi_device *
ddi_map(const char *id)
{
register struct ddi_device *dev;
PRINTK (("DDI: MAP: looking for \"%s\": ", id));
dev = devices;
while (dev->title != NULL) {
if (strncmp(dev->name, id, DDI_MAXNAME) == 0) {
PRINTK (("OK at 0x%X\n", dev));
return(dev);
}
dev++;
}
PRINTK (("NOT FOUND\n"));
return(NULL);
}
/*
* This is the function that is called by a kernel routine during
* system startup. Its purpose is to walk trough the "devices"
......@@ -68,24 +47,16 @@ ddi_map(const char *id)
void
ddi_init(void)
{
struct ddi_proto *pro;
struct ddi_device *dev;
PRINTK (("DDI: Starting up!\n"));
struct ddi_proto *pro;
/* First off, kick all configured protocols. */
pro = protocols;
while (pro->name != NULL) {
(*pro->init)(pro);
pro++;
}
/* Done. Now kick all configured device drivers. */
dev = devices;
while (dev->title != NULL) {
(*dev->init)(dev);
dev++;
}
PRINTK (("DDI: Starting up!\n"));
/* We're all done... */
/* Kick all configured protocols. */
pro = protocols;
while (pro->name != NULL)
{
(*pro->init)(pro);
pro++;
}
/* We're all done... */
}
......@@ -15,10 +15,21 @@
$(CC) $(CFLAGS) -S -o $*.s $<
OBJS = sock.o utils.o route.o proc.o timer.o protocol.o loopback.o \
OBJS = sock.o utils.o route.o proc.o timer.o protocol.o \
eth.o packet.o arp.o dev.o ip.o raw.o icmp.o tcp.o udp.o \
datagram.o skbuff.o
# ipx.o ax25.o ax25_in.o ax25_out.o ax25_subr.o ax25_timer.o
datagram.o skbuff.o devinet.o
ifdef CONFIG_AX25
OBJS := $(OBJS) ax25.o ax25_in.o ax25_out.o ax25_subr.o ax25_timer.o
endif
ifdef CONFIG_IPX
OBJS := $(OBJS) ipx.o
endif
ifdef CONFIG_INET
......
NET2Debugged 1.24 README
------------------------
Major Changes
o PLIP driver sort of works
o UDP and RAW have been partially rewritten for speed
o Internals heavily cleaned up, and memory monitoring of network
memory is now done. (On shift-scroll-lock)
o ARP should now not generate garbage
o Using MSG_PEEK can't cause race conditions and crashes
o Support for bootp clients.
o Supports RFC931 TAP authd
o NFS problems with certain types of network configuration are
fixed.
o Doesn't forward packets for other subnet (can cause packet storms)
o TCP won't ack rst frames causing packet storms (especially with
Lan workplace for DOS).
o Numerous fixes for solidity
o Verify_area used properly.
o MSG_PEEK is faster again
o Minor TCP fixes. Hopefully no more TCP lockups (ha!)
o Donald's promiscuous mode. Go forth and write protocol analysers...
-------------------------------------------------------------------------
NOTE:
Drivers for this stack set must be using alloc_skb() not just
kmalloc. If you get millions of 'non sk_buff...' errors please check the
driver you are using. All Donald's drivers know about this. If you have
a problem driver replace all cases of
.. =(struct sk_buff *)kmalloc(sizeof(struct sk_buff)+...
With
..=alloc_skb(sizeof(struct sk_buff)+...
And if it uses kfree_s on the packet change that to use kfree_skbmem().
-------------------------------------------------------------------------
Bug fixes and improvements for this section of the code should be mailed to
iiitac@pyr.swan.ac.uk.
Alan
This is snapshot 010
Notes:
ARP
As of snapshot 006, ARP should compile and work correctly
for any protocol that has the right build_header support.
AX25
This is an ALPHA release. It will not be a standard part
of the real release module. Please read the copyrights on
the AX.25 code carefully. When AX.25 is finished it will
be part of a seperatly available amateur radio add on. Also
please rememeber this is ALPHA code. It works well for a lot
of people but I know for a fact it is currently buggy.
IPX
The IPX module in here is fairly complete, and certainly
usable for things. The IPX user code isn't yet very useful
(nobody has written a RIP/SAP daemon!).
NetROM
I'm slowly doing bits of this code, but its not even fit
to include here.
Status:
Done:
Replaced ARP with Florian la Roche's ARP.
Replaced/improved sk_buff handlers (again from Florian)
Removed surplus DDI code.
Reformatted most modules.
Fixed ICMP handling bugs (ICMP error to ICMP error).
Fixed fragmentation bugs (both memory and mtu).
Moved some includes.
Drivers now build correctly with no IP layer.
Merged Linus 1.0.1 diffs and my patches 1-3.
Further fixups on clean driver build.
Loopback driver now lives where it belongs.
UDP verified against specification (passes).
IP verified against specification (two errors: Incorrect forwarding and
no mandatory option handling).
ARP verified against specification (passes: recommendation that ARP
rejects MAC broadcast/multicast addresses - this needs
driver changes doing).
All surplus skb->sk assignment and skb->mem_len skb->mem_addr removed.
eth.h became linux/etherdevice.h.
alloc_skb nows adds the sizeof(struct sk_buff) itself.
Now relative to Linux 1.0.4.
All IP wakeups are now callbacks.
IPX and AX.25 callbacks now use wake_up_interruptible correctly.
ICMP,IP and UDP collect snmp statistics.
Removed the 4K limit from the /proc/net/* files.
Routing bugs.
Cleaned up skb duplication.
IPX /proc from Mark Evans.
Driver packet ordering now enforced.
AX.25 unused SSID bits now set.
In Progress:
Module by module validation against specifications.
TCP delayed ACK [RFC1122 requires this].
Byte-order fixes.
Core code restructure to enable a working non IP build
Trying to fix /proc to do >4K correctly, as well as dynamic addition
of /proc/ and /proc/net/ objects (for module protocol layers).
Adding the extra NET2E driver ioctl() support.
SNMP MIB statistic capture - finish TCP and add device layer when
Donald is ready.
Donald Beckers latest driver mods.
Adding the ICMP_TIMESTAMP support patch.
Routing bugs.
Packet level time stamping.
Merging in support for the I^2IT 'TICK' time synchronisation chip.
Crynwyr compliant PLIP driver.
To Do:
Merge in sk_buff data handling module.
Socket family/protocol seperation.
Additional BSD options (SO_LOWAT etc).
IP option handling, especially on ip forwards.
AX.25 /proc support.
SNMP /proc support.
TCP MSS/Window and route metrics in the routing table.
TCP mtu discovery support.
NetROM.
TCP closing side state machine bug fixes.
NetBEUI (Lan Manager) [ie IEE802.3/IEE802.2/NetBIOS].
Make drivers record type and addressing category(Multicast/Broadcast..)
Speed it up.
Unix domain cleanup/rewrite.
This diff is collapsed.
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Definitions for the ARP protocol module.
*
* Version: @(#)arp.h 1.0.6 05/21/93
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
*
* 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.
*/
/* linux/net/inet/arp.h */
#ifndef _ARP_H
#define _ARP_H
#define ARP_TABLE_SIZE 16 /* size of ARP table */
#define ARP_TIMEOUT 30000 /* five minutes */
#define ARP_RES_TIME 250 /* 2.5 seconds */
#define ARP_MAX_TRIES 3 /* max # of tries to send ARP */
#define ARP_QUEUE_MAGIC 0x0432447A /* magic # for queues */
/* This structure defines the ARP mapping cache. */
struct arp_table {
struct arp_table *next;
volatile unsigned long last_used;
unsigned int flags;
#if 1
unsigned long ip;
#else
unsigned char pa[MAX_ADDR_LEN];
unsigned char plen;
unsigned char ptype;
#endif
unsigned char ha[MAX_ADDR_LEN];
unsigned char hlen;
unsigned char htype;
};
/* This is also used in "sock.c" and "tcp.c" - YUCK! - FvK */
extern struct sk_buff *arp_q;
extern void arp_destroy(unsigned long paddr);
extern void arp_init(void);
extern void arp_destroy(unsigned long paddr, int force);
extern int arp_rcv(struct sk_buff *skb, struct device *dev,
struct packet_type *pt);
extern int arp_find(unsigned char *haddr, unsigned long paddr,
struct device *dev, unsigned long saddr);
extern void arp_add(unsigned long addr, unsigned char *haddr,
struct device *dev);
extern void arp_add_broad(unsigned long addr, struct device *dev);
extern void arp_queue(struct sk_buff *skb);
extern int arp_get_info(char *buffer);
struct device *dev, unsigned long saddr, struct sk_buff *skb);
extern int arp_get_info(char *buffer, char **start, off_t origin, int length);
extern int arp_ioctl(unsigned int cmd, void *arg);
extern void arp_destroy_maybe(unsigned long paddr);
#endif /* _ARP_H */
/*
* SUCS NET2 Debugged.
* SUCS NET3:
*
* Generic datagram handling routines. These are generic for all protocols. Possibly a generic IP version on top
* of these would make sense. Not tonight however 8-).
......@@ -14,6 +14,11 @@
* Alan Cox : Added support for SOCK_SEQPACKET. IPX can no longer use the SO_TYPE hack but
* AX.25 now works right, and SPX is feasible.
* Alan Cox : Fixed write select of non IP protocol crash.
* Florian La Roche: Changed for my new skbuff handling.
*
* Note:
* A lot of this will change when the protocol/socket seperation
* occurs. Using this will make things reasonably clean.
*/
#include <linux/config.h>
......@@ -26,15 +31,14 @@
#include <linux/in.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include "inet.h"
#include "dev.h"
#include <linux/inet.h>
#include <linux/netdevice.h>
#include "ip.h"
#include "protocol.h"
#include "arp.h"
#include "route.h"
#include "tcp.h"
#include "udp.h"
#include "skbuff.h"
#include <linux/skbuff.h>
#include "sock.h"
......@@ -53,7 +57,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
/* Socket is inuse - so the timer doesn't attack it */
restart:
sk->inuse = 1;
while(sk->rqueue == NULL) /* No data */
while(skb_peek(&sk->receive_queue) == NULL) /* No data */
{
/* If we are shutdown then no more data is going to appear. We are done */
if (sk->shutdown & RCV_SHUTDOWN)
......@@ -91,7 +95,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
/* Interrupts off so that no packet arrives before we begin sleeping.
Otherwise we might miss our wake up */
cli();
if (sk->rqueue == NULL)
if (skb_peek(&sk->receive_queue) == NULL)
{
interruptible_sleep_on(sk->sleep);
/* Signals may need a restart of the syscall */
......@@ -115,10 +119,10 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
sti();
}
/* Again only user level code calls this function, so nothing interrupt level
will suddenely eat the rqueue */
will suddenely eat the receive_queue */
if (!(flags & MSG_PEEK))
{
skb=skb_dequeue(&sk->rqueue);
skb=skb_dequeue(&sk->receive_queue);
if(skb!=NULL)
skb->users++;
else
......@@ -127,7 +131,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
else
{
cli();
skb=skb_peek(&sk->rqueue);
skb=skb_peek(&sk->receive_queue);
if(skb!=NULL)
skb->users++;
sti();
......@@ -150,7 +154,7 @@ void skb_free_datagram(struct sk_buff *skb)
return;
}
/* See if it needs destroying */
if(skb->list == NULL) /* Been dequeued by someone - ie its read */
if(!skb->next && !skb->prev) /* Been dequeued by someone - ie its read */
kfree_skb(skb,FREE_READ);
restore_flags(flags);
}
......@@ -178,7 +182,7 @@ int datagram_select(struct sock *sk, int sel_type, select_table *wait)
/* Connection closed: Wake up */
return(1);
}
if (sk->rqueue != NULL || sk->err != 0)
if (skb_peek(&sk->receive_queue) != NULL || sk->err != 0)
{ /* This appears to be consistent
with other stacks */
return(1);
......
This diff is collapsed.
/*
* NET3 IP device support routines.
*
* 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.
*
* Derived from the IP parts of dev.c 1.0.19
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Mark Evans, <evansmp@uhura.aston.ac.uk>
*
* Additional Authors:
* Alan Cox, <gw4pts@gw4pts.ampr.org>
*/
#include <asm/segment.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/in.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/if_ether.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include "ip.h"
#include "route.h"
#include "protocol.h"
#include "tcp.h"
#include <linux/skbuff.h>
#include "sock.h"
#include "arp.h"
/*
* Determine a default network mask, based on the IP address.
*/
unsigned long ip_get_mask(unsigned long addr)
{
unsigned long dst;
if (addr == 0L)
return(0L); /* special case */
dst = ntohl(addr);
if (IN_CLASSA(dst))
return(htonl(IN_CLASSA_NET));
if (IN_CLASSB(dst))
return(htonl(IN_CLASSB_NET));
if (IN_CLASSC(dst))
return(htonl(IN_CLASSC_NET));
/*
* Something else, probably a multicast.
*/
return(0);
}
/*
* Perform an IP address matching operation
*/
int ip_addr_match(unsigned long me, unsigned long him)
{
int i;
unsigned long mask=0xFFFFFFFF;
DPRINTF((DBG_DEV, "ip_addr_match(%s, ", in_ntoa(me)));
DPRINTF((DBG_DEV, "%s)\n", in_ntoa(him)));
/*
* Simple case
*/
if (me == him)
return(1);
/*
* Look for a match ending in all 1's
*/
for (i = 0; i < 4; i++, me >>= 8, him >>= 8, mask >>= 8)
{
if ((me & 0xFF) != (him & 0xFF))
{
/*
* The only way this could be a match is for
* the rest of addr1 to be 0 or 255.
*/
if (me != 0 && me != mask)
return(0);
return(1);
}
}
return(1);
}
/*
* Check the address for our address, broadcasts, etc.
*
* I intend to fix this to at the very least cache the last
* resolved entry.
*/
int ip_chk_addr(unsigned long addr)
{
struct device *dev;
unsigned long mask;
/*
* Accept both `all ones' and `all zeros' as BROADCAST.
* (Support old BSD in other words). This old BSD
* support will go very soon as it messes other things
* up.
*/
if (addr == INADDR_ANY || addr == INADDR_BROADCAST)
return IS_BROADCAST;
mask = ip_get_mask(addr);
/*
* Accept all of the `loopback' class A net.
*/
if ((addr & mask) == htonl(0x7F000000L))
return IS_MYADDR;
/*
* OK, now check the interface addresses.
*/
for (dev = dev_base; dev != NULL; dev = dev->next)
{
if (!(dev->flags & IFF_UP))
continue;
/*
* If the protocol address of the device is 0 this is special
* and means we are address hunting (eg bootp).
*/
if ((dev->pa_addr == 0)/* || (dev->flags&IFF_PROMISC)*/)
return IS_MYADDR;
/*
* Is it the exact IP address?
*/
if (addr == dev->pa_addr)
return IS_MYADDR;
/*
* Is it our broadcast address?
*/
if ((dev->flags & IFF_BROADCAST) && addr == dev->pa_brdaddr)
return IS_BROADCAST;
/*
* Nope. Check for a subnetwork broadcast.
*/
if (((addr ^ dev->pa_addr) & dev->pa_mask) == 0)
{
if ((addr & ~dev->pa_mask) == 0)
return IS_BROADCAST;
if ((addr & ~dev->pa_mask) == ~dev->pa_mask)
return IS_BROADCAST;
}
/*
* Nope. Check for Network broadcast.
*/
if (((addr ^ dev->pa_addr) & mask) == 0)
{
if ((addr & ~mask) == 0)
return IS_BROADCAST;
if ((addr & ~mask) == ~mask)
return IS_BROADCAST;
}
}
return 0; /* no match at all */
}
/*
* Retrieve our own address.
*
* Because the loopback address (127.0.0.1) is already recognized
* automatically, we can use the loopback interface's address as
* our "primary" interface. This is the addressed used by IP et
* al when it doesn't know which address to use (i.e. it does not
* yet know from or to which interface to go...).
*/
unsigned long ip_my_addr(void)
{
struct device *dev;
for (dev = dev_base; dev != NULL; dev = dev->next)
{
if (dev->flags & IFF_LOOPBACK)
return(dev->pa_addr);
}
return(0);
}
/*
* Find an interface that can handle addresses for a certain address.
*
* This needs optimising, since its relatively trivial to collapse
* the two loops into one.
*/
struct device * ip_dev_check(unsigned long addr)
{
struct device *dev;
for (dev = dev_base; dev; dev = dev->next)
{
if (!(dev->flags & IFF_UP))
continue;
if (!(dev->flags & IFF_POINTOPOINT))
continue;
if (addr != dev->pa_dstaddr)
continue;
return dev;
}
for (dev = dev_base; dev; dev = dev->next)
{
if (!(dev->flags & IFF_UP))
continue;
if (dev->flags & IFF_POINTOPOINT)
continue;
if (dev->pa_mask & (addr ^ dev->pa_addr))
continue;
return dev;
}
return NULL;
}
......@@ -10,6 +10,8 @@
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Mark Evans, <evansmp@uhura.aston.ac.uk>
* Florian La Roche, <rzsfl@rz.uni-sb.de>
* Alan Cox, <gw4pts@gw4pts.ampr.org>
*
* Fixes:
* Mr Linux : Arp problems
......@@ -18,6 +20,9 @@
* Alan Cox : eth_rebuild_header missing an htons and
* minor other things.
* Tegge : Arp bug fixes.
* Florian : Removed many unnecessary functions, code cleanup
* and changes for new arp and skbuff.
* Alan Cox : Redid header building to reflect new format.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -33,40 +38,23 @@
#include <linux/mm.h>
#include <linux/socket.h>
#include <linux/in.h>
#include "inet.h"
#include "dev.h"
#include "eth.h"
#include "ip.h"
#include "route.h"
#include "protocol.h"
#include "tcp.h"
#include "skbuff.h"
#include "sock.h"
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/errno.h>
#include "arp.h"
/* Display an Ethernet address in readable format. */
char *eth_print(unsigned char *ptr)
{
static char buff[64];
if (ptr == NULL) return("[NONE]");
sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X",
(ptr[0] & 255), (ptr[1] & 255), (ptr[2] & 255),
(ptr[3] & 255), (ptr[4] & 255), (ptr[5] & 255)
);
return(buff);
}
void eth_setup(char *str, int *ints)
{
struct device *d = dev_base;
if (!str || !*str)
return;
while (d) {
if (!strcmp(str,d->name)) {
while (d)
{
if (!strcmp(str,d->name))
{
if (ints[0] > 0)
d->irq=ints[1];
if (ints[0] > 1)
......@@ -81,107 +69,102 @@ void eth_setup(char *str, int *ints)
}
}
/* Display the contents of the Ethernet MAC header. */
void
eth_dump(struct ethhdr *eth)
{
if (inet_debug != DBG_ETH) return;
printk("eth: SRC = %s ", eth_print(eth->h_source));
printk("DST = %s ", eth_print(eth->h_dest));
printk("TYPE = %04X\n", ntohs(eth->h_proto));
}
/* Create the Ethernet MAC header. */
int
eth_header(unsigned char *buff, struct device *dev, unsigned short type,
unsigned long daddr, unsigned long saddr, unsigned len)
{
struct ethhdr *eth;
DPRINTF((DBG_DEV, "ETH: header(%s, ", in_ntoa(saddr)));
DPRINTF((DBG_DEV, "%s, 0x%X)\n", in_ntoa(daddr), type));
/* Fill in the basic Ethernet MAC header. */
eth = (struct ethhdr *) buff;
eth->h_proto = htons(type);
/* We don't ARP for the LOOPBACK device... */
if (dev->flags & IFF_LOOPBACK) {
DPRINTF((DBG_DEV, "ETH: No header for loopback\n"));
memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
memset(eth->h_dest, 0, dev->addr_len);
return(dev->hard_header_len);
}
/* Check if we can use the MAC BROADCAST address. */
if (chk_addr(daddr) == IS_BROADCAST) {
DPRINTF((DBG_DEV, "ETH: Using MAC Broadcast\n"));
memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
memcpy(eth->h_dest, dev->broadcast, dev->addr_len);
return(dev->hard_header_len);
}
cli();
memcpy(eth->h_source, &saddr, 4);
/* No. Ask ARP to resolve the Ethernet address. */
if (arp_find(eth->h_dest, daddr, dev, dev->pa_addr))
{
sti();
if(type!=ETH_P_IP)
printk("Erk: protocol %X got into an arp request state!\n",type);
return(-dev->hard_header_len);
}
else
{
memcpy(eth->h_source,dev->dev_addr,dev->addr_len); /* This was missing causing chaos if the
header built correctly! */
sti();
return(dev->hard_header_len);
}
}
/*
* Create the Ethernet MAC header for an arbitary protocol layer
*
* saddr=NULL means use device source address
* daddr=NULL means leave destination address (eg unresolved arp)
*/
/* Rebuild the Ethernet MAC header. */
int
eth_rebuild_header(void *buff, struct device *dev)
int eth_header(unsigned char *buff, struct device *dev, unsigned short type,
void *daddr, void *saddr, unsigned len,
struct sk_buff *skb)
{
struct ethhdr *eth;
unsigned long src, dst;
DPRINTF((DBG_DEV, "ETH: Using MAC Broadcast\n"));
eth = (struct ethhdr *) buff;
src = *(unsigned long *) eth->h_source;
dst = *(unsigned long *) eth->h_dest;
DPRINTF((DBG_DEV, "ETH: RebuildHeader: SRC=%s ", in_ntoa(src)));
DPRINTF((DBG_DEV, "DST=%s\n", in_ntoa(dst)));
if(eth->h_proto!=htons(ETH_P_ARP)) /* This ntohs kind of helps a bit! */
if (arp_find(eth->h_dest, dst, dev, dev->pa_addr /* src */)) return(1);
memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
return(0);
struct ethhdr *eth = (struct ethhdr *)buff;
/*
* Set the protocol type. For a packet of type ETH_P_802_3 we put the length
* in here instead. It is up to the 802.2 layer to carry protocol information.
*/
if(type!=ETH_P_802_3)
eth->h_proto = htons(type);
else
eth->h_proto = htons(len);
/*
* Set the source hardware address.
*/
if(saddr)
memcpy(eth->h_source,saddr,dev->addr_len);
else
memcpy(eth->h_source,dev->dev_addr,dev->addr_len);
/*
* Anyway, the loopback-device should never use this function...
*/
if (dev->flags & IFF_LOOPBACK)
{
memset(eth->h_dest, 0, dev->addr_len);
return(dev->hard_header_len);
}
if(daddr)
{
memcpy(eth->h_dest,daddr,dev->addr_len);
return dev->hard_header_len;
}
return -dev->hard_header_len;
}
/* Add an ARP entry for a host on this interface. */
void
eth_add_arp(unsigned long addr, struct sk_buff *skb, struct device *dev)
/*
* Rebuild the Ethernet MAC header. This is called after an ARP
* (or in future other address resolution) has completed on this
* sk_buff. We now let ARP fill in the other fields.
*/
int eth_rebuild_header(void *buff, struct device *dev, unsigned long dst,
struct sk_buff *skb)
{
struct ethhdr *eth;
struct ethhdr *eth = (struct ethhdr *)buff;
/*
* Only ARP/IP is currently supported
*/
if(eth->h_proto != htons(ETH_P_IP))
{
printk("eth_rebuild_header: Don't know how to resolve type %d addreses?\n",(int)eth->h_proto);
memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
return 0;
}
eth = (struct ethhdr *) skb->data;
arp_add(addr, eth->h_source, dev);
/*
* Try and get ARP to resolve the header.
*/
return arp_find(eth->h_dest, dst, dev, dev->pa_addr, skb)? 1 : 0;
}
/* Determine the packet's protocol ID. */
unsigned short
eth_type_trans(struct sk_buff *skb, struct device *dev)
/*
* Determine the packet's protocol ID. The rule here is that we
* assume 802.3 if the type field is short enough to be a length.
* This is normal practice and works for any 'now in use' protocol.
*/
unsigned short eth_type_trans(struct sk_buff *skb, struct device *dev)
{
struct ethhdr *eth;
struct ethhdr *eth = (struct ethhdr *) skb->data;
eth = (struct ethhdr *) skb->data;
if (ntohs(eth->h_proto) < 1536)
return htons(ETH_P_802_3);
if(ntohs(eth->h_proto)<1536)
return(htons(ETH_P_802_3));
return(eth->h_proto);
return eth->h_proto;
}
This diff is collapsed.
......@@ -22,6 +22,8 @@
extern struct icmp_err icmp_err_convert[];
extern struct icmp_mib icmp_statistics;
extern void icmp_send(struct sk_buff *skb_in, int type, int code,
struct device *dev);
......
This diff is collapsed.
......@@ -9,6 +9,7 @@
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Alan Cox, <gw4pts@gw4pts.ampr.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -21,6 +22,9 @@
#include <linux/ip.h>
#ifndef _SNMP_H
#include "snmp.h"
#endif
#include "sock.h" /* struct sock */
......@@ -61,7 +65,7 @@ struct ipq {
extern int backoff(int n);
extern void ip_print(struct iphdr *ip);
extern void ip_print(const struct iphdr *ip);
extern int ip_ioctl(struct sock *sk, int cmd,
unsigned long arg);
extern void ip_route_check(unsigned long daddr);
......@@ -81,5 +85,7 @@ extern void ip_retransmit(struct sock *sk, int all);
extern void ip_do_retransmit(struct sock *sk, int all);
extern int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen);
extern int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen);
extern void ip_init(void);
extern struct ip_mib ip_statistics;
#endif /* _IP_H */
This diff is collapsed.
/*
* The following information is in its entirety obtained from:
*
* Novell 'IPX Router Specification' Version 1.10
* Part No. 107-000029-001
*
* Which is available from ftp.novell.com
*/
#ifndef _IPX_H
#define _IPX_H
#include <linux/ddi.h>
typedef struct
{
unsigned long net;
unsigned char node[6];
unsigned short sock;
} ipx_address;
#define ipx_broadcast_node "\377\377\377\377\377\377"
typedef struct ipx_packet
{
unsigned short ipx_checksum;
#define IPX_NO_CHECKSUM 0xFFFF
unsigned short ipx_pktsize;
unsigned char ipx_tctrl;
unsigned char ipx_type;
#define IPX_TYPE_UNKNOWN 0x00
#define IPX_TYPE_RIP 0x01 /* may also be 0 */
#define IPX_TYPE_SAP 0x04 /* may also be 0 */
#define IPX_TYPE_SPX 0x05 /* Not yet implemented */
#define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */
#define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast [Not supported] */
ipx_address ipx_dest __attribute__ ((packed));
ipx_address ipx_source __attribute__ ((packed));
} ipx_packet;
typedef struct ipx_route
{
unsigned long net;
unsigned char router_node[6];
unsigned long router_net;
unsigned short flags;
struct device *dev;
#define IPX_RT_ROUTED 1 /* This isn't a direct route. Send via this if to node router_node */
#define IPX_RT_BLUEBOOK 2 /* Use DIX 8137 frames not IEE802.3 */
struct ipx_route *next;
} ipx_route;
typedef struct sock ipx_socket;
#include "ipxcall.h"
extern int ipx_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt);
#endif
/* Seperate to keep compilation of Space.c simpler */
extern void ipx_proto_init(struct ddi_proto *pro);
This diff is collapsed.
......@@ -36,13 +36,13 @@
#include <linux/un.h>
#include <linux/in.h>
#include <linux/param.h>
#include "inet.h"
#include "dev.h"
#include <linux/inet.h>
#include <linux/netdevice.h>
#include "ip.h"
#include "protocol.h"
#include "tcp.h"
#include "udp.h"
#include "skbuff.h"
#include <linux/skbuff.h>
#include "sock.h"
#include "raw.h"
......@@ -54,18 +54,21 @@
* happens, get__netinfo returns only part of the available infos.
*/
static int
get__netinfo(struct proto *pro, char *buffer, int format)
get__netinfo(struct proto *pro, char *buffer, int format, char **start, off_t offset, int length)
{
struct sock **s_array;
struct sock *sp;
char *pos=buffer;
int i;
int timer_active;
unsigned long dest, src;
unsigned short destp, srcp;
int len=0;
off_t pos=0;
off_t begin=0;
s_array = pro->sock_array;
pos+=sprintf(pos, "sl local_address rem_address st tx_queue rx_queue tr tm->when uid\n");
len+=sprintf(buffer, "sl local_address rem_address st tx_queue rx_queue tr tm->when uid\n");
/*
* This was very pretty but didn't work when a socket is destroyed at the wrong moment
* (eg a syn recv socket getting a reset), or a memory timer destroy. Instead of playing
......@@ -86,7 +89,7 @@ get__netinfo(struct proto *pro, char *buffer, int format)
timer_active = del_timer(&sp->timer);
if (!timer_active)
sp->timer.expires = 0;
pos+=sprintf(pos, "%2d: %08lX:%04X %08lX:%04X %02X %08lX:%08lX %02X:%08lX %08X %d\n",
len+=sprintf(buffer+len, "%2d: %08lX:%04X %08lX:%04X %02X %08lX:%08lX %02X:%08lX %08X %d\n",
i, src, srcp, dest, destp, sp->state,
format==0?sp->write_seq-sp->rcv_ack_seq:sp->rmem_alloc,
format==0?sp->acked_seq-sp->copied_seq:sp->wmem_alloc,
......@@ -94,40 +97,47 @@ get__netinfo(struct proto *pro, char *buffer, int format)
SOCK_INODE(sp->socket)->i_uid);
if (timer_active)
add_timer(&sp->timer);
/* Is place in buffer too rare? then abort. */
if (pos > buffer+PAGE_SIZE-90) {
printk("oops, too many %s sockets for netinfo.\n",
pro->name);
return(strlen(buffer));
}
/*
* All sockets with (port mod SOCK_ARRAY_SIZE) = i
* are kept in sock_array[i], so we must follow the
* 'next' link to get them all.
*/
sp = sp->next;
pos=begin+len;
if(pos<offset)
{
len=0;
begin=pos;
}
if(pos>offset+length)
break;
}
sti(); /* We only turn interrupts back on for a moment, but because the interrupt queues anything built up
before this will clear before we jump back and cli, so its not as bad as it looks */
if(pos>offset+length)
break;
}
return(strlen(buffer));
*start=buffer+(offset-begin);
len-=(offset-begin);
if(len>length)
len=length;
return len;
}
int tcp_get_info(char *buffer)
int tcp_get_info(char *buffer, char **start, off_t offset, int length)
{
return get__netinfo(&tcp_prot, buffer,0);
return get__netinfo(&tcp_prot, buffer,0, start, offset, length);
}
int udp_get_info(char *buffer)
int udp_get_info(char *buffer, char **start, off_t offset, int length)
{
return get__netinfo(&udp_prot, buffer,1);
return get__netinfo(&udp_prot, buffer,1, start, offset, length);
}
int raw_get_info(char *buffer)
int raw_get_info(char *buffer, char **start, off_t offset, int length)
{
return get__netinfo(&raw_prot, buffer,1);
return get__netinfo(&raw_prot, buffer,1, start, offset, length);
}
......@@ -29,12 +29,12 @@
#include <linux/string.h>
#include <linux/socket.h>
#include <linux/in.h>
#include "inet.h"
#include "dev.h"
#include <linux/inet.h>
#include <linux/netdevice.h>
#include "ip.h"
#include "protocol.h"
#include "tcp.h"
#include "skbuff.h"
#include <linux/skbuff.h>
#include "sock.h"
#include "icmp.h"
#include "udp.h"
......
This diff is collapsed.
This diff is collapsed.
......@@ -37,11 +37,11 @@ struct rtable {
};
extern void rt_flush(struct device *dev);
extern void rt_add(short flags, unsigned long addr, unsigned long mask,
extern void ip_rt_flush(struct device *dev);
extern void ip_rt_add(short flags, unsigned long addr, unsigned long mask,
unsigned long gw, struct device *dev);
extern struct rtable *rt_route(unsigned long daddr, struct options *opt);
extern int rt_get_info(char * buffer);
extern int rt_ioctl(unsigned int cmd, void *arg);
extern struct rtable *ip_rt_route(unsigned long daddr, struct options *opt, unsigned long *src_addr);
extern int rt_get_info(char * buffer, char **start, off_t offset, int length);
extern int ip_rt_ioctl(unsigned int cmd, void *arg);
#endif /* _ROUTE_H */
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.
......@@ -17,6 +17,14 @@
* 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 module is effectively the top level interface to the BSD socket
* paradigm. Because it is very simple it works well for Unix domain sockets,
* but requires a whole layer of substructure for the other protocols.
*
* In addition it lacks an effective kernel -> kernel interface to go with
* the user one.
*/
#include <linux/config.h>
......
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