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

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

?? tcp_in.c

?? ARM7的一些試驗程序
?? 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()).
 */

void
tcp_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_t
tcp_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
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费成人av在线播放| 亚洲女爱视频在线| 久久精品国产999大香线蕉| 91麻豆精品国产自产在线观看一区| 亚洲国产精品嫩草影院| 538在线一区二区精品国产| 精品影视av免费| 欧美国产欧美亚州国产日韩mv天天看完整| 国产盗摄视频一区二区三区| 中文字幕一区二区三区色视频| 91一区二区三区在线观看| 亚洲va欧美va人人爽| 精品国产乱码久久久久久1区2区| 国产麻豆91精品| 日韩伦理av电影| 欧美剧情片在线观看| 国产九九视频一区二区三区| 成人免费在线播放视频| 欧美人与禽zozo性伦| 国产一区二区三区免费| 亚洲女同一区二区| 日韩视频在线观看一区二区| av午夜精品一区二区三区| 石原莉奈在线亚洲三区| 久久久久久久久久久久久夜| 91久久线看在观草草青青| 免费观看成人av| 中文字幕一区二区三区在线不卡| 欧美一区二区三区婷婷月色| 波多野结衣亚洲| 免费国产亚洲视频| 亚洲精品自拍动漫在线| 欧美本精品男人aⅴ天堂| 91片黄在线观看| 国产资源在线一区| 亚洲一区在线视频| 国产精品毛片高清在线完整版| 欧美精品乱码久久久久久| 9i在线看片成人免费| 免费看黄色91| 亚洲成人一区在线| 国产精品素人一区二区| 欧美大片在线观看一区二区| 91久久精品一区二区| 大尺度一区二区| 久久91精品国产91久久小草| 亚洲综合在线免费观看| 中文字幕免费不卡| 久久免费看少妇高潮| 777午夜精品视频在线播放| 99久久99久久久精品齐齐| 极品少妇一区二区| 久久精品免费观看| 亚洲18女电影在线观看| 亚洲精品日日夜夜| 国产精品免费久久久久| 久久丝袜美腿综合| 精品国产乱码久久久久久夜甘婷婷 | 日本高清不卡视频| 国产成人亚洲综合a∨婷婷| 美女诱惑一区二区| 日韩影视精彩在线| 日韩国产一区二| 日韩高清不卡一区| 日韩专区中文字幕一区二区| 午夜视频一区在线观看| 亚洲一卡二卡三卡四卡五卡| 一区二区三区在线视频免费| 亚洲日本va在线观看| 亚洲欧美影音先锋| 国产精品理论在线观看| 中文久久乱码一区二区| 国产精品久久久久久久久免费相片 | 精品久久久久久亚洲综合网| 日韩欧美你懂的| 日韩欧美国产午夜精品| 日韩一二三区视频| 日韩欧美不卡在线观看视频| 欧美不卡一区二区三区四区| 欧美va亚洲va国产综合| 精品国产a毛片| 国产欧美一区二区三区沐欲| 国产蜜臀97一区二区三区| 亚洲国产成人午夜在线一区| 1024国产精品| 一区二区高清在线| 石原莉奈在线亚洲三区| 久久精品国产**网站演员| 国产美女视频一区| kk眼镜猥琐国模调教系列一区二区| 99久久伊人精品| 91久久久免费一区二区| 在线播放91灌醉迷j高跟美女 | 精品久久久久一区| 国产亚洲成年网址在线观看| 亚洲欧洲日本在线| 五月开心婷婷久久| 狠狠色综合播放一区二区| 不卡av在线免费观看| 欧美性三三影院| 欧美刺激午夜性久久久久久久| 久久天堂av综合合色蜜桃网| 中文字幕在线不卡视频| 亚洲aⅴ怡春院| 国产美女精品人人做人人爽| 91麻豆免费观看| 欧美一区三区二区| 国产精品久久久久久久久果冻传媒 | 美女视频网站久久| 国产成人av福利| 欧洲一区二区三区在线| 日韩欧美国产一区二区在线播放 | 极品美女销魂一区二区三区| 99久久久无码国产精品| 欧美日韩国产高清一区二区三区 | 欧美在线视频全部完| 欧美大度的电影原声| 亚洲三级小视频| 久久不见久久见免费视频7| 99久久久国产精品| 欧美大度的电影原声| 亚洲夂夂婷婷色拍ww47| 国产真实乱偷精品视频免| 色噜噜夜夜夜综合网| 日韩欧美精品在线视频| 一区av在线播放| 国产在线精品一区二区| 欧美性猛交xxxxxx富婆| 欧美国产精品v| 久久精品国产第一区二区三区| 91年精品国产| 中文字幕av一区 二区| 日韩中文字幕亚洲一区二区va在线| 国产福利一区二区三区视频| 91精品国产入口| 亚洲精品视频自拍| av中文字幕在线不卡| 精品乱人伦一区二区三区| 亚洲国产欧美一区二区三区丁香婷| 日本高清不卡aⅴ免费网站| 26uuu另类欧美亚洲曰本| 日本人妖一区二区| 在线免费精品视频| 亚洲色图在线看| 成人av网站在线| 久久丝袜美腿综合| 精品一区二区三区香蕉蜜桃| 欧美区视频在线观看| 亚洲精品v日韩精品| av午夜一区麻豆| 国产蜜臀av在线一区二区三区| 国产自产v一区二区三区c| 日韩一本二本av| 蜜臀91精品一区二区三区| 欧美高清激情brazzers| 亚洲电影一区二区| 欧美熟乱第一页| 亚洲电影视频在线| 欧美日韩的一区二区| 婷婷六月综合网| 欧美日韩国产高清一区二区三区| 一级女性全黄久久生活片免费| 99综合影院在线| 一区二区在线看| 欧美三级欧美一级| 午夜精品在线看| 正在播放一区二区| 久久国产精品72免费观看| 日韩三级免费观看| 精久久久久久久久久久| 欧美va亚洲va香蕉在线| 国内成+人亚洲+欧美+综合在线| 久久这里都是精品| 成人午夜免费电影| 亚洲丝袜另类动漫二区| 91麻豆swag| 亚洲h精品动漫在线观看| 欧美另类一区二区三区| 麻豆精品在线看| 国产欧美日韩麻豆91| 99久久夜色精品国产网站| 亚洲精品视频在线观看网站| 欧美日韩的一区二区| 精品一二三四区| 欧美激情中文不卡| 在线观看av一区二区| 免费在线观看日韩欧美| 国产亚洲短视频| 色婷婷久久久亚洲一区二区三区| 亚洲成人免费看| 26uuu国产在线精品一区二区| 成人国产精品免费观看视频| 一区二区三区在线观看欧美| 在线不卡免费av| 国产精品一区二区无线| 亚洲自拍另类综合| 久久综合久久综合久久| 91美女片黄在线| 久久国产婷婷国产香蕉| 国产精品久久久久久久久久免费看 |