<div>Hi all,</div>
<div> </div>
<div>Please tell me the difference between using unsigned short and __be16 to declear a variable in a data structure.</div>
<div>For example, in include/net/inet_sock.h, struct inet_sock is decleared as </div>
<div> </div>
<div>struct inet_sock {<br> __be16 inet_dport;<br>};</div>
<div> </div>
<div>not </div>
<div> </div>
<div>
<div>struct inet_sock {<br> unsigned short inet_dport;<br>};</div>
<div> </div>
<div>I think it has something to do with endianness. But I see that both __le16 and __be16 are unsigned short when using gcc with -E option for little-endian and big-endian platform. Can someone give me more information?</div>
<div> </div>
<div>* little-endian</div>
<div>typedef unsigned short __u16;<br>typedef __u16 __le16;<br>typedef __u16 __be16;</div>
<div> </div>
<div>* big-endian</div>
<div>typedef unsigned short __u16;</div>
<div>typedef __u16 __le16;<br>typedef __u16 __be16;<br></div></div>
<div>Regards,</div>
<div>GC</div>