ntohs equivalent

Which is the kernel mode function equivalent to “ntohs” (winsock2.h) ?

Or you could just code it from scratch. From windns.h in the SDK (just
as a model):

#define INLINE_WORD_FLIP(out, in) \
{ \
WORD _in = (in); \
(out) = (_in << 8) | (_in >> 8); \
}
#define INLINE_HTONS(out, in) INLINE_WORD_FLIP(out, in)
#define INLINE_NTOHS(out, in) INLINE_WORD_FLIP(out, in)

Bryan S. Burgin
xxxxx@microsoft.com

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Abhijit Kulkarni
Sent: Wednesday, August 27, 2003 10:57 PM
To: Windows System Software Developers Interest List
Subject: [ntdev] ntohs equivalent

Which is the kernel mode function equivalent to “ntohs” (winsock2.h) ?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Will this work always ?

The macro is just flipping the word. This wont’t work if “TCP/IP network
byte order” and “host byte order” is same.

That is why ntohs.h is platform specific. At any rate, on all known NT
platforms, this is simply a non-issue. There are DDK functions for doing
byte swapping. See RtlUlongByteSwap and friends.

=====================
Mark Roddy
Hollis Technology Solutions
www.hollistech.com
xxxxx@hollistech.com

-----Original Message-----
From: Abhijit Kulkarni [mailto:xxxxx@yahoo.com]
Sent: Thursday, August 28, 2003 4:30 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] RE: ntohs equivalent

Will this work always ?

The macro is just flipping the word. This wont’t work if “TCP/IP network
byte order” and “host byte order” is same.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

This will work always on today’s Windows systems.
Network byte order is always big-endian. That won’t ever change.
Host byte order for today’s Windows platforms is little-endian. Only
Microsoft can say if it will ever be different, but I’m betting on a few
more years of little-endian domination there too.

You would make the same assumptions if calling the Rtl byte swapping
functions as Mark Roddy suggests.

Carl

“Abhijit Kulkarni” wrote in message news:xxxxx@ntdev…
>
> Will this work always ?
>
> The macro is just flipping the word. This wont’t work if “TCP/IP network
> byte order” and “host byte order” is same.
>
>
>