[En-Nut-Discussion] eboot, a tricky bit.
Damian Slee
damian at commtech.com.au
Fri Feb 20 02:35:24 CET 2004
I'm pretty sure its incrementing the contents of memory, not the ptr.
the above/below code would help to double check.
u_short *tmp;
tmp = (u_short *) data;
*tmp++; // or (*tmp)++ if it reads better
_____
From: Brett Abbott [mailto:Brett.Abbott at digital-telemetry.com]
Sent: Friday, 20 February 2004 9:22 AM
To: en-nut-discussion at egnite.de
Subject: [En-Nut-Discussion] eboot, a tricky bit.
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/f1042256/attachment.html>
More information about the En-Nut-Discussion
mailing list