亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? uip.c

?? freertosV4.40 是一種small的嵌入式系統(tǒng)。利于嵌入式開(kāi)好者入門學(xué)習(xí)嵌入式操作系統(tǒng)。通過(guò)對(duì)于源碼的學(xué)習(xí)可以很好的掌握f(shuō)reertos的運(yùn)行機(jī)制。
?? C
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
/**
 * \addtogroup uip
 * @{
 */

/**
 * \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.62.2.10 2003/10/07 13:23:01 adam Exp $
 *
 */

/*
This is a small implementation of the IP and TCP protocols (as well as
some basic ICMP stuff). The implementation couples the IP, TCP and the
application layers very tightly. To keep the size of the compiled code
down, this code also features heavy usage of the goto statement.

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 upon 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, 40 bytes from the start of the buffer. 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"

/*-----------------------------------------------------------------------------------*/
/* 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 u16_t uip_hostaddr[2] =
  {HTONS((UIP_IPADDR0 << 8) | UIP_IPADDR1),
   HTONS((UIP_IPADDR2 << 8) | UIP_IPADDR3)};
const u16_t uip_arp_draddr[2] =
  {HTONS((UIP_DRIPADDR0 << 8) | UIP_DRIPADDR1),
   HTONS((UIP_DRIPADDR2 << 8) | UIP_DRIPADDR3)};
const u16_t uip_arp_netmask[2] =
  {HTONS((UIP_NETMASK0 << 8) | UIP_NETMASK1),
   HTONS((UIP_NETMASK2 << 8) | UIP_NETMASK3)};
#else
u16_t uip_hostaddr[2];       
u16_t uip_arp_draddr[2], uip_arp_netmask[2];
#endif /* UIP_FIXEDADDR */

u8_t uip_buf[UIP_BUFSIZE+2];   /* The packet buffer that contains
				incoming packets. */
volatile u8_t *uip_appdata;  /* The uip_appdata pointer points to
				application data. */
volatile u8_t *uip_sappdata;  /* The uip_appdata pointer points to the
				 application data which is to be sent. */
#if UIP_URGDATA > 0
volatile u8_t *uip_urgdata;  /* The uip_urgdata pointer points to
				urgent data (out-of-band data), if
				present. */
volatile u8_t uip_urglen, uip_surglen;
#endif /* UIP_URGDATA > 0 */

volatile u16_t uip_len, uip_slen;
                             /* The uip_len is either 8 or 16 bits,
				depending on the maximum packet
				size. */

volatile 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. */

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. */
volatile u8_t uip_acc32[4];
static u8_t c, 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 ICMP_ECHO_REPLY 0
#define ICMP_ECHO       8     

/* Macros. */
#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
#define FBUF ((uip_tcpip_hdr *)&uip_reassbuf[0])
#define ICMPBUF ((uip_icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
#define UDPBUF ((uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])

#if UIP_STATISTICS == 1
struct uip_stats uip_stat;
#define UIP_STAT(s) s
#else
#define UIP_STAT(s)
#endif /* UIP_STATISTICS == 1 */

#if UIP_LOGGING == 1
#include <stdio.h>
void uip_log(char *msg);
#define UIP_LOG(m) uip_log(m)
#else
#define UIP_LOG(m)
#endif /* UIP_LOGGING == 1 */

/*-----------------------------------------------------------------------------------*/
void
uip_init(void)
{
  for(c = 0; c < UIP_LISTENPORTS; ++c) {
    uip_listenports[c] = 0;
  }
  for(c = 0; c < UIP_CONNS; ++c) {
    uip_conns[c].tcpstateflags = CLOSED;
  }
#if UIP_ACTIVE_OPEN
  lastport = 1024;
#endif /* UIP_ACTIVE_OPEN */

#if UIP_UDP
  for(c = 0; c < UIP_UDP_CONNS; ++c) {
    uip_udp_conns[c].lport = 0;
  }
#endif /* UIP_UDP */
  

  /* IPv4 initialization. */
#if UIP_FIXEDADDR == 0
  uip_hostaddr[0] = uip_hostaddr[1] = 0;
#endif /* UIP_FIXEDADDR */

}
/*-----------------------------------------------------------------------------------*/
#if UIP_ACTIVE_OPEN
struct uip_conn *
uip_connect(u16_t *ripaddr, u16_t rport)
{
  register struct uip_conn *conn, *cconn;
  
  /* Find an unused local port. */
 again:
  ++lastport;

  if(lastport >= 32000) {
    lastport = 4096;
  }

  /* Check if this port is already in use, and if so try to find
     another one. */
  for(c = 0; c < UIP_CONNS; ++c) {
    conn = &uip_conns[c];
    if(conn->tcpstateflags != CLOSED &&
       conn->lport == htons(lastport)) {
      goto again;
    }
  }


  conn = 0;
  for(c = 0; c < UIP_CONNS; ++c) {
    cconn = &uip_conns[c]; 
    if(cconn->tcpstateflags == CLOSED) {
      conn = cconn;
      break;
    }
    if(cconn->tcpstateflags == TIME_WAIT) {
      if(conn == 0 ||
	 cconn->timer > uip_conn->timer) {
	conn = cconn;
      }
    }
  }

  if(conn == 0) {
    return 0;
  }
  
  conn->tcpstateflags = SYN_SENT;

  conn->snd_nxt[0] = iss[0];
  conn->snd_nxt[1] = iss[1];
  conn->snd_nxt[2] = iss[2];
  conn->snd_nxt[3] = iss[3];

  conn->initialmss = conn->mss = UIP_TCP_MSS;
  
  conn->len = 1;   /* TCP length of the SYN is one. */
  conn->nrtx = 0;
  conn->timer = 1; /* Send the SYN next time around. */
  conn->rto = UIP_RTO;
  conn->sa = 0;
  conn->sv = 16;
  conn->lport = htons(lastport);
  conn->rport = rport;
  conn->ripaddr[0] = ripaddr[0];
  conn->ripaddr[1] = ripaddr[1];
  
  return conn;
}
#endif /* UIP_ACTIVE_OPEN */
/*-----------------------------------------------------------------------------------*/
#if UIP_UDP
struct uip_udp_conn *
uip_udp_new(u16_t *ripaddr, u16_t rport)
{
  register struct uip_udp_conn *conn;
  
  /* Find an unused local port. */
 again:
  ++lastport;

  if(lastport >= 32000) {
    lastport = 4096;
  }
  
  for(c = 0; c < UIP_UDP_CONNS; ++c) {
    if(uip_udp_conns[c].lport == lastport) {
      goto again;
    }
  }


  conn = 0;
  for(c = 0; c < UIP_UDP_CONNS; ++c) {
    if(uip_udp_conns[c].lport == 0) {
      conn = &uip_udp_conns[c]; 
      break;
    }
  }

  if(conn == 0) {
    return 0;
  }
  
  conn->lport = HTONS(lastport);
  conn->rport = HTONS(rport);
  conn->ripaddr[0] = ripaddr[0];
  conn->ripaddr[1] = ripaddr[1];
  
  return conn;
}
#endif /* UIP_UDP */
/*-----------------------------------------------------------------------------------*/
void
uip_unlisten(u16_t port)
{
  for(c = 0; c < UIP_LISTENPORTS; ++c) {
    if(uip_listenports[c] == port) {
      uip_listenports[c] = 0;
      return;
    }
  }
}
/*-----------------------------------------------------------------------------------*/
void
uip_listen(u16_t port)
{
  for(c = 0; c < UIP_LISTENPORTS; ++c) {
    if(uip_listenports[c] == 0) {
      uip_listenports[c] = port;
      return;
    }
  }
}
/*-----------------------------------------------------------------------------------*/
/* XXX: IP fragment reassembly: not well-tested. */

#if UIP_REASSEMBLY
#define UIP_REASS_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN)
static u8_t uip_reassbuf[UIP_REASS_BUFSIZE];
static u8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)];
static const u8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f,
				    0x0f, 0x07, 0x03, 0x01};
static u16_t uip_reasslen;
static u8_t uip_reassflags;
#define UIP_REASS_FLAG_LASTFRAG 0x01
static u8_t uip_reasstmr;

#define IP_HLEN 20
#define IP_MF   0x20

static u8_t
uip_reass(void)
{
  u16_t offset, len;
  u16_t i;

  /* If ip_reasstmr is zero, no packet is present in the buffer, so we
     write the IP header of the fragment into the reassembly
     buffer. The timer is updated with the maximum age. */
  if(uip_reasstmr == 0) {
    memcpy(uip_reassbuf, &BUF->vhl, IP_HLEN);
    uip_reasstmr = UIP_REASS_MAXAGE;
    uip_reassflags = 0;
    /* Clear the bitmap. */
    memset(uip_reassbitmap, sizeof(uip_reassbitmap), 0);
  }

  /* Check if the incoming fragment matches the one currently present
     in the reasembly buffer. If so, we proceed with copying the
     fragment into the buffer. */
  if(BUF->srcipaddr[0] == FBUF->srcipaddr[0] &&
     BUF->srcipaddr[1] == FBUF->srcipaddr[1] &&
     BUF->destipaddr[0] == FBUF->destipaddr[0] &&
     BUF->destipaddr[1] == FBUF->destipaddr[1] &&
     BUF->ipid[0] == FBUF->ipid[0] &&
     BUF->ipid[1] == FBUF->ipid[1]) {

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99精品视频在线播放观看| 国产日产精品1区| 欧美专区日韩专区| 91麻豆国产福利在线观看| 风间由美一区二区av101 | 国产裸体歌舞团一区二区| 日本中文在线一区| 免费av成人在线| 麻豆免费看一区二区三区| 日韩在线观看一区二区| 视频一区二区国产| 美女尤物国产一区| 久久99久久99| 国产乱码精品一区二区三区五月婷| 久久99精品久久久久久动态图| 久久99在线观看| 国产揄拍国内精品对白| 成人午夜免费视频| 色综合咪咪久久| 欧美日韩免费高清一区色橹橹| 欧美精选一区二区| 日韩欧美一级二级三级久久久| 精品久久免费看| 国产午夜亚洲精品羞羞网站| 国产精品电影一区二区| 1区2区3区欧美| 亚洲成人在线免费| 蜜臀国产一区二区三区在线播放 | 欧美日韩国产综合视频在线观看| 欧美乱妇23p| 日韩免费一区二区| 中文字幕第一区| 亚洲一区二区精品视频| 久久精品国产亚洲高清剧情介绍 | 午夜一区二区三区视频| 久久99精品一区二区三区三区| 国产乱码字幕精品高清av| av影院午夜一区| 欧洲国内综合视频| 久久日一线二线三线suv| 国产精品美女久久久久久2018| 一区二区三区在线观看网站| 日韩不卡一区二区| youjizz国产精品| 欧美猛男男办公室激情| 久久奇米777| 亚洲图片一区二区| 国产在线播放一区二区三区| 色综合久久88色综合天天免费| 91精品综合久久久久久| 国产区在线观看成人精品| 亚洲在线一区二区三区| 精品在线一区二区三区| 色婷婷一区二区| 精品久久人人做人人爰| 亚洲另类在线一区| 久久99国产精品久久99果冻传媒| 欧美成人高清电影在线| 国产精品不卡在线观看| 日韩av在线播放中文字幕| 成人h动漫精品一区二| 欧美一区二区在线免费播放| 国产精品久久国产精麻豆99网站| 麻豆成人久久精品二区三区小说| 色av成人天堂桃色av| 久久尤物电影视频在线观看| 亚洲国产一区视频| 成人久久18免费网站麻豆 | 亚洲国产高清在线观看视频| 天天操天天干天天综合网| 福利电影一区二区| 欧美va亚洲va在线观看蝴蝶网| 亚洲日本丝袜连裤袜办公室| 国产一区二区三区观看| 欧美丰满美乳xxx高潮www| 亚洲人被黑人高潮完整版| 国内成人精品2018免费看| 欧美午夜影院一区| 中文字幕色av一区二区三区| 国产一区二区不卡老阿姨| 欧美精品日韩一区| 亚洲精品久久嫩草网站秘色| 成人在线视频一区二区| 久久综合久久久久88| 肉丝袜脚交视频一区二区| 欧美午夜电影网| 亚洲美女屁股眼交3| 99久久婷婷国产综合精品| 国产丝袜在线精品| 国精品**一区二区三区在线蜜桃| 制服视频三区第一页精品| 亚洲一区二区三区四区在线观看| 一本一道久久a久久精品综合蜜臀| 国产偷国产偷精品高清尤物| 久久不见久久见免费视频1| 69堂国产成人免费视频| 亚洲成人在线网站| 欧美日韩三级视频| 亚洲第一成年网| 欧美丝袜丝nylons| 一区二区三区在线影院| 色综合天天综合| 亚洲天堂成人在线观看| 成人aaaa免费全部观看| 国产精品―色哟哟| 波多野结衣91| 国产精品国产三级国产普通话三级 | 免费观看在线综合色| 日韩一区二区三区免费观看| 日韩电影一区二区三区四区| 欧美日韩国产影片| 日韩精品1区2区3区| 日韩欧美在线123| 久草热8精品视频在线观看| 久久免费视频一区| 高清国产一区二区三区| 中文字幕在线不卡| 一本大道久久a久久精品综合| 日韩久久一区二区| 在线看不卡av| 丝袜美腿一区二区三区| 欧美一区二区三区视频免费 | 国产一区二区三区在线观看免费 | 欧洲色大大久久| 天堂va蜜桃一区二区三区漫画版| 在线播放中文一区| 青青青爽久久午夜综合久久午夜| 精品久久久久久无| 国产福利电影一区二区三区| 中文字幕一区在线观看| 91丝袜国产在线播放| 亚洲国产欧美日韩另类综合 | 精品久久久久久久人人人人传媒 | xvideos.蜜桃一区二区| 国产xxx精品视频大全| 亚洲人成影院在线观看| 欧美日韩午夜在线| 日本不卡的三区四区五区| 久久一夜天堂av一区二区三区| 欧美一卡2卡3卡4卡| 麻豆精品视频在线观看免费| 国产欧美视频在线观看| 在线国产电影不卡| 麻豆成人在线观看| 国产精品久久久久久久久免费丝袜 | 亚洲乱码国产乱码精品精98午夜| 欧美人与禽zozo性伦| 极品少妇xxxx精品少妇| 国产精品久久久久aaaa| 欧美日韩视频专区在线播放| 国产一区二区三区综合| 樱花草国产18久久久久| 欧美大片国产精品| 99久免费精品视频在线观看| 日韩国产欧美在线播放| 日本一区二区综合亚洲| 欧美日韩极品在线观看一区| 丰满少妇久久久久久久| 天堂在线一区二区| 国产精品理伦片| 欧美一卡2卡三卡4卡5免费| 成人福利视频在线| 免费成人你懂的| 亚洲美女精品一区| 久久久久久久久99精品| 精品视频在线看| 成人一区二区三区视频| 日韩国产高清影视| 综合久久久久久| 久久久久久免费毛片精品| 欧美日韩国产综合视频在线观看| 国产aⅴ综合色| 美女久久久精品| 亚洲一区在线观看视频| 国产农村妇女毛片精品久久麻豆| 欧美日韩一区二区欧美激情| 不卡一区在线观看| 国产最新精品免费| 日本亚洲欧美天堂免费| 亚洲一区免费观看| 国产精品成人一区二区三区夜夜夜| 欧美大白屁股肥臀xxxxxx| 在线观看欧美精品| 色综合视频在线观看| 成人激情文学综合网| 精彩视频一区二区| 日韩在线观看一区二区| 亚洲最大的成人av| 亚洲私人黄色宅男| 国产日韩欧美在线一区| 精品伦理精品一区| 日韩一区二区中文字幕| 欧美日韩一区二区三区四区五区| 91麻豆免费看| 成人18精品视频| eeuss鲁片一区二区三区在线观看| 国产精品夜夜爽| 国内精品视频666| 久久 天天综合| 国模冰冰炮一区二区|