Berkeley Packet Filter (BPF) assembler. https://godoc.org/maze.io/x/bpf
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
maze 348e672a15 Docfix преди 5 месеца
cmd/bpfasm Added Program.Verify method преди 5 месеца
internal/parser Cleanup преди 5 месеца
testdata Initial import преди 5 месеца
.gitignore Renamed BPF ANTLR module to Assembler преди 5 месеца
LICENSE Updated license преди 5 месеца
Makefile Renamed BPF ANTLR module to Assembler преди 5 месеца
README.md Docfix преди 5 месеца
assembler.go Added Program.Verify method преди 5 месеца
bpf.go Supply type aliases for the bpf package преди 5 месеца
doc.go Initial import преди 5 месеца
go.mod More representable bpfasm command line tool преди 5 месеца
go.sum More representable bpfasm command line tool преди 5 месеца
parse.go Updated license преди 5 месеца
program.go Added Program.Verify method преди 5 месеца
vm.go Added Program.Verify method преди 5 месеца
vm_alu_test.go Updated license преди 5 месеца
vm_debug.go Updated license преди 5 месеца
vm_extension_test.go Updated license преди 5 месеца
vm_jump_test.go Updated license преди 5 месеца
vm_load_test.go Ported the bpf vm with pluggable extensions преди 5 месеца
vm_registers.go Ported the bpf vm with pluggable extensions преди 5 месеца
vm_ret_test.go Ported the bpf vm with pluggable extensions преди 5 месеца
vm_scratch_test.go Updated license преди 5 месеца
vm_test.go Updated license преди 5 месеца

README.md

bpf

Berkeley Packet Filter (BPF) assembler.

Installation

Easy as running go get:

~$ go get maze.io/x/bpf/cmd/bpfasm

Usage

Compiling an assembly file:

demo.asm contents:

; icmp random packet sampling, 1 in 4
        ldh 	[12]
        jne 	#0x800, drop
        ldb 	[23]
        jneq 	#1, drop
        ; get a random uint32 number
        ld      rand
        mod 	#4
        jneq 	#1, drop
        ret 	#-1
drop:	ret 	#0

Assembling to (big endian) binary:

~$ bpfasm assemble demo.asm
writing to demo.asm.bin

Disassembling:

~$ bpfasm disassemble demo.asm.bin
ld     #12
jne    #2048,6
ld     #23
jneq   #1,4
ld     #rand
mod    #4
jneq   #1,1
ret    #4294967295
ret    #0

Copyright

The assembler parser and compiler are © 2019 Wijnand Modderman-Lenstra.

The assembler virtual machine and opcode assembler are © 2009, 2016 The Go Authors.

For more details, see the LICENSE.