From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCH 4/6] batman-adv: Distributed ARP Table - add ARP parsing functions
Date: Mon, 31 Oct 2011 01:10:04 +0100 [thread overview]
Message-ID: <20111031001004.GE10726@pandem0nium> (raw)
In-Reply-To: <1319964962-5092-5-git-send-email-ordex@autistici.org>
[-- Attachment #1: Type: text/plain, Size: 2011 bytes --]
This patch is not checkpatch.pl --strict clean
On Sun, Oct 30, 2011 at 09:56:00AM +0100, Antonio Quartulli wrote:
> ARP messages are now parsed to make it possible to trigger special actions
> depending on their types (snooping).
>
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> ---
> arp.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> arp.h | 7 +++++++
> 2 files changed, 50 insertions(+), 0 deletions(-)
>
> diff --git a/arp.c b/arp.c
> index 39043b8..ea7cc1e 100644
> --- a/arp.c
> +++ b/arp.c
> @@ -183,3 +183,46 @@ out:
> kfree(cand);
> return ret;
> }
> +
> +/* Returns arphdr->ar_op if the skb contains a valid ARP packet, otherwise
> + * returns 0 */
> +uint16_t arp_get_type(struct bat_priv *bat_priv, struct sk_buff *skb)
> +{
> + struct arphdr *arphdr;
> + struct ethhdr *ethhdr;
> + uint16_t type = 0;
> +
> + if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
> + goto out;
> +
> + ethhdr = (struct ethhdr *)skb_mac_header(skb);
> +
> + if (ethhdr->h_proto != htons(ETH_P_ARP))
> + goto out;
> +
> + if (unlikely(!pskb_may_pull(skb, ETH_HLEN + arp_hdr_len(skb->dev) + 8 + 12)))
> + goto out;
use ETH_ALEN * 2 + 4 * 2 instead to show where theses numbers come from.
> +
> + arphdr = (struct arphdr *)(skb->data + sizeof(struct ethhdr));
> +
> + /* Check whether the ARP packet carries a valid
> + * IP information */
> + if (arphdr->ar_hrd != htons(ARPHRD_ETHER))
> + goto out;
> +
> + if (arphdr->ar_pro != htons(ETH_P_IP))
> + goto out;
> +
> + if (arphdr->ar_hln != ETH_ALEN)
> + goto out;
> +
> + if (arphdr->ar_pln != 4)
> + goto out;
> +
> + type = ntohs(arphdr->ar_op);
> + bat_dbg(DBG_ARP, bat_priv, "ARP message of type %d recognised "
> + "[%pM-%pI4 %pM-%pI4]\n", type, ARP_HW_SRC(skb),
> + &ARP_IP_SRC(skb), ARP_HW_DST(skb), &ARP_IP_DST(skb));
Would you mind printing the type as string? something like REQUEST or REPLY instead of 1 and 2 ...
> +out:
> + return type;
> +}
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2011-10-31 0:10 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-30 8:55 [B.A.T.M.A.N.] [PATCH 0/6] DAT: Distributed ARP Table Antonio Quartulli
2011-10-30 8:55 ` [B.A.T.M.A.N.] [PATCH 1/6] batman-adv: implement an helper function to forge unicast packets Antonio Quartulli
2011-10-31 0:05 ` Simon Wunderlich
2011-11-01 9:12 ` Antonio Quartulli
2011-10-30 8:55 ` [B.A.T.M.A.N.] [PATCH 2/6] batman-adv: add a new log level for DAT-ARP debugging Antonio Quartulli
2011-10-30 8:55 ` [B.A.T.M.A.N.] [PATCH 3/6] batman-adv: Distributed ARP Table - create the DHT helper functions Antonio Quartulli
2011-10-31 0:08 ` Simon Wunderlich
2011-10-30 8:56 ` [B.A.T.M.A.N.] [PATCH 4/6] batman-adv: Distributed ARP Table - add ARP parsing functions Antonio Quartulli
2011-10-31 0:10 ` Simon Wunderlich [this message]
2011-11-01 9:14 ` Antonio Quartulli
2011-10-30 8:56 ` [B.A.T.M.A.N.] [PATCH 5/6] batman-adv: Distributed ARP Table - add snooping functions for ARP messages Antonio Quartulli
2011-10-30 9:18 ` Sven Eckelmann
2011-10-30 9:29 ` Antonio Quartulli
2011-10-31 0:12 ` Simon Wunderlich
2011-11-01 9:16 ` Antonio Quartulli
2011-10-30 8:56 ` [B.A.T.M.A.N.] [PATCH 6/6] batman-adv: Distributed ARP Table - increase default soft_iface ARP table timeout Antonio Quartulli
2011-10-31 0:03 ` [B.A.T.M.A.N.] [PATCH 0/6] DAT: Distributed ARP Table Simon Wunderlich
2011-10-31 9:26 ` Martin Hundebøll
2011-10-31 9:42 ` Marek Lindner
2011-10-31 9:48 ` Simon Wunderlich
2011-11-01 9:16 ` Antonio Quartulli
2011-10-31 18:53 ` Gus Wirth
2011-10-31 23:11 ` Simon Wunderlich
2011-11-01 9:10 ` Antonio Quartulli
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=20111031001004.GE10726@pandem0nium \
--to=simon.wunderlich@s2003.tu-chemnitz.de \
--cc=b.a.t.m.a.n@lists.open-mesh.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