diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
commit | d6434e1042f3b0a6dfe1b1f615af369486f9b1fa (patch) | |
tree | e2be02f33984c48ec019c654051d27964e42c441 /drivers/net/strip.c | |
parent | 609d1e803baf519487233b765eb487f9ec227a18 (diff) |
Merge with 2.3.19.
Diffstat (limited to 'drivers/net/strip.c')
-rw-r--r-- | drivers/net/strip.c | 76 |
1 files changed, 53 insertions, 23 deletions
diff --git a/drivers/net/strip.c b/drivers/net/strip.c index 32c208a8f..9acb7f031 100644 --- a/drivers/net/strip.c +++ b/drivers/net/strip.c @@ -89,7 +89,6 @@ static const char StripVersion[] = "1.3-STUART.CHESHIRE"; #endif #include <asm/system.h> -#include <linux/types.h> #include <asm/uaccess.h> #include <asm/segment.h> #include <asm/bitops.h> @@ -312,7 +311,7 @@ struct strip struct tty_struct *tty; /* ptr to TTY structure */ char8 if_name; /* Dynamically generated name */ - struct device dev; /* Our device structure */ + struct net_device dev; /* Our device structure */ /* * Neighbour radio records @@ -506,7 +505,7 @@ extern __inline__ void RestoreInterrupts(InterruptStatus x) restore_flags(x); } -static int arp_query(unsigned char *haddr, u32 paddr, struct device * dev) +static int arp_query(unsigned char *haddr, u32 paddr, struct net_device * dev) { struct neighbour *neighbor_entry; @@ -933,7 +932,7 @@ static __u8 *radio_address_to_string(const MetricomAddress *addr, MetricomAddres static int allocate_buffers(struct strip *strip_info) { - struct device *dev = &strip_info->dev; + struct net_device *dev = &strip_info->dev; int sx_size = MAX(STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096); int tx_size = STRIP_ENCAP_SIZE(dev->mtu) + MaxCommandStringLength; __u8 *r = kmalloc(MAX_RECV_MTU, GFP_ATOMIC); @@ -964,7 +963,7 @@ static int allocate_buffers(struct strip *strip_info) static void strip_changedmtu(struct strip *strip_info) { int old_mtu = strip_info->mtu; - struct device *dev = &strip_info->dev; + struct net_device *dev = &strip_info->dev; unsigned char *orbuff = strip_info->rx_buff; unsigned char *osbuff = strip_info->sx_buff; unsigned char *otbuff = strip_info->tx_buff; @@ -1465,9 +1464,18 @@ static unsigned char *strip_make_packet(unsigned char *buffer, struct strip *str */ if (haddr.c[0] == 0xFF) { - struct in_device *in_dev = strip_info->dev.ip_ptr; + u32 brd = 0; + struct in_device *in_dev = in_dev_get(&strip_info->dev); + if (in_dev == NULL) + return NULL; + read_lock(&in_dev->lock); + if (in_dev->ifa_list) + brd = in_dev->ifa_list->ifa_broadcast; + read_unlock(&in_dev->lock); + in_dev_put(in_dev); + /* arp_query returns 1 if it succeeds in looking up the address, 0 if it fails */ - if (!arp_query(haddr.c, in_dev->ifa_list->ifa_broadcast, &strip_info->dev)) + if (!arp_query(haddr.c, brd, &strip_info->dev)) { printk(KERN_ERR "%s: Unable to send packet (no broadcast hub configured)\n", strip_info->dev.name); @@ -1511,7 +1519,7 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb) unsigned char *ptr = strip_info->tx_buff; int doreset = (long)jiffies - strip_info->watchdog_doreset >= 0; int doprobe = (long)jiffies - strip_info->watchdog_doprobe >= 0 && !doreset; - struct in_device *in_dev = strip_info->dev.ip_ptr; + u32 addr, brd; /* * 1. If we have a packet, encapsulate it and put it in the buffer @@ -1595,6 +1603,21 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb) */ if (doreset) { ResetRadio(strip_info); return; } + if (1) { + struct in_device *in_dev = in_dev_get(&strip_info->dev); + brd = addr = 0; + if (in_dev) { + read_lock(&in_dev->lock); + if (in_dev->ifa_list) { + brd = in_dev->ifa_list->ifa_broadcast; + addr = in_dev->ifa_list->ifa_local; + } + read_unlock(&in_dev->lock); + in_dev_put(in_dev); + } + } + + /* * 6. If it is time for a periodic ARP, queue one up to be sent. * We only do this if: @@ -1611,7 +1634,7 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb) */ if (strip_info->working && (long)jiffies - strip_info->gratuitous_arp >= 0 && memcmp(strip_info->dev.dev_addr, zero_address.c, sizeof(zero_address)) && - arp_query(haddr.c, in_dev->ifa_list->ifa_broadcast, &strip_info->dev)) + arp_query(haddr.c, brd, &strip_info->dev)) { /*printk(KERN_INFO "%s: Sending gratuitous ARP with interval %ld\n", strip_info->dev.name, strip_info->arp_interval / HZ);*/ @@ -1619,12 +1642,12 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb) strip_info->arp_interval *= 2; if (strip_info->arp_interval > MaxARPInterval) strip_info->arp_interval = MaxARPInterval; - if (in_dev && in_dev->ifa_list) + if (addr) arp_send( ARPOP_REPLY, ETH_P_ARP, - in_dev->ifa_list->ifa_address, /* Target address of ARP packet is our address */ + addr, /* Target address of ARP packet is our address */ &strip_info->dev, /* Device to send packet on */ - in_dev->ifa_list->ifa_address, /* Source IP address this ARP packet comes from */ + addr, /* Source IP address this ARP packet comes from */ NULL, /* Destination HW address is NULL (broadcast it) */ strip_info->dev.dev_addr, /* Source HW address is our HW address */ strip_info->dev.dev_addr); /* Target HW address is our HW address (redundant) */ @@ -1637,7 +1660,7 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb) } /* Encapsulate a datagram and kick it into a TTY queue. */ -static int strip_xmit(struct sk_buff *skb, struct device *dev) +static int strip_xmit(struct sk_buff *skb, struct net_device *dev) { struct strip *strip_info = (struct strip *)(dev->priv); @@ -1694,7 +1717,7 @@ static int strip_xmit(struct sk_buff *skb, struct device *dev) static void strip_IdleTask(unsigned long parameter) { - strip_xmit(NULL, (struct device *)parameter); + strip_xmit(NULL, (struct net_device *)parameter); } /* @@ -1708,7 +1731,7 @@ static void strip_IdleTask(unsigned long parameter) * rebuild_header later to fill in the address) */ -static int strip_header(struct sk_buff *skb, struct device *dev, +static int strip_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len) { struct strip *strip_info = (struct strip *)(dev->priv); @@ -2019,7 +2042,7 @@ static void process_Info(struct strip *strip_info, __u8 *ptr, __u8 *end) if (ptr+16 > end) RecvErr("Bad Info Msg:", strip_info); } -static struct device *get_strip_dev(struct strip *strip_info) +static struct net_device *get_strip_dev(struct strip *strip_info) { /* If our hardware address is *manually set* to zero, and we know our */ /* real radio hardware address, try to find another strip device that has been */ @@ -2028,7 +2051,7 @@ static struct device *get_strip_dev(struct strip *strip_info) !memcmp(strip_info->dev.dev_addr, zero_address.c, sizeof(zero_address)) && memcmp(&strip_info->true_dev_addr, zero_address.c, sizeof(zero_address))) { - struct device *dev; + struct net_device *dev; read_lock_bh(&dev_base_lock); dev = dev_base; while (dev) @@ -2415,7 +2438,7 @@ static int set_mac_address(struct strip *strip_info, MetricomAddress *addr) return 0; } -static int dev_set_mac_address(struct device *dev, void *addr) +static int dev_set_mac_address(struct net_device *dev, void *addr) { struct strip *strip_info = (struct strip *)(dev->priv); struct sockaddr *sa = addr; @@ -2424,7 +2447,7 @@ static int dev_set_mac_address(struct device *dev, void *addr) return 0; } -static struct enet_statistics *strip_get_stats(struct device *dev) +static struct enet_statistics *strip_get_stats(struct net_device *dev) { static struct enet_statistics stats; struct strip *strip_info = (struct strip *)(dev->priv); @@ -2469,10 +2492,12 @@ static struct enet_statistics *strip_get_stats(struct device *dev) /* Open the low-level part of the STRIP channel. Easy! */ -static int strip_open_low(struct device *dev) +static int strip_open_low(struct net_device *dev) { struct strip *strip_info = (struct strip *)(dev->priv); +#if 0 struct in_device *in_dev = dev->ip_ptr; +#endif if (strip_info->tty == NULL) return(-ENODEV); @@ -2489,12 +2514,17 @@ static int strip_open_low(struct device *dev) strip_info->next_command = CompatibilityCommand; strip_info->user_baud = get_baud(strip_info->tty); +#if 0 /* * Needed because address '0' is special + * + * --ANK Needed it or not needed, it does not matter at all. + * Make it at user level, guys. */ if (in_dev->ifa_list->ifa_address == 0) in_dev->ifa_list->ifa_address = ntohl(0xC0A80001); +#endif dev->tbusy = 0; dev->start = 1; @@ -2510,7 +2540,7 @@ static int strip_open_low(struct device *dev) * Close the low-level part of the STRIP channel. Easy! */ -static int strip_close_low(struct device *dev) +static int strip_close_low(struct net_device *dev) { struct strip *strip_info = (struct strip *)(dev->priv); @@ -2547,7 +2577,7 @@ static int strip_close_low(struct device *dev) * (dynamically assigned) device is registered */ -static int strip_dev_init(struct device *dev) +static int strip_dev_init(struct net_device *dev) { /* * Finish setting up the DEVICE info. @@ -2822,7 +2852,7 @@ static int strip_ioctl(struct tty_struct *tty, struct file *file, #ifdef MODULE static #endif -int strip_init_ctrl_dev(struct device *dummy) +int strip_init_ctrl_dev(struct net_device *dummy) { static struct tty_ldisc strip_ldisc; int status; |