def buildArpResponse(packet, mac): if not isinstance(packet, Arp): packet = base.extract(packet, Arp) if packet is None: return None resp = Arp() resp.hwdst = packet.hwsrc resp.protodst = packet.protosrc resp.hwsrc = mac resp.protosrc = packet.protodst resp.hwtype = Arp.HW_TYPE_ETHERNET resp.hwlen = 6 resp.prototype = Arp.PROTO_TYPE_IP resp.protolen = 4 resp.opcode = Arp.REPLY return resp