[openbeos] Re: Some network land questions:

  • From: "Hugo Santos" <hugosantos@xxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Fri, 3 Aug 2007 18:06:50 +0200

Hi Oliver,

On 8/3/07, Oliver Ruiz Dorantes <urnenfel@xxxxxxxxxx> wrote:
>  Can I take as well for granted for the fields protocol & flags?

  Yes.

> Where can I find the list.h and slab.h "implementation" ?

  If you don't wish to use the slab implementation, you can easily
strip it from net_buffer. Just look at allocate_data_header() and
allocate_net_buffer() in net_buffer.cpp (and their free_ counterparts)
and replace the object_cache_alloc with malloc and object_cache_free
with free.

  Nevertheless, you can find the slab's include files in
headers/private/kernel/slab and the implementation in
src/system/kernel/slab.

> As for the use of the net_buffers:
>
> Once the buffer is created and afterwards you append or prepend some data:
> A) How are u supposed to proceed if you want to drop all its content
> "contiguously" somewhere (driver.. port)?

  The buffer might not be contiguous in memory, specially if it has
more than 256 of header space. You can try to obtain a pointer to the
contiguous buffer by using net_buffer's direct_access. It will return
< B_OK if it is not contiguous. The only alternative is then to read
(copy) it to a separate buffer.

> B) How are u supposed to proceed if u want to "map" a portion of the data to
> a given structure... how an incoming buffer's information is analized?

  Check headers/private/net/NetBufferUtilities.h for how
NetBufferFieldReader work. But in a nut shell, you try to
direct_access(), and if it isn't possible, copy the contents into a
temporary buffer.

  Hugo

Other related posts: