All pastes #67970 Raw Edit

Anonymous

public text v1 · immutable
#67970 ·published 2006-06-20 20:54 UTC
rendered paste body
int dhcp_ip_check(struct dhcp_ippacket_t *pack) {
  int i;
  uint32_t sum = 0;
  pack->iph.check = 0;
  for (i=0; i<(pack->iph.ihl * 2); i++) {
    sum += ((uint16_t*) &pack->iph)[i]; 
  } 
  while (sum>>16)
    sum = (sum & 0xFFFF)+(sum >> 16);
  pack->iph.check = ~sum;
  return 0;
}