Rule utilitaries.
More...
Rule utilitaries.
- Date
- 2022-11-02
- Copyright
- Copyright (c) 2022
◆ counter_duration_init()
Initialize the values of a duration_init_t structure.
Initialize the values of a duration_t structure.
- Parameters
-
nft_table_name | name of the nftables table containing the associated nftables counter |
nft_counter_name | name of the associated nftables counter |
- Returns
- duration_init_t struct containing the initial duration value
◆ counter_read_bytes()
int32_t counter_read_bytes |
( |
char * |
table_name, |
|
|
char * |
counter_name |
|
) |
| |
Read the bytes value of an nftables counter.
- Parameters
-
table_name | name of the nftables table containing the counter |
counter_name | name of the nftables counter to read |
- Returns
- bytes value of the counter
◆ counter_read_microseconds()
uint64_t counter_read_microseconds |
( |
| ) |
|
Read the current microseconds value.
- Returns
- current microseconds value
◆ counter_read_packets()
int32_t counter_read_packets |
( |
char * |
table_name, |
|
|
char * |
counter_name |
|
) |
| |
Read the packet count value of an nftables counter.
- Parameters
-
table_name | name of the nftables table containing the counter |
counter_name | name of the nftables counter to read |
- Returns
- packet count value of the counter
◆ delete_nft_rule()
bool delete_nft_rule |
( |
char * |
nft_table, |
|
|
char * |
nft_chain, |
|
|
char * |
nft_rule |
|
) |
| |
Delete an nftables rule.
Retrieve the rule handle, then delete the rule.
- Parameters
-
nft_table | nftables table containing the rule |
nft_chain | nftables chain containing the rule |
nft_rule | nftables rule to delete |
- Returns
- true if the rule was correctly deleted, false otherwise
◆ delete_nft_rule_by_handle()
bool delete_nft_rule_by_handle |
( |
char * |
nft_table, |
|
|
char * |
nft_chain, |
|
|
int16_t |
handle |
|
) |
| |
Delete an nftables rule, by specifying its handle.
- Parameters
-
nft_table | nftables table containing the rule |
nft_chain | nftables chain containing the rule |
handle | handle of the nftables rule to delete |
- Returns
- true if the rule was correctly deleted, false otherwise
◆ exec_nft_cmd()
bool exec_nft_cmd |
( |
char * |
cmd | ) |
|
Execute an nftables command.
- Parameters
-
cmd | nftables command to be executed |
- Returns
- true if the command was correctly executed, false otherwise
◆ exec_nft_cmd_verbose()
char* exec_nft_cmd_verbose |
( |
char * |
cmd | ) |
|
Execute an nftables command and return its output.
Uses libnftables to execute the command.
- Parameters
-
cmd | nftables command to be executed |
- Returns
- buffer containing the command output, or NULL in case of error
◆ get_nft_handle()
int16_t get_nft_handle |
( |
char * |
buf | ) |
|
Get an nftables handle from a command output.
- Parameters
-
buf | nftables command output to search for the handle |
- Returns
- nftables handle, or -1 in case of error