Packing netgraph structs

Anil Madhavapeddy anil at recoil.org
Thu Jul 1 12:29:34 PDT 2004


On 1 Jul 2004, at 18:20, Julian Elischer wrote:
>
> are syscall arguments packed? I know that they are defined rather
> strangely..

On OpenBSD at least, they are wrapped in unions to pad them to register 
sizes.

>
> what messages are you having troubles with?
>
> Usually, in my experience, 'packed' structures are limitted to
> structures that are defined in hardware, and message structures ae
> defined unpacked so that they can be efficiently passed around within a
> single system.
> Can you give me better examples..
> I'm also a little worried about architectures that have certain
> allignment restrictions on data, which is why packed and unpacked
> structures are different in the first place.

I'm just looking for a non-fragile way to create the structure 
specified by Netgraph without actually using C.  Of course, I can 
create a whole bunch of C structs using the local compiler and mirror 
OCaml functions, but it's an inelegant solution.

As others have helpfully pointed out, the current struct has been 
carefully designed to work well on existing architectures without the 
compiler padding (in particular, it looks like it will work on ARM 
which requires structs to be multiples of word size), and my initial 
tests have worked fine on i386.  Just wondering if others have come up 
with a better solution than a large set of FFI bindings.

--
Anil Madhavapeddy                                   
http://anil.recoil.org
University of Cambridge                            
http://www.cl.cam.ac.uk



More information about the freebsd-net mailing list