/*****************************************************************************/
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/net.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/bitops.h>
-#include <asm/uaccess.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
-#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/hdlcdrv.h>
-/* prototypes for ax25_encapsulate and ax25_rebuild_header */
#include <net/ax25.h>
+#include <asm/uaccess.h>
-/* make genksyms happy */
-#include <linux/ip.h>
-#include <linux/udp.h>
-#include <linux/tcp.h>
#include <linux/crc-ccitt.h>
/* --------------------------------------------------------------------- */
s->stats.rx_dropped++;
return;
}
- skb->dev = dev;
cp = skb_put(skb, pkt_len);
*cp++ = 0; /* KISS kludge */
memcpy(cp, s->hdlcrx.buffer, pkt_len - 1);
- skb->protocol = htons(ETH_P_AX25);
- skb->mac.raw = skb->data;
+ skb->protocol = ax25_type_trans(skb, dev);
netif_rx(skb);
dev->last_rx = jiffies;
s->stats.rx_packets++;
* ===================== network driver interface =========================
*/
-static inline int hdlcdrv_paranoia_check(struct net_device *dev,
- const char *routine)
-{
- if (!dev || !dev->priv ||
- ((struct hdlcdrv_state *)dev->priv)->magic != HDLCDRV_MAGIC) {
- printk(KERN_ERR "hdlcdrv: bad magic number for hdlcdrv_state "
- "struct in routine %s\n", routine);
- return 1;
- }
- return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
static int hdlcdrv_send_packet(struct sk_buff *skb, struct net_device *dev)
{
- struct hdlcdrv_state *sm;
+ struct hdlcdrv_state *sm = netdev_priv(dev);
- if (hdlcdrv_paranoia_check(dev, "hdlcdrv_send_packet"))
- return 0;
- sm = (struct hdlcdrv_state *)dev->priv;
if (skb->data[0] != 0) {
do_kiss_params(sm, skb->data, skb->len);
dev_kfree_skb(skb);
static struct net_device_stats *hdlcdrv_get_stats(struct net_device *dev)
{
- struct hdlcdrv_state *sm;
+ struct hdlcdrv_state *sm = netdev_priv(dev);
- if (hdlcdrv_paranoia_check(dev, "hdlcdrv_get_stats"))
- return NULL;
- sm = (struct hdlcdrv_state *)dev->priv;
/*
* Get the current statistics. This may be called with the
* card open or closed.
static int hdlcdrv_open(struct net_device *dev)
{
- struct hdlcdrv_state *s;
+ struct hdlcdrv_state *s = netdev_priv(dev);
int i;
- if (hdlcdrv_paranoia_check(dev, "hdlcdrv_open"))
- return -EINVAL;
- s = (struct hdlcdrv_state *)dev->priv;
-
if (!s->ops || !s->ops->open)
return -ENODEV;
static int hdlcdrv_close(struct net_device *dev)
{
- struct hdlcdrv_state *s;
+ struct hdlcdrv_state *s = netdev_priv(dev);
int i = 0;
- if (hdlcdrv_paranoia_check(dev, "hdlcdrv_close"))
- return -EINVAL;
- s = (struct hdlcdrv_state *)dev->priv;
-
netif_stop_queue(dev);
if (s->ops && s->ops->close)
static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
- struct hdlcdrv_state *s;
+ struct hdlcdrv_state *s = netdev_priv(dev);
struct hdlcdrv_ioctl bi;
-
- if (hdlcdrv_paranoia_check(dev, "hdlcdrv_ioctl"))
- return -EINVAL;
- s = (struct hdlcdrv_state *)dev->priv;
if (cmd != SIOCDEVPRIVATE) {
if (s->ops && s->ops->ioctl)
static const struct hdlcdrv_channel_params dflt_ch_params = {
20, 2, 10, 40, 0
};
- struct hdlcdrv_state *s = dev->priv;
+ struct hdlcdrv_state *s = netdev_priv(dev);
/*
* initialize the hdlcdrv_state struct
s->skb = NULL;
-#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
- dev->hard_header = ax25_encapsulate;
+ dev->hard_header = ax25_hard_header;
dev->rebuild_header = ax25_rebuild_header;
-#else /* CONFIG_AX25 || CONFIG_AX25_MODULE */
- dev->hard_header = NULL;
- dev->rebuild_header = NULL;
-#endif /* CONFIG_AX25 || CONFIG_AX25_MODULE */
dev->set_mac_address = hdlcdrv_set_mac_address;
dev->type = ARPHRD_AX25; /* AF_AX25 device */
/*
* initialize part of the hdlcdrv_state struct
*/
- s = dev->priv;
+ s = netdev_priv(dev);
s->magic = HDLCDRV_MAGIC;
s->ops = ops;
dev->base_addr = baseaddr;
void hdlcdrv_unregister(struct net_device *dev)
{
- struct hdlcdrv_state *s = dev->priv;
+ struct hdlcdrv_state *s = netdev_priv(dev);
BUG_ON(s->magic != HDLCDRV_MAGIC);