Solnix Language Keywords Reference
This document lists all available keywords in the Solnix language and provides brief descriptions of how each works.
Core Program Structure Keywords
unit
Defines a BPF program unit (eBPF program). Each unit represents a single eBPF program that can be attached to various kernel hooks.
Usage:
unit program_name {
// program body
}
section
Specifies the section name for the eBPF program. This determines where the program will be attached in the kernel (e.g., tracepoints, kprobes, XDP, etc.).
Usage:
section: "tracepoint/syscalls/sys_enter_execve";
license
Declares the license for the eBPF program. Required for kernel verification. Common values: "GPL", "Dual BSD/GPL".
Usage:
license: "GPL";
Variable Declaration Keywords
reg
Declares a register variable. Register variables are stored in CPU registers and are mutable. They are the primary way to store and manipulate data in eBPF programs.
Usage:
reg my_var = 10;
reg result = a + b;
imm
Declares an immediate (constant) variable. Immutable variables that hold constant values. Useful for values that won't change during program execution.
Usage:
imm k0 = 0;
imm index = 5;
heap
Declares a heap variable that references data from a BPF map. Used to access values stored in maps. The value is obtained via a map lookup operation.
Usage:
heap p0 = results.lookup(k0);
Map Declaration Keywords
map
Declares a BPF map. Maps are shared data structures between eBPF programs and user space, or between multiple eBPF programs.
Usage:
map map_name {
type: .array;
key: u32;
value: u64;
max: 8;
}
type
Specifies the map type within a map declaration. Must be prefixed with a dot (.). Available map types:
- .hash - Hash table map
- .array - Array map
- .ringbuf - Ring buffer map
- .lru_hash - LRU hash map
- .prog_array - Program array map
Usage:
type: .array;
key
Specifies the key type for a map. Must be one of: u32, u64, i32, i64.
Usage:
key: u32;
value
Specifies the value type for a map. Must be one of: u32, u64, i32, i64.
Usage:
value: u64;
max
Specifies the maximum number of entries in a map. Must be a non-negative integer.
Usage:
max: 1024;
Control Flow Keywords
if
Conditional statement that executes code based on a guard condition.
Usage:
if guard (condition_var) {
// code block
}
guard
Used with if to specify the guard condition. The condition is checked against a variable.
Usage:
if guard (my_var) {
// executes if my_var is non-zero
}
return
Returns a value from the eBPF program. The return value typically indicates success (0) or error codes.
Usage:
return 0;
return error_code;
Type Keywords
These are also recognized as keywords but represent primitive types:
u32- 32-bit unsigned integeru64- 64-bit unsigned integeri32- 32-bit signed integeri64- 64-bit signed integer
Usage:
key: u32;
value: u64;
Summary
Total Keywords: 13
1. unit - Program definition
2. section - Section name declaration
3. license - License declaration
4. reg - Register variable declaration
5. imm - Immediate/constant variable declaration
6. heap - Heap variable (map lookup) declaration
7. map - Map declaration
8. type - Map type specification
9. key - Map key type specification
10. value - Map value type specification
11. max - Map max entries specification
12. if - Conditional statement
13. guard - Guard condition (used with if)
14. return - Return statement
Type Keywords: 4
- u32, u64, i32, i64
Map Type Keywords: 5 (used with type:)
- hash, array, ringbuf, lru_hash, prog_array