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

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

 



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).
--
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