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