This command sets the filter program that will be applied to incoming data on a hook. The following structure must be supplied as an argument:
struct ng_bpf_hookprog {
char thisHook[NG_HOOKSIZ];/* name of hook */
char ifMatch[NG_HOOKSIZ]; /* match dest hook */
char ifNotMatch[NG_HOOKSIZ]; /* !match dest hook */
int32_t bpf_prog_len; /* #isns in program */
struct bpf_insn bpf_prog[0]; /* bpf program */
};
The hook to be updated is specified in thisHook. The BPF program is the sequence of instructions in the bpf_prog array; there must be bpf_prog_len of them. Matching and non-matching incoming packets are delivered out the hooks named ifMatch and ifNotMatch, respectively. The program must be a valid bpf(4) program or else EINVAL is returned.
NGM_BPF_GET_PROGRAM
This command takes an ASCII string argument, the hook name, and returns the corresponding "struct ng_bpf_hookprog" as shown above.
NGM_BPF_GET_STATS
This command takes an ASCII string argument, the hook name, and returns the statistics associated with the hook as a "struct ng_bpf_hookstat".
NGM_BPF_CLR_STATS
This command takes an ASCII string argument, the hook name, and clears the statistics associated with the hook.
NGM_BPF_GETCLR_STATS
This command is identical to NGM_BPF_GET_STATS, except that the statistics are also atomically cleared.