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

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

?? udp.c

?? FreeRtos Source code Version 4.04
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/** * @file * User Datagram Protocol module * *//* * 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> * *//* udp.c * * The code for the User Datagram Protocol UDP. * */#include <string.h>#include "lwip/opt.h"#include "lwip/def.h"#include "lwip/memp.h"#include "lwip/inet.h"#include "lwip/ip_addr.h"#include "lwip/netif.h"#include "lwip/udp.h"#include "lwip/icmp.h"#include "lwip/stats.h"#include "arch/perf.h"#include "lwip/snmp.h"/* The list of UDP PCBs */#if LWIP_UDP/* was static, but we may want to access this from a socket layer */struct udp_pcb *udp_pcbs = NULL;static struct udp_pcb *pcb_cache = NULL;voidudp_init(void){  udp_pcbs = pcb_cache = NULL;}/** * Process an incoming UDP datagram. * * Given an incoming UDP datagram (as a chain of pbufs) this function * finds a corresponding UDP PCB and * * @param pbuf pbuf to be demultiplexed to a UDP PCB. * @param netif network interface on which the datagram was received. * */voidudp_input(struct pbuf *p, struct netif *inp){  struct udp_hdr *udphdr;  struct udp_pcb *pcb;  struct ip_hdr *iphdr;  u16_t src, dest;#if SO_REUSE  struct udp_pcb *pcb_temp;  int reuse = 0;  int reuse_port_1 = 0;  int reuse_port_2 = 0;#endif /* SO_REUSE */    PERF_START;  UDP_STATS_INC(udp.recv);  iphdr = p->payload;  if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) {    /* drop short packets */    LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len));    UDP_STATS_INC(udp.lenerr);    UDP_STATS_INC(udp.drop);    snmp_inc_udpinerrors();    pbuf_free(p);    goto end;  }  udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN);  LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %u\n", p->tot_len));  src = ntohs(udphdr->src);  dest = ntohs(udphdr->dest);  udp_debug_print(udphdr);  /* print the UDP source and destination */  LWIP_DEBUGF(UDP_DEBUG, ("udp (%u.%u.%u.%u, %u) <-- (%u.%u.%u.%u, %u)\n",    ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest),    ip4_addr3(&iphdr->dest), ip4_addr4(&iphdr->dest), ntohs(udphdr->dest),    ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src),    ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src), ntohs(udphdr->src)));#if SO_REUSE  pcb_temp = udp_pcbs;   again_1:    /* Iterate through the UDP pcb list for a fully matching pcb */  for (pcb = pcb_temp; pcb != NULL; pcb = pcb->next) {#else  /* SO_REUSE */   /* Iterate through the UDP pcb list for a fully matching pcb */  for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {#endif  /* SO_REUSE */     /* print the PCB local and remote address */    LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n",      ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip),      ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port,      ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip),      ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port));       /* PCB remote port matches UDP source port? */    if ((pcb->remote_port == src) &&       /* PCB local port matches UDP destination port? */       (pcb->local_port == dest) &&       /* accepting from any remote (source) IP address? or... */       (ip_addr_isany(&pcb->remote_ip) ||       /* PCB remote IP address matches UDP source IP address? */        ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&       /* accepting on any local (netif) IP address? or... */       (ip_addr_isany(&pcb->local_ip) ||       /* PCB local IP address matches UDP destination IP address? */        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(UDP_DEBUG, ("udp_input: second or later PCB and SOF_REUSEPORT set.\n"));        } else {          /* First PCB with this address */          LWIP_DEBUGF(UDP_DEBUG, ("udp_input: first PCB and SOF_REUSEPORT set.\n"));          reuse = 1;        }                reuse_port_1 = 1;         p->ref++;        LWIP_DEBUGF(UDP_DEBUG, ("udp_input: reference counter on PBUF set to %i\n", p->ref));      } else {        if (reuse) {          /* We processed one PCB already */          LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB but SOF_REUSEPORT not set !\n"));        }      }#endif /* SO_REUSE */      break;    }  }  /* no fully matching pcb found? then look for an unconnected pcb */  if (pcb == NULL) {    /* Iterate through the UDP PCB list for a pcb that matches       the local address. */#if SO_REUSE    pcb_temp = udp_pcbs;      again_2:    for (pcb = pcb_temp; pcb != NULL; pcb = pcb->next) {#else  /* SO_REUSE */     for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {#endif  /* SO_REUSE */       LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n",        ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip),        ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port,        ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip),        ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port));      /* unconnected? */      if (((pcb->flags & UDP_FLAGS_CONNECTED) == 0) &&         /* destination port matches? */        (pcb->local_port == dest) &&        /* not bound to a specific (local) interface address? or... */        (ip_addr_isany(&pcb->local_ip) ||        /* ...matching interface address? */        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(UDP_DEBUG, ("udp_input: second or later PCB and SOF_REUSEPORT set.\n"));          } else {            /* First PCB with this address */            LWIP_DEBUGF(UDP_DEBUG, ("udp_input: first PCB and SOF_REUSEPORT set.\n"));            reuse = 1;          }                    reuse_port_2 = 1;           p->ref++;          LWIP_DEBUGF(UDP_DEBUG, ("udp_input: reference counter on PBUF set to %i\n", p->ref));        } else {          if (reuse) {            /* We processed one PCB already */            LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB but SOF_REUSEPORT not set !\n"));          }        }#endif /* SO_REUSE */        break;      }    }  }  /* Check checksum if this is a match or if it was directed at us. */  if (pcb != NULL  || ip_addr_cmp(&inp->ip_addr, &iphdr->dest))    {    LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: calculating checksum\n"));    pbuf_header(p, UDP_HLEN);#ifdef IPv6    if (iphdr->nexthdr == IP_PROTO_UDPLITE) {#else    if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) {#endif /* IPv4 */      /* Do the UDP Lite checksum */#if CHECKSUM_CHECK_UDP      if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),         (struct ip_addr *)&(iphdr->dest),         IP_PROTO_UDPLITE, ntohs(udphdr->len)) != 0) {  LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP Lite datagram discarded due to failing checksum\n"));  UDP_STATS_INC(udp.chkerr);  UDP_STATS_INC(udp.drop);  snmp_inc_udpinerrors();  pbuf_free(p);  goto end;      }#endif    } else {#if CHECKSUM_CHECK_UDP      if (udphdr->chksum != 0) {  if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),       (struct ip_addr *)&(iphdr->dest),        IP_PROTO_UDP, p->tot_len) != 0) {    LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP datagram discarded due to failing checksum\n"));    UDP_STATS_INC(udp.chkerr);    UDP_STATS_INC(udp.drop);    snmp_inc_udpinerrors();    pbuf_free(p);    goto end;  }      }#endif    }    pbuf_header(p, -UDP_HLEN);    if (pcb != NULL) {      snmp_inc_udpindatagrams();      pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);#if SO_REUSE      /* First socket should receive now */      if(reuse_port_1 || reuse_port_2) {        /* We want to search on next socket after receiving */        pcb_temp = pcb->next;                if(reuse_port_1) {          /* We are searching connected sockets */          reuse_port_1 = 0;          reuse_port_2 = 0;          goto again_1;        } else {          /* We are searching unconnected sockets */          reuse_port_1 = 0;          reuse_port_2 = 0;          goto again_2;        }      }#endif /* SO_REUSE */     } else {#if SO_REUSE      if(reuse) {        LWIP_DEBUGF(UDP_DEBUG, ("udp_input: freeing PBUF with reference counter set to %i\n", p->ref));        pbuf_free(p);        goto end;      }#endif /* SO_REUSE */      LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: not for us.\n"));      /* No match was found, send ICMP destination port unreachable unless      destination address was broadcast/multicast. */      if (!ip_addr_isbroadcast(&iphdr->dest, inp) &&          !ip_addr_ismulticast(&iphdr->dest)) {  /* adjust pbuf pointer */  p->payload = iphdr;  icmp_dest_unreach(p, ICMP_DUR_PORT);      }      UDP_STATS_INC(udp.proterr);      UDP_STATS_INC(udp.drop);    snmp_inc_udpnoports();      pbuf_free(p);    }  } else {    pbuf_free(p);  }  end:  PERF_STOP("udp_input");}/** * Send data to a specified address using UDP. * * @param pcb UDP PCB used to send the data. * @param pbuf chain of pbuf's to be sent. * @param dst_ip Destination IP address. * @param dst_port Destination UDP port. * * If the PCB already has a remote address association, it will * be restored after the data is sent. *  * @return lwIP error code. * - ERR_OK. Successful. No error occured. * - ERR_MEM. Out of memory. * - ERR_RTE. Could not find route to destination address. * * @see udp_disconnect() udp_send() */err_tudp_sendto(struct udp_pcb *pcb, struct pbuf *p,  struct ip_addr *dst_ip, u16_t dst_port){  err_t err;  /* temporary space for current PCB remote address */  struct ip_addr pcb_remote_ip;  u16_t pcb_remote_port;  /* remember current remote peer address of PCB */  pcb_remote_ip.addr = pcb->remote_ip.addr;  pcb_remote_port = pcb->remote_port;  /* copy packet destination address to PCB remote peer address */  pcb->remote_ip.addr = dst_ip->addr;  pcb->remote_port = dst_port;  /* send to the packet destination address */  err = udp_send(pcb, p);  /* restore PCB remote peer address */  pcb->remote_ip.addr = pcb_remote_ip.addr;  pcb->remote_port = pcb_remote_port;  return err;}/** * Send data using UDP. * * @param pcb UDP PCB used to send the data. * @param pbuf chain of pbuf's to be sent. * * @return lwIP error code. * - ERR_OK. Successful. No error occured. * - ERR_MEM. Out of memory. * - ERR_RTE. Could not find route to destination address. * * @see udp_disconnect() udp_sendto() */err_tudp_send(struct udp_pcb *pcb, struct pbuf *p){  struct udp_hdr *udphdr;  struct netif *netif;  struct ip_addr *src_ip;  err_t err;  struct pbuf *q; /* q will be sent down the stack */  LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_send\n"));  /* if the PCB is not yet bound to a port, bind it here */  if (pcb->local_port == 0) {

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本大道久久a久久精品综合| 成人av在线网| 久久99热狠狠色一区二区| 国产亚洲精久久久久久| 在线免费av一区| 成人性视频免费网站| 免费在线看成人av| 一区二区三区资源| 国产精品美女久久久久久| 日韩一区二区三区四区五区六区| 97se亚洲国产综合自在线| 韩国欧美一区二区| 天堂va蜜桃一区二区三区| 中文字幕av资源一区| 欧美成人性福生活免费看| 欧美在线观看视频在线| 99r国产精品| 国产成人鲁色资源国产91色综| 日韩不卡在线观看日韩不卡视频| 亚洲欧美日韩中文播放| 国产精品久线在线观看| 久久只精品国产| 日韩精品一区二区在线观看| 欧美日韩精品一区二区三区蜜桃| 99精品久久久久久| 成人免费视频视频在线观看免费| 精品一区二区三区的国产在线播放| 亚洲国产精品久久人人爱蜜臀| 日韩理论片一区二区| 国产精品久久久久久久久免费桃花| 久久综合九色综合97婷婷| 欧美一区2区视频在线观看| 欧美日韩一区成人| 欧美日本在线一区| 欧美日本免费一区二区三区| 欧美性猛交xxxxxxxx| 在线视频欧美精品| 欧美影视一区在线| 91国内精品野花午夜精品 | 日韩va亚洲va欧美va久久| 亚洲乱码国产乱码精品精98午夜| 国产精品久久久久久久久晋中 | 成人黄色国产精品网站大全在线免费观看 | 在线播放亚洲一区| 7777精品伊人久久久大香线蕉超级流畅 | 日韩中文欧美在线| 日本麻豆一区二区三区视频| 人人超碰91尤物精品国产| 青草av.久久免费一区| 麻豆国产精品一区二区三区| 精品写真视频在线观看| 国产精品自拍毛片| 成人国产电影网| 一本色道久久加勒比精品| 欧美优质美女网站| 91精品国产色综合久久不卡电影| 欧美一级二级三级蜜桃| 精品国产一区二区精华| 中文字幕第一区综合| 一区免费观看视频| 亚洲v精品v日韩v欧美v专区| 日韩电影网1区2区| 国产一区二区导航在线播放| 成人黄色大片在线观看| 日本韩国欧美三级| 日韩欧美在线网站| 日本一区二区三区高清不卡| 成人欧美一区二区三区在线播放| 亚洲一区在线免费观看| 免费观看成人鲁鲁鲁鲁鲁视频| 国模娜娜一区二区三区| 91在线观看免费视频| 69av一区二区三区| 中文字幕的久久| 亚洲成a人片在线观看中文| 九一九一国产精品| 91丝袜高跟美女视频| 8x福利精品第一导航| 国产欧美日韩另类一区| 亚洲综合久久久久| 国产美女视频一区| 欧美自拍偷拍一区| 久久免费电影网| 亚洲一线二线三线视频| 欧美老年两性高潮| 久久久久久免费| 亚洲一区二区三区四区在线观看 | 蜜臀av国产精品久久久久| 岛国精品在线播放| 91精品久久久久久蜜臀| 欧美国产日本视频| 日韩电影在线免费观看| www.亚洲在线| 日韩美女天天操| 一区二区久久久久| 风间由美中文字幕在线看视频国产欧美| 91福利国产成人精品照片| 欧美精品一区二区三区蜜桃视频| 一区二区视频在线| 成人午夜视频网站| 精品国产电影一区二区| 亚洲第一搞黄网站| 播五月开心婷婷综合| 精品国产欧美一区二区| 亚洲高清免费观看 | 日本韩国欧美三级| 中文字幕乱码亚洲精品一区| 蜜臀av性久久久久蜜臀aⅴ流畅| 91麻豆精品一区二区三区| 久久久久久免费| 麻豆一区二区三区| 精品视频资源站| 亚洲激情成人在线| av成人动漫在线观看| 久久久久久电影| 精东粉嫩av免费一区二区三区| 欧美影院一区二区| 亚洲乱码日产精品bd| 国产成人免费高清| 久久久综合视频| 精彩视频一区二区三区| 日韩一区二区不卡| 日本视频在线一区| 欧美日韩国产一区二区三区地区| 亚洲人成精品久久久久| 成人一级片在线观看| 久久精品视频在线免费观看| 蜜桃av一区二区| 亚洲精品国产高清久久伦理二区| 国产福利精品一区二区| 久久夜色精品国产噜噜av| 久久精品噜噜噜成人av农村| 日韩三级视频在线看| 日韩av电影天堂| 在线综合视频播放| 免费xxxx性欧美18vr| 日韩欧美一区二区视频| 麻豆国产欧美一区二区三区| 日韩欧美一二三四区| 久久99国产精品久久| 欧美成va人片在线观看| 国产一区视频网站| 欧美激情综合在线| 成人app网站| 亚洲日韩欧美一区二区在线| 99国产一区二区三精品乱码| 亚洲欧美日韩国产综合在线| 欧美亚洲国产一区在线观看网站| 亚洲在线成人精品| 欧美精品在线观看播放| 免费精品视频在线| 精品国内二区三区| 成人av在线播放网站| 一区二区三区四区蜜桃| 在线不卡中文字幕| 精品伊人久久久久7777人| 日本一区二区在线不卡| 色综合色狠狠天天综合色| 亚洲福利一二三区| 久久这里只有精品视频网| 成人免费高清在线| 亚洲最快最全在线视频| 日韩欧美中文字幕一区| 国产a精品视频| 亚洲国产中文字幕在线视频综合| 日韩三级视频在线看| 成人精品一区二区三区四区| 亚洲主播在线播放| 精品久久久三级丝袜| 不卡av免费在线观看| 天天色综合天天| 久久综合国产精品| 91国偷自产一区二区开放时间 | 亚洲一区自拍偷拍| 精品日产卡一卡二卡麻豆| 99久久99久久精品国产片果冻| 亚洲午夜国产一区99re久久| 久久综合成人精品亚洲另类欧美| 国产日本欧洲亚洲| 欧美中文字幕一区二区三区亚洲| 青青草国产成人99久久| 国产精品久久综合| 777亚洲妇女| 国产成人免费视频网站高清观看视频| 亚洲免费av高清| 久久综合中文字幕| 欧美无砖砖区免费| 成人污视频在线观看| 视频在线观看一区| 国产精品全国免费观看高清| 欧美美女一区二区三区| 大美女一区二区三区| 蜜臀av一区二区| 亚洲精品国产第一综合99久久 | 免费一级欧美片在线观看| 综合精品久久久| 久久综合av免费| 777欧美精品| 欧美性高清videossexo| 暴力调教一区二区三区|