RFC 1141 (rfc1141) - Page 2 of 2
Incremental updating of the Internet checksum
Alternative Format: Original Text Document
RFC 1141 Incremental Updating January 1990
can bundle updating and checking the ttl. Compiler mileage may vary.
Here is a more general and possibly more helpful example which
updates the ttl by n seconds:
UpdateTTL(iph,n)
struct ip_hdr *ipptr;
unsigned char n;
{
unsigned long sum;
unsigned short old;
old = ntohs(*(unsigned short *)&ipptr->ttl);
ipptr->ttl -= n;
sum = old + (~ntohs(*(unsigned short *)&ipptr->ttl) & 0xffff);
sum += ntohs(ipptr->Checksum);
sum = (sum & 0xffff) + (sum>>16);
ipptr->Checksum = htons(sum + (sum>>16));
}
Security Considerations
Security issues are not addressed in this memo.
Authors' Addresses
Tracy Mallory
BBN Communications Corporation
50 Moulton Street
Cambridge, MA 02238
Phone: (617) 873-3193
EMail:
A. Kullberg
BBN Communications Corporation
50 Moulton Street
Cambridge, MA 02238
Phone: (617) 873-4000
EMail:
Mallory & Kullberg