Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
|
Network Packet Filter API . More...
Topics | |
Basic Filter Conditions | |
Ethernet Filter Conditions | |
Data Structures | |
struct | npf_test |
common filter test structure to be embedded into larger structures More... | |
struct | npf_rule |
filter rule structure More... | |
struct | npf_rule_list |
rule set for a given test location More... | |
Macros | |
#define | NPF_RULE(_name, _result, ...) |
Statically define one packet filter rule. | |
Functions | |
void | npf_insert_rule (struct npf_rule_list *rules, struct npf_rule *rule) |
Insert a rule at the front of given rule list. | |
void | npf_append_rule (struct npf_rule_list *rules, struct npf_rule *rule) |
Append a rule at the end of given rule list. | |
bool | npf_remove_rule (struct npf_rule_list *rules, struct npf_rule *rule) |
Remove a rule from the given rule list. | |
bool | npf_remove_all_rules (struct npf_rule_list *rules) |
Remove all rules from the given rule list. | |
Variables | |
struct npf_rule | npf_default_ok |
Default rule list termination for accepting a packet. | |
struct npf_rule | npf_default_drop |
Default rule list termination for rejecting a packet. | |
struct npf_rule_list | npf_send_rules |
rule list applied to outgoing packets | |
struct npf_rule_list | npf_recv_rules |
rule list applied to incoming packets | |
struct npf_rule_list | npf_local_in_recv_rules |
rule list applied for local incoming packets | |
struct npf_rule_list | npf_ipv4_recv_rules |
rule list applied for IPv4 incoming packets | |
struct npf_rule_list | npf_ipv6_recv_rules |
rule list applied for IPv6 incoming packets | |
Network Packet Filter API .
#define NPF_RULE | ( | _name, | |
_result, | |||
... ) |
#include <zephyr/net/net_pkt_filter.h>
Statically define one packet filter rule.
This creates a rule from a variable amount of filter conditions. This rule can then be inserted or appended to the rule list for a given network packet path.
Example:
The above would accept IP packets that are 200 bytes or smaller, and drop all other packets.
Another (less efficient) way to create the same result could be:
The first rule in the list for which all conditions are true determines the fate of the packet. If one condition is false then the next rule in the list is evaluated.
_name | Name for this rule. |
_result | Fate of the packet if all conditions are true, either NET_OK or NET_DROP . |
... | List of conditions for this rule. |
void npf_append_rule | ( | struct npf_rule_list * | rules, |
struct npf_rule * | rule ) |
#include <zephyr/net/net_pkt_filter.h>
Append a rule at the end of given rule list.
rules | the affected rule list |
rule | the rule to be appended |
void npf_insert_rule | ( | struct npf_rule_list * | rules, |
struct npf_rule * | rule ) |
#include <zephyr/net/net_pkt_filter.h>
Insert a rule at the front of given rule list.
rules | the affected rule list |
rule | the rule to be inserted |
bool npf_remove_all_rules | ( | struct npf_rule_list * | rules | ) |
#include <zephyr/net/net_pkt_filter.h>
Remove all rules from the given rule list.
rules | the affected rule list |
true | if at least one rule was removed from the rule list |
bool npf_remove_rule | ( | struct npf_rule_list * | rules, |
struct npf_rule * | rule ) |
#include <zephyr/net/net_pkt_filter.h>
Remove a rule from the given rule list.
rules | the affected rule list |
rule | the rule to be removed |
true | if given rule was found in the rule list and removed |
|
extern |
#include <zephyr/net/net_pkt_filter.h>
Default rule list termination for rejecting a packet.
|
extern |
#include <zephyr/net/net_pkt_filter.h>
Default rule list termination for accepting a packet.
|
extern |
#include <zephyr/net/net_pkt_filter.h>
rule list applied for IPv4 incoming packets
|
extern |
#include <zephyr/net/net_pkt_filter.h>
rule list applied for IPv6 incoming packets
|
extern |
#include <zephyr/net/net_pkt_filter.h>
rule list applied for local incoming packets
|
extern |
#include <zephyr/net/net_pkt_filter.h>
rule list applied to incoming packets
|
extern |
#include <zephyr/net/net_pkt_filter.h>
rule list applied to outgoing packets