[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20111219.144704.1132849710000837906.davem@davemloft.net>
Date: Mon, 19 Dec 2011 14:47:04 -0500 (EST)
From: David Miller <davem@...emloft.net>
To: alex.bluesman.smirnov@...il.com
Cc: dbaryshkov@...il.com, linux-zigbee-devel@...ts.sourceforge.net,
netdev@...r.kernel.org, alexander@...ovo
Subject: Re: [PATCH 12/14] mac802154: monitor device support
From: Alexander Smirnov <alex.bluesman.smirnov@...il.com>
Date: Mon, 19 Dec 2011 19:33:52 +0300
> + IEEE802154_DEV_MONITOR = 1, /* for compatibility with WireShark */
What's this "compatability" all about? Explain it.
> + dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
> + name, mac802154_monitor_setup);
Line up the arguments properly.
> + break;
> default:
> dev = NULL;
> err = -EINVAL;
> diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
> index f6f6f0a..2a301d0 100644
> --- a/net/mac802154/mac802154.h
> +++ b/net/mac802154/mac802154.h
> @@ -90,6 +90,9 @@ extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
> int mac802154_slave_open(struct net_device *dev);
> int mac802154_slave_close(struct net_device *dev);
>
> +void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb);
> +void mac802154_monitor_setup(struct net_device *dev);
> +
> netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
> u8 page, u8 chan);
>
> diff --git a/net/mac802154/monitor.c b/net/mac802154/monitor.c
> new file mode 100644
> index 0000000..ccc5e81
> --- /dev/null
> +++ b/net/mac802154/monitor.c
> @@ -0,0 +1,115 @@
> +/*
> + * Copyright 2007, 2008, 2009 Siemens AG
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + *
> + * Written by:
> + * Dmitry Eremin-Solenikov <dbaryshkov@...il.com>
> + * Sergey Lapin <slapin@...fans.org>
> + * Maxim Gorbachyov <maxim.gorbachev@...mens.com>
> + */
> +
> +#include <linux/netdevice.h>
> +#include <linux/skbuff.h>
> +#include <linux/if_arp.h>
> +#include <linux/crc-ccitt.h>
> +#include <linux/nl802154.h>
> +#include <net/ieee802154.h>
> +#include <net/mac802154.h>
> +#include <net/wpan-phy.h>
> +
> +#include "mac802154.h"
> +
> +static netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb, struct net_device *dev)
> +{
> + struct mac802154_sub_if_data *priv;
> + u8 chan, page;
> +
> + priv = netdev_priv(dev);
> +
> + /* FIXME: locking */
> + chan = priv->hw->phy->current_channel;
> + page = priv->hw->phy->current_page;
> +
> + if (chan == (u8)-1) /* not init */
...
> + priv->chan = -1; /* not initialized */
This mixing of the integer "-1" value with a "u8" type is asking for trouble.
Define something like:
#define MAC802154_CHAN_NONE 0xff
or
#define MAC802154_CHAN_NONE (~(u8)0)
and use it consistently.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists