[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1282346230.3454.193.camel@localhost>
Date: Sat, 21 Aug 2010 00:17:09 +0100
From: Ben Hutchings <bhutchings@...arflare.com>
To: Ben Greear <greearb@...delatech.com>
Cc: NetDev <netdev@...r.kernel.org>
Subject: Re: ip_tables.h can't be used in C++ programs.
On Fri, 2010-08-20 at 11:54 -0700, Ben Greear wrote:
> This method returns void* but is defined to return
> a pointer to struct ipt_entry_target.
>
> This will not compile under g++ (or, I'm unable to figure out
> how to make it work w/out editing the header file).
>
> Any reason this shouldn't be changed to:
>
> return (struct ipt_entry_target*)e + e->target_offset;
Because that multiplies the offset by sizeof(struct ipt_entry_target)!
> /* Helper functions */
> static __inline__ struct ipt_entry_target *
> ipt_get_target(struct ipt_entry *e)
> {
> return (void *)e + e->target_offset;
> }
For extra unportability, this is relying on the gcc extension for void
pointer arithmetic. Try something like:
return (struct ipt_entry_target *)((char *)e + e->target_offset);
Ben.
> IPv6 has similar issue....
>
> Thanks,
> Ben
>
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists