This function first copies from the header section of the buffer and then copy from the data section of the buffer.
 
This function first copies from the header section of the buffer and then copy from the data section of the buffer.
The following lines copies the data from the header section of the packetbuf. The destination address is "to" and the source address is the address of the entry packetbuf[hdrptr] which is packetbuf+hdrptr. PACKETBUF_HDR_SIZE - hdrptr is the actual size of the header i.e the number of bytes to be copied for the header only.
+
The following lines copies the data from the header section of the packetbuf. The destination address is '''"to"''' and the source address is the address of the entry '''packetbuf[hdrptr]''' which is '''(packetbuf+hdrptr)'''. '''(PACKETBUF_HDR_SIZE - hdrptr)''' is the actual size of the header i.e the number of bytes to be copied for the header only.
    
  memcpy(to, packetbuf + hdrptr, PACKETBUF_HDR_SIZE - hdrptr);
 
  memcpy(to, packetbuf + hdrptr, PACKETBUF_HDR_SIZE - hdrptr);
   Exception encountered, of type "Error"