Home | History | Annotate | Download | only in android-clat

Lines Matching refs:checksum

31 #include "checksum.h"
38 * calculates the checksum over all the packet components starting from pos
39 * checksum - checksum of packet components before pos
40 * packet - packet to calculate the checksum of
42 * returns - the completed 16-bit checksum, ready to write into a checksum header field
44 uint16_t packet_checksum(uint32_t checksum, clat_packet packet, int pos) {
48 checksum = ip_checksum_add(checksum, packet[i].iov_base, packet[i].iov_len);
51 return ip_checksum_finish(checksum);
182 * checksum - pseudo-header checksum
187 int icmp_to_icmp6(clat_packet out, int pos, const struct icmphdr *icmp, uint32_t checksum,
208 // The pseudo-header checksum was calculated on the transport length of the original IPv4
212 // alternative, which is to always update the pseudo-header checksum in all UDP/TCP/ICMP
215 // pseudo-header when calculating its checksum (as the IPv4 header has its own checksum).
216 checksum = htonl(ntohl(checksum) + 20);
229 icmp6_targ->icmp6_cksum = 0; // Checksum field must be 0 when calculating checksum.
230 icmp6_targ->icmp6_cksum = packet_checksum(checksum, out, pos);
239 * checksum - pseudo-header checksum (unused)
244 int icmp6_to_icmp(clat_packet out, int pos, const struct icmp6_hdr *icmp6, uint32_t checksum,
277 icmp_targ->checksum = 0; // Checksum field must be 0 when calculating checksum.
278 icmp_targ->checksum = packet_checksum(0, out, pos);
287 * checksum - pseudo-header checksum
290 int udp_packet(clat_packet out, int pos, const struct udphdr *udp, uint32_t checksum, size_t len) {
302 return udp_translate(out, pos, udp, checksum, payload, payload_size);
309 * checksum - pseudo-header checksum
313 int tcp_packet(clat_packet out, int pos, const struct tcphdr *tcp, uint32_t checksum, size_t len) {
336 return tcp_translate(out, pos, tcp, header_size, checksum, payload, payload_size);
340 * common between ipv4/ipv6 - setup checksum and send udp packet
343 * checksum - pseudo-header checksum
348 int udp_translate(clat_packet out, int pos, const struct udphdr *udp, uint32_t checksum,
358 udp_targ->check = 0; // Checksum field must be 0 when calculating checksum.
359 udp_targ->check = packet_checksum(checksum, out, pos);
365 * common between ipv4/ipv6 - setup checksum and send tcp packet
369 * checksum - partial checksum covering ipv4/ipv6 header
378 uint32_t checksum, const char *payload, size_t payload_size) {
395 tcp_targ->check = 0; // Checksum field must be 0 when calculating checksum.
396 tcp_targ->check = packet_checksum(checksum, out, pos);