From: Patrick McHardy <kaber@trash.net>
To: Pierre Chifflier <pchifflier@edenwall.com>
Cc: Jan Engelhardt <jengelh@medozas.de>,
David Miller <davem@davemloft.net>,
netfilter-devel@vger.kernel.org, eleblond@inl.fr
Subject: Re: [PATCH 1/2] Add new input plugin UNIXSOCK
Date: Mon, 09 Nov 2009 14:09:38 +0100 [thread overview]
Message-ID: <4AF81492.7040604@trash.net> (raw)
In-Reply-To: <20091106200907.GB3089@piche.inl.fr>
Pierre Chifflier wrote:
> I am not very familiar with these kind of problems (alignment). If I
> understand correctly, what I need to avoid is playing with pointers on a
> buffer, especially if trying to read a structure.
>
> Since what I am trying to read is formatted as following:
>
> marker (uint32)
> total_size (uint16)
> payload_length (uint16)
> payload (struct iphdr)
This looks fine. Your input buffer should be suitably aligned
by the allocator and these members are all well-aligned
themselves.
> Followed by a sequence of
> option_id (uint16)
> option_length (uint16)
> option_value (variable, equal to option_length)
> Am I right to assume that:
> - I can define a (packed) structure for the first part, and that I can
> set the pointer on the data buffer which was allocated by malloc
> without problems ? [*]
You don't even need packing.
> - For the second part, there are 2 cases:
> + integers must be read byte per byte
> + strings can be used directly ?
Assuming integers do not exceed 32 bit, just make sure the entire
sequence is aligned to a multiple of four (which it is for the
first entry, further ones need to use padding).
next prev parent reply other threads:[~2009-11-09 13:09 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-01 10:53 [ULOGD2] UNIXSOCK plugin (v3) Pierre Chifflier
2009-11-01 10:53 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2009-11-01 12:45 ` Jan Engelhardt
2009-11-01 13:07 ` Pierre Chifflier
2009-11-01 13:41 ` Jan Engelhardt
2009-11-01 17:01 ` Pierre Chifflier
2009-11-02 6:22 ` David Miller
2009-11-03 17:01 ` Jan Engelhardt
2009-11-06 20:09 ` Pierre Chifflier
2009-11-09 13:09 ` Patrick McHardy [this message]
2009-11-01 10:53 ` [PATCH 2/2] Add helper script pcap2ulog Pierre Chifflier
-- strict thread matches above, loose matches on Subject: below --
2010-01-14 19:41 [ULOGD2] UNIXSOCK plugin (v4) Pierre Chifflier
2010-01-14 19:41 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2010-02-26 20:54 [ULOGD2] UNIXSOCK plugin (v5) Pierre Chifflier
2010-02-26 20:54 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2010-02-27 13:55 ` Pablo Neira Ayuso
2010-02-28 14:06 ` Pierre Chifflier
2010-02-28 16:28 ` Pablo Neira Ayuso
2010-02-28 17:29 ` Jan Engelhardt
2010-02-28 18:05 ` Pierre Chifflier
2010-03-01 19:33 ` Pablo Neira Ayuso
2010-03-01 22:16 ` Pierre Chifflier
2010-03-03 17:42 ` Jan Engelhardt
2010-03-03 18:14 ` Jan Engelhardt
2010-03-05 11:15 ` Patrick McHardy
2010-03-05 17:10 ` Pablo Neira Ayuso
2010-03-08 11:13 ` Patrick McHardy
2010-10-20 11:44 [ULOGD2] UNIXSOCK plugin (v5b) Pierre Chifflier
2010-10-20 11:44 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
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=4AF81492.7040604@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=eleblond@inl.fr \
--cc=jengelh@medozas.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pchifflier@edenwall.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;
as well as URLs for NNTP newsgroup(s).