123

Committer:
hudakz
Date:
Thu Nov 20 21:26:54 2014 +0000
Revision:
1:01c2344f98a3
Parent:
uitility/uip_arch.h@0:5350a66d5279
rev. 01

Who changed what in which revision?

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