标签:stat unsigned icmp while ++ sig ati turn char
static int icmp_cksum(unsigned char *data, int len)
{
int nleft = len;
uint16_t *data_tmp = (uint16_t *)data;
int sum = 0;
uint16_t tmp = 0;
while(nleft > 1)
{
sum += *data_tmp++;
nleft -= 2;
}
if(nleft == 1)
{
*(uint8_t *)(&tmp) = *(uint8_t *)data_tmp;
sum += tmp;
}
sum = (sum >> 16) + (sum &0xffff);
sum += (sum >> 16);
tmp = ~sum;
return tmp;
}
标签:stat unsigned icmp while ++ sig ati turn char
原文地址:http://www.cnblogs.com/adelep/p/6056281.html