Re: [PATCH 1/2] Add new input plugin UNIXSOCK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 03, 2009 at 06:01:46PM +0100, Jan Engelhardt wrote:
> >
> >If GCC can see at the inlining point that 'ptr' is of a type that
> >should be properly aligned it can inline the memcpy and still emit
> >the very unaligned load or store that you're trying to avoid.
> 
> Hi Dave,
> 
> Indeed it seems to be this way. Hm, bad.
> 
> What codes are you using on your alignment-sensitive SPARCs -
> the standard bitshifting, "char *p; p[0]<<24 | p[1]<<16 | p[2]<<8 | p[3]"?

Hi all,

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)

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 ? [*]
- For the second part, there are 2 cases:
  + integers must be read byte per byte
  + strings can be used directly ?

[*] none of the iphdr, ip or similar structures are defined as packed in
netinet/ip.h

Thanks,
Pierre

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux