From: Sven Eckelmann <sven@narfation.org>
To: Dominic Follett-Smith <dominicfollett@gmail.com>,
b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] mac address from packet
Date: Fri, 05 Oct 2012 09:11:32 +0200 [thread overview]
Message-ID: <1710035.x7kxmPdvcU@bentobox> (raw)
In-Reply-To: <CA+h5VgqcOikZGAGhw7Ztz+H6E8EtA39o0V-qFYxPGRv=d4ws=w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]
On Thursday 04 October 2012 21:30:24 you wrote:
> However we need the mac address of the neighbouring station that sent
> the OGM. But we are not sure how to go about retrieving the mac
> address which is part of the ethernet mac header at the beginning of
> the frame.
You don't have this information when you receive the data through an UDP
socket (this is one of the reasons why all development is now done in batman-
adv). What you can do is to rewrite the batmand socket handling stuff using
PF_PACKET. Small hint: you should use BPF to reduce the amount of packets
received by userspace since your HW doesn't look really powerful. Even better
hint: BPF codes can be created using tcpdump. Here an example for udp port
4305:
$ tcpdump -dd 'ip and udp and port 4305'
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 0, 10, 0x00000800 },
{ 0x30, 0, 0, 0x00000017 },
{ 0x15, 0, 8, 0x00000011 },
{ 0x28, 0, 0, 0x00000014 },
{ 0x45, 6, 0, 0x00001fff },
{ 0xb1, 0, 0, 0x0000000e },
{ 0x48, 0, 0, 0x0000000e },
{ 0x15, 2, 0, 0x000010d1 },
{ 0x48, 0, 0, 0x00000010 },
{ 0x15, 0, 1, 0x000010d1 },
{ 0x6, 0, 0, 0x0000ffff },
{ 0x6, 0, 0, 0x00000000 },
This code has to be attached to the "PF_PACKET, SOCK_RAW"-socket using
setsockopt's SO_ATTACH_FILTER.
The packets can be received using recvmsg (don't forget to use MSG_TRUNC or
you will get problems to differentiate different packets. Your biggest problem
will be the handling of fragmented IP packets... but you should not get them
when you listen for these broadcast announcements.
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-10-05 7:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-04 16:21 [B.A.T.M.A.N.] mac address from packet Dominic Follett-Smith
2012-10-04 16:30 ` Sven Eckelmann
2012-10-04 16:32 ` Sven Eckelmann
2012-10-04 19:30 ` Dominic Follett-Smith
2012-10-05 7:11 ` Sven Eckelmann [this message]
2012-10-04 16:38 ` Gui Iribarren
[not found] ` <CA+h5VgobQQZWN+Vr_+UbQaxLw6qV=G6C0XYGLvHA+88QRzGQwQ@mail.gmail.com>
[not found] ` <CAHD-aq+BO6JZtojFHNgZ+pyHd_9nLviTUi9+xbenpFwyaPM3jw@mail.gmail.com>
2012-10-04 21:11 ` [B.A.T.M.A.N.] Fwd: " Gui Iribarren
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=1710035.x7kxmPdvcU@bentobox \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=dominicfollett@gmail.com \
/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