Thread (2 messages) 2 messages, 2 authors, 2011-08-14

Purpose of using __be16 inside a data structure?

From: Michael Blizek <hidden>
Date: 2011-08-14 06:21:02

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help