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