Last active
December 17, 2015 23:39
-
-
Save leonardoeloy/5691141 to your computer and use it in GitHub Desktop.
O_O!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline unsigned short fe_ip_checksum(unsigned char *iph, unsigned int ihl) { | |
unsigned int soma; | |
asm volatile( | |
"movl (%1), %0" \ | |
"subl $4, %2" \ | |
"jbe 2f" \ | |
"addl 4(%1), %0" \ | |
"adcl 8(%1), %0" \ | |
"adcl 12(%1), %0" \ | |
"1: adcl 16(%1), %0" \ | |
"lea 4(%1), %1" \ | |
"decl %2" \ | |
"jne 1b" \ | |
"adcl $0, %0" \ | |
"movl %0, %2" \ | |
"shrl $16, %0" \ | |
"addw %w2, %w0" \ | |
"adcl $0, %0" \ | |
"notl %0" \ | |
"2:" \ | |
" " \ | |
: "=r" (soma), "=r" (iph), "=r" (ihl) : "1" (iph), "2" (ihl)); | |
return soma; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment