Re: Purpose of using __be16 inside a data structure?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

On 08:41 Sun 14 Aug     , ?????? wrote:
> Hi all,
> 
> Please tell me the difference between using unsigned short and __be16
> to declear a variable in a data structure.
> For example, in include/net/inet_sock.h, struct inet_sock is decleared as
> 
> struct inet_sock {
>         __be16                  inet_dport;
> };
> 
> not
> 
> struct inet_sock {
>         unsigned short                  inet_dport;
> };

This is mostly to avoid confusion about where byte order conversation has to
be done. When reading "unsigned short" you would normally expect the variable
to contain host byte order.

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux