- Main Page
- Modules
- Data Structures
- Files
- Examples

- File List
- Globals

# uip/uip_arch.h

Go to the documentation of this file.

    00001 /**
    00002  * \addtogroup uip
    00003  * {@
    00004  */
    00005
    00006 /**
    00007  * \defgroup uiparch Architecture specific uIP functions
    00008  * @{
    00009  *
    00010  * The functions in the architecture specific module implement the IP
    00011  * check sum and 32-bit additions.
    00012  *
    00013  * The IP checksum calculation is the most computationally expensive
    00014  * operation in the TCP/IP stack and it therefore pays off to
    00015  * implement this in efficient assembler. The purpose of the uip-arch
    00016  * module is to let the checksum functions to be implemented in
    00017  * architecture specific assembler.
    00018  *
    00019  */
    00020
    00021 /**
    00022  * \file
    00023  * Declarations of architecture specific functions.
    00024  * \author Adam Dunkels <adam@dunkels.com>
    00025  */
    00026
    00027 /*
    00028  * Copyright (c) 2001, Adam Dunkels.
    00029  * All rights reserved.
    00030  *
    00031  * Redistribution and use in source and binary forms, with or without
    00032  * modification, are permitted provided that the following conditions
    00033  * are met:
    00034  * 1. Redistributions of source code must retain the above copyright
    00035  *    notice, this list of conditions and the following disclaimer.
    00036  * 2. Redistributions in binary form must reproduce the above copyright
    00037  *    notice, this list of conditions and the following disclaimer in the
    00038  *    documentation and/or other materials provided with the distribution.
    00039  * 3. The name of the author may not be used to endorse or promote
    00040  *    products derived from this software without specific prior
    00041  *    written permission.
    00042  *
    00043  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
    00044  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    00045  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    00046  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
    00047  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    00048  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    00049  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    00050  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    00051  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00052  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00053  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00054  *
    00055  * This file is part of the uIP TCP/IP stack.
    00056  *
    00057  * $Id: uip_arch.h,v 1.2 2006/06/07 09:15:19 adam Exp $
    00058  *
    00059  */
    00060
    00061 #ifndef __UIP_ARCH_H__
    00062 #define __UIP_ARCH_H__
    00063
    00064 #include "uip.h"
    00065
    00066 /**
    00067  * Carry out a 32-bit addition.
    00068  *
    00069  * Because not all architectures for which uIP is intended has native
    00070  * 32-bit arithmetic, uIP uses an external C function for doing the
    00071  * required 32-bit additions in the TCP protocol processing. This
    00072  * function should add the two arguments and place the result in the
    00073  * global variable uip_acc32.
    00074  *
    00075  * \note The 32-bit integer pointed to by the op32 parameter and the
    00076  * result in the uip_acc32 variable are in network byte order (big
    00077  * endian).
    00078  *
    00079  * \param op32 A pointer to a 4-byte array representing a 32-bit
    00080  * integer in network byte order (big endian).
    00081  *
    00082  * \param op16 A 16-bit integer in host byte order.
    00083  */
    00084 void uip_add32(u8_t *op32, u16_t op16);
    00085
    00086 /**
    00087  * Calculate the Internet checksum over a buffer.
    00088  *
    00089  * The Internet checksum is the one's complement of the one's
    00090  * complement sum of all 16-bit words in the buffer.
    00091  *
    00092  * See RFC1071.
    00093  *
    00094  * \note This function is not called in the current version of uIP,
    00095  * but future versions might make use of it.
    00096  *
    00097  * \param buf A pointer to the buffer over which the checksum is to be
    00098  * computed.
    00099  *
    00100  * \param len The length of the buffer over which the checksum is to
    00101  * be computed.
    00102  *
    00103  * \return The Internet checksum of the buffer.
    00104  */
    00105 u16_t uip_chksum(u16_t *buf, u16_t len);
    00106
    00107 /**
    00108  * Calculate the IP header checksum of the packet header in uip_buf.
    00109  *
    00110  * The IP header checksum is the Internet checksum of the 20 bytes of
    00111  * the IP header.
    00112  *
    00113  * \return The IP header checksum of the IP header in the uip_buf
    00114  * buffer.
    00115  */
    00116 u16_t uip_ipchksum(void);
    00117
    00118 /**
    00119  * Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
    00120  *
    00121  * The TCP checksum is the Internet checksum of data contents of the
    00122  * TCP segment, and a pseudo-header as defined in RFC793.
    00123  *
    00124  * \note The uip_appdata pointer that points to the packet data may
    00125  * point anywhere in memory, so it is not possible to simply calculate
    00126  * the Internet checksum of the contents of the uip_buf buffer.
    00127  *
    00128  * \return The TCP checksum of the TCP segment in uip_buf and pointed
    00129  * to by uip_appdata.
    00130  */
    00131 u16_t uip_tcpchksum(void);
    00132
    00133 u16_t uip_udpchksum(void);
    00134
    00135 /** @} */
    00136 /** @} */
    00137
    00138 #endif /* __UIP_ARCH_H__ */