[riot-devel] pktbuf question

Martine Lenders authmillenon at gmail.com
Wed Jun 17 11:22:05 CEST 2015

Hey Kaspar,
You normally would mark the header out, not the payload, since this is the
marker for the packet buffer, that the packet is receiving:

pkt = ng_pktbuf_add(0,src,size,undef);
hdr = ng_pktbuf_add(pkt, pkt->data, hdr_size, hdr_type);

For sending you just add new snips to the packet:

payload = ng_pktbuf_add(0, pl_data, pl_size, undef);
hdr = ng_pktbuf_add(payload, hdr_data, hdr_size, hdr_type);

Does this answer your question?

Am 16.06.2015 23:01 schrieb "Kaspar Schleiser" <kaspar at schleiser.de>:

> Hey,
> (this goes probably to Martine)
> The docs of ng_pktbuf_add say:
> "If @p data is already in the packet buffer (e.g. a payload of an
> already allocated packet) it will not be duplicated."
> Does this check for pointer equality, or would it correctly de-duplicate
> the snip if I add e.g., just the end of a packet a second time?
> e.g.
> pkt = ng_pktbuf_add(0,0,size,undef);
> memcpy(pkt->data, src, size);
> payload = ng_pktbuf_add(pkt, pkt->data + hdr_size, size-hdr_size,
> hdr_type);
> Would this allocate the space for pkt->data + hdr_size a second time?
> Kaspar
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/devel/attachments/20150617/e017c921/attachment-0001.html>

More information about the devel mailing list