netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: alex.bluesman.smirnov@gmail.com
Cc: dbaryshkov@gmail.com, linux-zigbee-devel@lists.sourceforge.net,
	netdev@vger.kernel.org, alexander@Lenovo
Subject: Re: [PATCH 12/14] mac802154: monitor device support
Date: Mon, 19 Dec 2011 14:47:04 -0500 (EST)	[thread overview]
Message-ID: <20111219.144704.1132849710000837906.davem@davemloft.net> (raw)
In-Reply-To: <1324312434-13151-12-git-send-email-alex.bluesman.smirnov@gmail.com>

From: Alexander Smirnov <alex.bluesman.smirnov@gmail.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@gmail.com>
> + * Sergey Lapin <slapin@ossfans.org>
> + * Maxim Gorbachyov <maxim.gorbachev@siemens.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.

  reply	other threads:[~2011-12-19 19:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-19 16:31 [PATCH series v1] IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
2011-12-19 16:33 ` [PATCH 01/14] mac802154: basic ieee802.15.4 device structures Alexander Smirnov
2011-12-19 19:32   ` David Miller
2011-12-19 16:33 ` [PATCH 02/14] mac802154: allocation of ieee802154 device Alexander Smirnov
     [not found]   ` <1324312434-13151-2-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:34     ` David Miller
2011-12-19 16:33 ` [PATCH 03/14] mac802154: RX data path Alexander Smirnov
     [not found]   ` <1324312434-13151-3-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:36     ` David Miller
2011-12-19 16:33 ` [PATCH 04/14] mac802154: TX " Alexander Smirnov
     [not found]   ` <1324312434-13151-4-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:38     ` David Miller
     [not found] ` <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
2011-12-19 16:33   ` [PATCH 05/14] mac802154: define reduced mlme operations Alexander Smirnov
2011-12-19 16:33   ` [PATCH 06/14] mac802154: slave interfaces definition Alexander Smirnov
     [not found]     ` <1324312434-13151-6-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:38       ` David Miller
2011-12-19 16:33   ` [PATCH 07/14] mac802154: reduced mlme operations Alexander Smirnov
2011-12-19 16:33   ` [PATCH 08/14] mac802154: basic mib support Alexander Smirnov
     [not found]     ` <1324312434-13151-8-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:39       ` David Miller
2011-12-19 16:33   ` [PATCH 09/14] ieee802154: remove ieee802154 policy from globals Alexander Smirnov
     [not found]     ` <1324312434-13151-9-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:40       ` David Miller
2011-12-19 16:33   ` [PATCH 10/14] ieee802154: interface type to be added Alexander Smirnov
     [not found]     ` <1324312434-13151-10-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:42       ` David Miller
2011-12-19 16:33   ` [PATCH 11/14] mac802154: slaves manipulation routine Alexander Smirnov
     [not found]     ` <1324312434-13151-11-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:43       ` David Miller
2011-12-20  1:08         ` Joe Perches
2011-12-19 16:33   ` [PATCH 12/14] mac802154: monitor device support Alexander Smirnov
2011-12-19 19:47     ` David Miller [this message]
2011-12-19 16:33   ` [PATCH 13/14] drivers/ieee802154: IEEE 802.15.4 loopback driver Alexander Smirnov
     [not found]     ` <1324312434-13151-13-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-19 19:49       ` David Miller
2011-12-19 16:33 ` [PATCH 14/14] Documentation/networking/ieee802154: update MAC chapter Alexander Smirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111219.144704.1132849710000837906.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=alex.bluesman.smirnov@gmail.com \
    --cc=alexander@Lenovo \
    --cc=dbaryshkov@gmail.com \
    --cc=linux-zigbee-devel@lists.sourceforge.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).