亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲精品在线观| 成人av资源下载| 7777精品伊人久久久大香线蕉的 | 欧美人牲a欧美精品| 婷婷中文字幕一区三区| 久久亚洲精华国产精华液 | 欧美一区二区黄| 成人福利视频在线看| 日韩精品成人一区二区三区| 久久丝袜美腿综合| 欧美色窝79yyyycom| 黄色日韩网站视频| 亚洲成人资源在线| 亚洲免费观看高清完整版在线 | 成人a级免费电影| 日韩中文字幕亚洲一区二区va在线| 欧美激情一区二区三区蜜桃视频| 91精品国产品国语在线不卡| 黄色小说综合网站| 亚洲色图制服诱惑| 综合在线观看色| 国产精品久久久久久久久久免费看| 欧美一区二区精品在线| 99re在线视频这里只有精品| 高清在线观看日韩| 高清不卡一区二区| 国产乱码精品一区二区三区五月婷 | 一区二区三区四区不卡在线| 中文字幕亚洲一区二区va在线| 久久久亚洲午夜电影| 欧美经典一区二区三区| 久久在线免费观看| 国产女人aaa级久久久级| 国产日韩精品一区二区三区在线| 久久夜色精品国产噜噜av| 久久久久国产一区二区三区四区| 欧美精品一区二区在线观看| 国产亚洲欧美日韩日本| 成人免费视频在线观看| 亚洲伦理在线免费看| 亚洲国产精品久久久久婷婷884| 精品国产免费一区二区三区四区 | 欧美xxxxxxxx| 2020国产精品久久精品美国| 国产精品国产三级国产aⅴ原创| 亚洲日本欧美天堂| 一区二区三区av电影| 美日韩一区二区| 99久久精品免费看国产免费软件| 欧美午夜在线一二页| 日韩免费视频线观看| 亚洲欧美另类在线| 人人超碰91尤物精品国产| 成人免费精品视频| 欧美久久久久免费| 26uuu欧美日本| 亚洲成人精品一区| www.欧美色图| 精品理论电影在线| 午夜精品视频在线观看| av电影在线观看完整版一区二区| 91精品久久久久久久91蜜桃| 日韩美女精品在线| 五月婷婷另类国产| 91麻豆产精品久久久久久| 欧美日本一区二区三区四区| 中文字幕第一区二区| 国内精品嫩模私拍在线| 色激情天天射综合网| 精品日产卡一卡二卡麻豆| 午夜精品久久久久久久蜜桃app| 91原创在线视频| 国产精品三级视频| 国产成人av电影在线观看| 久久综合久久综合亚洲| 亚洲一卡二卡三卡四卡无卡久久| 亚洲午夜激情av| 色噜噜狠狠色综合中国| 一区二区三区精品在线| 在线观看视频一区二区欧美日韩| 国产欧美一区二区三区网站 | 亚洲免费三区一区二区| 99久久99久久精品国产片果冻| 国产精品五月天| 91女人视频在线观看| 亚洲欧美成人一区二区三区| 在线中文字幕不卡| 午夜视频在线观看一区二区三区| 91精品中文字幕一区二区三区| 日本午夜精品视频在线观看| 日韩免费一区二区| 加勒比av一区二区| 国产精品理论片| 欧美日韩一区二区三区四区五区| 青青草成人在线观看| 日韩一级完整毛片| 国产成人综合在线| 亚洲国产精品天堂| 久久精品欧美一区二区三区麻豆| 国产一区在线视频| 亚洲第一电影网| 国产日本欧美一区二区| 欧美精品久久天天躁| 国产精品亚洲人在线观看| 亚洲一区二区偷拍精品| 国产视频视频一区| 51精品国自产在线| 97se亚洲国产综合自在线| 久久精品999| 亚洲成人免费av| 久久亚洲精品国产精品紫薇| 亚洲自拍欧美精品| 欧美国产精品一区二区三区| 欧美日韩午夜在线视频| 亚洲亚洲人成综合网络| 精品国产精品网麻豆系列 | 成人av在线资源网| 激情五月播播久久久精品| 午夜精品成人在线视频| 亚洲人成在线播放网站岛国| 国产情人综合久久777777| 在线不卡的av| 91女神在线视频| 成人国产精品免费观看| 岛国av在线一区| 激情成人午夜视频| 另类人妖一区二区av| 精品一区二区在线观看| 日韩国产欧美在线视频| 日韩和欧美的一区| 美女国产一区二区| 韩国欧美国产一区| 丰满少妇在线播放bd日韩电影| 九九视频精品免费| 国产精品亚洲专一区二区三区| 国产一区二区三区免费在线观看| 日产国产高清一区二区三区| 奇米888四色在线精品| 国产一区二区三区四区在线观看| 国产美女主播视频一区| 色综合天天综合网国产成人综合天 | 日韩一区二区三区电影 | 亚洲男人的天堂在线观看| 午夜伊人狠狠久久| 国产成人精品亚洲777人妖| 91蝌蚪国产九色| 精品粉嫩超白一线天av| 亚洲三级在线看| 久久97超碰国产精品超碰| 91老师国产黑色丝袜在线| 精品福利二区三区| 日韩中文字幕1| 色天天综合久久久久综合片| 久久久久久久久久看片| 欧美日韩精品二区第二页| 久久久www成人免费毛片麻豆| 日韩激情中文字幕| 日韩午夜电影在线观看| 五月激情丁香一区二区三区| 日韩美一区二区三区| 亚洲v精品v日韩v欧美v专区| 成人综合婷婷国产精品久久| 中文字幕在线不卡一区 | 天天色 色综合| 7777精品伊人久久久大香线蕉完整版| 伊人开心综合网| 成人激情免费视频| 26uuu色噜噜精品一区| 久久66热re国产| 日韩精品一区在线| 九九视频精品免费| 中文字幕国产精品一区二区| 高清不卡一区二区| 国产精品国产自产拍高清av王其| 高清视频一区二区| 136国产福利精品导航| 99久久精品免费看| 亚洲午夜一区二区三区| 色8久久精品久久久久久蜜| 亚洲天堂网中文字| 欧美日韩一级黄| 国产成人免费在线观看不卡| 中文字幕在线免费不卡| 欧美区视频在线观看| 日韩精品91亚洲二区在线观看| 久久久久久久精| 91麻豆文化传媒在线观看| 亚洲va中文字幕| 综合激情成人伊人| 日韩欧美卡一卡二| k8久久久一区二区三区| 秋霞午夜鲁丝一区二区老狼| 日本一区二区在线不卡| 欧洲一区二区三区在线| 国产一区二区三区免费在线观看| 国产精品国产自产拍在线| 欧美一区日本一区韩国一区| 色一区在线观看| 国产激情一区二区三区四区 | 91精品国产入口|