patch-1.3.7 linux/net/netrom/nr_dev.c
Next file: linux/net/netrom/nr_in.c
Previous file: linux/net/netrom/af_netrom.c
Back to the patch index
Back to the overall index
- Lines: 161
- Date:
Wed Jul 5 13:06:28 1995
- Orig file:
v1.3.6/linux/net/netrom/nr_dev.c
- Orig date:
Fri Jun 30 16:22:34 1995
diff -u --recursive --new-file v1.3.6/linux/net/netrom/nr_dev.c linux/net/netrom/nr_dev.c
@@ -46,59 +46,48 @@
#include <net/netrom.h>
/*
- * Only allow IP over NET/ROM frames through if the netrom device is up.
+ * Only allow IP over NET/ROM frames through if the netrom device is up.
*/
int nr_rx_ip(struct sk_buff *skb, struct device *dev)
{
struct enet_statistics *stats = (struct enet_statistics *)dev->priv;
- if (!dev->start) {
+ if (!dev->start)
+ {
stats->rx_errors++;
return 0;
}
stats->rx_packets++;
- skb->protocol=htons(ETH_P_IP);
+ skb->protocol = htons(ETH_P_IP);
+
/* Spoof incoming device */
- skb->dev=dev;
+ skb->dev = dev;
- ip_rcv(skb, dev, NULL);
+ skb->h.raw = skb->data;
+ ip_rcv(skb, skb->dev, NULL);
return 1;
}
-/*
- * We can't handle ARP so put some identification characters into the ARP
- * packet so that the transmit routine can identify it, and throw it away.
- */
-
static int nr_header(struct sk_buff *skb, struct device *dev, unsigned short type,
void *daddr, void *saddr, unsigned len)
{
- unsigned char *buff=skb_push(skb,37);
- if (type == ETH_P_ARP) {
- *buff++ = 0xFF; /* Mark it */
- *buff++ = 0xFE;
- return 37;
- }
+ unsigned char *buff = skb_push(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
- buff += 16;
-
- *buff++ = AX25_P_NETROM;
-
memcpy(buff, (saddr != NULL) ? saddr : dev->dev_addr, dev->addr_len);
buff[6] &= ~LAPB_C;
buff[6] &= ~LAPB_E;
buff[6] |= SSID_SPARE;
- buff += dev->addr_len;
+ buff += AX25_ADDR_LEN;
if (daddr != NULL)
memcpy(buff, daddr, dev->addr_len);
buff[6] &= ~LAPB_C;
buff[6] |= LAPB_E;
buff[6] |= SSID_SPARE;
- buff += dev->addr_len;
+ buff += AX25_ADDR_LEN;
*buff++ = nr_default.ttl;
@@ -117,20 +106,35 @@
static int nr_rebuild_header(void *buff, struct device *dev,
unsigned long raddr, struct sk_buff *skb)
{
+ struct enet_statistics *stats = (struct enet_statistics *)dev->priv;
unsigned char *bp = (unsigned char *)buff;
- if (arp_find(bp + 24, raddr, dev, dev->pa_addr, skb))
+ skb_device_unlock(skb);
+
+ if (!arp_query(bp + 7, raddr, ARPHRD_NETROM)) {
+ skb->free = 1;
+ kfree_skb(skb, FREE_WRITE);
return 1;
+ }
- bp[23] &= ~LAPB_C;
- bp[23] &= ~LAPB_E;
- bp[23] |= SSID_SPARE;
+ bp[6] &= ~LAPB_C;
+ bp[6] &= ~LAPB_E;
+ bp[6] |= SSID_SPARE;
+ bp += AX25_ADDR_LEN;
- bp[30] &= ~LAPB_C;
- bp[30] |= LAPB_E;
- bp[30] |= SSID_SPARE;
+ bp[6] &= ~LAPB_C;
+ bp[6] |= LAPB_E;
+ bp[6] |= SSID_SPARE;
+
+ if (!nr_route_frame(skb, NULL)) {
+ skb->free = 1;
+ kfree_skb(skb, FREE_WRITE);
+ stats->tx_errors++;
+ }
- return 0;
+ stats->tx_packets++;
+
+ return 1;
}
static int nr_set_mac_address(struct device *dev, void *addr)
@@ -159,7 +163,6 @@
static int nr_xmit(struct sk_buff *skb, struct device *dev)
{
struct enet_statistics *stats = (struct enet_statistics *)dev->priv;
- struct sk_buff *skbn;
if (skb == NULL || dev == NULL)
return 0;
@@ -181,25 +184,9 @@
sti();
- if (skb->data[0] != 0xFF && skb->data[1] != 0xFE) {
- if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) {
- dev->tbusy = 0;
- stats->tx_errors++;
- return 1;
- }
-
- if (!nr_route_frame(skbn, NULL)) {
- skbn->free = 1;
- kfree_skb(skbn, FREE_WRITE);
- dev->tbusy = 0;
- stats->tx_errors++;
- return 1;
- }
- }
-
dev_kfree_skb(skb, FREE_WRITE);
- stats->tx_packets++;
+ stats->tx_errors++;
dev->tbusy = 0;
@@ -224,8 +211,8 @@
dev->stop = nr_close;
dev->hard_header = nr_header;
- dev->hard_header_len = 37;
- dev->addr_len = 7;
+ dev->hard_header_len = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + 2 + NR_NETWORK_LEN + NR_TRANSPORT_LEN;
+ dev->addr_len = AX25_ADDR_LEN;
dev->type = ARPHRD_NETROM;
dev->rebuild_header = nr_rebuild_header;
dev->set_mac_address = nr_set_mac_address;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this