assigning an integer to the negation of ...

Steve Alexander stevea at laidbak.UUCP
Fri Dec 23 02:16:54 AEST 1988


In article <22651 at apple.Apple.COM> desnoyer at Apple.COM (Peter Desnoyers) writes:
[ About i = -(unsigned short)j producing different results on BSD and SunOS ]
>
>It was pointed out that the context in which this problem arose was
>TCP software - I would bet it was the window size calculations.
>				Peter Desnoyers

Err, umm, (sorry, Guy) actually, this code is in IP, not TCP.  It occurs 
in netinet/ip_input.c at the point where IP is deciding how big the 
datagram is.  It negates the data length in the IP header 
(i = -(unsigned short)ip->ip_len) and then adds the lengths of all mbufs
in the chain to the negated length.  If the result is negative, the 
datagram is thrown away because it is too short.  Otherwise, m_adj is 
called to trim the excess garbage from the end of the chain.

-- 
Steve Alexander, TCP/IP Development | stevea%laidbak at sun.com
Lachman Associates, Inc.            | ...!sun!laidbak!stevea



More information about the Comp.lang.c mailing list