From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 16 07:14:09 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 698AB16A400 for ; Mon, 16 Apr 2007 07:14:09 +0000 (UTC) (envelope-from alan@fromorbit.com) Received: from thing1.auspcmarket.com.au (mail.fromorbit.com [203.31.169.65]) by mx1.freebsd.org (Postfix) with ESMTP id 2EFE013C459 for ; Mon, 16 Apr 2007 07:14:09 +0000 (UTC) (envelope-from alan@fromorbit.com) Received: from [192.168.1.99] (unknown [192.168.1.99]) by thing1.auspcmarket.com.au (Postfix) with ESMTP id 94F7B5CE3 for ; Mon, 16 Apr 2007 17:14:06 +1000 (EST) From: Alan Garfield To: freebsd-hackers@freebsd.org Content-Type: text/plain Date: Mon, 16 Apr 2007 17:14:06 +1000 Message-Id: <1176707646.5068.23.camel@hiro.auspc.com.au> Mime-Version: 1.0 X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) Content-Transfer-Encoding: 7bit Subject: mbuf and IP frame lengths X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2007 07:14:09 -0000 Hi all! A question, is it ok to just say pass an entire rx buffer of your ethernet device up the chain and let the ip stack figure out the frame size. I have a device that can only ever receive 255 bytes of data, I receive this data from a buffer in the PRS. On an interrupt I read this data out of the PRS buffer into a local buffer, which I then :- ---- eh = mtod(m, struct ether_header *); // Copy buf into mbuf bcopy(buf + 1, (char *)eh, FIFO_SIZE - 1); // Set the header length m->m_pkthdr.len = m->m_len = FIFO_SIZE - 1; JNET_UNLOCK(sc); (*ifp->if_input)(ifp, m); JNET_LOCK(sc); ---- FIFO_SIZE = 256, minus 1 for a control character in the device (which handily keeps under the 256 frame size). The interface is working just fine, but I'm not sure if I'm completely correct in the way I'm doing this. I've tried casting the buffer to struct ip* to get ip->ip_len but I always get a "dereferencing pointer to incomplete type" error (don't exactly know why). Any help would be greatly appreciated. Thanks, Alan.