LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: ilw10000

有个mac的问题,请高手帮忙解答.谢谢了!!!!!

[复制链接]
发表于 2005-6-16 15:12:41 | 显示全部楼层
请问如果向对方发送mac地址算是你要得答案吗? 比如用sendarp发送mac地址过去。

[root@eddie /]# sendarp --help
sendarp: send an arp packet
    usage: sendarp [-?] [-v] [-t message_type] [-i interface]
                   [-p sender_protocol_address] [-P target_protocol_address]
                   [-h sender_hardware_address] [-H target_hardware_address] [-v
]

    -?    display this message

    -v    verbose                         Default: not verbose
              Be verbose

    -t    message type               Default: 1
              Identifies the purpose for this ARP packet
              1    ARP Request
              2    ARP Response
              3    Reverse ARP Request
              4    Reverse ARP Response
              8    Inverse ARP Request
              9    Inverse ARP Response

    -i    interface                       Default: eth0
              Select an interface (eth1, lo, ppp0, whatever...)

    -p    sender protocol address         Default: 0.0.0.0
              Identifies the ip address of the system issuing the ARP packet.

    -P    target protocol address         Default: 0.0.0.0
              Identifies the ip address of the ARP packet's destination.

    -h    sender hardware address         Default: 00:00:00:00:00:00
              Identifies the hardware address of the system issuing the ARP pack
et.

    -H    target hardware address    Default: 00:00:00:00:00:00
              Identifies the hardware address of the ARP packet's destination.
回复 支持 反对

使用道具 举报

发表于 2005-6-16 16:19:13 | 显示全部楼层
如果不是只发送MAC地址,而是发送整个MAC帧呢?包括数据报
回复 支持 反对

使用道具 举报

发表于 2005-6-16 16:26:42 | 显示全部楼层
:~    不晓得
回复 支持 反对

使用道具 举报

发表于 2005-6-16 19:41:37 | 显示全部楼层

libnet

我记得有一个库叫libnet,你可以用它构造你想要的包,包括IP包和以太网帧,再与libcap库联合使用就可以实现在链路层的通讯了.
回复 支持 反对

使用道具 举报

发表于 2005-6-16 22:10:40 | 显示全部楼层
太谢谢你了!!
回复 支持 反对

使用道具 举报

发表于 2005-6-17 12:51:41 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2005-6-17 13:39:39 | 显示全部楼层
谢谢!
真是好人啊!
这位大虾知道直接使用系统调用可以吗?
就比如接收数据报是:recvfrom(),那么发送可以用sendto()吗?
需要修改什么参数吗?或者有什么细节需要注意吗?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-6-17 15:53:48 | 显示全部楼层
实在太感谢了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-6-17 15:58:54 | 显示全部楼层
接受是也同样可以抓到MAC了?
回复 支持 反对

使用道具 举报

发表于 2005-6-18 17:34:52 | 显示全部楼层
对,我记得我将例子提供的程序修改一下可以跑起来(lLINUX),在另外一台机子(windows)先用ping,再用arp -a可以看到从运行程序的机子(LINUX)传过来的MAC,即使这个MAC是虚构的。
另,直接用系统调用可能不行,这个我没有试过,应该是不行,recvfrom() 和sendto()本身就是发送和接收IP包的,顶多在使用原始套接字时可以随意生成IP包,但是要生成以太网的帧应该是不行的。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表