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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tcp.c

?? 基于AT91SAM7x256的硬件平臺的WEB服務器源碼(A&shy DS版本, ucOS_II+LWIP+自己編寫的DNS查詢工具)
?? C
?? 第 1 頁 / 共 3 頁
字號:
/** * @file * * Transmission Control Protocol for IP * * This file contains common functions for the TCP implementation, such as functinos * for manipulating the data structures and the TCP timer functions. TCP functions * related to input and output is found in tcp_in.c and tcp_out.c respectively. * *//* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * 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 lwIP TCP/IP stack. *  * Author: Adam Dunkels <adam@sics.se> * */#include <string.h>#include "lwip/opt.h"#include "lwip/def.h"#include "lwip/mem.h"#include "lwip/memp.h"#include "lwip/tcp.h"#if LWIP_TCP/* Incremented every coarse grained timer shot   (typically every 500 ms, determined by TCP_COARSE_TIMEOUT). */u32_t tcp_ticks;const u8_t tcp_backoff[13] =    { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7};/* The TCP PCB lists. *//** List of all TCP PCBs in LISTEN state */union tcp_listen_pcbs_t tcp_listen_pcbs;/** List of all TCP PCBs that are in a state in which * they accept or send data. */struct tcp_pcb *tcp_active_pcbs;  /** List of all TCP PCBs in TIME-WAIT state */struct tcp_pcb *tcp_tw_pcbs;struct tcp_pcb *tcp_tmp_pcb;static u8_t tcp_timer;static u16_t tcp_new_port(void);/** * Initializes the TCP layer. */voidtcp_init(void){  /* Clear globals. */  tcp_listen_pcbs.listen_pcbs = NULL;  tcp_active_pcbs = NULL;  tcp_tw_pcbs = NULL;  tcp_tmp_pcb = NULL;    /* initialize timer */  tcp_ticks = 0;  tcp_timer = 0;  }/** * Called periodically to dispatch TCP timers. * */voidtcp_tmr(void){  /* Call tcp_fasttmr() every 250 ms */  tcp_fasttmr();  if (++tcp_timer & 1) {    /* Call tcp_tmr() every 500 ms, i.e., every other timer       tcp_tmr() is called. */    tcp_slowtmr();  }}/** * Closes the connection held by the PCB. * */err_ttcp_close(struct tcp_pcb *pcb){  err_t err;#if TCP_DEBUG  LWIP_DEBUGF(TCP_DEBUG, ("tcp_close: closing in state "));  tcp_debug_print_state(pcb->state);  LWIP_DEBUGF(TCP_DEBUG, ("\n"));#endif /* TCP_DEBUG */  switch (pcb->state) {  case CLOSED:    /* Closing a pcb in the CLOSED state might seem erroneous,     * however, it is in this state once allocated and as yet unused     * and the user needs some way to free it should the need arise.     * Calling tcp_close() with a pcb that has already been closed, (i.e. twice)     * or for a pcb that has been used and then entered the CLOSED state      * is erroneous, but this should never happen as the pcb has in those cases     * been freed, and so any remaining handles are bogus. */    err = ERR_OK;    memp_free(MEMP_TCP_PCB, pcb);    pcb = NULL;    break;  case LISTEN:    err = ERR_OK;    tcp_pcb_remove((struct tcp_pcb **)&tcp_listen_pcbs.pcbs, pcb);    memp_free(MEMP_TCP_PCB_LISTEN, pcb);    pcb = NULL;    break;  case SYN_SENT:    err = ERR_OK;    tcp_pcb_remove(&tcp_active_pcbs, pcb);    memp_free(MEMP_TCP_PCB, pcb);    pcb = NULL;    break;  case SYN_RCVD:  case ESTABLISHED:    err = tcp_send_ctrl(pcb, TCP_FIN);    if (err == ERR_OK) {      pcb->state = FIN_WAIT_1;    }    break;  case CLOSE_WAIT:    err = tcp_send_ctrl(pcb, TCP_FIN);    if (err == ERR_OK) {      pcb->state = LAST_ACK;    }    break;  default:    /* Has already been closed, do nothing. */    err = ERR_OK;    pcb = NULL;    break;  }  if (pcb != NULL && err == ERR_OK) {    err = tcp_output(pcb);  }  return err;}/** * Aborts a connection by sending a RST to the remote host and deletes * the local protocol control block. This is done when a connection is * killed because of shortage of memory. * */voidtcp_abort(struct tcp_pcb *pcb){  u32_t seqno, ackno;  u16_t remote_port, local_port;  struct ip_addr remote_ip, local_ip;#if LWIP_CALLBACK_API    void (* errf)(void *arg, err_t err);#endif /* LWIP_CALLBACK_API */  void *errf_arg;    /* Figure out on which TCP PCB list we are, and remove us. If we     are in an active state, call the receive function associated with     the PCB with a NULL argument, and send an RST to the remote end. */  if (pcb->state == TIME_WAIT) {    tcp_pcb_remove(&tcp_tw_pcbs, pcb);    memp_free(MEMP_TCP_PCB, pcb);  } else {    seqno = pcb->snd_nxt;    ackno = pcb->rcv_nxt;    ip_addr_set(&local_ip, &(pcb->local_ip));    ip_addr_set(&remote_ip, &(pcb->remote_ip));    local_port = pcb->local_port;    remote_port = pcb->remote_port;#if LWIP_CALLBACK_API    errf = pcb->errf;#endif /* LWIP_CALLBACK_API */    errf_arg = pcb->callback_arg;    tcp_pcb_remove(&tcp_active_pcbs, pcb);    if (pcb->unacked != NULL) {      tcp_segs_free(pcb->unacked);    }    if (pcb->unsent != NULL) {      tcp_segs_free(pcb->unsent);    }#if TCP_QUEUE_OOSEQ        if (pcb->ooseq != NULL) {      tcp_segs_free(pcb->ooseq);    }#endif /* TCP_QUEUE_OOSEQ */    memp_free(MEMP_TCP_PCB, pcb);    TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT);    LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abort: sending RST\n"));    tcp_rst(seqno, ackno, &local_ip, &remote_ip, local_port, remote_port);  }}/** * Binds the connection to a local portnumber and IP address. If the * IP address is not given (i.e., ipaddr == NULL), the IP address of * the outgoing network interface is used instead. * */err_ttcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port){  struct tcp_pcb *cpcb;  if (port == 0) {    port = tcp_new_port();  }  /* Check if the address already is in use. */  for(cpcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs;      cpcb != NULL; cpcb = cpcb->next) {    if (cpcb->local_port == port) {      if (ip_addr_isany(&(cpcb->local_ip)) ||        ip_addr_isany(ipaddr) ||        ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {          return ERR_USE;      }    }  }  for(cpcb = tcp_active_pcbs;      cpcb != NULL; cpcb = cpcb->next) {    if (cpcb->local_port == port) {      if (ip_addr_isany(&(cpcb->local_ip)) ||   ip_addr_isany(ipaddr) ||   ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {  return ERR_USE;      }    }  }  if (!ip_addr_isany(ipaddr)) {    pcb->local_ip = *ipaddr;  }  pcb->local_port = port;  LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %"U16_F"\n", port));  return ERR_OK;}#if LWIP_CALLBACK_APIstatic err_ttcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err){  (void)arg;  (void)pcb;  (void)err;  return ERR_ABRT;}#endif /* LWIP_CALLBACK_API *//** * Set the state of the connection to be LISTEN, which means that it * is able to accept incoming connections. The protocol control block * is reallocated in order to consume less memory. Setting the * connection to LISTEN is an irreversible process. * */struct tcp_pcb *tcp_listen(struct tcp_pcb *pcb){  struct tcp_pcb_listen *lpcb;  /* already listening? */  if (pcb->state == LISTEN) {    return pcb;  }  lpcb = memp_malloc(MEMP_TCP_PCB_LISTEN);  if (lpcb == NULL) {    return NULL;  }  lpcb->callback_arg = pcb->callback_arg;  lpcb->local_port = pcb->local_port;  lpcb->state = LISTEN;  lpcb->so_options = pcb->so_options;  lpcb->so_options |= SOF_ACCEPTCONN;  lpcb->ttl = pcb->ttl;  lpcb->tos = pcb->tos;  ip_addr_set(&lpcb->local_ip, &pcb->local_ip);  memp_free(MEMP_TCP_PCB, pcb);#if LWIP_CALLBACK_API  lpcb->accept = tcp_accept_null;#endif /* LWIP_CALLBACK_API */  TCP_REG(&tcp_listen_pcbs.listen_pcbs, lpcb);  return (struct tcp_pcb *)lpcb;}/** * This function should be called by the application when it has * processed the data. The purpose is to advertise a larger window * when the data has been processed. * */voidtcp_recved(struct tcp_pcb *pcb, u16_t len){  if ((u32_t)pcb->rcv_wnd + len > TCP_WND) {    pcb->rcv_wnd = TCP_WND;  } else {    pcb->rcv_wnd += len;  }  if (!(pcb->flags & TF_ACK_DELAY) &&     !(pcb->flags & TF_ACK_NOW)) {    /*     * We send an ACK here (if one is not already pending, hence     * the above tests) as tcp_recved() implies that the application     * has processed some data, and so we can open the receiver's     * window to allow more to be transmitted.  This could result in     * two ACKs being sent for each received packet in some limited cases     * (where the application is only receiving data, and is slow to     * process it) but it is necessary to guarantee that the sender can     * continue to transmit.     */    tcp_ack(pcb);  }   else if (pcb->flags & TF_ACK_DELAY && pcb->rcv_wnd >= TCP_WND/2) {    /* If we can send a window update such that there is a full     * segment available in the window, do so now.  This is sort of     * nagle-like in its goals, and tries to hit a compromise between     * sending acks each time the window is updated, and only sending     * window updates when a timer expires.  The "threshold" used     * above (currently TCP_WND/2) can be tuned to be more or less     * aggressive  */    tcp_ack_now(pcb);  }  LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %"U16_F" bytes, wnd %"U16_F" (%"U16_F").\n",         len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd));}/** * A nastly hack featuring 'goto' statements that allocates a * new TCP local port. */static u16_ttcp_new_port(void){  struct tcp_pcb *pcb;#ifndef TCP_LOCAL_PORT_RANGE_START#define TCP_LOCAL_PORT_RANGE_START 4096#define TCP_LOCAL_PORT_RANGE_END   0x7fff#endif  static u16_t port = TCP_LOCAL_PORT_RANGE_START;   again:  if (++port > TCP_LOCAL_PORT_RANGE_END) {    port = TCP_LOCAL_PORT_RANGE_START;  }    for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {    if (pcb->local_port == port) {      goto again;    }  }  for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {    if (pcb->local_port == port) {      goto again;    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产亚洲精品超碰| 午夜av区久久| 天堂av在线一区| 国产一区二区在线视频| 91麻豆精品一区二区三区| 5月丁香婷婷综合| 亚洲欧美自拍偷拍| 激情综合一区二区三区| 欧美日韩精品系列| 国产精品国模大尺度视频| 美女国产一区二区| 91丨porny丨户外露出| 国产亚洲一区字幕| 久久成人麻豆午夜电影| 欧美性猛片xxxx免费看久爱| 国产欧美日韩在线观看| 久久国产夜色精品鲁鲁99| 在线观看日韩一区| 成人免费在线视频观看| 国产成人精品免费网站| 日韩一区二区三区视频| 亚洲与欧洲av电影| 91麻豆成人久久精品二区三区| 久久人人爽人人爽| 精品亚洲国产成人av制服丝袜 | 美女视频网站黄色亚洲| 色天使久久综合网天天| 欧美国产成人精品| 成人精品免费视频| 国产日韩欧美电影| 国产精品综合在线视频| 久久影院电视剧免费观看| 日本欧美大码aⅴ在线播放| 欧美无人高清视频在线观看| 亚洲美女电影在线| 色综合中文字幕| 亚洲视频1区2区| 91丨九色丨蝌蚪丨老版| 亚洲免费观看视频| 欧美影院午夜播放| 日韩福利电影在线| 欧美一级片在线观看| 青娱乐精品视频| 日韩午夜在线影院| 国产永久精品大片wwwapp | 美女视频免费一区| 精品久久久久99| 国产综合久久久久影院| 久久婷婷一区二区三区| 国产传媒日韩欧美成人| 国产精品毛片无遮挡高清| 99久久99久久精品免费观看| 亚洲激情欧美激情| 欧美一区二区视频在线观看| 久久精品国产精品亚洲综合| 久久久精品综合| 不卡电影免费在线播放一区| 亚洲天堂av一区| 欧美久久一区二区| 另类小说图片综合网| 欧美极品少妇xxxxⅹ高跟鞋| 色综合咪咪久久| 日本美女一区二区| 国产欧美日韩一区二区三区在线观看| 99久久久久久99| 亚洲444eee在线观看| 精品国产123| 99久久久国产精品免费蜜臀| 婷婷六月综合网| 国产欧美精品一区| 欧美日韩国产免费| 成人国产一区二区三区精品| 亚洲国产精品尤物yw在线观看| 精品久久久久一区| 在线这里只有精品| 国产一区二区三区四区五区美女| 亚洲视频一区二区在线观看| 欧美日韩高清影院| 成人黄动漫网站免费app| 奇米一区二区三区| 亚洲精品免费看| 欧美mv日韩mv亚洲| 欧美日韩免费一区二区三区| 国产精品乡下勾搭老头1| 亚洲二区在线视频| 成人欧美一区二区三区| 日韩欧美激情在线| 欧美亚日韩国产aⅴ精品中极品| 国产麻豆精品久久一二三| 午夜精品久久久久久久99水蜜桃 | 狠狠色丁香婷婷综合久久片| 玉足女爽爽91| 欧美国产激情二区三区 | 91一区二区三区在线播放| 狠狠色综合色综合网络| 亚欧色一区w666天堂| 国产精品久久久久久亚洲毛片 | 美女视频一区二区三区| 夜夜嗨av一区二区三区中文字幕 | 欧美成人激情免费网| 色综合久久综合中文综合网| 国产精品12区| 免费成人在线视频观看| 一区二区三区产品免费精品久久75| 亚洲精品在线免费观看视频| 欧美久久一区二区| 欧美体内she精视频| 91免费视频观看| 成人黄色小视频| 成人网在线播放| 国产一区二区精品久久| 久久不见久久见免费视频1| 五月天网站亚洲| 亚洲成人一区二区在线观看| 亚洲精品伦理在线| 亚洲摸摸操操av| 亚洲精品国产第一综合99久久| 中文字幕五月欧美| 一区在线中文字幕| 国产精品国产三级国产普通话三级 | 亚洲人成网站色在线观看| 国产精品福利av| 欧美激情一区二区| 国产精品麻豆视频| 亚洲色大成网站www久久九九| 国产精品久久久久四虎| 亚洲欧美日韩在线| 亚洲一区中文日韩| 日本欧美一区二区| 韩国三级电影一区二区| 韩日精品视频一区| 粉嫩一区二区三区性色av| 成人国产精品免费| 91国内精品野花午夜精品| 欧美日韩日日骚| 91麻豆精品91久久久久同性| 精品动漫一区二区三区在线观看| 337p日本欧洲亚洲大胆精品 | 色综合久久综合网97色综合| 在线观看一区不卡| 一区二区三区欧美日| 亚洲图片你懂的| 亚洲va欧美va国产va天堂影院| 青青草精品视频| 国产精品自拍网站| 不卡一区在线观看| 欧美日韩精品欧美日韩精品一综合| 6080yy午夜一二三区久久| 久久精品欧美日韩精品| 亚洲精品国产品国语在线app| 日韩国产欧美视频| 高清在线成人网| 欧美视频一二三区| 久久久亚洲综合| 亚洲综合免费观看高清在线观看| 蜜桃久久久久久| www.亚洲色图.com| 欧美一级夜夜爽| 国产精品精品国产色婷婷| 日本三级亚洲精品| bt欧美亚洲午夜电影天堂| 91.xcao| 中文字幕日本乱码精品影院| 亚洲宅男天堂在线观看无病毒| 精品亚洲免费视频| 欧美日韩午夜在线| 国产精品久久看| 美女网站色91| 欧美亚洲精品一区| 国产欧美一区视频| 日产国产高清一区二区三区 | 91福利视频网站| 久久精品人人做人人综合| 一区二区三区日韩欧美| 国产激情一区二区三区桃花岛亚洲| 欧美在线你懂的| 国产精品成人免费| 国产美女久久久久| 91精品免费观看| 亚洲欧美二区三区| av成人免费在线观看| 精品免费一区二区三区| 亚洲成av人影院| 一本大道久久a久久综合婷婷| 久久综合久久久久88| 免费人成在线不卡| 在线一区二区观看| 自拍视频在线观看一区二区| 国产精品一区在线观看你懂的| 制服视频三区第一页精品| 亚洲综合一区二区| 一本高清dvd不卡在线观看| 国产精品国产三级国产有无不卡| 国产麻豆91精品| 久久蜜臀精品av| 国产一区二区三区精品欧美日韩一区二区三区 | 国产精品三级av| 国产精品香蕉一区二区三区| 日韩精品资源二区在线| 日韩精品一二三|