pktbuf question

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

Hi,

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?

Cheers, Martine

Hey,