[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <55c333c0906100708q1b0be2ffkc80c2f3258f0e681@mail.gmail.com>
Date: Wed, 10 Jun 2009 17:08:12 +0300
From: Kevin Wilson <wkevils@...il.com>
To: netdev@...r.kernel.org
Subject: ntohs() and htons() usgae in the network stack
Hello,
I will appreciate if someone can explain this mystery to me:
While debugging some kernel module, I added printing of ports.
I had printer both ntohs() and htons() of a port number. I got the same
values. Since I used low port number, I decided to find out from which
port there begins to be a difference. So I tried to write in a simple
kernel module this loop, which tests all ports up till 65536 (since
port number is 16 bit wide):
...
int i;
for (i=0;i<65536;i++)
if (ntohs(i) != htons(i))
printk("found inequality: ntohs(i) != htons(i)\n");
And when running it it did **not** find such a port where ntohs(i) !=
htons ( "found inequality:.. was **not** printed).
So I wondered : when is ntohs(i) != htons(i) ?
Are they always equal (I doubt it); or am I missing something silly here?
I am testing it on x86_64 Intel machine (little endian).
Rgs,
Kevin
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists