2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-23 19:51:46 +00:00

Moved uIP and tcp.c from proto/ to net/

This commit is contained in:
Michael Brown 2006-04-30 01:16:37 +00:00
parent 352bf1bda2
commit 592a5a99c8
8 changed files with 3512 additions and 3 deletions

View File

@ -132,8 +132,7 @@ DEBUG_TARGETS += dbg2.o dbg.o c s
#
SRCDIRS += core
SRCDIRS += proto
SRCDIRS += net
SRCDIRS += proto/uip
SRCDIRS += net net/uip
#SRCDIRS += image
SRCDIRS += drivers/bus
SRCDIRS += drivers/net

View File

@ -11,7 +11,7 @@
#include <gpxe/if_ether.h>
#include <gpxe/pkbuff.h>
#include <gpxe/netdevice.h>
#include "../proto/uip/uip.h"
#include "uip/uip.h"
/** @file
*

164
src/net/tcp.c Normal file
View File

@ -0,0 +1,164 @@
#include <string.h>
#include <assert.h>
#include <byteswap.h>
#include <gpxe/tcp.h>
#include "uip/uip.h"
/** @file
*
* TCP protocol
*
* The gPXE TCP stack is currently implemented on top of the uIP
* protocol stack. This file provides wrappers around uIP so that
* higher-level protocol implementations do not need to talk directly
* to uIP (which has a somewhat baroque API).
*
* Basic operation is to create a #tcp_connection structure, call
* tcp_connect() and then call run_tcpip() in a loop until the
* operation has completed. The TCP stack will call the various
* methods defined in the #tcp_operations structure in order to send
* and receive data.
*
* See hello.c for a trivial example of a TCP protocol using this
* API.
*
*/
/**
* TCP transmit buffer
*
* When a tcp_operations::senddata() method is called, it is
* guaranteed to be able to use this buffer as temporary space for
* constructing the data to be sent. For example, code such as
*
* @code
*
* static void my_senddata ( struct tcp_connection *conn ) {
* int len;
*
* len = snprintf ( tcp_buffer, tcp_buflen, "FETCH %s\r\n", filename );
* tcp_send ( conn, tcp_buffer + already_sent, len - already_sent );
* }
*
* @endcode
*
* is allowed, and is probably the best way to deal with
* variably-sized data.
*
* Note that you cannot use this simple mechanism if you want to be
* able to construct single data blocks of more than #tcp_buflen
* bytes.
*/
void *tcp_buffer = uip_buf + ( 40 + UIP_LLH_LEN );
/** Size of #tcp_buffer */
size_t tcp_buflen = UIP_BUFSIZE - ( 40 + UIP_LLH_LEN );
/**
* Open a TCP connection
*
* @v conn TCP connection
* @ret 0 Success
* @ret <0 Failure
*
* This sets up a new TCP connection to the remote host specified in
* tcp_connection::sin. The actual SYN packet will not be sent out
* until run_tcpip() is called for the first time.
*
* @todo Use linked lists instead of a static buffer, and thereby
* remove the only potential failure case, giving this function
* a void return type.
*/
int tcp_connect ( struct tcp_connection *conn ) {
struct uip_conn *uip_conn;
u16_t ipaddr[2];
assert ( conn->sin.sin_addr.s_addr != 0 );
assert ( conn->sin.sin_port != 0 );
assert ( conn->tcp_op != NULL );
assert ( sizeof ( uip_conn->appstate ) == sizeof ( conn ) );
* ( ( uint32_t * ) ipaddr ) = conn->sin.sin_addr.s_addr;
uip_conn = uip_connect ( ipaddr, conn->sin.sin_port );
if ( ! uip_conn )
return -1;
*( ( void ** ) uip_conn->appstate ) = conn;
return 0;
}
/**
* Send data via a TCP connection
*
* @v conn TCP connection
* @v data Data to send
* @v len Length of data
*
* Data will be automatically limited to the current TCP window size.
*
* If retransmission is required, the connection's
* tcp_operations::senddata() method will be called again in order to
* regenerate the data.
*/
void tcp_send ( struct tcp_connection *conn __unused,
const void *data, size_t len ) {
assert ( conn = *( ( void ** ) uip_conn->appstate ) );
if ( len > tcp_buflen )
len = tcp_buflen;
memmove ( tcp_buffer, data, len );
uip_send ( tcp_buffer, len );
}
/**
* Close a TCP connection
*
* @v conn TCP connection
*/
void tcp_close ( struct tcp_connection *conn __unused ) {
assert ( conn = *( ( void ** ) uip_conn->appstate ) );
uip_close();
}
/**
* uIP TCP application call interface
*
* This is the entry point of gPXE from the point of view of the uIP
* protocol stack. This function calls the appropriate methods from
* the connection's @tcp_operations table in order to process received
* data, transmit new data etc.
*/
void uip_tcp_appcall ( void ) {
struct tcp_connection *conn = *( ( void ** ) uip_conn->appstate );
struct tcp_operations *op = conn->tcp_op;
assert ( conn->tcp_op->closed != NULL );
assert ( conn->tcp_op->connected != NULL );
assert ( conn->tcp_op->acked != NULL );
assert ( conn->tcp_op->newdata != NULL );
assert ( conn->tcp_op->senddata != NULL );
if ( uip_aborted() && op->aborted ) /* optional method */
op->aborted ( conn );
if ( uip_timedout() && op->timedout ) /* optional method */
op->timedout ( conn );
if ( uip_closed() && op->closed ) /* optional method */
op->closed ( conn );
if ( uip_connected() )
op->connected ( conn );
if ( uip_acked() )
op->acked ( conn, uip_conn->len );
if ( uip_newdata() )
op->newdata ( conn, ( void * ) uip_appdata, uip_len );
if ( uip_rexmit() || uip_newdata() || uip_acked() ||
uip_connected() || uip_poll() )
op->senddata ( conn );
}
/* Present here to allow everything to link. Will go into separate
* udp.c file
*/
void uip_udp_appcall ( void ) {
}

1501
src/net/uip/uip.c Normal file

File diff suppressed because it is too large Load Diff

1060
src/net/uip/uip.h Normal file

File diff suppressed because it is too large Load Diff

83
src/net/uip/uip_arch.c Normal file
View File

@ -0,0 +1,83 @@
#include <stdint.h>
#include <byteswap.h>
#include "uip_arch.h"
#include "uip.h"
volatile u8_t uip_acc32[4];
void uip_add32 ( u8_t *op32, u16_t op16 ) {
* ( ( uint32_t * ) uip_acc32 ) =
htonl ( ntohl ( *( ( uint32_t * ) op32 ) ) + op16 );
}
#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
#define IP_PROTO_TCP 6
u16_t uip_chksum(u16_t *sdata, u16_t len) {
u16_t acc;
for(acc = 0; len > 1; len -= 2) {
acc += *sdata;
if(acc < *sdata) {
/* Overflow, so we add the carry to acc (i.e., increase by
one). */
++acc;
}
++sdata;
}
/* add up any odd byte */
if(len == 1) {
acc += htons(((u16_t)(*(u8_t *)sdata)) << 8);
if(acc < htons(((u16_t)(*(u8_t *)sdata)) << 8)) {
++acc;
}
}
return acc;
}
u16_t uip_ipchksum(void) {
return uip_chksum((u16_t *)&uip_buf[UIP_LLH_LEN], 20);
}
u16_t uip_tcpchksum(void) {
u16_t hsum, sum;
/* Compute the checksum of the TCP header. */
hsum = uip_chksum((u16_t *)&uip_buf[20 + UIP_LLH_LEN], 20);
/* Compute the checksum of the data in the TCP packet and add it to
the TCP header checksum. */
sum = uip_chksum((u16_t *)uip_appdata,
(u16_t)(((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - 40)));
if((sum += hsum) < hsum) {
++sum;
}
if((sum += BUF->srcipaddr[0]) < BUF->srcipaddr[0]) {
++sum;
}
if((sum += BUF->srcipaddr[1]) < BUF->srcipaddr[1]) {
++sum;
}
if((sum += BUF->destipaddr[0]) < BUF->destipaddr[0]) {
++sum;
}
if((sum += BUF->destipaddr[1]) < BUF->destipaddr[1]) {
++sum;
}
if((sum += (u16_t)htons((u16_t)IP_PROTO_TCP)) < (u16_t)htons((u16_t)IP_PROTO_TCP)) {
++sum;
}
hsum = (u16_t)htons((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - 20);
if((sum += hsum) < hsum) {
++sum;
}
return sum;
}

130
src/net/uip/uip_arch.h Normal file
View File

@ -0,0 +1,130 @@
/**
* \defgroup uiparch Architecture specific uIP functions
* @{
*
* The functions in the architecture specific module implement the IP
* check sum and 32-bit additions.
*
* The IP checksum calculation is the most computationally expensive
* operation in the TCP/IP stack and it therefore pays off to
* implement this in efficient assembler. The purpose of the uip-arch
* module is to let the checksum functions to be implemented in
* architecture specific assembler.
*
*/
/**
* \file
* Declarations of architecture specific functions.
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* Copyright (c) 2001, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id$
*
*/
#ifndef __UIP_ARCH_H__
#define __UIP_ARCH_H__
#include "uip.h"
/**
* Carry out a 32-bit addition.
*
* Because not all architectures for which uIP is intended has native
* 32-bit arithmetic, uIP uses an external C function for doing the
* required 32-bit additions in the TCP protocol processing. This
* function should add the two arguments and place the result in the
* global variable uip_acc32.
*
* \note The 32-bit integer pointed to by the op32 parameter and the
* result in the uip_acc32 variable are in network byte order (big
* endian).
*
* \param op32 A pointer to a 4-byte array representing a 32-bit
* integer in network byte order (big endian).
*
* \param op16 A 16-bit integer in host byte order.
*/
void uip_add32(u8_t *op32, u16_t op16);
/**
* Calculate the Internet checksum over a buffer.
*
* The Internet checksum is the one's complement of the one's
* complement sum of all 16-bit words in the buffer.
*
* See RFC1071.
*
* \note This function is not called in the current version of uIP,
* but future versions might make use of it.
*
* \param buf A pointer to the buffer over which the checksum is to be
* computed.
*
* \param len The length of the buffer over which the checksum is to
* be computed.
*
* \return The Internet checksum of the buffer.
*/
u16_t uip_chksum(u16_t *buf, u16_t len);
/**
* Calculate the IP header checksum of the packet header in uip_buf.
*
* The IP header checksum is the Internet checksum of the 20 bytes of
* the IP header.
*
* \return The IP header checksum of the IP header in the uip_buf
* buffer.
*/
u16_t uip_ipchksum(void);
/**
* Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
*
* The TCP checksum is the Internet checksum of data contents of the
* TCP segment, and a pseudo-header as defined in RFC793.
*
* \note The uip_appdata pointer that points to the packet data may
* point anywhere in memory, so it is not possible to simply calculate
* the Internet checksum of the contents of the uip_buf buffer.
*
* \return The TCP checksum of the TCP segment in uip_buf and pointed
* to by uip_appdata.
*/
u16_t uip_tcpchksum(void);
/** @} */
#endif /* __UIP_ARCH_H__ */

572
src/net/uip/uipopt.h Normal file
View File

@ -0,0 +1,572 @@
/**
* \defgroup uipopt Configuration options for uIP
* @{
*
* uIP is configured using the per-project configuration file
* "uipopt.h". This file contains all compile-time options for uIP and
* should be tweaked to match each specific project. The uIP
* distribution contains a documented example "uipopt.h" that can be
* copied and modified for each project.
*/
/**
* \file
* Configuration options for uIP.
* \author Adam Dunkels <adam@dunkels.com>
*
* This file is used for tweaking various configuration options for
* uIP. You should make a copy of this file into one of your project's
* directories instead of editing this example "uipopt.h" file that
* comes with the uIP distribution.
*/
/*
* Copyright (c) 2001-2003, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id$
*
*/
#ifndef __UIPOPT_H__
#define __UIPOPT_H__
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipopttypedef uIP type definitions
* @{
*/
/**
* The 8-bit unsigned data type.
*
* This may have to be tweaked for your particular compiler. "unsigned
* char" works for most compilers.
*/
typedef unsigned char u8_t;
/**
* The 16-bit unsigned data type.
*
* This may have to be tweaked for your particular compiler. "unsigned
* short" works for most compilers.
*/
typedef unsigned short u16_t;
/**
* The statistics data type.
*
* This datatype determines how high the statistics counters are able
* to count.
*/
typedef unsigned short uip_stats_t;
/** @} */
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipoptstaticconf Static configuration options
* @{
*
* These configuration options can be used for setting the IP address
* settings statically, but only if UIP_FIXEDADDR is set to 1. The
* configuration options for a specific node includes IP address,
* netmask and default router as well as the Ethernet address. The
* netmask, default router and Ethernet address are appliciable only
* if uIP should be run over Ethernet.
*
* All of these should be changed to suit your project.
*/
/**
* Determines if uIP should use a fixed IP address or not.
*
* If uIP should use a fixed IP address, the settings are set in the
* uipopt.h file. If not, the macros uip_sethostaddr(),
* uip_setdraddr() and uip_setnetmask() should be used instead.
*
* \hideinitializer
*/
#define UIP_FIXEDADDR 0
/**
* Ping IP address asignment.
*
* uIP uses a "ping" packets for setting its own IP address if this
* option is set. If so, uIP will start with an empty IP address and
* the destination IP address of the first incoming "ping" (ICMP echo)
* packet will be used for setting the hosts IP address.
*
* \note This works only if UIP_FIXEDADDR is 0.
*
* \hideinitializer
*/
#define UIP_PINGADDRCONF 0
#define UIP_IPADDR0 0 /**< The first octet of the IP address of
this uIP node, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_IPADDR1 0 /**< The second octet of the IP address of
this uIP node, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_IPADDR2 0 /**< The third octet of the IP address of
this uIP node, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_IPADDR3 0 /**< The fourth octet of the IP address of
this uIP node, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_NETMASK0 0 /**< The first octet of the netmask of
this uIP node, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_NETMASK1 0 /**< The second octet of the netmask of
this uIP node, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_NETMASK2 0 /**< The third octet of the netmask of
this uIP node, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_NETMASK3 0 /**< The fourth octet of the netmask of
this uIP node, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_DRIPADDR0 0 /**< The first octet of the IP address of
the default router, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_DRIPADDR1 0 /**< The second octet of the IP address of
the default router, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_DRIPADDR2 0 /**< The third octet of the IP address of
the default router, if UIP_FIXEDADDR is
1. \hideinitializer */
#define UIP_DRIPADDR3 0 /**< The fourth octet of the IP address of
the default router, if UIP_FIXEDADDR is
1. \hideinitializer */
/**
* Specifies if the uIP ARP module should be compiled with a fixed
* Ethernet MAC address or not.
*
* If this configuration option is 0, the macro uip_setethaddr() can
* be used to specify the Ethernet address at run-time.
*
* \hideinitializer
*/
#define UIP_FIXEDETHADDR 0
#define UIP_ETHADDR0 0x00 /**< The first octet of the Ethernet
address if UIP_FIXEDETHADDR is
1. \hideinitializer */
#define UIP_ETHADDR1 0xbd /**< The second octet of the Ethernet
address if UIP_FIXEDETHADDR is
1. \hideinitializer */
#define UIP_ETHADDR2 0x3b /**< The third octet of the Ethernet
address if UIP_FIXEDETHADDR is
1. \hideinitializer */
#define UIP_ETHADDR3 0x33 /**< The fourth octet of the Ethernet
address if UIP_FIXEDETHADDR is
1. \hideinitializer */
#define UIP_ETHADDR4 0x05 /**< The fifth octet of the Ethernet
address if UIP_FIXEDETHADDR is
1. \hideinitializer */
#define UIP_ETHADDR5 0x71 /**< The sixth octet of the Ethernet
address if UIP_FIXEDETHADDR is
1. \hideinitializer */
/** @} */
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipoptip IP configuration options
* @{
*
*/
/**
* The IP TTL (time to live) of IP packets sent by uIP.
*
* This should normally not be changed.
*/
#define UIP_TTL 255
/**
* Turn on support for IP packet reassembly.
*
* uIP supports reassembly of fragmented IP packets. This features
* requires an additonal amount of RAM to hold the reassembly buffer
* and the reassembly code size is approximately 700 bytes. The
* reassembly buffer is of the same size as the uip_buf buffer
* (configured by UIP_BUFSIZE).
*
* \note IP packet reassembly is not heavily tested.
*
* \hideinitializer
*/
#define UIP_REASSEMBLY 0
/**
* The maximum time an IP fragment should wait in the reassembly
* buffer before it is dropped.
*
*/
#define UIP_REASS_MAXAGE 40
/** @} */
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipoptudp UDP configuration options
* @{
*
* \note The UDP support in uIP is still not entirely complete; there
* is no support for sending or receiving broadcast or multicast
* packets, but it works well enough to support a number of vital
* applications such as DNS queries, though
*/
/**
* Toggles wether UDP support should be compiled in or not.
*
* \hideinitializer
*/
#define UIP_UDP 1
/**
* Toggles if UDP checksums should be used or not.
*
* \note Support for UDP checksums is currently not included in uIP,
* so this option has no function.
*
* \hideinitializer
*/
#define UIP_UDP_CHECKSUMS 0
/**
* The maximum amount of concurrent UDP connections.
*
* \hideinitializer
*/
#define UIP_UDP_CONNS 10
/**
* The name of the function that should be called when UDP datagrams arrive.
*
* \hideinitializer
*/
extern void uip_udp_appcall ( void );
#define UIP_UDP_APPCALL uip_udp_appcall
/** @} */
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipopttcp TCP configuration options
* @{
*/
/**
* Determines if support for opening connections from uIP should be
* compiled in.
*
* If the applications that are running on top of uIP for this project
* do not need to open outgoing TCP connections, this configration
* option can be turned off to reduce the code size of uIP.
*
* \hideinitializer
*/
#define UIP_ACTIVE_OPEN 1
/**
* The maximum number of simultaneously open TCP connections.
*
* Since the TCP connections are statically allocated, turning this
* configuration knob down results in less RAM used. Each TCP
* connection requires approximatly 30 bytes of memory.
*
* \hideinitializer
*/
#define UIP_CONNS 10
/**
* The maximum number of simultaneously listening TCP ports.
*
* Each listening TCP port requires 2 bytes of memory.
*
* \hideinitializer
*/
#define UIP_LISTENPORTS 10
/**
* The size of the advertised receiver's window.
*
* Should be set low (i.e., to the size of the uip_buf buffer) is the
* application is slow to process incoming data, or high (32768 bytes)
* if the application processes data quickly.
*
* \hideinitializer
*/
#define UIP_RECEIVE_WINDOW 32768
/**
* Determines if support for TCP urgent data notification should be
* compiled in.
*
* Urgent data (out-of-band data) is a rarely used TCP feature that
* very seldom would be required.
*
* \hideinitializer
*/
#define UIP_URGDATA 1
/**
* The initial retransmission timeout counted in timer pulses.
*
* This should not be changed.
*/
#define UIP_RTO 3
/**
* The maximum number of times a segment should be retransmitted
* before the connection should be aborted.
*
* This should not be changed.
*/
#define UIP_MAXRTX 8
/**
* The maximum number of times a SYN segment should be retransmitted
* before a connection request should be deemed to have been
* unsuccessful.
*
* This should not need to be changed.
*/
#define UIP_MAXSYNRTX 3
/**
* The TCP maximum segment size.
*
* This is should not be to set to more than UIP_BUFSIZE - UIP_LLH_LEN - 40.
*/
#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - 40)
/**
* How long a connection should stay in the TIME_WAIT state.
*
* This configiration option has no real implication, and it should be
* left untouched.
*/
#define UIP_TIME_WAIT_TIMEOUT 120
/** @} */
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipoptarp ARP configuration options
* @{
*/
/**
* The size of the ARP table.
*
* This option should be set to a larger value if this uIP node will
* have many connections from the local network.
*
* \hideinitializer
*/
#define UIP_ARPTAB_SIZE 8
/**
* The maxium age of ARP table entries measured in 10ths of seconds.
*
* An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
* default).
*/
#define UIP_ARP_MAXAGE 120
/** @} */
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipoptgeneral General configuration options
* @{
*/
/**
* The size of the uIP packet buffer.
*
* The uIP packet buffer should not be smaller than 60 bytes, and does
* not need to be larger than 1500 bytes. Lower size results in lower
* TCP throughput, larger size results in higher TCP throughput.
*
* \hideinitializer
*/
#define UIP_BUFSIZE 1500
/**
* Determines if statistics support should be compiled in.
*
* The statistics is useful for debugging and to show the user.
*
* \hideinitializer
*/
#define UIP_STATISTICS 0
/**
* Determines if logging of certain events should be compiled in.
*
* This is useful mostly for debugging. The function uip_log()
* must be implemented to suit the architecture of the project, if
* logging is turned on.
*
* \hideinitializer
*/
#define UIP_LOGGING 0
/**
* Print out a uIP log message.
*
* This function must be implemented by the module that uses uIP, and
* is called by uIP whenever a log message is generated.
*/
void uip_log(char *msg);
/**
* The link level header length.
*
* This is the offset into the uip_buf where the IP header can be
* found. For Ethernet, this should be set to 14. For SLIP, this
* should be set to 0.
*
* \hideinitializer
*/
#define UIP_LLH_LEN 0
/** @} */
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipoptcpu CPU architecture configuration
* @{
*
* The CPU architecture configuration is where the endianess of the
* CPU on which uIP is to be run is specified. Most CPUs today are
* little endian, and the most notable exception are the Motorolas
* which are big endian. The BYTE_ORDER macro should be changed to
* reflect the CPU architecture on which uIP is to be run.
*/
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 3412
#endif /* LITTLE_ENDIAN */
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 1234
#endif /* BIGE_ENDIAN */
/**
* The byte order of the CPU architecture on which uIP is to be run.
*
* This option can be either BIG_ENDIAN (Motorola byte order) or
* LITTLE_ENDIAN (Intel byte order).
*
* \hideinitializer
*/
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif /* BYTE_ORDER */
/** @} */
/*------------------------------------------------------------------------------*/
/**
* \defgroup uipoptapp Appication specific configurations
* @{
*
* An uIP application is implemented using a single application
* function that is called by uIP whenever a TCP/IP event occurs. The
* name of this function must be registered with uIP at compile time
* using the UIP_APPCALL definition.
*
* uIP applications can store the application state within the
* uip_conn structure by specifying the size of the application
* structure with the UIP_APPSTATE_SIZE macro.
*
* The file containing the definitions must be included in the
* uipopt.h file.
*
* The following example illustrates how this can look.
\code
void httpd_appcall(void);
#define UIP_APPCALL httpd_appcall
struct httpd_state {
u8_t state;
u16_t count;
char *dataptr;
char *script;
};
#define UIP_APPSTATE_SIZE (sizeof(struct httpd_state))
\endcode
*/
/**
* \var #define UIP_APPCALL
*
* The name of the application function that uIP should call in
* response to TCP/IP events.
*
*/
extern void uip_tcp_appcall ( void );
#define UIP_APPCALL uip_tcp_appcall
/**
* \var #define UIP_APPSTATE_SIZE
*
* The size of the application state that is to be stored in the
* uip_conn structure.
*/
#define UIP_APPSTATE_SIZE sizeof ( void * )
/** @} */
/* Include the header file for the application program that should be
used. If you don't use the example web server, you should change
this. */
//#include "httpd.h"
#warning "Remove this static IP address hack"
#undef UIP_FIXEDADDR
#undef UIP_IPADDR0
#undef UIP_IPADDR1
#undef UIP_IPADDR2
#undef UIP_IPADDR3
#define UIP_FIXEDADDR 1
#define UIP_IPADDR0 10
#define UIP_IPADDR1 254
#define UIP_IPADDR2 254
#define UIP_IPADDR3 1
#endif /* __UIPOPT_H__ */