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

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

?? udp.c

?? MCS-51的一個Free小型操作系統,在KeilC中下編譯工作
?? C
?? 第 1 頁 / 共 2 頁
字號:
/** * @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 udp_pcb *uncon_pcb;  struct ip_hdr *iphdr;  u16_t src, dest;  u8_t local_match;  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 (%"U16_F" 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 %"U16_F"\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 (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") <-- (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\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)));  local_match = 0;  uncon_pcb = NULL;  /* Iterate through the UDP pcb list for a matching pcb */  for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {    /* print the PCB local and remote address */    LWIP_DEBUGF(UDP_DEBUG, ("pcb (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") --- (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\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));    /* compare PCB local addr+port to UDP destination addr+port */    if ((pcb->local_port == dest) &&       (ip_addr_isany(&pcb->local_ip) ||        ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {       local_match = 1;       if ((uncon_pcb == NULL) &&            ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) {         /* the first unconnected matching PCB */              uncon_pcb = pcb;       }    }    /* compare PCB remote addr+port to UDP source addr+port */    if ((local_match != 0) &&       (pcb->remote_port == src) &&       (ip_addr_isany(&pcb->remote_ip) ||       ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)))) {       /* the first fully matching PCB */      break;    }  }  /* no fully matching pcb found? then look for an unconnected pcb */  if (pcb == NULL) {    pcb = uncon_pcb;  }  /* 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();      /* callback */      if (pcb->recv != NULL)      {        pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);      }        } else {      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) {    LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: not yet bound to a port, binding now\n"));    err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);    if (err != ERR_OK) {      LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: forced port bind failed\n"));      return err;    }  }  /* find the outgoing network interface for this packet */  netif = ip_route(&(pcb->remote_ip));  /* no outgoing network interface could be found? */  if (netif == NULL) {    LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%"X32_F"\n", pcb->remote_ip.addr));    UDP_STATS_INC(udp.rterr);    return ERR_RTE;  }  /* not enough space to add an UDP header to first pbuf in given p chain? */  if (pbuf_header(p, UDP_HLEN)) {    /* allocate header in a seperate new pbuf */    q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM);    /* new header pbuf could not be allocated? */    if (q == NULL) {      LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: could not allocate header\n"));      return ERR_MEM;    }    /* chain header q in front of given pbuf p */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线综合亚洲欧美在线视频| 久久精品99国产精品日本| 国产aⅴ综合色| 国产三区在线成人av| 国产成人av电影免费在线观看| 久久久五月婷婷| 成人国产精品免费观看动漫| 国产精品国产三级国产| 91久久国产综合久久| 日韩中文字幕不卡| 欧美一区二区在线不卡| 国产在线播放一区| 国产精品久久久久久亚洲毛片| 97精品视频在线观看自产线路二| 亚洲电影中文字幕在线观看| 欧美一区二区三区免费视频| 国产乱码精品一品二品| 中文字幕日韩精品一区| 欧美日韩国产免费| 高清在线不卡av| 亚洲一区二区精品久久av| 欧美一级电影网站| 97精品久久久午夜一区二区三区| 天堂蜜桃91精品| 欧美国产欧美综合| 日韩三级视频在线观看| 国产高清不卡二三区| 亚洲午夜视频在线观看| 精品国产一区二区国模嫣然| 97se亚洲国产综合自在线不卡| 午夜精品福利视频网站| 久久久青草青青国产亚洲免观| 色婷婷综合中文久久一本| 首页综合国产亚洲丝袜| 国产精品毛片a∨一区二区三区| 欧美日韩五月天| 成人av免费在线观看| 日韩电影在线观看网站| 国产精品福利一区| 欧美r级电影在线观看| 99视频精品免费视频| 美女网站一区二区| 亚洲卡通动漫在线| 国产欧美一区二区三区在线看蜜臀 | 日韩美女主播在线视频一区二区三区| 国产精品白丝jk白祙喷水网站| 亚洲香肠在线观看| 国产精品无人区| 26uuu久久天堂性欧美| 欧美色图片你懂的| 成人av电影在线播放| 精品综合久久久久久8888| 亚洲主播在线观看| 中文字幕一区二区视频| 精品剧情在线观看| 日韩欧美一区二区不卡| 欧美日韩视频第一区| 色婷婷国产精品久久包臀| 成人免费黄色在线| 国产毛片精品国产一区二区三区| 五月天视频一区| 一区二区三区精品视频在线| 久久午夜色播影院免费高清| 日韩三级视频中文字幕| 91精品国产综合久久精品| 91福利国产精品| 色噜噜狠狠色综合欧洲selulu| 国产1区2区3区精品美女| 国内外成人在线视频| 日本vs亚洲vs韩国一区三区二区 | 亚洲成人精品影院| 亚洲精品自拍动漫在线| 亚洲欧洲国产日本综合| 中文字幕乱码久久午夜不卡| 国产日韩影视精品| 国产精品久久久久毛片软件| 国产欧美一区在线| 国产精品国产三级国产aⅴ原创 | 欧美不卡视频一区| 日韩午夜电影在线观看| 日韩欧美色电影| 久久综合久久鬼色| 国产日韩欧美综合在线| 国产蜜臀av在线一区二区三区| 久久久久久久久久久电影| 久久先锋资源网| 国产精品美女久久久久高潮| 亚洲丝袜美腿综合| 亚洲综合激情网| 天天综合网 天天综合色| 亚洲va韩国va欧美va| 日本一不卡视频| 国产麻豆一精品一av一免费| 成人免费看黄yyy456| 一本一道久久a久久精品| 精品视频在线免费观看| 欧美精品tushy高清| 日韩免费观看2025年上映的电影| 久久久久久久久久久99999| 国产欧美精品一区二区色综合朱莉| 国产亚洲精久久久久久| 亚洲欧美另类小说视频| 亚洲午夜免费电影| 国产制服丝袜一区| 色悠久久久久综合欧美99| 欧洲视频一区二区| 精品日韩成人av| 国产精品成人一区二区三区夜夜夜| 一色屋精品亚洲香蕉网站| 偷窥少妇高潮呻吟av久久免费| 精品一区二区三区在线播放 | 欧美tickling网站挠脚心| 日本一区二区三级电影在线观看 | 国产精品911| 色婷婷精品大在线视频| 欧美videossexotv100| 国产精品私房写真福利视频| 亚洲成人资源在线| 成人性生交大片免费看中文| 欧美群妇大交群中文字幕| 精品国产乱码久久久久久夜甘婷婷 | 亚洲国产精品精华液2区45| 一区二区三区四区精品在线视频| 日本系列欧美系列| 色综合天天狠狠| www国产亚洲精品久久麻豆| 一区二区三区加勒比av| 成人在线综合网站| 日韩一区和二区| 亚洲精品久久久蜜桃| 国产成人精品一区二区三区网站观看| 欧美色老头old∨ideo| 成人免费在线播放视频| 极品少妇xxxx精品少妇| 精品视频1区2区| 国产精品国产自产拍高清av| 精东粉嫩av免费一区二区三区| 欧美性色黄大片| 亚洲欧洲成人精品av97| 99久久99久久久精品齐齐| 亚洲精品一区二区三区99| 亚洲va欧美va人人爽| 色呦呦网站一区| 国产精品麻豆欧美日韩ww| 寂寞少妇一区二区三区| 欧美精品色一区二区三区| 中文字幕一区二| 丰满亚洲少妇av| 国产欧美精品一区| 国产在线视频不卡二| 日韩亚洲欧美高清| 五月天激情小说综合| 欧美乱妇20p| 亚洲国产精品视频| 91成人在线免费观看| 日韩高清中文字幕一区| 91成人国产精品| 成人精品高清在线| 色综合天天综合网天天狠天天| 久久久欧美精品sm网站 | 玉米视频成人免费看| 成人国产精品免费| 91福利国产精品| 日本在线不卡视频一二三区| 久久精品一区二区三区不卡牛牛| 色妹子一区二区| 国产精品一区二区在线观看不卡| 亚洲精品国产无套在线观| 久久一区二区三区国产精品| 美女网站视频久久| 亚洲妇女屁股眼交7| 亚洲最新在线观看| 美女视频网站久久| 一区二区在线免费观看| 日韩一区欧美小说| 国产精品久久久久久久久免费桃花 | 色国产综合视频| 亚洲视频网在线直播| 91在线观看地址| 亚洲欧美日韩中文播放 | 制服丝袜日韩国产| 青娱乐精品视频在线| 久久亚洲春色中文字幕久久久| 国产精品乡下勾搭老头1| 国产精品三级视频| 在线这里只有精品| 爽好久久久欧美精品| 国产另类ts人妖一区二区| 色香蕉成人二区免费| 91在线观看成人| 成人免费电影视频| 国产传媒一区在线| 韩国一区二区三区| 亚洲国产一二三| 无码av免费一区二区三区试看| 中文字幕不卡在线| 亚洲亚洲人成综合网络| 欧美a级理论片| 麻豆国产精品一区二区三区 | a在线播放不卡|