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

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

?? raw.c

?? 包含lwip這個(gè)精簡IP協(xié)議棧的ucos源代碼.
?? 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 <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/raw.h"

#include "lwip/stats.h"

#include "arch/perf.h"
#include "lwip/snmp.h"

#if LWIP_RAW

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

void
raw_init(void)
{
  raw_pcbs = NULL;
}

/**
 * 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 pbuf pbuf to be demultiplexed to a RAW PCB.
 * @param netif 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;
  struct ip_hdr *iphdr;
  int proto;
  u8_t eaten = 0;

  iphdr = p->payload;
  proto = IPH_PROTO(iphdr);

  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) {
      /* 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, &(iphdr->src)) != 0)
        {
          /* receive function ate the packet */
          p = NULL;
          eaten = 1;
        }
      }
      /* no receive callback function was set for this raw PCB */
      /* drop the packet */
    }
    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, struct ip_addr *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, struct ip_addr *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,
         u8_t (* recv)(void *arg, struct raw_pcb *upcb, struct pbuf *p,
                      struct ip_addr *addr),
         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, struct ip_addr *ipaddr)
{
  err_t err;
  struct netif *netif;
  struct ip_addr *src_ip;
  struct pbuf *q; /* q will be sent down the stack */
  
  LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 3, ("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 | DBG_TRACE | 2, ("raw_sendto: could not allocate header\n"));
      return ERR_MEM;
    }
    /* 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;
    pbuf_header(q, -IP_HLEN);
  }
  
  if ((netif = ip_route(ipaddr)) == NULL) {
    LWIP_DEBUGF(RAW_DEBUG | 1, ("raw_sendto: No route to 0x%lx\n", ipaddr->addr));
#if RAW_STATS
    /*    ++lwip_stats.raw.rterr;*/
#endif /* RAW_STATS */
    /* free any temporary header pbuf allocated by pbuf_header() */
    if (q != p) {
      pbuf_free(q);
    }
    return ERR_RTE;
  }

  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);
  }

  err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif);

  /* 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
 * @param ipaddr the destination address of the IP packet
 *
 */
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(u16_t proto) {
  struct raw_pcb *pcb;

  LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 3, ("raw_new\n"));

  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 */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区不卡| 在线免费一区三区| 伊人婷婷欧美激情| 精品国产乱码久久久久久影片| jizz一区二区| 蜜臀久久99精品久久久久宅男 | 亚洲国产精品精华液2区45| 色婷婷av一区二区三区之一色屋| 裸体歌舞表演一区二区| 亚洲精品亚洲人成人网在线播放| 2023国产精华国产精品| 欧美日韩另类一区| av在线不卡免费看| 极品尤物av久久免费看| 亚洲午夜精品一区二区三区他趣| 久久精品人人做| 欧美一区二区视频在线观看 | 欧美专区日韩专区| 国产精品亚洲第一区在线暖暖韩国 | 久久精品免费看| 亚洲高清久久久| 中文字幕一区二区三区不卡在线 | 中文字幕精品三区| 精品欧美乱码久久久久久| 欧美视频在线不卡| 91在线观看高清| 国产成人免费视频精品含羞草妖精| 亚洲一区二区三区美女| 亚洲天堂精品视频| 亚洲综合小说图片| 国产亚洲一区字幕| 国产精品萝li| 在线看国产日韩| 奇米精品一区二区三区在线观看| 日韩欧美国产一二三区| 欧美美女视频在线观看| 狠狠色丁香久久婷婷综合丁香| 久久久久久久久久久久久夜| 亚洲精品国产无天堂网2021| 欧美亚洲国产怡红院影院| 男人的j进女人的j一区| 久久综合资源网| 日本道精品一区二区三区| 亚洲一区二区成人在线观看| 5月丁香婷婷综合| 成人aaaa免费全部观看| 成人av在线资源网站| 成人晚上爱看视频| 久久久久久一二三区| 亚洲视频香蕉人妖| 亚洲chinese男男1069| 精油按摩中文字幕久久| 一本久久精品一区二区| 2020国产精品| 另类综合日韩欧美亚洲| 日本韩国一区二区| 91精品在线观看入口| 欧美三级乱人伦电影| 欧美日韩午夜在线| 欧美一区二区视频在线观看2022 | 综合在线观看色| 欧美一区二区三区喷汁尤物| 日韩免费性生活视频播放| 亚洲欧洲成人精品av97| 爽爽淫人综合网网站| 99在线热播精品免费| 在线观看日韩一区| 国产人成亚洲第一网站在线播放| 日韩一区二区视频| 成人激情综合网站| 91麻豆国产福利精品| 宅男噜噜噜66一区二区66| 精品久久久久久最新网址| 亚洲欧洲三级电影| 精品一区在线看| 粉嫩13p一区二区三区| 色婷婷综合久久| 欧美精品亚洲二区| 成熟亚洲日本毛茸茸凸凹| 日韩精品久久理论片| 激情文学综合网| 成人av在线播放网站| 精品99999| 美女网站视频久久| 欧美怡红院视频| 亚洲午夜三级在线| 欧美亚洲免费在线一区| 日韩黄色小视频| 欧美精品粉嫩高潮一区二区| 卡一卡二国产精品| 国产亚洲精品中文字幕| 蜜臀av在线播放一区二区三区| 国产精品资源网| 色综合久久久久| 国产精品区一区二区三区| 国产成a人无v码亚洲福利| 久久久久久免费| 成人听书哪个软件好| 久久综合狠狠综合久久激情 | 国产一区二区按摩在线观看| 不卡一区二区三区四区| 欧美一区二区三区在线看| 国产精品欧美经典| 麻豆久久久久久久| 欧美在线三级电影| 亚洲欧美在线观看| 国模一区二区三区白浆| 欧美日韩日本视频| 亚洲欧美在线视频| 粉嫩在线一区二区三区视频| 91精品国产欧美一区二区成人| 国产精品乱码一区二区三区软件 | 久久国产欧美日韩精品| 日本道色综合久久| 国产精品欧美久久久久无广告 | 国内精品伊人久久久久av一坑| 欧美主播一区二区三区美女| 国产亚洲欧洲997久久综合| 午夜精品福利一区二区三区av| www.亚洲激情.com| 337p日本欧洲亚洲大胆精品 | 成人污视频在线观看| 亚洲精品一区二区三区影院| 日韩精品午夜视频| 在线看国产一区二区| 亚洲色图清纯唯美| 成人激情小说网站| 国产精品系列在线| 成人短视频下载| 国产精品你懂的在线欣赏| 国产成人在线视频网址| 精品国产3级a| 国产综合久久久久久鬼色| 日韩一区二区免费在线电影| 日韩不卡一区二区三区| 欧美精品乱人伦久久久久久| 夜夜嗨av一区二区三区| 欧美中文字幕一区二区三区| 亚洲三级在线观看| 日本道在线观看一区二区| 一区二区三区在线视频播放| 色成人在线视频| 亚洲一卡二卡三卡四卡| 欧美视频一区二区三区四区| 五月综合激情网| 91精品国产欧美一区二区成人| 青草av.久久免费一区| 欧美一区二区高清| 国产一区欧美日韩| 国产日本欧洲亚洲| 成年人网站91| 一区二区三区免费看视频| 欧美日韩一区二区三区在线| 天堂午夜影视日韩欧美一区二区| 欧美日韩国产一级片| 日韩精品91亚洲二区在线观看 | 国产精品久久久久影院老司| 国产99一区视频免费| 亚洲一二三区在线观看| 亚洲成人精品一区二区| 久久亚洲二区三区| 青娱乐精品视频| 欧美日韩一二三区| 亚洲成人第一页| 日韩欧美美女一区二区三区| 午夜欧美电影在线观看| 日韩手机在线导航| 国产盗摄视频一区二区三区| 国产日韩av一区| 在线观看中文字幕不卡| 亚洲国产aⅴ天堂久久| 精品精品国产高清a毛片牛牛| 亚洲一区二区影院| 日韩三级免费观看| 成人美女视频在线看| 国产精品久久久久影院老司| 欧美日韩免费视频| 蜜桃视频在线观看一区| 国产精品久久久久影院老司| 欧美丝袜自拍制服另类| 蜜臀a∨国产成人精品| 国产日产亚洲精品系列| 91蜜桃免费观看视频| 蜜桃av一区二区三区电影| 成人久久18免费网站麻豆| 亚洲va韩国va欧美va精品| 久久久久久久久免费| 99在线精品一区二区三区| 美女网站一区二区| 中文字幕不卡的av| 777a∨成人精品桃花网| 成人夜色视频网站在线观看| 亚洲精品成人悠悠色影视| 欧美刺激午夜性久久久久久久| 国产麻豆精品在线| 日韩激情av在线| 国产亚洲成av人在线观看导航| 91同城在线观看| 国产一区二区女| 亚洲免费观看在线观看|