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

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

?? raw.c

?? ARM7的一些試驗程序
?? 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 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲人成人一区二区在线观看| 国产91清纯白嫩初高中在线观看| 黑人巨大精品欧美一区| 不卡一区二区三区四区| 日韩一区二区高清| 亚洲一二三四在线| av在线不卡网| 欧美韩国日本一区| 国产麻豆91精品| 欧美一区二区在线视频| 亚洲午夜精品一区二区三区他趣| 国产成人精品亚洲午夜麻豆| 欧美久久久久久蜜桃| 中文字幕一区二区在线播放| 国产乱人伦精品一区二区在线观看| 欧美日韩国产a| 伊人婷婷欧美激情| 99精品欧美一区二区三区综合在线| 精品国产亚洲一区二区三区在线观看 | 日韩av不卡一区二区| 成人国产一区二区三区精品| 日韩女优毛片在线| 日本视频一区二区三区| 欧美性做爰猛烈叫床潮| 亚洲综合色区另类av| 色视频一区二区| 亚洲视频在线一区二区| 9i在线看片成人免费| 欧美国产激情一区二区三区蜜月| 激情丁香综合五月| 欧美精品一区二区三区很污很色的| 日韩专区一卡二卡| 欧美一级艳片视频免费观看| 婷婷一区二区三区| 欧美一区二区三区在| 日日噜噜夜夜狠狠视频欧美人 | 北条麻妃国产九九精品视频| 欧美激情一区二区三区| 风流少妇一区二区| 中文字幕一区二| 日本韩国一区二区三区| 亚洲女人的天堂| 欧美视频中文一区二区三区在线观看| 亚洲自拍都市欧美小说| 欧美在线短视频| 视频一区中文字幕| 日韩免费看的电影| 国内精品伊人久久久久av影院| 久久只精品国产| 成人性生交大片免费看中文网站| 亚洲欧洲日韩av| 欧美日韩精品电影| 久久91精品国产91久久小草| 国产亚洲欧美中文| 日本精品一区二区三区高清 | 欧美一级片在线| 国产剧情一区在线| 亚洲天堂av一区| 51午夜精品国产| 国产.欧美.日韩| 亚洲大片在线观看| 久久久www成人免费无遮挡大片| 成人免费毛片a| 亚洲电影中文字幕在线观看| 日韩一区二区三区电影在线观看| 国产69精品久久久久毛片| 一区二区三区四区中文字幕| 51精品秘密在线观看| 日本欧美一区二区三区| 国产精品狼人久久影院观看方式| 欧美日韩一区高清| 岛国一区二区三区| 日本中文字幕一区二区视频| 中文字幕第一区综合| 这里只有精品免费| 91网站视频在线观看| 人人精品人人爱| 亚洲黄色小视频| 国产亚洲欧美日韩俺去了| 欧美日韩在线观看一区二区 | 这里只有精品视频在线观看| 成人激情视频网站| 久久99国内精品| 亚洲一区在线观看免费观看电影高清| 久久蜜桃一区二区| 欧美精品久久一区二区三区| 91在线观看一区二区| 国产精品一区二区视频| 日本最新不卡在线| 亚洲最大色网站| 亚洲视频网在线直播| 国产日本一区二区| 精品国产伦一区二区三区观看体验| 欧美日韩一区二区三区在线看| 不卡一区二区在线| 成人污视频在线观看| 99久久久久久| 韩国v欧美v亚洲v日本v| 丝袜美腿亚洲一区二区图片| 一二三四区精品视频| 亚洲人精品一区| 亚洲三级在线免费观看| 国产精品久久免费看| 国产欧美日韩在线视频| 久久品道一品道久久精品| 精品国产精品一区二区夜夜嗨| 日韩视频永久免费| 欧美va在线播放| 欧美一卡2卡3卡4卡| 欧美一区二区三区白人| 7777精品伊人久久久大香线蕉| 欧美三级日本三级少妇99| 欧美性做爰猛烈叫床潮| 欧美日韩国产片| 欧美日韩精品一区视频| 在线成人午夜影院| 91精品免费观看| 这里只有精品99re| 精品国产一区二区在线观看| 精品免费国产一区二区三区四区| 日韩美女视频在线| 久久美女艺术照精彩视频福利播放| 26uuu国产日韩综合| 久久久亚洲高清| 亚洲国产精品ⅴa在线观看| 中文字幕不卡的av| 亚洲免费av在线| 亚洲综合一区在线| 男男gaygay亚洲| 国产麻豆成人精品| 91麻豆福利精品推荐| 在线日韩av片| 日韩一区和二区| 国产欧美日韩在线观看| 一区免费观看视频| 天天综合网天天综合色 | 天天综合色天天综合| 奇米精品一区二区三区在线观看| 激情六月婷婷久久| 成人美女在线视频| 欧美日韩精品三区| 久久伊人蜜桃av一区二区| 国产午夜精品一区二区三区视频| 国产精品久久久久婷婷| 亚洲成人在线免费| 国产一区二区视频在线| 99精品国产一区二区三区不卡| 欧美日韩国产精品自在自线| 欧美精品一区二区三区蜜桃| 中文字幕一区二区三区不卡 | 成人深夜视频在线观看| 欧美在线一区二区| 久久综合精品国产一区二区三区| 国产精品天美传媒| 日日摸夜夜添夜夜添亚洲女人| 国产一区二区伦理| 欧美日韩亚洲综合在线| 欧美激情一区二区三区不卡 | 久久久久9999亚洲精品| 一区二区在线观看av| 久久精品国产99久久6| 99精品久久久久久| 久久久噜噜噜久噜久久综合| 亚洲一区二区三区影院| 国产盗摄视频一区二区三区| 欧美视频一区二区三区四区| 国产亚洲一区二区在线观看| 亚洲一区二区在线视频| 成人性视频网站| 精品国内二区三区| 首页亚洲欧美制服丝腿| 4438亚洲最大| 亚洲精品久久久蜜桃| 国产精品资源在线看| 欧美一区二区播放| 亚洲电影在线免费观看| 91色综合久久久久婷婷| 国产清纯白嫩初高生在线观看91| 日本女优在线视频一区二区| 色婷婷久久久综合中文字幕| 亚洲国产精品二十页| 国产在线视视频有精品| 717成人午夜免费福利电影| 亚洲另类春色校园小说| 成人午夜看片网址| 国产欧美日韩综合精品一区二区| 裸体歌舞表演一区二区| 欧美精品色综合| 亚洲第一成年网| 欧美日韩精品福利| 亚洲国产aⅴ天堂久久| 在线看一区二区| 一个色综合av| 欧美三区在线视频| 亚洲第一激情av| 欧美男同性恋视频网站| 午夜影院久久久| 3atv一区二区三区| 捆绑调教一区二区三区| 欧美变态tickle挠乳网站|