Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segevfiner/pybpf_asm
Python BPF Assembler
https://github.com/segevfiner/pybpf_asm
bpf cython python python3
Last synced: about 2 months ago
JSON representation
Python BPF Assembler
- Host: GitHub
- URL: https://github.com/segevfiner/pybpf_asm
- Owner: segevfiner
- License: gpl-2.0
- Created: 2022-02-06T09:39:16.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T09:15:38.000Z (about 2 months ago)
- Last Synced: 2024-10-29T10:06:30.971Z (about 2 months ago)
- Topics: bpf, cython, python, python3
- Language: Yacc
- Homepage: https://pypi.org/project/bpf-asm/
- Size: 286 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
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: DocsPython 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 `_.
* On macOS (and sometimes on Linux, on older distributions), you can install them from `Homebrew `_. 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:: pythonimport 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.