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

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

?? eth4510if.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"

//added by dy
#include <string.h>
#include "eth4510if.h"
#include "MacUtil.h"

/*dy's debug*/
#include "snds.h"
#include "std.h"
#include "HW_Periph.h"
#include "HW_func.h"
#include "sysconf.h"
/*dy's debug*/

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

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



/* Forward declarations. */
void
ethernetif_input(struct netif *netif,u8_t* ptr ,u32_t len);
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] = 0x55;
  netif->hwaddr[1] = 0x44;
  netif->hwaddr[2] = 0x33;
  netif->hwaddr[3] = 0x22;
  netif->hwaddr[4] = 0x11;
  netif->hwaddr[5] = 0x00;//硬件上的初始化需要與這里一致
	ethernetif->ethaddr->addr[0] = netif->hwaddr[0];
  	ethernetif->ethaddr->addr[1] = netif->hwaddr[1];
  	ethernetif->ethaddr->addr[2] = netif->hwaddr[2];
  	ethernetif->ethaddr->addr[3] = netif->hwaddr[3];
  	ethernetif->ethaddr->addr[4] = netif->hwaddr[4];
  	ethernetif->ethaddr->addr[5] = netif->hwaddr[5];
  /* maximum transfer unit */
  netif->mtu = 1500;
  /* broadcast capability */
  netif->flags = NETIF_FLAG_BROADCAST;

 //init hardware
 LanInitialize();

 
  /* 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 netif *ethernetif, struct pbuf *p)
{
	u8_t 			*pFrameData,*tmp ;
	u32_t			FrameLength ;
	struct pbuf		*q;



       pFrameData = mem_malloc(p->tot_len);
       if (pFrameData == NULL)return ERR_MEM;
       FrameLength = p->tot_len;
	tmp = pFrameData;
  	for(q = p; q != NULL; q = q->next) 
  	{
  	memcpy ((u8_t *)tmp,(u8_t *)q->payload,q->len);
  	tmp+=q->len;
 /* 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. */
  	}


  	SendPacket((u8_t *)pFrameData , FrameLength );
  	
  	mem_free(pFrameData);
  
#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,u8_t* ptr ,u32_t length)
{
  struct pbuf *p, *q;
  u16_t len;

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

  /* 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) {
    	
    	memcpy ((u8_t *)q->payload,(u8_t *)ptr,q->len);
    	ptr+=q->len;
    	
      /* 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 = arp_query(netif, ethernetif->ethaddr, queryaddr);
    if(q != NULL) {


      err = low_level_output(netif, 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(netif, 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.
 *
 */
/*-----------------------------------------------------------------------------------*/

//這個函數在中斷中被調用,其參數netif被設置為 netif_default指針,
//該指針需要在開始時被初始化,否則其沒有input()回調函數。


void ethernetif_input(struct netif *netif,u8_t* ptr ,u32_t len)
{
  struct ethernetif *ethernetif;
  struct eth_hdr *ethhdr;
  struct pbuf *p;
  ethernetif = netif->state;


p = low_level_input(ethernetif,ptr,len);

  if(p != NULL) {

/*dy's debug*/
	IOPDATA= IOPDATA&0x01 ? IOPDATA &(~0x01) : IOPDATA |0x01;
/*dy's debug*/


#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:
/*dy's debug*/
	IOPDATA= IOPDATA&0x02 ? IOPDATA &(~0x02) : IOPDATA |0x02;
/*dy's debug*/
      p = etharp_arp_input(netif, ethernetif->ethaddr, p);
      if(p != NULL) {
	low_level_output(netif, 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一区二区三区免费野_久草精品视频
久久精品一区二区三区不卡 | 亚洲在线一区二区三区| 亚洲成va人在线观看| 国产一区91精品张津瑜| 欧美系列一区二区| 久久精品在线观看| 日韩高清一级片| 国产99久久久国产精品潘金网站| www.欧美.com| 久久色.com| 视频一区二区三区入口| 99精品视频一区| 久久精品在线免费观看| 美国一区二区三区在线播放| 欧美私人免费视频| 国产精品欧美一区喷水| 国产一区欧美一区| 717成人午夜免费福利电影| 一区在线观看视频| 国产一区二区不卡老阿姨| 7777精品久久久大香线蕉| 一区二区免费视频| caoporn国产一区二区| 国产喂奶挤奶一区二区三区| 日韩二区三区四区| 欧美日韩国产首页在线观看| 亚洲最新视频在线播放| 一本久久综合亚洲鲁鲁五月天 | 成人欧美一区二区三区视频网页| 激情欧美一区二区| 欧美成人欧美edvon| 偷拍日韩校园综合在线| 在线观看日韩国产| 亚洲黄色免费网站| 91久久精品国产91性色tv| 国产精品另类一区| 国产成人一区在线| 亚洲国产高清不卡| www.欧美色图| 亚洲另类一区二区| 91久久免费观看| 亚洲成人av一区二区| 欧美精品一二三| 日韩av电影天堂| 欧美成人精品3d动漫h| 国内精品第一页| 国产日韩欧美高清| 91丨porny丨首页| 亚洲亚洲精品在线观看| 欧美精品久久久久久久久老牛影院| 日日欢夜夜爽一区| 日韩欧美卡一卡二| 成人免费视频国产在线观看| 国产精品高潮呻吟| 欧美亚洲国产一区二区三区 | 久久99精品久久久| 国产亚洲成年网址在线观看| 成人黄色综合网站| 亚洲福利视频三区| 久久午夜羞羞影院免费观看| 成人污污视频在线观看| 亚洲精品日日夜夜| 91麻豆精品国产91久久久使用方法 | 国产免费久久精品| 99精品视频免费在线观看| 亚洲777理论| 2023国产精品| 91麻豆精东视频| 日本欧美一区二区在线观看| 久久久亚洲欧洲日产国码αv| 99re这里只有精品首页| 天天av天天翘天天综合网色鬼国产 | 亚洲精品一区二区三区99| 丰满岳乱妇一区二区三区| 亚洲综合图片区| 久久综合国产精品| 91精品办公室少妇高潮对白| 免费成人小视频| 综合久久国产九一剧情麻豆| 欧美久久久久久蜜桃| 成人性色生活片| 日韩成人一区二区三区在线观看| 日本一区二区三级电影在线观看| 欧美中文字幕亚洲一区二区va在线 | 精品欧美黑人一区二区三区| 91在线一区二区三区| 久久成人久久爱| 亚洲第四色夜色| 亚洲欧洲av在线| 久久久亚洲国产美女国产盗摄| 欧美优质美女网站| 国产99久久久国产精品潘金网站| 免费看欧美美女黄的网站| 亚洲国产一区二区在线播放| 国产精品私房写真福利视频| 91麻豆精品国产91久久久久| 91丨porny丨首页| 成人一区二区视频| 久久99精品视频| 日韩国产精品久久| 亚洲va在线va天堂| 亚洲黄色免费电影| 中文字幕乱码一区二区免费| 精品国产第一区二区三区观看体验| 欧美性大战久久久久久久| 97久久久精品综合88久久| 国产精品中文有码| 国产在线精品视频| 国产一区999| 国产一区 二区| 国产福利视频一区二区三区| 国产一区二三区好的| 九一九一国产精品| 另类小说综合欧美亚洲| 麻豆成人久久精品二区三区红 | 日韩免费看的电影| 91精品福利在线一区二区三区 | 久久婷婷久久一区二区三区| 精品人伦一区二区色婷婷| 日韩女优av电影| 欧美裸体一区二区三区| 日本精品视频一区二区三区| 国产精品亚洲一区二区三区在线| 国产一区二区调教| 精品一区二区三区在线播放| 午夜精品福利在线| 亚洲成人自拍偷拍| 日韩电影一区二区三区四区| 午夜久久久久久久久| 亚洲激情欧美激情| 亚洲制服丝袜av| 亚洲综合999| 日日摸夜夜添夜夜添国产精品 | 91精品国产免费久久综合| 欧美三级蜜桃2在线观看| 成人不卡免费av| 在线视频国内自拍亚洲视频| 91蜜桃网址入口| 91久久久免费一区二区| 色欧美片视频在线观看| 大尺度一区二区| 在线观看视频一区二区| 欧美午夜精品久久久久久超碰| 欧美无砖专区一中文字| 欧美伊人久久久久久午夜久久久久| 一本久道久久综合中文字幕| 日本电影欧美片| 欧美日韩免费电影| 日韩亚洲欧美高清| 26uuu国产一区二区三区| 精品福利一二区| 亚洲欧美日韩中文播放 | 91麻豆精品国产91久久久更新时间| 欧美色男人天堂| 91精品国产色综合久久ai换脸| 亚洲精品在线观看视频| 国产校园另类小说区| 国产精品久久久久永久免费观看 | 91麻豆精品国产91久久久久久久久 | 成人欧美一区二区三区白人| 国产无一区二区| 日韩av中文字幕一区二区三区| 久久国产精品一区二区| 成人影视亚洲图片在线| 欧美亚洲综合另类| 日韩一二在线观看| 一区二区视频在线看| 日本亚洲欧美天堂免费| 国产乱人伦精品一区二区在线观看 | 在线精品国精品国产尤物884a| 91美女视频网站| 欧美一区二区成人| 国产精品久久久久久久久搜平片 | 亚洲毛片av在线| 免费日韩伦理电影| av中文字幕在线不卡| 91麻豆精品国产91久久久使用方法 | 2023国产精华国产精品| 成人免费一区二区三区在线观看| 丝袜美腿成人在线| 久久电影网电视剧免费观看| 一本久道中文字幕精品亚洲嫩| 日韩欧美在线综合网| 亚洲欧美日韩国产成人精品影院 | 欧美系列亚洲系列| 日本一二三四高清不卡| 日韩av电影免费观看高清完整版 | 91精品国产色综合久久不卡蜜臀| 国产精品久久久久影视| 精品亚洲免费视频| 欧美一区二区啪啪| 亚洲综合激情网| 另类调教123区| 欧美少妇一区二区| 国产精品区一区二区三区| 性欧美疯狂xxxxbbbb| 欧美日韩国产系列| 一个色综合网站| 成人黄色在线视频| 久久久99久久|