<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://anrg.usc.edu/contiki/index.php?action=history&amp;feed=atom&amp;title=Packetbuffer_Basics</id>
		<title>Packetbuffer Basics - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://anrg.usc.edu/contiki/index.php?action=history&amp;feed=atom&amp;title=Packetbuffer_Basics"/>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;action=history"/>
		<updated>2026-04-22T05:10:50Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;diff=982&amp;oldid=prev</id>
		<title>Pradiptg: /* int packetbuf_hdralloc(int size) */</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;diff=982&amp;oldid=prev"/>
				<updated>2014-11-08T00:07:27Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;int packetbuf_hdralloc(int size)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&#039;diff diff-contentalign-left&#039;&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 00:07, 8 November 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l609&quot; &gt;Line 609:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 609:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; hdrptr -= size;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; hdrptr -= size;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This increases the header size. Since the end location of the header is fixed at PACKETBUF_HDR_SIZE-1, only way to assign more space is to move the beginning location.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This increases the header size. Since the end location of the header is fixed at PACKETBUF_HDR_SIZE-1, only way to assign more space is to move the beginning location &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;pointer&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pradiptg</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;diff=981&amp;oldid=prev</id>
		<title>Pradiptg: /* int packetbuf_hdralloc(int size) */</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;diff=981&amp;oldid=prev"/>
				<updated>2014-11-08T00:06:56Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;int packetbuf_hdralloc(int size)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&#039;diff diff-contentalign-left&#039;&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 00:06, 8 November 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l606&quot; &gt;Line 606:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 606:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;if hdrptr &amp;gt;= size then, there is a possibility. But if the total length of the packet after adding extra space is greater PACKETBUF_SIZE then we can allocate more space. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;if hdrptr &amp;gt;= size then, there is a possibility. But if the total length of the packet after adding extra space is greater PACKETBUF_SIZE then we can allocate more space. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;if hdrptr &amp;lt;= size or packet total &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;nebgth &lt;/del&gt;+ size &amp;gt; PACKETBUF_SIZE, it is not possible to allocate &amp;quot;size&amp;quot; amount of extra bytes or space.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;if hdrptr &amp;lt;= size or packet total &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;length &lt;/ins&gt;+ size &amp;gt; PACKETBUF_SIZE, it is not possible to allocate &amp;quot;size&amp;quot; amount of extra bytes or space.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; hdrptr -= size;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; hdrptr -= size;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This increases the header size. Since the end location of the header is fixed at PACKETBUF_HDR_SIZE-1, only way to assign more space is to move the beginning location.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This increases the header size. Since the end location of the header is fixed at PACKETBUF_HDR_SIZE-1, only way to assign more space is to move the beginning location.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pradiptg</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;diff=980&amp;oldid=prev</id>
		<title>Pradiptg: /* int packetbuf_copyto(void *to) */</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;diff=980&amp;oldid=prev"/>
				<updated>2014-11-08T00:05:59Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;int packetbuf_copyto(void *to)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&#039;diff diff-contentalign-left&#039;&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 00:05, 8 November 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l586&quot; &gt;Line 586:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 586:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; memcpy(to, packetbuf + hdrptr, PACKETBUF_HDR_SIZE - hdrptr);&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; memcpy(to, packetbuf + hdrptr, PACKETBUF_HDR_SIZE - hdrptr);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following lines copies the data from the data/payload section of the packetbuf. The destination address is &amp;#039;&amp;#039;&amp;#039;&amp;quot;(uint8_t *)to + PACKETBUF_HDR_SIZE - hdrptr&amp;quot;&amp;#039;&amp;#039;&amp;#039;. The reason is that &amp;#039;&amp;#039;&amp;#039;&amp;quot;PACKETBUF_HDR_SIZE - hdrptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; bytes of header data is already copied. This gives us the next available memory location. The source address is &amp;#039;&amp;#039;&amp;#039;(packetbufptr + bufptr)&amp;#039;&amp;#039;&amp;#039;. &amp;#039;&amp;#039;&amp;#039;&amp;quot;packetbufptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; points to the packet&amp;#039;s data part beginning. If the data is external, &amp;#039;&amp;#039;&amp;#039;&amp;quot;packetbufptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; points to the external source, otherwise packetbufptr &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;point &lt;/del&gt;to &amp;#039;&amp;#039;&amp;#039;packetbuf[PACKETBUF_HDR_SIZE]&amp;#039;&amp;#039;&amp;#039;. &amp;#039;&amp;#039;&amp;#039;&amp;quot;buflen&amp;quot;&amp;#039;&amp;#039;&amp;#039; is the actual size of the data i.e the number of bytes to be copied for the packet&amp;#039;s data part only.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following lines copies the data from the data/payload section of the packetbuf. The destination address is &amp;#039;&amp;#039;&amp;#039;&amp;quot;(uint8_t *)to + PACKETBUF_HDR_SIZE - hdrptr&amp;quot;&amp;#039;&amp;#039;&amp;#039;. The reason is that &amp;#039;&amp;#039;&amp;#039;&amp;quot;PACKETBUF_HDR_SIZE - hdrptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; bytes of header data is already copied. This gives us the next available memory location. The source address is &amp;#039;&amp;#039;&amp;#039;(packetbufptr + bufptr)&amp;#039;&amp;#039;&amp;#039;. &amp;#039;&amp;#039;&amp;#039;&amp;quot;packetbufptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; points to the packet&amp;#039;s data part beginning. If the data is external, &amp;#039;&amp;#039;&amp;#039;&amp;quot;packetbufptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; points to the external source, otherwise &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#039;&amp;#039;&amp;#039;&amp;quot;&lt;/ins&gt;packetbufptr&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;&amp;#039;&amp;#039;&amp;#039; points &lt;/ins&gt;to &amp;#039;&amp;#039;&amp;#039;packetbuf[PACKETBUF_HDR_SIZE]&amp;#039;&amp;#039;&amp;#039;. &amp;#039;&amp;#039;&amp;#039;&amp;quot;buflen&amp;quot;&amp;#039;&amp;#039;&amp;#039; is the actual size of the data i.e the number of bytes to be copied for the packet&amp;#039;s data part only.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; memcpy((uint8_t *)to + PACKETBUF_HDR_SIZE - hdrptr, packetbufptr + bufptr, buflen);&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; memcpy((uint8_t *)to + PACKETBUF_HDR_SIZE - hdrptr, packetbufptr + bufptr, buflen);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pradiptg</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;diff=979&amp;oldid=prev</id>
		<title>Pradiptg: /* int packetbuf_copyto(void *to) */</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=Packetbuffer_Basics&amp;diff=979&amp;oldid=prev"/>
				<updated>2014-11-08T00:05:30Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;int packetbuf_copyto(void *to)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&#039;diff diff-contentalign-left&#039;&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 00:05, 8 November 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l586&quot; &gt;Line 586:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 586:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; memcpy(to, packetbuf + hdrptr, PACKETBUF_HDR_SIZE - hdrptr);&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; memcpy(to, packetbuf + hdrptr, PACKETBUF_HDR_SIZE - hdrptr);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following lines copies the data from the data/payload section of the packetbuf. The destination address is &amp;#039;&amp;#039;&amp;#039;&amp;quot;(uint8_t *)to + PACKETBUF_HDR_SIZE - hdrptr&amp;quot;&amp;#039;&amp;#039;&amp;#039;. The reason is that &amp;#039;&amp;#039;&amp;#039;&amp;quot;PACKETBUF_HDR_SIZE - hdrptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; bytes of header data is already copied. This gives us the next available memory location. The source address is &amp;#039;&amp;#039;&amp;#039;(packetbufptr + bufptr)&amp;#039;&amp;#039;&amp;#039;. packetbufptr points to the packet&amp;#039;s data part beginning. If the data is external, &amp;#039;&amp;#039;&amp;#039;&amp;quot;packetbufptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; points to the external source, otherwise packetbufptr point to &amp;#039;&amp;#039;&amp;#039;packetbuf[PACKETBUF_HDR_SIZE]&amp;#039;&amp;#039;&amp;#039;. &amp;#039;&amp;#039;&amp;#039;&amp;quot;buflen&amp;quot;&amp;#039;&amp;#039;&amp;#039; is the actual size of the data i.e the number of bytes to be copied for the packet&amp;#039;s data part only.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following lines copies the data from the data/payload section of the packetbuf. The destination address is &amp;#039;&amp;#039;&amp;#039;&amp;quot;(uint8_t *)to + PACKETBUF_HDR_SIZE - hdrptr&amp;quot;&amp;#039;&amp;#039;&amp;#039;. The reason is that &amp;#039;&amp;#039;&amp;#039;&amp;quot;PACKETBUF_HDR_SIZE - hdrptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; bytes of header data is already copied. This gives us the next available memory location. The source address is &amp;#039;&amp;#039;&amp;#039;(packetbufptr + bufptr)&amp;#039;&amp;#039;&amp;#039;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#039;&amp;#039;&amp;#039;&amp;quot;&lt;/ins&gt;packetbufptr&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;&amp;#039;&amp;#039;&amp;#039; &lt;/ins&gt;points to the packet&amp;#039;s data part beginning. If the data is external, &amp;#039;&amp;#039;&amp;#039;&amp;quot;packetbufptr&amp;quot;&amp;#039;&amp;#039;&amp;#039; points to the external source, otherwise packetbufptr point to &amp;#039;&amp;#039;&amp;#039;packetbuf[PACKETBUF_HDR_SIZE]&amp;#039;&amp;#039;&amp;#039;. &amp;#039;&amp;#039;&amp;#039;&amp;quot;buflen&amp;quot;&amp;#039;&amp;#039;&amp;#039; is the actual size of the data i.e the number of bytes to be copied for the packet&amp;#039;s data part only.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; memcpy((uint8_t *)to + PACKETBUF_HDR_SIZE - hdrptr, packetbufptr + bufptr, buflen);&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; memcpy((uint8_t *)to + PACKETBUF_HDR_SIZE - hdrptr, packetbufptr + bufptr, buflen);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pradiptg</name></author>	</entry>

<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l586" ><!--LINE 586--></td>
<td colspan="2" class="diff-lineno"><!--LINE 586--></td></tr>
<tr><td class='diff-marker'>&#160;</td><td class='diff-context'><div>&#160; memcpy(to, packetbuf + hdrptr, PACKETBUF_HDR_SIZE - hdrptr);</div></td><td class='diff-marker'>&#160;</td><td class='diff-context'><div>&#160; memcpy(to, packetbuf + hdrptr, PACKETBUF_HDR_SIZE - hdrptr);</div></td></tr>
<tr><td class='diff-marker'>&#160;</td><td class='diff-context'></td><td class='diff-marker'>&#160;</td><td class='diff-context'></td></tr>
Exception encountered, of type &quot;Error&quot;
