<div dir="ltr">Sorry for the delayed reply, Ben<div><br></div><div style>I&#39;m about to conduct a final review and then pass the patch. Thanks,</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 25, 2013 at 9:10 AM, Ben Pfaff <span dir="ltr">&lt;<a href="mailto:blp@nicira.com" target="_blank">blp@nicira.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Jun 25, 2013 at 08:32:34AM -0700, Alex Wang wrote:<br>
&gt; &gt; &gt; &gt; &gt; &quot;<br>
&gt; &gt; &gt; &gt; &gt;         oem = ofpbuf_put_uninit(buf, sizeof *oem);<br>
&gt; &gt; &gt; &gt; &gt;         oem-&gt;type = htons(NXET_VENDOR);<br>
&gt; &gt; &gt; &gt; &gt; &quot;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; In the &quot;ovs_hex_dump()&quot; function which prints the encoded header, it<br>
&gt; &gt; uses<br>
&gt; &gt; &gt; &gt; &gt; &quot;fprintf(stream, &quot;%02hhx&quot;<br>
&gt; &gt; &gt; &gt; &gt; to print it and the value is again in host order (if %x is used, it<br>
&gt; &gt; will<br>
&gt; &gt; &gt; &gt; &gt; print the network order).<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; So I want to ask what is the use of &quot;hhx&quot; here? and why can&#39;t we get<br>
&gt; &gt; rid<br>
&gt; &gt; &gt; &gt; of<br>
&gt; &gt; &gt; &gt; &gt; htons and use %x in<br>
&gt; &gt; &gt; &gt; &gt; ovs_hex_dump?<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &#39;oem&#39; is a &quot;wire format&quot; type, and its member &#39;type&#39; is an ovs_be16,<br>
&gt; &gt; &gt; &gt; so to appropriately assign it a value it must be converted to network<br>
&gt; &gt; &gt; &gt; byte order first.  That is why htons() is used.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; ovs_hex_dump() dumps the contents of a structure byte by byte.  Its<br>
&gt; &gt; &gt; &gt; output will depend on the byte order of the underlying data.  In this<br>
&gt; &gt; &gt; &gt; case the data is in network byte order, so the byte-by-byte dump will<br>
&gt; &gt; &gt; &gt; reflect that.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &#39;hh&#39; doesn&#39;t have anything to do with byte order.  It means that the<br>
&gt; &gt; &gt; &gt; argument is a char type.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks for the explanation. My previous experiment was wrong. And I found<br>
&gt; &gt; &gt; out that the if &quot;htons&quot; is not used the &quot;0xb0c2&quot; when converted to &quot;uint8<br>
&gt; &gt; &gt; buf[2]&quot; will be &quot;buf[0]=0xc2&quot; and &quot;buf[1]=0xb0&quot;. So I think the &quot;htons&quot;<br>
&gt; &gt; &gt; also helps preserve the hex order. right?<br>
&gt; &gt;<br>
&gt; &gt; It depends on the machine&#39;s endianness.  You&#39;re using x86 or x86-64 (I<br>
&gt; &gt; guess), which is little-endian, so you see what you&#39;re reporting.  If<br>
&gt; &gt; you were using a SPARC or some other big-endian machine, the htons()<br>
&gt; &gt; would have no effect and you would see no difference, because host and<br>
&gt; &gt; network byte order are the same on a big-endian machine.<br>
&gt; &gt;<br>
&gt;<br>
&gt; Thanks Ben,<br>
&gt;<br>
&gt; This makes sense,<br>
<br>
</div></div>Thanks.<br>
<br>
Are you satisfied with this patch series, then?<br>
</blockquote></div><br></div>