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

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

?? raw.c

?? NXPl788上lwip的無操作系統移植,基于Embest開發板
?? C
字號:
/**
 * @file
 * Implementation of raw protocol PCBs for low-level handling of
 * different types of protocols besides (or overriding) those
 * already available in lwIP.
 *
 */

/*
 * 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/opt.h"

#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */

#include "lwip/def.h"
#include "lwip/memp.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/raw.h"
#include "lwip/stats.h"
#include "arch/perf.h"

#include <string.h>

/** The list of RAW PCBs */
static struct raw_pcb *raw_pcbs;

/**
 * Determine if in incoming IP packet is covered by a RAW PCB
 * and if so, pass it to a user-provided receive callback function.
 *
 * Given an incoming IP datagram (as a chain of pbufs) this function
 * finds a corresponding RAW PCB and calls the corresponding receive
 * callback function.
 *
 * @param p pbuf to be demultiplexed to a RAW PCB.
 * @param inp network interface on which the datagram was received.
 * @return - 1 if the packet has been eaten by a RAW PCB receive
 *           callback function. The caller MAY NOT not reference the
 *           packet any longer, and MAY NOT call pbuf_free().
 * @return - 0 if packet is not eaten (pbuf is still referenced by the
 *           caller).
 *
 */
u8_t
raw_input(struct pbuf *p, struct netif *inp)
{
  struct raw_pcb *pcb, *prev;
  struct ip_hdr *iphdr;
  s16_t proto;
  u8_t eaten = 0;

  LWIP_UNUSED_ARG(inp);

  iphdr = (struct ip_hdr *)p->payload;
  proto = IPH_PROTO(iphdr);

  prev = NULL;
  pcb = raw_pcbs;
  /* loop through all raw pcbs until the packet is eaten by one */
  /* this allows multiple pcbs to match against the packet by design */
  while ((eaten == 0) && (pcb != NULL)) {
    if ((pcb->protocol == proto) &&
        (ip_addr_isany(&pcb->local_ip) ||
         ip_addr_cmp(&(pcb->local_ip), &current_iphdr_dest))) {
#if IP_SOF_BROADCAST_RECV
      /* broadcast filter? */
      if ((pcb->so_options & SOF_BROADCAST) || !ip_addr_isbroadcast(&current_iphdr_dest, inp))
#endif /* IP_SOF_BROADCAST_RECV */
      {
        /* receive callback function available? */
        if (pcb->recv != NULL) {
          /* the receive callback function did not eat the packet? */
          if (pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr()) != 0) {
            /* receive function ate the packet */
            p = NULL;
            eaten = 1;
            if (prev != NULL) {
            /* move the pcb to the front of raw_pcbs so that is
               found faster next time */
              prev->next = pcb->next;
              pcb->next = raw_pcbs;
              raw_pcbs = pcb;
            }
          }
        }
        /* no receive callback function was set for this raw PCB */
      }
      /* drop the packet */
    }
    prev = pcb;
    pcb = pcb->next;
  }
  return eaten;
}

/**
 * Bind a RAW PCB.
 *
 * @param pcb RAW PCB to be bound with a local address ipaddr.
 * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to
 * bind to all local interfaces.
 *
 * @return lwIP error code.
 * - ERR_OK. Successful. No error occured.
 * - ERR_USE. The specified IP address is already bound to by
 * another RAW PCB.
 *
 * @see raw_disconnect()
 */
err_t
raw_bind(struct raw_pcb *pcb, ip_addr_t *ipaddr)
{
  ip_addr_set(&pcb->local_ip, ipaddr);
  return ERR_OK;
}

/**
 * Connect an RAW PCB. This function is required by upper layers
 * of lwip. Using the raw api you could use raw_sendto() instead
 *
 * This will associate the RAW PCB with the remote address.
 *
 * @param pcb RAW PCB to be connected with remote address ipaddr and port.
 * @param ipaddr remote IP address to connect with.
 *
 * @return lwIP error code
 *
 * @see raw_disconnect() and raw_sendto()
 */
err_t
raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr)
{
  ip_addr_set(&pcb->remote_ip, ipaddr);
  return ERR_OK;
}


/**
 * Set the callback function for received packets that match the
 * raw PCB's protocol and binding. 
 * 
 * The callback function MUST either
 * - eat the packet by calling pbuf_free() and returning non-zero. The
 *   packet will not be passed to other raw PCBs or other protocol layers.
 * - not free the packet, and return zero. The packet will be matched
 *   against further PCBs and/or forwarded to another protocol layers.
 * 
 * @return non-zero if the packet was free()d, zero if the packet remains
 * available for others.
 */
void
raw_recv(struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg)
{
  /* remember recv() callback and user data */
  pcb->recv = recv;
  pcb->recv_arg = recv_arg;
}

/**
 * Send the raw IP packet to the given address. Note that actually you cannot
 * modify the IP headers (this is inconsistent with the receive callback where
 * you actually get the IP headers), you can only specify the IP payload here.
 * It requires some more changes in lwIP. (there will be a raw_send() function
 * then.)
 *
 * @param pcb the raw pcb which to send
 * @param p the IP payload to send
 * @param ipaddr the destination address of the IP packet
 *
 */
err_t
raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)
{
  err_t err;
  struct netif *netif;
  ip_addr_t *src_ip;
  struct pbuf *q; /* q will be sent down the stack */
  
  LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\n"));
  
  /* not enough space to add an IP header to first pbuf in given p chain? */
  if (pbuf_header(p, IP_HLEN)) {
    /* allocate header in new pbuf */
    q = pbuf_alloc(PBUF_IP, 0, PBUF_RAM);
    /* new header pbuf could not be allocated? */
    if (q == NULL) {
      LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("raw_sendto: could not allocate header\n"));
      return ERR_MEM;
    }
    if (p->tot_len != 0) {
      /* chain header q in front of given pbuf p */
      pbuf_chain(q, p);
    }
    /* { first pbuf q points to header pbuf } */
    LWIP_DEBUGF(RAW_DEBUG, ("raw_sendto: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p));
  }  else {
    /* first pbuf q equals given pbuf */
    q = p;
    if(pbuf_header(q, -IP_HLEN)) {
      LWIP_ASSERT("Can't restore header we just removed!", 0);
      return ERR_MEM;
    }
  }

  if ((netif = ip_route(ipaddr)) == NULL) {
    LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
      ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr)));
    /* free any temporary header pbuf allocated by pbuf_header() */
    if (q != p) {
      pbuf_free(q);
    }
    return ERR_RTE;
  }

#if IP_SOF_BROADCAST
  /* broadcast filter? */
  if (((pcb->so_options & SOF_BROADCAST) == 0) && ip_addr_isbroadcast(ipaddr, netif)) {
    LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb));
    /* free any temporary header pbuf allocated by pbuf_header() */
    if (q != p) {
      pbuf_free(q);
    }
    return ERR_VAL;
  }
#endif /* IP_SOF_BROADCAST */

  if (ip_addr_isany(&pcb->local_ip)) {
    /* use outgoing network interface IP address as source address */
    src_ip = &(netif->ip_addr);
  } else {
    /* use RAW PCB local IP address as source address */
    src_ip = &(pcb->local_ip);
  }

#if LWIP_NETIF_HWADDRHINT
  netif->addr_hint = &(pcb->addr_hint);
#endif /* LWIP_NETIF_HWADDRHINT*/
  err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif);
#if LWIP_NETIF_HWADDRHINT
  netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/

  /* did we chain a header earlier? */
  if (q != p) {
    /* free the header */
    pbuf_free(q);
  }
  return err;
}

/**
 * Send the raw IP packet to the address given by raw_connect()
 *
 * @param pcb the raw pcb which to send
 * @param p the IP payload to send
 *
 */
err_t
raw_send(struct raw_pcb *pcb, struct pbuf *p)
{
  return raw_sendto(pcb, p, &pcb->remote_ip);
}

/**
 * Remove an RAW PCB.
 *
 * @param pcb RAW PCB to be removed. The PCB is removed from the list of
 * RAW PCB's and the data structure is freed from memory.
 *
 * @see raw_new()
 */
void
raw_remove(struct raw_pcb *pcb)
{
  struct raw_pcb *pcb2;
  /* pcb to be removed is first in list? */
  if (raw_pcbs == pcb) {
    /* make list start at 2nd pcb */
    raw_pcbs = raw_pcbs->next;
    /* pcb not 1st in list */
  } else {
    for(pcb2 = raw_pcbs; pcb2 != NULL; pcb2 = pcb2->next) {
      /* find pcb in raw_pcbs list */
      if (pcb2->next != NULL && pcb2->next == pcb) {
        /* remove pcb from list */
        pcb2->next = pcb->next;
      }
    }
  }
  memp_free(MEMP_RAW_PCB, pcb);
}

/**
 * Create a RAW PCB.
 *
 * @return The RAW PCB which was created. NULL if the PCB data structure
 * could not be allocated.
 *
 * @param proto the protocol number of the IPs payload (e.g. IP_PROTO_ICMP)
 *
 * @see raw_remove()
 */
struct raw_pcb *
raw_new(u8_t proto)
{
  struct raw_pcb *pcb;

  LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_new\n"));

  pcb = (struct raw_pcb *)memp_malloc(MEMP_RAW_PCB);
  /* could allocate RAW PCB? */
  if (pcb != NULL) {
    /* initialize PCB to all zeroes */
    memset(pcb, 0, sizeof(struct raw_pcb));
    pcb->protocol = proto;
    pcb->ttl = RAW_TTL;
    pcb->next = raw_pcbs;
    raw_pcbs = pcb;
  }
  return pcb;
}

#endif /* LWIP_RAW */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合天天综合色综合av| 欧美xxxxx牲另类人与| 日韩欧美精品在线视频| 亚洲人精品午夜| 国产精品一区二区在线看| 欧美日韩一区三区| 自拍偷自拍亚洲精品播放| 国产一区久久久| 9191成人精品久久| 亚洲一区二区不卡免费| 成人午夜又粗又硬又大| 日韩欧美黄色影院| 日韩成人午夜电影| 欧美视频一区二| 亚洲欧美日韩精品久久久久| 精品在线你懂的| 91精品国产欧美一区二区| 亚洲国产欧美在线| 色94色欧美sute亚洲13| 亚洲美女少妇撒尿| 97精品国产露脸对白| 国产日产欧美一区二区三区| 精品一区免费av| 日韩你懂的在线观看| 日韩中文字幕不卡| 欧美日韩在线播放| 日韩电影在线一区二区| 欧美日本国产一区| 肉色丝袜一区二区| 欧美一三区三区四区免费在线看| 亚洲妇女屁股眼交7| 欧美色视频一区| 亚洲18影院在线观看| 欧美精品色综合| 美日韩黄色大片| 欧美videos大乳护士334| 久久99热这里只有精品| 精品成a人在线观看| 国产成人在线看| 中文字幕日韩av资源站| 一本到不卡免费一区二区| 一区二区三区产品免费精品久久75| 欧美影院午夜播放| 日韩成人精品在线| wwwwxxxxx欧美| 成人免费毛片aaaaa**| 中文字幕视频一区| 欧美巨大另类极品videosbest | 99久久精品免费看| 亚洲欧美成aⅴ人在线观看| 色综合网色综合| 天天综合天天综合色| 日韩视频一区二区三区| 国产成人综合自拍| 亚洲精品国产a| 欧美一区二区三区在线观看| 国产乱码精品一区二区三区五月婷| 欧美国产激情二区三区| 欧美亚洲一区三区| 韩国一区二区在线观看| 国产精品久久久久久久久免费桃花| 色综合久久久网| 亚洲成人一区在线| 久久久久久久久久看片| 色婷婷综合在线| 另类专区欧美蜜桃臀第一页| 最新国产成人在线观看| 56国语精品自产拍在线观看| 国产盗摄精品一区二区三区在线| 亚洲欧美色一区| 精品久久一区二区| 色噜噜狠狠成人网p站| 激情综合五月婷婷| 一区二区成人在线| 国产欧美视频一区二区| 欧美日韩极品在线观看一区| 粉嫩av一区二区三区| 午夜精品久久久久久久久| 国产精品理伦片| 日韩欧美专区在线| 91免费视频观看| 国内久久婷婷综合| 日韩黄色免费电影| 亚洲精品国产无天堂网2021 | 337p亚洲精品色噜噜| 成人av网站在线观看| 久久精品国产成人一区二区三区| 亚洲精品视频免费看| 久久日一线二线三线suv| 欧美日韩精品欧美日韩精品一| 成人av在线一区二区三区| 激情图区综合网| 免费人成黄页网站在线一区二区 | 国产精品久久久久久久久晋中| 欧美一区二区三区在| 在线观看日韩电影| 91欧美激情一区二区三区成人| 国产成人av在线影院| 狠狠色伊人亚洲综合成人| 奇米影视在线99精品| 午夜影院久久久| 一区二区三区免费在线观看| 亚洲欧洲精品一区二区三区 | 亚洲精品一区二区三区四区高清 | 亚洲精品成人悠悠色影视| 中文av一区二区| 国产亚洲欧美中文| www成人在线观看| 久久免费午夜影院| 久久久久久亚洲综合影院红桃 | 欧美大白屁股肥臀xxxxxx| 欧美日产在线观看| 日韩一区二区在线看片| 欧美一级在线免费| 精品国产乱码久久久久久久| 精品少妇一区二区三区视频免付费 | 亚洲黄色片在线观看| 中文字幕日韩欧美一区二区三区| 中文字幕不卡的av| 国产精品情趣视频| 亚洲欧美一区二区三区孕妇| 夜夜爽夜夜爽精品视频| 亚洲电影你懂得| 欧美aaaaaa午夜精品| 久久99久久久久久久久久久| 狠狠色综合播放一区二区| 国产98色在线|日韩| av中文字幕亚洲| 色综合久久久久网| 欧美丰满少妇xxxbbb| 日韩美女天天操| 国产日韩欧美在线一区| 中文字幕一区二| 亚洲成av人片| 国产在线精品免费| 成人黄色大片在线观看| 91免费版pro下载短视频| 一本一道综合狠狠老| 欧美色老头old∨ideo| 欧美精品vⅰdeose4hd| www国产精品av| 国产精品卡一卡二卡三| 亚洲国产精品久久人人爱蜜臀 | 亚洲国产精品一区二区尤物区| 性做久久久久久免费观看| 九九久久精品视频| 91视频91自| 日韩一级成人av| 国产精品每日更新在线播放网址| 亚洲国产裸拍裸体视频在线观看乱了| 六月丁香婷婷久久| 91高清在线观看| 国产免费久久精品| 亚洲在线视频网站| 经典三级视频一区| 91国产免费观看| 久久精品视频在线看| 亚洲午夜久久久久久久久电影网 | 欧美群妇大交群的观看方式| 精品国产91亚洲一区二区三区婷婷| 亚洲欧洲在线观看av| 日本va欧美va瓶| 欧洲精品在线观看| 久久久久综合网| 视频一区国产视频| 91免费看`日韩一区二区| 久久精品视频在线看| 欧美96一区二区免费视频| 91小视频免费观看| 欧美极品另类videosde| 久久超碰97中文字幕| 在线欧美日韩精品| 三级在线观看一区二区| 91精品国产综合久久久久久| 亚洲电影视频在线| 国产清纯在线一区二区www| 国产美女av一区二区三区| 精品精品国产高清a毛片牛牛| 日韩欧美成人午夜| 亚洲综合男人的天堂| www.在线成人| 国产色产综合产在线视频| 免费成人在线网站| 欧美嫩在线观看| 亚洲成人黄色小说| 在线观看一区日韩| 中文字幕中文在线不卡住| 国产suv精品一区二区883| 日韩欧美视频在线| 免费不卡在线视频| 欧美一区二区人人喊爽| 五月激情丁香一区二区三区| 欧美性色综合网| 夜夜揉揉日日人人青青一国产精品| 99久久99久久免费精品蜜臀| 国产日韩欧美综合一区| 国产精品1区二区.| 国产成人亚洲综合a∨婷婷 | 国产成人精品免费| 久久久久久99精品|