You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * \defgroup uiparch Architecture specific uIP functions
  3. * @{
  4. *
  5. * The functions in the architecture specific module implement the IP
  6. * check sum and 32-bit additions.
  7. *
  8. * The IP checksum calculation is the most computationally expensive
  9. * operation in the TCP/IP stack and it therefore pays off to
  10. * implement this in efficient assembler. The purpose of the uip-arch
  11. * module is to let the checksum functions to be implemented in
  12. * architecture specific assembler.
  13. *
  14. */
  15. /**
  16. * \file
  17. * Declarations of architecture specific functions.
  18. * \author Adam Dunkels <adam@dunkels.com>
  19. */
  20. /*
  21. * Copyright (c) 2001, Adam Dunkels.
  22. * All rights reserved.
  23. *
  24. * Redistribution and use in source and binary forms, with or without
  25. * modification, are permitted provided that the following conditions
  26. * are met:
  27. * 1. Redistributions of source code must retain the above copyright
  28. * notice, this list of conditions and the following disclaimer.
  29. * 2. Redistributions in binary form must reproduce the above copyright
  30. * notice, this list of conditions and the following disclaimer in the
  31. * documentation and/or other materials provided with the distribution.
  32. * 3. The name of the author may not be used to endorse or promote
  33. * products derived from this software without specific prior
  34. * written permission.
  35. *
  36. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  37. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  38. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  39. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  40. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  41. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  42. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  43. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  44. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  45. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  46. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47. *
  48. * This file is part of the uIP TCP/IP stack.
  49. *
  50. * $Id$
  51. *
  52. */
  53. #ifndef __UIP_ARCH_H__
  54. #define __UIP_ARCH_H__
  55. #include "uip.h"
  56. /**
  57. * Carry out a 32-bit addition.
  58. *
  59. * Because not all architectures for which uIP is intended has native
  60. * 32-bit arithmetic, uIP uses an external C function for doing the
  61. * required 32-bit additions in the TCP protocol processing. This
  62. * function should add the two arguments and place the result in the
  63. * global variable uip_acc32.
  64. *
  65. * \note The 32-bit integer pointed to by the op32 parameter and the
  66. * result in the uip_acc32 variable are in network byte order (big
  67. * endian).
  68. *
  69. * \param op32 A pointer to a 4-byte array representing a 32-bit
  70. * integer in network byte order (big endian).
  71. *
  72. * \param op16 A 16-bit integer in host byte order.
  73. */
  74. void uip_add32(u8_t *op32, u16_t op16);
  75. /**
  76. * Calculate the Internet checksum over a buffer.
  77. *
  78. * The Internet checksum is the one's complement of the one's
  79. * complement sum of all 16-bit words in the buffer.
  80. *
  81. * See RFC1071.
  82. *
  83. * \note This function is not called in the current version of uIP,
  84. * but future versions might make use of it.
  85. *
  86. * \param buf A pointer to the buffer over which the checksum is to be
  87. * computed.
  88. *
  89. * \param len The length of the buffer over which the checksum is to
  90. * be computed.
  91. *
  92. * \return The Internet checksum of the buffer.
  93. */
  94. u16_t uip_chksum(u16_t *buf, u16_t len);
  95. /**
  96. * Calculate the IP header checksum of the packet header in uip_buf.
  97. *
  98. * The IP header checksum is the Internet checksum of the 20 bytes of
  99. * the IP header.
  100. *
  101. * \return The IP header checksum of the IP header in the uip_buf
  102. * buffer.
  103. */
  104. u16_t uip_ipchksum(void);
  105. /**
  106. * Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
  107. *
  108. * The TCP checksum is the Internet checksum of data contents of the
  109. * TCP segment, and a pseudo-header as defined in RFC793.
  110. *
  111. * \note The uip_appdata pointer that points to the packet data may
  112. * point anywhere in memory, so it is not possible to simply calculate
  113. * the Internet checksum of the contents of the uip_buf buffer.
  114. *
  115. * \return The TCP checksum of the TCP segment in uip_buf and pointed
  116. * to by uip_appdata.
  117. */
  118. u16_t uip_tcpchksum(void);
  119. /** @} */
  120. #endif /* __UIP_ARCH_H__ */