Skip to main content

Python BPF Assembler

Project description

PyPI Build & Test 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.

  • 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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bpf_asm-0.1.3.tar.gz (24.4 kB view hashes)

Uploaded Source

Built Distributions

bpf_asm-0.1.3-cp312-cp312-win_amd64.whl (54.2 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

bpf_asm-0.1.3-cp312-cp312-win32.whl (48.6 kB view hashes)

Uploaded CPython 3.12 Windows x86

bpf_asm-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (66.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

bpf_asm-0.1.3-cp312-cp312-macosx_10_9_universal2.whl (94.8 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64)

bpf_asm-0.1.3-cp311-cp311-win_amd64.whl (54.0 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

bpf_asm-0.1.3-cp311-cp311-win32.whl (49.5 kB view hashes)

Uploaded CPython 3.11 Windows x86

bpf_asm-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (65.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

bpf_asm-0.1.3-cp311-cp311-macosx_10_9_universal2.whl (95.3 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

bpf_asm-0.1.3-cp310-cp310-win_amd64.whl (53.9 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

bpf_asm-0.1.3-cp310-cp310-win32.whl (49.6 kB view hashes)

Uploaded CPython 3.10 Windows x86

bpf_asm-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (66.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

bpf_asm-0.1.3-cp310-cp310-macosx_10_9_universal2.whl (95.3 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

bpf_asm-0.1.3-cp39-cp39-win_amd64.whl (53.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

bpf_asm-0.1.3-cp39-cp39-win32.whl (49.6 kB view hashes)

Uploaded CPython 3.9 Windows x86

bpf_asm-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (66.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

bpf_asm-0.1.3-cp39-cp39-macosx_10_9_universal2.whl (95.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

bpf_asm-0.1.3-cp38-cp38-win_amd64.whl (53.9 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

bpf_asm-0.1.3-cp38-cp38-win32.whl (49.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

bpf_asm-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (66.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

bpf_asm-0.1.3-cp38-cp38-macosx_10_9_universal2.whl (95.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

bpf_asm-0.1.3-cp37-cp37m-win_amd64.whl (54.4 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

bpf_asm-0.1.3-cp37-cp37m-win32.whl (49.5 kB view hashes)

Uploaded CPython 3.7m Windows x86

bpf_asm-0.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (65.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page