[En-Nut-Discussion] eboot, a tricky bit.
Brett Abbott
Brett.Abbott at digital-telemetry.com
Fri Feb 20 02:22:08 CET 2004
Hi
Ive almost completed the port to ICC of eboot but have found a segment
of code that has stumped my self taught C programming skills. Could I
ask if someone could advise us of the appropriate ICC equivalent?
In particular, the line Im having trouble compiling is "sum +=
*((u_short *) data)++;"
Many Thanks, Any help appreciated.
Brett
from eboot\ip.c:
/*!
* \brief Calculate the IP checksum over a block of data.
*
* \param data Pointer to the data block.
* \param size Size of the data block.
*
* \return The checksum in network byte order.
*/
static u_short IpChkSum(const void *data, u_short size)
{
register u_long sum = 0;
for (;;) {
if (size < 2)
break;
sum += *((u_short *) data)++;
size -= 2;
}
if (size)
sum += *(u_char *) data;
while ((size = (u_short) (sum >> 16)) != 0)
sum = (u_short) sum + size;
return (u_short) sum ^ 0xFFFF;
}
--
-----------------------------------------------------------------
Brett Abbott, Managing Director, Digital Telemetry Limited
Email: Brett.Abbott at digital-telemetry.com
PO Box 24 036 Manners Street, Wellington, New Zealand
Phone +64 (4) 5666-860 Mobile +64 (21) 656-144
------------------- Commercial in confidence --------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.egnite.de/pipermail/en-nut-discussion/attachments/20040220/1847a458/attachment-0001.html>
More information about the En-Nut-Discussion
mailing list