57 #include <linux/errno.h>
58 #include <linux/types.h>
59 #include <linux/socket.h>
61 #include <linux/kernel.h>
62 #include <linux/string.h>
63 #include <linux/net.h>
64 #include <linux/slab.h>
67 #include <linux/netdevice.h>
69 #include <linux/if_arp.h>
72 #include <asm/uaccess.h>
78 #include <linux/stat.h>
79 #include <linux/netfilter.h>
80 #include <linux/module.h>
82 #include <linux/rtnetlink.h>
91 "AX.25: bpqether driver version 004\n";
93 static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
95 static char bpq_eth_addr[6];
98 static int bpq_device_event(
struct notifier_block *,
unsigned long,
void *);
106 .notifier_call =bpq_device_event,
128 static void bpq_set_lockdep_class_one(
struct net_device *
dev,
138 netdev_for_each_tx_queue(dev, bpq_set_lockdep_class_one,
NULL);
149 struct bpqdev *bpq = netdev_priv(dev);
161 list_for_each_entry_rcu(bpq, &bpq_devices,
bpq_list) {
168 static inline int dev_is_ethdev(
struct net_device *dev)
186 if (!net_eq(dev_net(dev), &
init_net))
192 if (!pskb_may_pull(skb,
sizeof(
struct ethhdr)))
196 dev = bpq_get_ax25_dev(dev);
198 if (dev ==
NULL || !netif_running(dev))
206 bpq = netdev_priv(dev);
214 if (skb_cow(skb,
sizeof(
struct ethhdr)))
217 len = skb->
data[0] + skb->
data[1] * 256 - 5;
222 dev->
stats.rx_packets++;
223 dev->
stats.rx_bytes += len;
228 skb->
protocol = ax25_type_trans(skb, dev);
258 if (!netif_running(dev)) {
273 pr_err(
"bpqether: out of memory\n");
281 *ptr++ = (size + 5) % 256;
282 *ptr++ = (size + 5) / 256;
284 bpq = netdev_priv(dev);
287 if ((dev = bpq_get_ether_dev(dev)) ==
NULL) {
288 orig_dev->
stats.tx_dropped++;
293 skb->
protocol = ax25_type_trans(skb, dev);
294 skb_reset_network_header(skb);
296 dev->
stats.tx_packets++;
300 netif_wake_queue(dev);
307 static int bpq_set_mac_address(
struct net_device *dev,
void *
addr)
326 struct bpqdev *bpq = netdev_priv(dev);
364 netif_start_queue(dev);
370 netif_stop_queue(dev);
381 static void *bpq_seq_start(
struct seq_file *seq, loff_t *
pos)
392 list_for_each_entry_rcu(bpqdev, &bpq_devices,
bpq_list) {
399 static void *bpq_seq_next(
struct seq_file *seq,
void *
v, loff_t *
pos)
402 struct bpqdev *bpqdev =
v;
411 return (p == &bpq_devices) ?
NULL
415 static void bpq_seq_stop(
struct seq_file *seq,
void *v)
422 static int bpq_seq_show(
struct seq_file *seq,
void *v)
426 "dev ether destination accept from\n");
428 const struct bpqdev *bpqdev =
v;
434 if (is_multicast_ether_addr(bpqdev->
acpt_addr))
444 .start = bpq_seq_start,
445 .next = bpq_seq_next,
446 .stop = bpq_seq_stop,
447 .show = bpq_seq_show,
457 .open = bpq_info_open,
467 .ndo_open = bpq_open,
468 .ndo_stop = bpq_close,
469 .ndo_start_xmit = bpq_xmit,
470 .ndo_set_mac_address = bpq_set_mac_address,
471 .ndo_do_ioctl = bpq_ioctl,
484 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
498 static int bpq_new_device(
struct net_device *edev)
510 bpq = netdev_priv(ndev);
521 bpq_set_lockdep_class(ndev);
524 list_add_rcu(&bpq->
bpq_list, &bpq_devices);
534 static void bpq_free_device(
struct net_device *ndev)
536 struct bpqdev *bpq = netdev_priv(ndev);
541 unregister_netdevice(ndev);
551 if (!net_eq(dev_net(dev), &
init_net))
554 if (!dev_is_ethdev(dev))
559 if (bpq_get_ax25_dev(dev) ==
NULL)
564 if ((dev = bpq_get_ax25_dev(dev)) !=
NULL)
569 if ((dev = bpq_get_ax25_dev(dev)) !=
NULL)
570 bpq_free_device(dev);
586 static int __init bpq_init_driver(
void)
588 #ifdef CONFIG_PROC_FS
591 "bpq: cannot create /proc/net/bpqether entry.\n");
605 static void __exit bpq_cleanup_driver(
void)
616 while (!list_empty(&bpq_devices)) {
618 bpq_free_device(bpq->
axdev);