Re: [dev] network protocol packing

From: Dimitris Papastamos <>
Date: Tue, 1 Jul 2014 13:24:59 +0100

On Tue, Jul 01, 2014 at 01:56:04PM +0200, Markus Teich wrote:
> struct msg_signed_data {
> unsigned int op;
> struct foo data;
> struct bar signature;
> };

If this is data that goes across the network then instead of
directly mapping a struct on that data I'd simply have functions that
create a struct out of that data.

The format of the data on the wire would be specified somewhere.

So the data would arrive as a series of bytes and whenever my packet
parsing function would indicate that a valid packet has been seen, it would
extract data from that ring buffer and map it onto a struct. The particular
layout of that struct could be different across different architectures/ABIs
in order to meet alignment requirements etc.

Parsing valid packets for further processing could be done with
a table of function pointers indexed by the packet type.

You'd expect to access the struct via functions in the above case.

This is not specific to data across a network, that's just used as an
Received on Tue Jul 01 2014 - 14:24:59 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 01 2014 - 14:36:07 CEST