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

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

?? ethernetif.c

?? 一個輕量tcpip協議在移植在ucOS2系統上運行
?? C
字號:
/*
 * Copyright (c) 2001-2003 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>
 *
 */

/*
 * This file is a skeleton for developing Ethernet network interface
 * drivers for lwIP. Add code to the low_level functions and do a
 * search-and-replace for the word "ethernetif" to replace it with
 * something that better describes your network interface.
 *
 * THIS CODE NEEDS TO BE FIXED - IT IS NOT In SYNC WITH CURRENT ETHARP API
 */

#include "lwip/debug.h"

#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/sys.h"

#include "netif/etharp.h"
#include "netif/arp.h"

/* Define those to better describe your network interface. */
#define IFNAME0 'e'
#define IFNAME1 't'

struct ethernetif {
  struct eth_addr *ethaddr;
  /* Add whatever per-interface state that is needed here. */
};

static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};

/* Forward declarations. */
static void  ethernetif_input(struct netif *netif);
static err_t ethernetif_output(struct netif *netif, struct pbuf *p,
			       struct ip_addr *ipaddr);

/*-----------------------------------------------------------------------------------*/
static void
low_level_init(struct netif *netif)
{
  struct ethernetif *ethernetif;

  ethernetif = netif->state;
  
  /* set MAC hardware address length */
  netif->hwaddr_len = 6;

  /* set MAC hardware address */
  netif->hwaddr[0] = 0x00;
  netif->hwaddr[1] = 0x11;
  netif->hwaddr[2] = 0x22;
  netif->hwaddr[3] = 0x33;
  netif->hwaddr[4] = 0x44;
  netif->hwaddr[5] = 0x55;

  /* maximum transfer unit */
  netif->mtu = 1500;
  
  /* broadcast capability */
  netif->flags = NETIF_FLAG_BROADCAST;
 
  /* Do whatever else is needed to initialize interface. */  
}
/*-----------------------------------------------------------------------------------*/
/*
 * low_level_output():
 *
 * Should do the actual transmission of the packet. The packet is
 * contained in the pbuf that is passed to the function. This pbuf
 * might be chained.
 *
 */
/*-----------------------------------------------------------------------------------*/

static err_t
low_level_output(struct ethernetif *ethernetif, struct pbuf *p)
{
  struct pbuf *q;

//  initiate transfer();
  
  for(q = p; q != NULL; q = q->next) {
    /* Send the data from the pbuf to the interface, one pbuf at a
       time. The size of the data in each pbuf is kept in the ->len
       variable. */
//    send data from(q->payload, q->len);
  }

//  signal that packet should be sent();
  
#ifdef LINK_STATS
  lwip_stats.link.xmit++;
#endif /* LINK_STATS */      

  return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
/*
 * low_level_input():
 *
 * Should allocate a pbuf and transfer the bytes of the incoming
 * packet from the interface into the pbuf.
 *
 */
/*-----------------------------------------------------------------------------------*/
static struct pbuf *
low_level_input(struct ethernetif *ethernetif)
{
  struct pbuf *p, *q;
  u16_t len;

  /* Obtain the size of the packet and put it into the "len"
     variable. */
//  len = ;

  /* We allocate a pbuf chain of pbufs from the pool. */
  p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
  
  if(p != NULL) {
    /* We iterate over the pbuf chain until we have read the entire
       packet into the pbuf. */
    for(q = p; q != NULL; q = q->next) {
      /* Read enough bytes to fill this pbuf in the chain. The
         available data in the pbuf is given by the q->len
         variable. */
 //     read data into(q->payload, q->len);
    }
 //   acknowledge that packet has been read();
#ifdef LINK_STATS
    lwip_stats.link.recv++;
#endif /* LINK_STATS */      
  } else {
//    drop packet();
#ifdef LINK_STATS
    lwip_stats.link.memerr++;
    lwip_stats.link.drop++;
#endif /* LINK_STATS */      
  }

  return p;  
}
/*-----------------------------------------------------------------------------------*/
/*
 * ethernetif_output():
 *
 * This function is called by the TCP/IP stack when an IP packet
 * should be sent. It calls the function called low_level_output() to
 * do the actuall transmission of the packet.
 *
 */
/*-----------------------------------------------------------------------------------*/
static err_t
ethernetif_output(struct netif *netif, struct pbuf *p,
		  struct ip_addr *ipaddr)
{
  struct ethernetif *ethernetif;
  struct pbuf *q;
  struct eth_hdr *ethhdr;
  struct eth_addr *dest, mcastaddr;
  struct ip_addr *queryaddr;
  err_t err;
  u8_t i;
  
  ethernetif = netif->state;

  /* Make room for Ethernet header. */
  if(pbuf_header(p, 14) != 0) {
    /* The pbuf_header() call shouldn't fail, but we allocate an extra
       pbuf just in case. */
    q = pbuf_alloc(PBUF_LINK, 14, PBUF_RAM);
    if(q == NULL) {
#ifdef LINK_STATS
      lwip_stats.link.drop++;
      lwip_stats.link.memerr++;
#endif /* LINK_STATS */      
      return ERR_MEM;
    }
    pbuf_chain(q, p);
    p = q;
  }

  /* Construct Ethernet header. Start with looking up deciding which
     MAC address to use as a destination address. Broadcasts and
     multicasts are special, all other addresses are looked up in the
     ARP table. */
  queryaddr = ipaddr;
  if(ip_addr_isany(ipaddr) ||
     ip_addr_isbroadcast(ipaddr, &(netif->netmask))) {
    dest = (struct eth_addr *)&ethbroadcast;
  } else if(ip_addr_ismulticast(ipaddr)) {
    /* Hash IP multicast address to MAC address. */
    mcastaddr.addr[0] = 0x01;
    mcastaddr.addr[1] = 0x0;
    mcastaddr.addr[2] = 0x5e;
    mcastaddr.addr[3] = ip4_addr2(ipaddr) & 0x7f;
    mcastaddr.addr[4] = ip4_addr3(ipaddr);
    mcastaddr.addr[5] = ip4_addr4(ipaddr);
    dest = &mcastaddr;
  } else {

    if(ip_addr_maskcmp(ipaddr, &(netif->ip_addr), &(netif->netmask))) {
      /* Use destination IP address if the destination is on the same
         subnet as we are. */
      queryaddr = ipaddr;
    } else {
      /* Otherwise we use the default router as the address to send
         the Ethernet frame to. */
      queryaddr = &(netif->gw);
    }
    dest = arp_lookup(queryaddr);
  }


  /* If the arp_lookup() didn't find an address, we send out an ARP
     query for the IP address. */
  if(dest == NULL) {
    q = etharp_query(netif, ethernetif->ethaddr, queryaddr);
    if(q != NULL) {
      err = low_level_output(ethernetif, q);
      pbuf_free(q);
      return err;
    }
#ifdef LINK_STATS
    lwip_stats.link.drop++;
    lwip_stats.link.memerr++;
#endif /* LINK_STATS */          
    return ERR_MEM;
  }
  ethhdr = p->payload;

  for(i = 0; i < 6; i++) {
    ethhdr->dest.addr[i] = dest->addr[i];
    ethhdr->src.addr[i] = ethernetif->ethaddr->addr[i];
  }
  
  ethhdr->type = htons(ETHTYPE_IP);
  
  return low_level_output(ethernetif, p);

}
/*-----------------------------------------------------------------------------------*/
/*
 * ethernetif_input():
 *
 * This function should be called when a packet is ready to be read
 * from the interface. It uses the function low_level_input() that
 * should handle the actual reception of bytes from the network
 * interface.
 *
 */
/*-----------------------------------------------------------------------------------*/
static void
ethernetif_input(struct netif *netif)
{
  struct ethernetif *ethernetif;
  struct eth_hdr *ethhdr;
  struct pbuf *p;


  ethernetif = netif->state;
  
  p = low_level_input(ethernetif);

  if(p != NULL) {

#ifdef LINK_STATS
    lwip_stats.link.recv++;
#endif /* LINK_STATS */

    ethhdr = p->payload;
    
    switch(htons(ethhdr->type)) {
    case ETHTYPE_IP:
      etharp_ip_input(netif, p);
      pbuf_header(p, -14);
      netif->input(p, netif);
      break;
    case ETHTYPE_ARP:
      p = etharp_arp_input(netif, ethernetif->ethaddr, p);
      if(p != NULL) {
	low_level_output(ethernetif, p);
	pbuf_free(p);
      }
      break;
    default:
      pbuf_free(p);
      break;
    }
  }
}
/*-----------------------------------------------------------------------------------*/
static void
arp_timer(void *arg)
{
  etharp_tmr();
  sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
}
/*-----------------------------------------------------------------------------------*/
/*
 * ethernetif_init():
 *
 * Should be called at the beginning of the program to set up the
 * network interface. It calls the function low_level_init() to do the
 * actual setup of the hardware.
 *
 */
/*-----------------------------------------------------------------------------------*/
err_t
ethernetif_init(struct netif *netif)
{
  struct ethernetif *ethernetif;
    
  ethernetif = mem_malloc(sizeof(struct ethernetif));
  if(ethernetif=NULL)  return ERR_MEM;//added by dy
  
  netif->state = ethernetif;
  netif->name[0] = IFNAME0;
  netif->name[1] = IFNAME1;
  netif->output = ethernetif_output;
  netif->linkoutput = low_level_output;
  
  ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
  
  low_level_init(netif);
  etharp_init();

  sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
  
  return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美xfplay| 亚洲一级片在线观看| 51精品久久久久久久蜜臀| 99精品欧美一区二区三区综合在线| 国产精品一区二区x88av| 国产伦精品一区二区三区在线观看| 久久er99精品| 成a人片亚洲日本久久| 色婷婷综合久久久久中文 | 色婷婷一区二区三区四区| 日韩视频免费观看高清完整版在线观看| 91精品视频网| 亚洲无人区一区| 精品在线你懂的| 99久久精品国产一区| 国产亚洲欧美日韩在线一区| 日韩码欧中文字| 日韩av高清在线观看| 国产黄色精品视频| 欧美午夜宅男影院| 久久精品一区四区| 国产在线精品一区二区三区不卡| 欧美欧美欧美欧美首页| 久久久不卡网国产精品一区| 亚洲天堂2016| 97精品电影院| 亚洲免费在线观看视频| 经典三级一区二区| 欧美不卡一区二区| 激情综合色播五月| 成人免费av在线| 91精品国产手机| 亚洲人成伊人成综合网小说| 99精品久久99久久久久| 国产精品美女一区二区在线观看| 午夜精品123| 暴力调教一区二区三区| 日韩精品一区二区三区视频在线观看| 国产精品你懂的在线| 成人a免费在线看| 日韩一区中文字幕| 国模冰冰炮一区二区| 久久亚洲综合色| 日韩综合在线视频| 91污片在线观看| 久久久久国产精品免费免费搜索| 国产成人午夜电影网| 国产精品麻豆99久久久久久| 91老司机福利 在线| 亚洲成在人线在线播放| 91在线视频18| 亚洲成人激情综合网| 日韩欧美黄色影院| 成人h动漫精品一区二| 亚洲综合久久av| 精品久久久久久久久久久久久久久| 国产一区二区三区av电影| 亚洲国产精品成人综合色在线婷婷| 美日韩黄色大片| 欧美一激情一区二区三区| 国产一区二区三区免费播放| 综合久久综合久久| 欧美一区二区三区的| 大桥未久av一区二区三区中文| 一区二区理论电影在线观看| 91麻豆免费视频| 日本aⅴ亚洲精品中文乱码| 欧美精品tushy高清| 丝袜美腿亚洲一区二区图片| 国产色婷婷亚洲99精品小说| 欧美日韩电影在线| 国产成人精品一区二| 午夜精品一区二区三区免费视频| www国产成人免费观看视频 深夜成人网| 99re视频精品| 国产一区视频网站| 婷婷国产v国产偷v亚洲高清| 国产精品视频在线看| 在线综合视频播放| 91在线国内视频| 狠狠色伊人亚洲综合成人| 亚洲黄色性网站| 正在播放亚洲一区| 色综合天天综合色综合av| 亚洲欧美日韩在线播放| 久久久九九九九| 91精品国产高清一区二区三区| 99久久综合精品| 国产一区二区三区免费看| 午夜伦理一区二区| 夜夜精品视频一区二区| 日本一区二区三级电影在线观看 | 欧美日韩综合一区| 亚洲成人在线观看视频| 国产精品久久久久久久久久免费看| 成年人午夜久久久| 国产乱码精品一区二区三| 日韩成人免费电影| 亚洲成人动漫在线免费观看| 亚洲麻豆国产自偷在线| 国产精品久久久久久户外露出| 久久久91精品国产一区二区精品| 日韩欧美一区二区在线视频| 欧美午夜免费电影| 在线亚洲免费视频| 精品一区二区在线播放| 日韩高清不卡一区二区三区| 亚洲自拍偷拍九九九| 一区二区三区.www| 夜夜爽夜夜爽精品视频| 一区二区三区波多野结衣在线观看| 亚洲欧美日韩国产综合| 亚洲欧美另类小说视频| 一区二区免费看| 亚洲二区在线视频| 亚洲成人在线观看视频| 日韩电影在线看| 久久99国内精品| 狠狠狠色丁香婷婷综合激情| 国产乱妇无码大片在线观看| 国产成人免费在线| 99国产精品一区| 欧美亚洲动漫精品| 在线成人av影院| 精品日本一线二线三线不卡| www成人在线观看| 国产精品亲子伦对白| 亚洲色图欧美激情| 午夜国产精品一区| 免费日本视频一区| 国产91丝袜在线18| 久久精品国产99国产| 国产一区二区三区精品欧美日韩一区二区三区 | 国产精品久久久久久亚洲毛片| 中文字幕一区二区三区在线不卡 | 欧美在线高清视频| 91精品国产日韩91久久久久久| 日韩欧美一级二级| 国产欧美日本一区视频| 亚洲啪啪综合av一区二区三区| 亚洲专区一二三| 另类的小说在线视频另类成人小视频在线 | 欧美精品一卡两卡| 久久影院午夜片一区| 日韩一区在线看| 丝袜脚交一区二区| 东方aⅴ免费观看久久av| 色综合天天综合给合国产| 欧美高清激情brazzers| 日本一区二区免费在线观看视频| 伦理电影国产精品| 成人18视频在线播放| 在线不卡中文字幕播放| 欧美国产日本视频| 日本aⅴ亚洲精品中文乱码| 成人小视频在线| 日韩精品一区二区三区视频播放 | 麻豆极品一区二区三区| 成人av电影在线观看| 欧美电影在哪看比较好| 日本一区二区免费在线观看视频 | 精品剧情v国产在线观看在线| 中文一区二区在线观看| 日本少妇一区二区| 91片黄在线观看| 精品国产乱码久久久久久1区2区 | 欧美—级在线免费片| 日日欢夜夜爽一区| 91蜜桃在线免费视频| 久久久99精品免费观看| 婷婷丁香久久五月婷婷| 91麻豆文化传媒在线观看| 久久精品欧美一区二区三区不卡 | 成人在线视频首页| 精品免费国产一区二区三区四区| 一区二区久久久久| a4yy欧美一区二区三区| 国产午夜亚洲精品理论片色戒| 丝袜脚交一区二区| 欧美午夜电影一区| 国产精品国产三级国产普通话蜜臀 | 成人h动漫精品| 国产婷婷色一区二区三区四区| 男人的天堂久久精品| 欧美亚洲一区三区| 亚洲欧美另类图片小说| 波多野结衣中文字幕一区| 久久久久97国产精华液好用吗| 蓝色福利精品导航| 欧美一区二区三区精品| 日本欧洲一区二区| 欧美人体做爰大胆视频| 亚洲成人av在线电影| 欧美日韩一级片网站| 亚洲综合免费观看高清在线观看| 91麻豆免费在线观看| 一区二区三区在线免费视频| 91麻豆高清视频| 亚洲一区二区三区中文字幕在线 | 精品免费一区二区三区|