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

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

?? tcp_in.c

?? 基于AT91SAM7x256的硬件平臺的WEB服務器源碼(A&shy DS版本, ucOS_II+LWIP+自己編寫的DNS查詢工具)
?? C
?? 第 1 頁 / 共 3 頁
字號:
/** * @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;  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 (%"U16_F" 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%04"X16_F"\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;    for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {    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))) {      /* 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) {  prev->next = pcb->next;  pcb->next = tcp_active_pcbs;  tcp_active_pcbs = 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) {            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. */  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;  }    tcp_listen_input(lpcb);  pbuf_free(p);  return;      }      prev = (struct tcp_pcb *)lpcb;    }  }  if (pcb != NULL) {    /* The incoming segment belongs to a connection. */    /* 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);        } else {    /* If no matching PCB was found, send a TCP RST (reset) to the       sender. */        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);  }}/* 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. */    LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n"));    tcp_rst(ackno + 1, seqno + tcplen,      &(iphdr->dest), &(iphdr->src),      tcphdr->dest, tcphdr->src);  } else if (flags & TCP_SYN) {    LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest));    npcb = tcp_alloc(pcb->prio);    /* If a new PCB could not be created (probably due to lack of memory),       we don't do anything, but rely on the sender will retransmit the       SYN at a time when we have more memory available. */    if (npcb == NULL) {      LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n"));      TCP_STATS_INC(tcp.memerr);      return ERR_MEM;    }    /* Set up the new PCB. */    ip_addr_set(&(npcb->local_ip), &(iphdr->dest));    npcb->local_port = pcb->local_port;    ip_addr_set(&(npcb->remote_ip), &(iphdr->src));    npcb->remote_port = tcphdr->src;    npcb->state = SYN_RCVD;    npcb->rcv_nxt = seqno + 1;    npcb->snd_wnd = tcphdr->wnd;    npcb->ssthresh = npcb->snd_wnd;    npcb->snd_wl1 = seqno - 1;/* initialise to seqno-1 to force window update */    npcb->callback_arg = pcb->callback_arg;#if LWIP_CALLBACK_API    npcb->accept = pcb->accept;#endif /* LWIP_CALLBACK_API */    /* inherit socket options */    npcb->so_options = pcb->so_options & (SOF_DEBUG|SOF_DONTROUTE|SOF_KEEPALIVE|SOF_OOBINLINE|SOF_LINGER);    /* Register the new PCB so that we can begin receiving segments       for it. */    TCP_REG(&tcp_active_pcbs, npcb);    /* Parse any options in the SYN. */    tcp_parseopt(npcb);    /* Build an MSS option. */    optdata = htonl(((u32_t)2 << 24) |        ((u32_t)4 << 16) |        (((u32_t)npcb->mss / 256) << 8) |        (npcb->mss & 255));    /* Send a SYN|ACK together with the MSS option. */    tcp_enqueue(npcb, NULL, 0, TCP_SYN | TCP_ACK, 0, (u8_t *)&optdata, 4);    return tcp_output(npcb);  }  return ERR_OK;}/* tcp_timewait_input(): * * Called by tcp_input() when a segment arrives for a connection in * TIME_WAIT. */static err_ttcp_timewait_input(struct tcp_pcb *pcb){  if (TCP_SEQ_GT(seqno + tcplen, pcb->rcv_nxt)) {    pcb->rcv_nxt = seqno + tcplen;  }  if (tcplen > 0) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品你懂的在线| 日韩综合在线视频| 制服丝袜成人动漫| 国产伦精品一区二区三区免费迷| 91精品国产欧美一区二区| 蜜臀av一区二区在线观看| 2023国产一二三区日本精品2022| 国内精品第一页| 亚洲一区二区三区美女| 欧美精品一区二区三区蜜桃| www.久久精品| 国产精品白丝jk白祙喷水网站| 亚洲黄色av一区| 中文字幕乱码久久午夜不卡| 在线播放中文字幕一区| 欧美在线free| 色妹子一区二区| 大尺度一区二区| 韩国精品在线观看| 免费人成在线不卡| 午夜精品久久久久久久99樱桃| 亚洲精品伦理在线| 一区在线播放视频| 中文字幕综合网| 亚洲欧美另类综合偷拍| 国产精品久久久久久久久动漫| 久久精品人人做人人综合| 日韩精品一区二区三区视频| 欧美精品色综合| 7777精品久久久大香线蕉| 色94色欧美sute亚洲线路一ni| 色吧成人激情小说| 久久久精品免费网站| 欧美经典三级视频一区二区三区| 久久夜色精品国产欧美乱极品| 久久综合九色综合97婷婷| 国产精品欧美久久久久无广告| 国产精品卡一卡二| 国产一区在线不卡| 一本大道av伊人久久综合| 欧美高清视频一二三区| 欧美精品一区二区精品网| 久久丝袜美腿综合| 亚洲成av人综合在线观看| 久久99国产精品久久99 | 欧美激情综合在线| 五月婷婷激情综合| 高清久久久久久| 欧美另类久久久品| 国产精品电影院| 狠狠v欧美v日韩v亚洲ⅴ| 蓝色福利精品导航| 91久久精品午夜一区二区| 日韩一区二区在线观看视频| 国产性做久久久久久| 日韩av电影免费观看高清完整版 | 丁香啪啪综合成人亚洲小说| 欧美日韩一区国产| 一区二区激情小说| 91网址在线看| 国产精品美女一区二区三区 | 国产精品久久久久久久第一福利 | 26uuu久久综合| 国产福利精品导航| 国产欧美一二三区| 波多野结衣亚洲| 国产精品国产三级国产aⅴ入口| 看国产成人h片视频| 欧美大片拔萝卜| 琪琪久久久久日韩精品| 欧美日韩美少妇| 奇米影视7777精品一区二区| 欧美一区二区啪啪| 国产一区在线看| 亚洲精品国产成人久久av盗摄| 色婷婷亚洲综合| 免费观看日韩av| 中文字幕av资源一区| 一本色道亚洲精品aⅴ| 亚洲成a人在线观看| 久久亚洲一区二区三区四区| 成人免费看视频| 亚洲成人一区在线| 久久日韩精品一区二区五区| 97精品国产97久久久久久久久久久久| 亚洲日本va午夜在线影院| 欧美日韩一区二区三区四区五区| 性欧美大战久久久久久久久| 久久久.com| 欧美日韩国产精品成人| 懂色av中文字幕一区二区三区| 婷婷夜色潮精品综合在线| 久久久久久久久97黄色工厂| 精品视频123区在线观看| 国产精品一区二区不卡| 婷婷久久综合九色综合伊人色| 精品剧情v国产在线观看在线| 欧美在线观看视频在线| 国产成人精品aa毛片| 麻豆成人免费电影| 夜夜操天天操亚洲| 综合色天天鬼久久鬼色| 国产欧美日韩视频在线观看| 日韩免费高清av| 日韩一区二区影院| 91精品麻豆日日躁夜夜躁| 欧美电影一区二区| 欧美美女直播网站| 日本高清无吗v一区| 91在线观看免费视频| 成人美女视频在线观看| 成人黄色片在线观看| 国产69精品一区二区亚洲孕妇| 国产成人精品一区二| 99精品偷自拍| 欧美性猛交一区二区三区精品| 欧美私模裸体表演在线观看| 在线成人小视频| 国产精品午夜春色av| 一区二区三区免费在线观看| 五月综合激情婷婷六月色窝| 日本成人中文字幕| 丰满亚洲少妇av| 欧美性受xxxx黑人xyx| 欧美日韩国产首页在线观看| 精品国产乱码久久久久久老虎| 欧美激情一区二区三区不卡| 亚洲欧美区自拍先锋| 久久超碰97中文字幕| 色视频欧美一区二区三区| 精品免费国产二区三区| 中文字幕一区在线| 韩国欧美国产1区| 欧美日韩一级大片网址| 欧美国产日韩在线观看| 喷白浆一区二区| 欧美午夜电影网| 亚洲国产日韩a在线播放性色| 麻豆极品一区二区三区| 在线观看网站黄不卡| 亚洲婷婷综合色高清在线| 久久狠狠亚洲综合| 欧美日韩精品欧美日韩精品| 国产精品久久久久一区 | 午夜激情综合网| 欧美色涩在线第一页| 亚洲女与黑人做爰| 99v久久综合狠狠综合久久| 欧美国产视频在线| 波多野洁衣一区| 亚洲九九爱视频| 色激情天天射综合网| 一区二区理论电影在线观看| 91福利国产精品| 天堂成人免费av电影一区| 欧美系列亚洲系列| 三级不卡在线观看| 精品久久久久久久一区二区蜜臀| 免费人成在线不卡| 久久网这里都是精品| 成人性生交大片免费看视频在线 | 国产成人综合亚洲网站| 国产欧美日韩视频一区二区| 成人高清在线视频| 亚洲国产一区二区在线播放| 7777精品伊人久久久大香线蕉最新版| 日本91福利区| 欧美激情一区三区| 69精品人人人人| 国产一区二区三区在线看麻豆| 日本一区二区不卡视频| 精品视频全国免费看| 国产激情精品久久久第一区二区 | 九九热在线视频观看这里只有精品| 久久久另类综合| 日韩欧美另类在线| 色综合天天综合| 国产麻豆精品久久一二三| 夜夜精品视频一区二区| 国产情人综合久久777777| 日韩欧美一区二区免费| 国产成人aaaa| 另类小说视频一区二区| 亚洲高清视频在线| 国产精品午夜电影| 久久综合久久综合久久综合| 欧美日韩亚洲综合在线| 色综合天天做天天爱| 成人18视频在线播放| 国产精品久久久久婷婷二区次| 国产精品人成在线观看免费| 91精品国产欧美一区二区18| 色综合欧美在线视频区| av电影在线观看一区| 成人黄色av电影| 国产成人免费视频一区| 欧美日韩黄色影视| 日韩av网站在线观看| 精品国产三级a在线观看| 日本一区二区三区久久久久久久久不|