scapy_driver.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:steth 作者: openstack 项目源码 文件源码
def send_dhcp_over_qvb(self, port_id, port_mac):
        """Send DHCP Discovery over qvb device.
        """
        qvb_device = utils.get_vif_name(constants.QVB_DEVICE_PREFIX, port_id)
        ethernet = scapy.Ether(dst='ff:ff:ff:ff:ff:ff',
                               src=port_mac, type=0x800)
        ip = scapy.IP(src='0.0.0.0', dst='255.255.255.255')
        udp = scapy.UDP(sport=68, dport=67)
        port_mac_t = tuple(map(lambda x: int(x, 16), port_mac.split(':')))
        hw = struct.pack('6B', *port_mac_t)
        bootp = scapy.BOOTP(chaddr=hw, flags=1)
        dhcp = scapy.DHCP(options=[("message-type", "discover"), "end"])
        packet = ethernet / ip / udp / bootp / dhcp
        scapy.sendp(packet, iface=qvb_device)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号