Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Libnet
[Top] [All Lists]

Re: IP cheksum and libnet_pblock_coalesce

Subject: Re: IP cheksum and libnet_pblock_coalesce
Date: Tue, 28 Sep 2004 11:28:27 +0800
Hi,

That is a known (but tricky) bug reported some times ago. David
Baroso proposed something like :

sum += ((*(u_int8_t *)addr & 0xFF)<<8);

The difficulty is to find something working on both big and little endian systems.

The expression above seems to work only on big-endian machines and proves wrong in my test on x86 (contrary to Mr David Barroso's statement). The third edition of UNIX Network Programming has something like this (adapted):


u_int16_t last_byte = 0;
...
if (nleft == 1) {
    *(u_int8_t*)&last_byte = *(u_int8_t*)addr;
    sum += last_byte;
}

I feel this is good.

Best regards,

Yongwei


<Prev in Thread] Current Thread [Next in Thread>