*BSD News Article 28495


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!hookup!swrinde!cs.utexas.edu!utnut!nott!netfs.dnd.ca!rads.dnd.ca!usenet
From: spagnolo@nrnsinc.on.ca (Joe Spagnolo)
Newsgroups: comp.os.386bsd.development
Subject: Re: mbuf doubts
Date: 15 Mar 1994 20:18:21 GMT
Organization: NRNS Incorporated
Lines: 58
Message-ID: <2m556d$qc9@rads.dnd.ca>
References: <2m26h9$13b@ysics.physics.sunysb.edu>
Reply-To: spagnolo@nrnsinc.on.ca (Joe Spagnolo)
NNTP-Posting-Host: tomcat.nrnsinc.on.ca
X-Newsreader: IBM NewsReader/2 v1.00

Hi Chitra,

Here are a few things to consider.

In <2m26h9$13b@ysics.physics.sunysb.edu>, chitra@cs.sunysb.edu (Chitra Venkatramani) writes:
>
>Hi!
> I am working on the low level network code in 386bsd and have trouble
>sending out mbufs larger than MINCLSIZE...basically, i have trouble
>while trying to send cluster mbufs. Here's part of my code :
>
>sending side:
>	struct s { 
>		    char data[1400];
>		 }*my_struct;
>
>	MGET(m, M_WAIT, MT_DATA);
>	MCLGET(m, M_WAIT);
>	my_struct = mtod(m, (struct s *));
>	...fill up my_struct...
>	m->m_len = sizeof(*my_struct);

May want to do some error checking. Use M_TRAILINGSPACE to determine if
MCLGET succeeded.

>	...
>	...
>	...
>	...ifp->if_output.....

The interface 'if_output' function or other lower layer protocol functions may be
prepending protocol headers to the mbuf chain. If you are supplying the
'if_start' routine, you may want to check if it can deal with an mbuf chain.

>
>
>At the receiving side, I receive the packet but the length m->m_len
>is only 84 bytes! 

You are making an assumption that the receiving side put the entire packet
into a single mbuf. If 'm' is the first mbuf in a chain, then 'm->m_len' is the
amount of packet data contained in the first mbuf only - not the entire
packet.

>
>Maybe I'm missing some more initialization stuff...Maybe I'm not 
>filling up the m_buf header properly...
>Any help about this would be appreciated....
>	
>-Chitra Venkatramani
>
>chitra@cs.sunysb.edu

--

Joe Spagnolo