#define DEBUG_PRINTF(...) /*printf(__VA_ARGS__)*/
/**
* \defgroup uip The uIP TCP/IP stack
* @{
*
* uIP is an implementation of the TCP/IP protocol stack intended for
* small 8-bit and 16-bit microcontrollers.
*
* uIP provides the necessary protocols for Internet communication,
* with a very small code footprint and RAM requirements - the uIP
* code size is on the order of a few kilobytes and RAM usage is on
* the order of a few hundred bytes.
*/
/**
* \file
* The uIP TCP/IP stack code.
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* 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: uip.c,v 1.65 2006/06/11 21:46:39 adam Exp $
*
*/
/*
* uIP is a small implementation of the IP, UDP and TCP protocols (as
* well as some basic ICMP stuff). The implementation couples the IP,
* UDP, TCP and the application layers very tightly. To keep the size
* of the compiled code down, this code frequently uses the goto
* statement. While it would be possible to break the uip_process()
* function into many smaller functions, this would increase the code
* size because of the overhead of parameter passing and the fact that
* the optimier would not be as efficient.
*
* The principle is that we have a small buffer, called the uip_buf,
* in which the device driver puts an incoming packet. The TCP/IP
* stack parses the headers in the packet, and calls the
* application. If the remote host has sent data to the application,
* this data is present in the uip_buf and the application read the
* data from there. It is up to the application to put this data into
* a byte stream if needed. The application will not be fed with data
* that is out of sequence.
*
* If the application whishes to send data to the peer, it should put
* its data into the uip_buf. The uip_appdata pointer points to the
* first available byte. The TCP/IP stack will calculate the
* checksums, and fill in the necessary header fields and finally send
* the packet back to the peer.
*/
#include "uip.h"
#include "uipopt.h"
//#include "uip_arch.h"
#if UIP_CONF_IPV6
#include "uip-neighbor.h"
#endif /* UIP_CONF_IPV6 */
#include <string.h>
/*---------------------------------------------------------------------------*/
/* Variable definitions. */
/* The IP address of this host. If it is defined to be fixed (by
setting UIP_FIXEDADDR to 1 in uipopt.h), the address is set
here. Otherwise, the address */
#if UIP_FIXEDADDR > 0
const uip_ipaddr_t uip_hostaddr =
{HTONS((UIP_IPADDR0 << 8) | UIP_IPADDR1),
HTONS((UIP_IPADDR2 << 8) | UIP_IPADDR3)};
const uip_ipaddr_t uip_draddr =
{HTONS((UIP_DRIPADDR0 << 8) | UIP_DRIPADDR1),
HTONS((UIP_DRIPADDR2 << 8) | UIP_DRIPADDR3)};
const uip_ipaddr_t uip_netmask =
{HTONS((UIP_NETMASK0 << 8) | UIP_NETMASK1),
HTONS((UIP_NETMASK2 << 8) | UIP_NETMASK3)};
#else
uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask;
#endif /* UIP_FIXEDADDR */
static const uip_ipaddr_t all_ones_addr =
#if UIP_CONF_IPV6
{0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
#else /* UIP_CONF_IPV6 */
{0xffff,0xffff};
#endif /* UIP_CONF_IPV6 */
static const uip_ipaddr_t all_zeroes_addr =
#if UIP_CONF_IPV6
{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};
#else /* UIP_CONF_IPV6 */
{0x0000,0x0000};
#endif /* UIP_CONF_IPV6 */
#if UIP_FIXEDETHADDR
const struct uip_eth_addr uip_ethaddr = {{UIP_ETHADDR0,
UIP_ETHADDR1,
UIP_ETHADDR2,
UIP_ETHADDR3,
UIP_ETHADDR4,
UIP_ETHADDR5}};
#else
struct uip_eth_addr uip_ethaddr = {{0,0,0,0,0,0}};
#endif
#ifndef UIP_CONF_EXTERNAL_BUFFER
u8_t uip_buf[UIP_BUFSIZE + 2]; /* The packet buffer that contains
incoming packets. */
#endif /* UIP_CONF_EXTERNAL_BUFFER */
void *uip_appdata; /* The uip_appdata pointer points to
application data. */
void *uip_sappdata; /* The uip_appdata pointer points to
the application data which is to
be sent. */
#if UIP_URGDATA > 0
void *uip_urgdata; /* The uip_urgdata pointer points to
urgent data (out-of-band data), if
present. */
u16_t uip_urglen, uip_surglen;
#endif /* UIP_URGDATA > 0 */
u16_t uip_len, uip_slen;
/* The uip_len is either 8 or 16 bits,
depending on the maximum packet
size. */
u8_t uip_flags; /* The uip_flags variable is used for
communication between the TCP/IP stack
and the application program. */
struct uip_conn *uip_conn; /* uip_conn always points to the current
connection. */
struct uip_conn uip_conns[UIP_CONNS];
/* The uip_conns array holds all TCP
connections. */
u16_t uip_listenports[UIP_LISTENPORTS];
/* The uip_listenports list all currently
listning ports. */
#if UIP_UDP
struct uip_udp_conn *uip_udp_conn;
struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
#endif /* UIP_UDP */
static u16_t ipid; /* Ths ipid variable is an increasing
number that is used for the IP ID
field. */
void uip_setipid(u16_t id) { ipid = id; }
static u8_t iss[4]; /* The iss variable is used for the TCP
initial sequence number. */
#if UIP_ACTIVE_OPEN
static u16_t lastport; /* Keeps track of the last port used for
a new connection. */
#endif /* UIP_ACTIVE_OPEN */
/* Temporary variables. */
u8_t uip_acc32[4];
static u8_t opt;
static u16_t tmp16;
/* Structures and definitions. */
#define TCP_FIN 0x01
#define TCP_SYN 0x02
#define TCP_RST 0x04
#define TCP_PSH 0x08
#define TCP_ACK 0x10
#define TCP_URG 0x20
#define TCP_CTL 0x3f
#define TCP_OPT_END 0 /* End of TCP options list */
#define TCP_OPT_NOOP 1 /* "No-operation" TCP option */
#define TCP_OPT_MSS 2 /* Maximum segment size TCP option */
#define TCP_OPT_MSS_LEN 4 /* Length of TCP MSS option. */
#define ICMP_ECHO_REPLY 0
#define ICMP_ECHO 8
#define ICMP6_ECHO_REPLY 129
#define ICMP6_ECHO 128
#define ICMP6_NEIGHBOR_SOLICITATION 135
#define ICMP6_NEIGHBOR_ADVERTISEMENT 136
#define ICMP6_FLAG_S (1 << 6)
#define ICMP6_OPTION_SOURCE_LINK_ADDRESS 1
#define ICMP6_OPTION_TARGET_LINK_ADDRESS 2
/* Macros. */
#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
#define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0])
#define ICMPBUF ((struct uip_icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
#define UDPBUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
#if UIP_STATISTICS == 1
struct uip_stats uip_stat;
#define UIP_STAT(s) s
#el
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
stm32_ucos_uip_i2c.zip (55个子文件)
stm32+ucos+uip+i2c
源代码
STM32F103ZET6.htm 59KB
STM32F103ZET6.tra 2KB
STM32F103ZET6.lnp 447B
obj
os_cpu_a.lst 22KB
STM32F103ZET6_Target 1.dep 51KB
STM32F103ZET6.map 113KB
STM32F10x.lst 34KB
STM32F10x.s 11KB
SYSTEM
usart
usart.c 3KB
usart.h 377B
delay
delay.c 1018B
delay.h 300B
sys
sys.c 6KB
sys.h 3KB
STM32F103ZET6.uvproj 19KB
STM32F103ZET6_uvproj.bak 20KB
UCOSII
CORE
OS_MBOX.C 23KB
uCOS_II.C 1KB
uCOS_II.H 46KB
OS_TIME.C 10KB
OS_MUTEX.C 24KB
OS_TASK.C 35KB
OS_FLAG.C 36KB
OS_SEM.C 19KB
OS_CORE.C 45KB
OS_Q.C 34KB
OS_MEM.C 14KB
PORT
os_cpu_c.c 9KB
os_cpu.h 3KB
os_cpu_a.asm 7KB
CONFIG
os_cfg.h 6KB
includes.h 628B
STM32F103ZET6.sct 479B
STM32F103ZET6_uvopt.bak 150KB
STM32F103ZET6.plg 57KB
STM32F103ZET6.uvopt 150KB
USER
RTS.c 4KB
UIP
clock-arch.c 2KB
uip_arch.h 4KB
clock-arch.h 2KB
uip-conf.h 4KB
app.c 2KB
uip.h 44KB
uip_arp.h 5KB
uip_arp.c 13KB
clock.h 3KB
uip.c 57KB
timer.c 4KB
timer.h 3KB
uipopt.h 14KB
app.h 1KB
HARDWARE
ETHERNET
dm9k_uip.c 9KB
dm9k_uip.h 4KB
I2C
i2c_at24c02.h 93B
i2c_at24c02.c 4KB
共 55 条
- 1
资源评论
- qq7826113702016-10-28没看懂,能力有限!
- maye3112015-08-03非常好,很实用,谢谢
- hjl28322013-11-19基于DM9000的UIP移植,没有使用库函数。美中不足。
- diexide2013-08-15不错,值得参考,最近在弄i2c的eeprom,比较有帮助
yuluyangguang
- 粉丝: 4
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功