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

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

?? tcp_in.c

?? MCS-51的一個(gè)Free小型操作系統(tǒng),在KeilC中下編譯工作
?? C
?? 第 1 頁 / 共 3 頁
字號(hào):
/** * @file * * Transmission Control Protocol, incoming traffic * * The input processing functions of TCP. * * These functions are generally called in the order (ip_input() ->) tcp_input() -> * tcp_process() -> tcp_receive() (-> application). *  *//* * 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 "lwip/def.h"#include "lwip/opt.h"#include "lwip/ip_addr.h"#include "lwip/netif.h"#include "lwip/mem.h"#include "lwip/memp.h"#include "lwip/inet.h"#include "lwip/tcp.h"#include "lwip/stats.h"#include "arch/perf.h"#if LWIP_TCP/* These variables are global to all functions involved in the input   processing of TCP segments. They are set by the tcp_input()   function. */static struct tcp_seg inseg;static struct tcp_hdr *tcphdr;static struct ip_hdr *iphdr;static u32_t seqno, ackno;static u8_t flags;static u16_t tcplen;static u8_t recv_flags;static struct pbuf *recv_data;struct tcp_pcb *tcp_input_pcb;/* Forward declarations. */static err_t tcp_process(struct tcp_pcb *pcb);static void tcp_receive(struct tcp_pcb *pcb);static void tcp_parseopt(struct tcp_pcb *pcb);static err_t tcp_listen_input(struct tcp_pcb_listen *pcb);static err_t tcp_timewait_input(struct tcp_pcb *pcb);/* tcp_input: * * The initial input processing of TCP. It verifies the TCP header, demultiplexes * the segment between the PCBs and passes it on to tcp_process(), which implements * the TCP finite state machine. This function is called by the IP layer (in * ip_input()). */voidtcp_input(struct pbuf *p, struct netif *inp){  struct tcp_pcb *pcb, *prev;  struct tcp_pcb_listen *lpcb;  u8_t hdrlen;  err_t err;#if SO_REUSE  struct tcp_pcb *pcb_temp;  int reuse = 0;  int reuse_port = 0;#endif /* SO_REUSE */  PERF_START;  TCP_STATS_INC(tcp.recv);  iphdr = p->payload;  tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);#if TCP_INPUT_DEBUG  tcp_debug_print(tcphdr);#endif  /* remove header from payload */  if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) {    /* drop short packets */    LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%u bytes) discarded\n", p->tot_len));    TCP_STATS_INC(tcp.lenerr);    TCP_STATS_INC(tcp.drop);    pbuf_free(p);    return;  }  /* Don't even process incoming broadcasts/multicasts. */  if (ip_addr_isbroadcast(&(iphdr->dest), inp) ||      ip_addr_ismulticast(&(iphdr->dest))) {    pbuf_free(p);    return;  }#if CHECKSUM_CHECK_TCP  /* Verify TCP checksum. */  if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),      (struct ip_addr *)&(iphdr->dest),      IP_PROTO_TCP, p->tot_len) != 0) {      LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04x\n",        inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), (struct ip_addr *)&(iphdr->dest),      IP_PROTO_TCP, p->tot_len)));#if TCP_DEBUG    tcp_debug_print(tcphdr);#endif /* TCP_DEBUG */    TCP_STATS_INC(tcp.chkerr);    TCP_STATS_INC(tcp.drop);    pbuf_free(p);    return;  }#endif  /* Move the payload pointer in the pbuf so that it points to the     TCP data instead of the TCP header. */  hdrlen = TCPH_HDRLEN(tcphdr);  pbuf_header(p, -(hdrlen * 4));  /* Convert fields in TCP header to host byte order. */  tcphdr->src = ntohs(tcphdr->src);  tcphdr->dest = ntohs(tcphdr->dest);  seqno = tcphdr->seqno = ntohl(tcphdr->seqno);  ackno = tcphdr->ackno = ntohl(tcphdr->ackno);  tcphdr->wnd = ntohs(tcphdr->wnd);  flags = TCPH_FLAGS(tcphdr) & TCP_FLAGS;  tcplen = p->tot_len + ((flags & TCP_FIN || flags & TCP_SYN)? 1: 0);  /* Demultiplex an incoming segment. First, we check if it is destined     for an active connection. */  prev = NULL;#if SO_REUSE  pcb_temp = tcp_active_pcbs;   again_1:    /* Iterate through the TCP pcb list for a fully matching pcb */  for(pcb = pcb_temp; pcb != NULL; pcb = pcb->next) {#else  /* SO_REUSE */  for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {#endif  /* SO_REUSE */    LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED);    LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);    LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN);    if (pcb->remote_port == tcphdr->src &&       pcb->local_port == tcphdr->dest &&       ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) &&       ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) {#if SO_REUSE      if(pcb->so_options & SOF_REUSEPORT) {        if(reuse) {          /* We processed one PCB already */          LWIP_DEBUGF(TCP_INPUT_DEBUG,("tcp_input: second or later PCB and SOF_REUSEPORT set.\n"));        } else {          /* First PCB with this address */          LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: first PCB and SOF_REUSEPORT set.\n"));          reuse = 1;        }                reuse_port = 1;         p->ref++;                /* We want to search on next socket after receiving */        pcb_temp = pcb->next;                LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: reference counter on PBUF set to %i\n", p->ref));      } else  {        if(reuse) {          /* We processed one PCB already */          LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: second or later PCB but SOF_REUSEPORT not set !\n"));        }      }#endif /* SO_REUSE */      /* Move this PCB to the front of the list so that subsequent   lookups will be faster (we exploit locality in TCP segment   arrivals). */      LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb);      if (prev != NULL) {  prev->next = pcb->next;  pcb->next = tcp_active_pcbs;  tcp_active_pcbs = pcb;      }      LWIP_ASSERT("tcp_input: pcb->next != pcb (after cache)", pcb->next != pcb);      break;    }    prev = pcb;  }  if (pcb == NULL) {    /* If it did not go to an active connection, we check the connections       in the TIME-WAIT state. */    for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {      LWIP_ASSERT("tcp_input: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);      if (pcb->remote_port == tcphdr->src &&   pcb->local_port == tcphdr->dest &&   ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) &&         ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) {  /* We don't really care enough to move this PCB to the front     of the list since we are not very likely to receive that     many segments for connections in TIME-WAIT. */  LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n"));  tcp_timewait_input(pcb);  pbuf_free(p);  return;      }    }  /* Finally, if we still did not get a match, we check all PCBs that     are LISTENing for incoming connections. */    prev = NULL;    for(lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {      if ((ip_addr_isany(&(lpcb->local_ip)) ||    ip_addr_cmp(&(lpcb->local_ip), &(iphdr->dest))) &&   lpcb->local_port == tcphdr->dest) {  /* Move this PCB to the front of the list so that subsequent     lookups will be faster (we exploit locality in TCP segment     arrivals). */  if (prev != NULL) {    ((struct tcp_pcb_listen *)prev)->next = lpcb->next;          /* our successor is the remainder of the listening list */    lpcb->next = tcp_listen_pcbs.listen_pcbs;          /* put this listening pcb at the head of the listening list */    tcp_listen_pcbs.listen_pcbs = lpcb;  }  LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n"));  tcp_listen_input(lpcb);  pbuf_free(p);  return;      }      prev = (struct tcp_pcb *)lpcb;    }  }#if TCP_INPUT_DEBUG  LWIP_DEBUGF(TCP_INPUT_DEBUG, ("+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags "));  tcp_debug_print_flags(TCPH_FLAGS(tcphdr));  LWIP_DEBUGF(TCP_INPUT_DEBUG, ("-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n"));#endif /* TCP_INPUT_DEBUG */  if (pcb != NULL) {    /* The incoming segment belongs to a connection. */#if TCP_INPUT_DEBUG#if TCP_DEBUG    tcp_debug_print_state(pcb->state);#endif /* TCP_DEBUG */#endif /* TCP_INPUT_DEBUG */    /* Set up a tcp_seg structure. */    inseg.next = NULL;    inseg.len = p->tot_len;    inseg.dataptr = p->payload;    inseg.p = p;    inseg.tcphdr = tcphdr;    recv_data = NULL;    recv_flags = 0;    tcp_input_pcb = pcb;    err = tcp_process(pcb);    tcp_input_pcb = NULL;    /* A return value of ERR_ABRT means that tcp_abort() was called       and that the pcb has been freed. If so, we don't do anything. */    if (err != ERR_ABRT) {      if (recv_flags & TF_RESET) {  /* TF_RESET means that the connection was reset by the other     end. We then call the error callback to inform the     application that the connection is dead before we     deallocate the PCB. */  TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST);  tcp_pcb_remove(&tcp_active_pcbs, pcb);  memp_free(MEMP_TCP_PCB, pcb);      } else if (recv_flags & TF_CLOSED) {  /* The connection has been closed and we will deallocate the     PCB. */  tcp_pcb_remove(&tcp_active_pcbs, pcb);  memp_free(MEMP_TCP_PCB, pcb);      } else {  err = ERR_OK;  /* If the application has registered a "sent" function to be     called when new send buffer space is available, we call it     now. */  if (pcb->acked > 0) {    TCP_EVENT_SENT(pcb, pcb->acked, err);  }  if (recv_data != NULL) {    /* Notify application that data has been received. */    TCP_EVENT_RECV(pcb, recv_data, ERR_OK, err);  }  /* If a FIN segment was received, we call the callback     function with a NULL buffer to indicate EOF. */  if (recv_flags & TF_GOT_FIN) {    TCP_EVENT_RECV(pcb, NULL, ERR_OK, err);  }  /* If there were no errors, we try to send something out. */  if (err == ERR_OK) {    tcp_output(pcb);  }      }    }    /* We deallocate the incoming pbuf. If it was buffered by the       application, the application should have called pbuf_ref() to       increase the reference counter in the pbuf. If so, the buffer       isn't actually deallocated by the call to pbuf_free(), only the       reference count is decreased. */    if (inseg.p != NULL) pbuf_free(inseg.p);#if TCP_INPUT_DEBUG#if TCP_DEBUG    tcp_debug_print_state(pcb->state);#endif /* TCP_DEBUG */#endif /* TCP_INPUT_DEBUG */#if SO_REUSE    /* First socket should receive now */    if(reuse_port) {      LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: searching next PCB.\n"));      reuse_port = 0;            /* We are searching connected sockets */      goto again_1;    }#endif /* SO_REUSE */  } else {#if SO_REUSE    if(reuse) {      LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: freeing PBUF with reference counter set to %i\n", p->ref));      pbuf_free(p);      goto end;    }#endif /* SO_REUSE */    /* If no matching PCB was found, send a TCP RST (reset) to the       sender. */    LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n"));    if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) {      TCP_STATS_INC(tcp.proterr);      TCP_STATS_INC(tcp.drop);      tcp_rst(ackno, seqno + tcplen,        &(iphdr->dest), &(iphdr->src),        tcphdr->dest, tcphdr->src);    }    pbuf_free(p);  }#if SO_REUSE end:#endif /* SO_REUSE */  LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane());  PERF_STOP("tcp_input");}/* tcp_listen_input(): * * Called by tcp_input() when a segment arrives for a listening * connection. */static err_ttcp_listen_input(struct tcp_pcb_listen *pcb){  struct tcp_pcb *npcb;  u32_t optdata;  /* In the LISTEN state, we check for incoming SYN segments,     creates a new PCB, and responds with a SYN|ACK. */  if (flags & TCP_ACK) {    /* For incoming segments with the ACK flag set, respond with a       RST. */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色琪琪一区二区三区亚洲区| 国产精品久久久久久久浪潮网站| 色丁香久综合在线久综合在线观看| 狠狠色伊人亚洲综合成人| 亚洲高清三级视频| 一区二区三区在线观看动漫| 国产精品电影院| 日本一区二区三区视频视频| 久久久www成人免费毛片麻豆| 91精品国产黑色紧身裤美女| 欧美日韩国产大片| 欧洲国内综合视频| 日本道免费精品一区二区三区| 福利一区在线观看| 国产精品一色哟哟哟| 久久精品国产精品亚洲综合| 亚洲不卡一区二区三区| 亚洲成人三级小说| 日韩二区在线观看| 免费在线看成人av| 久久激情五月婷婷| 韩国成人精品a∨在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 久久精品免费观看| 韩国午夜理伦三级不卡影院| 狠狠色综合播放一区二区| 国内一区二区视频| 成人精品免费看| 不卡的av网站| 91国偷自产一区二区开放时间| 在线精品观看国产| 欧美一级视频精品观看| 精品噜噜噜噜久久久久久久久试看| 日韩视频一区二区| 久久中文字幕电影| 久久精品一区二区三区不卡牛牛 | 精品国产乱码久久久久久浪潮| 7777女厕盗摄久久久| 日韩欧美一二三| 2021中文字幕一区亚洲| 国产欧美在线观看一区| 国产精品欧美精品| 亚洲欧美色一区| 午夜精品久久久久久久久| 毛片一区二区三区| 国产精品一二三区| 91色乱码一区二区三区| 欧美色网站导航| 日韩精品一区二区三区三区免费 | 亚洲一二三四区| 日日摸夜夜添夜夜添亚洲女人| 久久精品国产99久久6| 国产在线观看一区二区| av激情综合网| 国产欧美日韩在线| 日韩一区中文字幕| 日韩va欧美va亚洲va久久| 国产麻豆午夜三级精品| 99re这里都是精品| 91精品国产色综合久久| 国产色综合久久| 午夜免费久久看| 国产成人免费网站| 67194成人在线观看| 久久久99久久| 五月天国产精品| 国产盗摄女厕一区二区三区| 日本伦理一区二区| 精品福利在线导航| 亚洲一区二区四区蜜桃| 国产精品91xxx| 欧美日韩激情一区二区| 久久久精品tv| 日韩成人一级大片| 99久久精品一区二区| 日韩亚洲电影在线| 亚洲激情第一区| 国产精品一区二区免费不卡 | 一区二区三区在线不卡| 激情综合网av| 欧美视频日韩视频在线观看| 欧美高清在线精品一区| 亚洲一区二区欧美| 成人免费视频一区| 精品久久久三级丝袜| 亚洲一区日韩精品中文字幕| 国产99久久久国产精品免费看| 91精品国产色综合久久不卡电影 | 97国产精品videossex| 精品免费视频.| 亚洲成人免费观看| 99久久久久免费精品国产| 69成人精品免费视频| 一区二区三区国产精品| av高清久久久| 国产日韩欧美电影| 久久国产成人午夜av影院| 在线看国产一区二区| 日韩理论在线观看| 不卡电影一区二区三区| 久久久久国产成人精品亚洲午夜| 日韩制服丝袜av| 欧美日韩电影在线| 一区二区激情小说| 日本韩国欧美国产| 亚洲精品中文在线| 91丨九色丨蝌蚪富婆spa| 国产精品免费av| 粉嫩13p一区二区三区| 久久久久亚洲蜜桃| jizz一区二区| 国产亚洲一区字幕| 国产一区二区三区免费看| 日韩免费高清电影| 图片区小说区国产精品视频| 色老汉av一区二区三区| 国产精品视频九色porn| 国产精品12区| 国产日韩高清在线| 国产成人免费视| 国产精品女同互慰在线看| 成人免费视频网站在线观看| 国产精品―色哟哟| 国产不卡免费视频| 日本一区二区三区视频视频| 国产成人综合在线播放| 国产日韩欧美不卡在线| 成人亚洲一区二区一| 国产精品色眯眯| 91免费看片在线观看| 亚洲激情欧美激情| 欧美日韩精品欧美日韩精品| 午夜av电影一区| 在线播放视频一区| 麻豆精品一二三| 久久久久久久免费视频了| 成人夜色视频网站在线观看| 日韩伦理电影网| 欧美精选在线播放| 韩国女主播一区| 自拍偷自拍亚洲精品播放| 欧美性生交片4| 麻豆中文一区二区| 久久精品亚洲一区二区三区浴池| 成人免费视频网站在线观看| 亚洲日本在线看| 欧美高清激情brazzers| 国产一区视频导航| 中文字幕欧美一| 欧美丰满一区二区免费视频 | 色综合天天综合网天天看片| 国产精品日韩成人| 91小视频在线免费看| 亚洲人午夜精品天堂一二香蕉| 91国产丝袜在线播放| 奇米色一区二区三区四区| 久久综合av免费| 一本大道久久精品懂色aⅴ| 视频一区免费在线观看| 欧美精品一区二区三区蜜桃| 成人97人人超碰人人99| 亚洲18色成人| 中文字幕乱码日本亚洲一区二区| 欧美影院一区二区| 国产一区二区女| 亚洲视频免费观看| 日韩精品一区二区在线| 91污在线观看| 久久精品国产免费看久久精品| 亚洲国产精品国自产拍av| 欧美日韩久久一区二区| 成人午夜在线视频| 五月激情综合婷婷| 日韩欧美美女一区二区三区| 成人听书哪个软件好| 亚洲午夜激情av| 久久婷婷色综合| 欧美日本一区二区三区四区| 国产精品一区2区| 亚洲bt欧美bt精品| 中文字幕不卡在线| 91精品久久久久久久91蜜桃| 99精品在线免费| 国产一区91精品张津瑜| 日日夜夜精品免费视频| 中文字幕在线不卡视频| 成人美女在线视频| 国产自产高清不卡| 亚洲h动漫在线| 国产精品久久777777| 日本一区二区不卡视频| 欧美成人午夜电影| 欧美日韩国产美| 欧美日韩高清一区二区不卡| 99精品视频在线观看| 国产盗摄视频一区二区三区| 国产美女精品一区二区三区| 麻豆精品一区二区| 亚洲国产视频直播| 亚洲午夜久久久久久久久电影网 |