unsigned long ctl_net_sum_bytes(unsigned long sum, const unsigned char *data, size_t byte_count);
ctl_net_sum_bytes calculates the checksum over an array of shorts. See RFC 1071. The returned value is 0 through 65535 with all end-around carries accounted for.
Data in and out of checksum functions are in network byte order. Actually, it doesn't matter which byte order is used as long as the answer is the same byte order.