Re: [dev] network protocol packing

2014-07-01 Thread Steve Dee
See also: https://kentonv.github.io/capnproto/

Re: [dev] network protocol packing

2014-07-01 Thread Markus Teich
Rob wrote: You've got alignment issues here - msg will be aligned to support any type (as malloc's interface specifies) so msg+1 will most likely be on an odd address, one byte off a highly aligned address. This means if your struct contains anything other than chars, you'll have UB. This is

Re: [dev] network protocol packing

2014-07-01 Thread Martti Kühne
On Tue, Jul 1, 2014 at 2:56 PM, Markus Teich markus.te...@stusta.mhn.de wrote: thanks for your feedback. What about declaring a struct for each message-type: struct msg_signed_data { unsigned int op; struct foo data; struct bar signature; }; This should also solve

Re: [dev] network protocol packing

2014-07-01 Thread Dimitris Papastamos
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

Re: [dev] network protocol packing

2014-07-01 Thread Markus Teich
Rob wrote: You've got alignment issues here - msg will be aligned to support any type (as malloc's interface specifies) so msg+1 will most likely be on an odd address, one byte off a highly aligned address. This means if your struct contains anything other than chars, you'll have UB. This is

Re: [dev] network protocol packing

2014-07-01 Thread Dimitris Papastamos
On Tue, Jul 01, 2014 at 05:01:43PM +0200, Markus Teich wrote: Rob wrote: You've got alignment issues here - msg will be aligned to support any type (as malloc's interface specifies) so msg+1 will most likely be on an odd address, one byte off a highly aligned address. This means if your

Re: [dev] network protocol packing

2014-07-01 Thread Steve Dee
On Tue, Jul 1, 2014 at 8:01 AM, Markus Teich markus.te...@stusta.mhn.de wrote: Rob wrote: You've got alignment issues here - msg will be aligned to support any type (as malloc's interface specifies) so msg+1 will most likely be on an odd address, one byte off a highly aligned address. This

Re: [dev] network protocol packing

2014-07-01 Thread Markus Wichmann
On Mon, Jun 30, 2014 at 08:54:52PM +0200, Markus Teich wrote: Heyho, since I did not find any suckless project regarding this issue, I would like to ask you guys for some feedback: unsigned char *msg; size_t msg_size; struct foo *msg_data; struct bar *msg_signature; msg_size =

[dev] network protocol packing

2014-06-30 Thread Markus Teich
Heyho, since I did not find any suckless project regarding this issue, I would like to ask you guys for some feedback: unsigned char *msg; size_t msg_size; struct foo *msg_data; struct bar *msg_signature; msg_size = sizeof(unsigned char)// op + sizeof(struct foo)// data

Re: [dev] network protocol packing

2014-06-30 Thread Rob
On 30/06/14, Markus Teich wrote: Heyho, Hello there, since I did not find any suckless project regarding this issue, I would like to ask you guys for some feedback: unsigned char *msg; size_t msg_size; struct foo *msg_data; struct bar *msg_signature; msg_size = sizeof(unsigned char)