Metadata-Version: 2.1
Name: bpf_asm
Version: 0.1.4
Summary: Python BPF Assembler
Home-page: https://github.com/segevfiner/pybpf_asm
Author: Segev Finer
Author-email: segev208@gmail.com
License: GPL-2.0-only
Project-URL: Documentation, https://segevfiner.github.io/pybpf_asm/
Project-URL: Issue Tracker, https://github.com/segevfiner/pybpf_asm/issues
Keywords: bpf
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: System :: Networking :: Monitoring
Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: flake8; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: sphinx==5.*; extra == "dev"

pybpf_asm
=========
.. image:: https://img.shields.io/pypi/v/bpf_asm.svg
   :target: https://pypi.org/project/bpf_asm/
   :alt: PyPI

.. image:: https://github.com/segevfiner/pybpf_asm/actions/workflows/build-and-test.yml/badge.svg
   :target: https://github.com/segevfiner/pybpf_asm/actions/workflows/build-and-test.yml
   :alt: Build & Test

.. image:: https://github.com/segevfiner/pybpf_asm/actions/workflows/docs.yml/badge.svg
   :target: https://segevfiner.github.io/pybpf_asm/
   :alt: Docs

Python BPF Assembler.

Based on the BPF assembler in Linux sources.

Installations
-------------
Wheels are available.

To build from source you need a relatively recent Flex & Bison:

* On Windows, you can use `winflexbison <https://github.com/lexxmark/winflexbison>`_.
* On macOS (and sometimes on Linux, on older distributions), you can install them from `Homebrew <https://brew.sh/>`_. Note that you might have to add Homebrew's version to the front of the ``PATH``, e.g. ``PATH="$(brew --prefix)/opt/flex/bin:$(brew --prefix)/opt/bison/bin:$PATH"``.

Usage
-----
.. code-block:: python

    import bpf_asm


    ASM = """\
        ldh [12]
        jeq #0x800, accept, drop
    accept:
        ret #65536
    drop:
        ret #0
    """

    print(bpf_asm.assemble(ASM))


Or use the ``pybpf_asm`` script. See ``pybpf_asm --help`` for usage.

License
-------
GPL-2.0-only.
