Mbed library for ENC28J60 Ethernet modules. Full support for TCP/IP and UDP Server, Client and HTTP server (webserver). DHCP and DNS is included.

Dependents:   mBuino_ENC28_MQTT Nucleo_Web_ENC28J60 Nucleo_Web_ENC28J60_ADC Serial_over_Ethernet ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers uip_arch.h Source File

uip_arch.h

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