From: Patrick McHardy <kaber@trash.net>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: Netfilter Developer Mailing List <netfilter-devel@vger.kernel.org>
Subject: Re: libiptc, arptables, ebtables plans or so - and header files
Date: Wed, 12 Nov 2008 12:13:23 +0100 [thread overview]
Message-ID: <491ABA53.8040703@trash.net> (raw)
In-Reply-To: <alpine.LNX.1.10.0811101936100.3005@fbirervta.pbzchgretzou.qr>
Jan Engelhardt wrote:
> On Monday 2008-11-10 19:07, Patrick McHardy wrote:
>> Without having looked at it in much detail, I think it should
>> be pretty easy to define per-family functions to fill the
>> ipt_entry/ip6t_entry structs and a struct to describe the
>> length and offset differences. The remaining parts are invariant
>> across families, so the code should be easily unifiable.
>
> struct iptc_handle {
> struct ipt_getinfo {
> };
> struct ipt_get_entries {
> struct ipt_entry [];
> };
> };
>
> TC_INIT/create_tc_socket(table)
> {
> STRUCT_GETINFO info;
> strcpy(info.name, table);
> getsockopt(sockfd, TC_IPPROTO, SO_GET_INFO, &info...);
> h = alloc_handle(info.name, info.size, info.num_entries);
> }
>
> Just look at this pseudocode. The primitive transformation approach would be
>
> create_v4_socket(table)
> {
> struct ip6t_getinfo info;
> strcpy...
> getsockopt..
> h = alloc_handle...
> }
>
> create_v6_socket(table)
> {
> struct ip6t_getinfo info;
> strcpy...
> getsockopt..
> h = alloc_handle...
> }
>
> create_socket(table, proto)
> {
> return proto_vft[proto]->create_socket(table)
> }
>
> This because every line where a member of info is accessed is
> essentially af-dependent already.
An af-dependant function to get a pointer to the sub-structures
might simplify this a bit.
> And I am not even down to
> ipt_entry. It's not clear what to do here -- apart from ugly
> tricks to record the offsets of members and then dereferencing
> through void à la (char *)(((void *)&info) + af->name_offset).
proto_vft[proto]->fill_entry(...)?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-11-12 11:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-10 16:48 libiptc, arptables, ebtables plans or so - and header files Jan Engelhardt
2008-11-10 18:01 ` Rick Jones
2008-11-10 18:07 ` Patrick McHardy
2008-11-10 18:47 ` Jan Engelhardt
2008-11-12 11:13 ` Patrick McHardy [this message]
2008-11-10 18:53 ` Rick Jones
2008-11-10 19:09 ` Jan Engelhardt
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=491ABA53.8040703@trash.net \
--to=kaber@trash.net \
--cc=jengelh@medozas.de \
--cc=netfilter-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.