From owner-freebsd-net@FreeBSD.ORG Thu Jul 1 19:29:34 2004 Return-Path: Delivered-To: freebsd-net@www.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3F84916A4CE for ; Thu, 1 Jul 2004 19:29:34 +0000 (GMT) Received: from quick.recoil.org (quick.recoil.org [194.70.3.133]) by mx1.FreeBSD.org (Postfix) with SMTP id 680FA43D1D for ; Thu, 1 Jul 2004 19:29:33 +0000 (GMT) (envelope-from anil@recoil.org) Received: (qmail 53 invoked from network); 1 Jul 2004 19:28:01 -0000 Received: from localhost (HELO ?IPv6:::1?) (127.0.0.1) by quick.recoil.org with SMTP; 1 Jul 2004 19:28:01 -0000 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v618) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Anil Madhavapeddy Date: Thu, 1 Jul 2004 20:28:10 +0100 To: Julian Elischer X-Mailer: Apple Mail (2.618) cc: freebsd-net@lists.freebsd.org Subject: Re: Packing netgraph structs X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2004 19:29:34 -0000 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