你知道Uboot中的net是怎样的?

//net读
//api/api.c
static cfp_t calls_table[api_maxcall] = { null, };
void api_init(void)
{
...
calls_table[api_rsvd] = null;
calls_table[api_getc] = &api_getc;
calls_table[api_putc] = &api_putc;
calls_table[api_tstc] = &api_tstc;
calls_table[api_puts] = &api_puts;
calls_table[api_reset] = &api_reset;
calls_table[api_get_sys_info] = &api_get_sys_info;
calls_table[api_udelay] = &api_udelay;
calls_table[api_get_timer] = &api_get_timer;
calls_table[api_dev_enum] = &api_dev_enum;
calls_table[api_dev_open] = &api_dev_open;
calls_table[api_dev_close] = &api_dev_close;
calls_table[api_dev_read] = &api_dev_read;
calls_table[api_dev_write] = &api_dev_write;
calls_table[api_env_get] = &api_env_get;
calls_table[api_env_set] = &api_env_set;
calls_table[api_env_enum] = &api_env_enum;
calls_no = api_maxcall;
...
}
static int api_dev_read(va_list ap)
{
...
else if (di->type & dev_typ_net)
{
len_net = (int *)va_arg(ap, u_int32_t);
if (!len_net)
return api_einval;
if (*len_net cookie, buf, *len_net);
}
...
}
//api/api_net.c
int dev_read_net(void *cookie, void *buf, int len)
{
return eth_receive(buf, len);
}
//net/eth.c
int eth_receive(volatile void *packet, int length)
{
if (eth_rcv_current == eth_rcv_last)
{
...
push_packet = eth_save_packet;
eth_rx();
push_packet = pp;
if (eth_rcv_current == eth_rcv_last)
return -1;
...
}
//drivers\net\higmacv300\higmac.c
int eth_rx(void)
{
...
netreceive(netrxpackets[0], len);
...
}
//net/net.c
voidnetreceive(volatile uchar * inpkt, int len)
{
...
x = ntohs(vet->vet_type);
...
switch (x)
{
case prot_arp:
...
switch (ntohs(arp->ar_op))
{
...
case arpop_request:
...
case arpop_reply:
...
tmp = netreadip(&arp->ar_data[6]);
if (tmp == netarpwaitreplyip)
{
...
(*packethandler)(0,0,0,0);
...
}
case prot_rarp:
...
case prot_ip:
...
if (ip->ip_p == ipproto_icmp)
{
...
switch (icmph->type)
{
case icmp_redirect:
...
case icmp_echo_reply:
...
case icmp_echo_request:
...
}
}
}
}
}
static rxhand_f *packethandler;/* current rx packet handler*/
voidnetsethandler(rxhand_f * f)
{
packethandler = f;
}
//net/net.h
typedef voidrxhand_f(uchar *, unsigned, unsigned, unsigned);
举例tftp通讯
//net/tftp.c
voidtftpstart (void)
{
...
netsethandler (tftphandler);
...
}
static voidtftphandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
{
...
s = (ushort *)pkt;
proto = *s++;
...
switch (ntohs(proto))
{
case tftp_rrq:
case tftp_wrq:
break;
case tftp_ack:
}
}
好记性不如烂笔头

基于数字锁相环4046实现汽车测速系统的设计
如何有效降低白色家电电源待机功耗?
小米松果处理器终于要来了,小米5C也会一起同时发布
梳理STC15系列UART串口的用法
斩波器的工作原理 斩波电路的三种控制方式
你知道Uboot中的net是怎样的?
工信部初步确定5G部署频段 5G核心网架构确认
苹果耗巨资研发的地图有优于谷歌地图吗?
iPad案中案:苹果或存重大违法行为
plc控制柜制作标准
网络交换机常见的类型 优秀的网络交换机厂商介绍
独立式烟雾报警器、联网型烟雾报警器、智能无线烟感报警器具有五大独特发展优势
霍尔传感器在自助咖啡机中的应用
柜台电子签名板应该怎么挑选?电子签批板推荐
科普:深度学习真的那么难吗?
realme真我X50 5G将于2020年1月7日发布 将是2020年第一款5G手机
凌锐半导体正式推出新一代1200V 18毫欧和35毫欧SiC MOS
人工智能实现触觉和视觉的信息交互
TI 音频创新日:闭环放大器性能介绍
互联网对于世界的影响有多大