Re: Building IP header

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

 



On Mon, 24 Dec 2001, S Ramesh wrote:

> htons(140) but the field is filled with value zero.
> 
Aha!  I see the problem now.  The protocol field is only 8 bits, so don't
use htons().  htons (on an intel m/c) swaps the bytes, so htons(140)
returns 0x8C00.  When you then cast this to a single byte for the protocol
field, you get the low byte (ie zero).
You should use htons() on 16bit values, htonl() on 32 bit values, but
don't do anything to 8bit values.

> Also will your tool support this( Unassigned protocol - both sending and
> reception ), yet to check out.

Yes, it will.


-- 
Mike Ricketts <mike@earth.li>                      http://www.earth.li/~mike/

A real gentleman never takes bases unless he really has to.
		-- Overheard in an algebra lecture.

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux