韦东山视频实验之虚拟网卡

来源:互联网 发布:怎样检查网络设置 编辑:程序博客网 时间:2024/04/29 04:02

遇到的问题

1.调试老是弹出以下问题

/home/smb/pro/16th_virtnet/virtnet.c: In function 'emulator_rx_packet':
/home/smb/pro/16th_virtnet/virtnet.c:48: error: dereferencing pointer to incomplete type
/home/smb/pro/16th_virtnet/virtnet.c:49: error: dereferencing pointer to incomplete type
/home/smb/pro/16th_virtnet/virtnet.c:55: error: invalid application of 'sizeof' to incomplete type 'struct iphdr'
/home/smb/pro/16th_virtnet/virtnet.c:59: error: dereferencing pointer to incomplete type
/home/smb/pro/16th_virtnet/virtnet.c:60: error: dereferencing pointer to incomplete type
/home/smb/pro/16th_virtnet/virtnet.c:60: error: dereferencing pointer to incomplete type
make[2]: *** [/home/smb/pro/16th_virtnet/virtnet.o] 错误 1
make[1]: *** [_module_/home/smb/pro/16th_virtnet] 错误 2
make[1]: Leaving directory `/home/smb/pro/linux-2.6.29'
make: *** [all] 错误 2

后来使用对比软件,才知道少了头文件 ”ip.h“

2. 调试的时候有一个并不相同

 1) insmod virt_net.ko
 2) ifconfig vnet0 3.3.3.3
        ifconfig // 查看
3. ping 3.3.3.3  // 成功  
    ping 3.3.3.4  // 死机

最后一个我也能ping通,而且在ping 3.3.3.3 时候发现根本不调用自己写的函数virt_net->hard_start_xmit = virt_net_send_packet;

这个函数并没有使用,只有ping 3.3.3.4的时候才使用了这个函数?估计跟我使用路由器有关,自用搜寻到在同一网段,而且采用广播的形式,只不过没有进行过滤,所以导致别的ip地址也能收到。

原创粉丝点击