checksum.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _ASM_IA64_CHECKSUM_H
  2. #define _ASM_IA64_CHECKSUM_H
  3. /*
  4. * Modified 1998, 1999
  5. * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
  6. */
  7. /*
  8. * This is a version of ip_compute_csum() optimized for IP headers,
  9. * which always checksum on 4 octet boundaries.
  10. */
  11. extern unsigned short ip_fast_csum (unsigned char * iph, unsigned int ihl);
  12. /*
  13. * Computes the checksum of the TCP/UDP pseudo-header returns a 16-bit
  14. * checksum, already complemented
  15. */
  16. extern unsigned short int csum_tcpudp_magic (unsigned long saddr,
  17. unsigned long daddr,
  18. unsigned short len,
  19. unsigned short proto,
  20. unsigned int sum);
  21. extern unsigned int csum_tcpudp_nofold (unsigned long saddr,
  22. unsigned long daddr,
  23. unsigned short len,
  24. unsigned short proto,
  25. unsigned int sum);
  26. /*
  27. * Computes the checksum of a memory block at buff, length len,
  28. * and adds in "sum" (32-bit)
  29. *
  30. * returns a 32-bit number suitable for feeding into itself
  31. * or csum_tcpudp_magic
  32. *
  33. * this function must be called with even lengths, except
  34. * for the last fragment, which may be odd
  35. *
  36. * it's best to have buff aligned on a 32-bit boundary
  37. */
  38. extern unsigned int csum_partial (const unsigned char * buff, int len,
  39. unsigned int sum);
  40. /*
  41. * Same as csum_partial, but copies from src while it checksums.
  42. *
  43. * Here it is even more important to align src and dst on a 32-bit (or
  44. * even better 64-bit) boundary.
  45. */
  46. extern unsigned int csum_partial_copy_from_user (const char *src, char *dst,
  47. int len, unsigned int sum,
  48. int *errp);
  49. extern unsigned int csum_partial_copy_nocheck (const char *src, char *dst,
  50. int len, unsigned int sum);
  51. /*
  52. * This routine is used for miscellaneous IP-like checksums, mainly in
  53. * icmp.c
  54. */
  55. extern unsigned short ip_compute_csum (unsigned char *buff, int len);
  56. /*
  57. * Fold a partial checksum without adding pseudo headers.
  58. */
  59. static inline unsigned short
  60. csum_fold (unsigned int sum)
  61. {
  62. sum = (sum & 0xffff) + (sum >> 16);
  63. sum = (sum & 0xffff) + (sum >> 16);
  64. return ~sum;
  65. }
  66. #endif /* _ASM_IA64_CHECKSUM_H */