Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
dba994ab
提交
dba994ab
12月 26, 2011
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The start of a lwIP netif for xv6
上级
3d835a09
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
104 行增加
和
0 行删除
+104
-0
net.mk
net.mk
+1
-0
if.c
net/if.c
+103
-0
没有找到文件。
net.mk
浏览文件 @
dba994ab
...
...
@@ -53,6 +53,7 @@ LWIP_SRCFILES += \
lwip/src/core/udp.c \
lwip/src/netif/etharp.c \
net/sys_arch.c \
net/if.c \
LWIP_OBJFILES := $(patsubst %.c, $(O)/%.o, $(LWIP_SRCFILES))
LWIP_OBJFILES := $(patsubst %.S, $(O)/%.o, $(LWIP_OBJFILES))
...
...
net/if.c
0 → 100644
浏览文件 @
dba994ab
#include "lwip/stats.h"
#include "netif/etharp.h"
#include "kernel.h"
/**
* In this function, the hardware should be initialized.
* Called from if_init().
*
* @param netif the already initialized lwip network interface structure
* for this ethernetif
*/
static
void
low_level_init
(
struct
netif
*
netif
)
{
/* set MAC hardware address length */
netif
->
hwaddr_len
=
ETHARP_HWADDR_LEN
;
/* set MAC hardware address */
e1000hwaddr
(
netif
->
hwaddr
);
/* maximum transfer unit */
netif
->
mtu
=
1500
;
/* device capabilities */
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
netif
->
flags
=
NETIF_FLAG_BROADCAST
;
//| NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
/* Do whatever else is needed to initialize interface. */
}
/**
* This function 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.
*
* @param netif the lwip network interface structure for this ethernetif
* @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
* @return ERR_OK if the packet could be sent
* an err_t value if the packet couldn't be sent
*
* @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
* strange results. You might consider waiting for space in the DMA queue
* to become availale since the stack doesn't retry to send a packet
* dropped because of memory failure (except for the TCP timers).
*/
static
err_t
low_level_output
(
struct
netif
*
netif
,
struct
pbuf
*
p
)
{
struct
pbuf
*
q
;
panic
(
"low_level_output"
);
// initiate transfer();
#if ETH_PAD_SIZE
pbuf_header
(
p
,
-
ETH_PAD_SIZE
);
/* drop the padding word */
#endif
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();
#if ETH_PAD_SIZE
pbuf_header
(
p
,
ETH_PAD_SIZE
);
/* reclaim the padding word */
#endif
LINK_STATS_INC
(
link
.
xmit
);
return
ERR_OK
;
}
/**
* 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.
*
* This function should be passed as a parameter to netif_add().
*
* @param netif the lwip network interface structure for this ethernetif
* @return ERR_OK if the loopif is initialized
* ERR_MEM if private data couldn't be allocated
* any other err_t on error
*/
err_t
if_init
(
struct
netif
*
netif
)
{
netif
->
state
=
NULL
;
netif
->
output
=
etharp_output
;
netif
->
linkoutput
=
low_level_output
;
memmove
(
&
netif
->
name
[
0
],
"en"
,
2
);
/* initialize the hardware */
low_level_init
(
netif
);
return
ERR_OK
;
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论