|
Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
|
Network Packet Filter API. More...
Topics | |
| Basic Filter Conditions | |
| Ethernet Filter Conditions | |
| IP Filter Conditions | |
| TCP Filter Conditions | |
| UDP 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. | |
| #define | NPF_PRIORITY(_name, _priority, ...) |
| Statically define one packet filter rule that sets the packet priority. | |
Typedefs | |
| typedef void(* | npf_rule_cb_t) (struct npf_rule *rule, enum npf_rule_type type, void *user_data) |
| Callback used while iterating over network packet filter rules. | |
Enumerations | |
| enum | npf_rule_type { NPF_RULE_TYPE_UNKNOWN = 0 , NPF_RULE_TYPE_SEND , NPF_RULE_TYPE_RECV , NPF_RULE_TYPE_LOCAL_IN_RECV , NPF_RULE_TYPE_IPV4_RECV , NPF_RULE_TYPE_IPV6_RECV } |
| Type of the packet filter rule. More... | |
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. | |
| void | npf_rules_foreach (npf_rule_cb_t cb, void *user_data) |
| Go through all the network packet filter rules and call callback for each of them. | |
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_PRIORITY | ( | _name, | |
| _priority, | |||
| ... ) |
#include <zephyr/net/net_pkt_filter.h>
Statically define one packet filter rule that sets the packet priority.
This creates a rule from a variable amount of filter conditions. Unlike a rule created with NPF_RULE(), it does not determine the fate of the packet: if all conditions are true, the priority of the packet is set to _priority and the next rule in the list is evaluated.
A priority rule does not end the evaluation. If no later rule in the list matches, the packet is dropped, so the list needs a terminating rule such as npf_default_ok, as in the example below.
Example:
The above would accept all packets and give the PTP packets the network control priority.
| _name | Name for this rule. |
| _priority | Priority of the packet if all conditions are true, one of net_priority. |
| ... | List of conditions for this rule. |
| #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.
| typedef void(* npf_rule_cb_t) (struct npf_rule *rule, enum npf_rule_type type, void *user_data) |
#include <zephyr/net/net_pkt_filter.h>
Callback used while iterating over network packet filter rules.
| rule | Pointer to current network packet filter rule |
| type | Type of the rule (rx, tx, local_in, IPv4 or IPv6) |
| user_data | A valid pointer to user data or NULL |
| enum npf_rule_type |
#include <zephyr/net/net_pkt_filter.h>
Type of the packet filter 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 |
| void npf_rules_foreach | ( | npf_rule_cb_t | cb, |
| void * | user_data ) |
#include <zephyr/net/net_pkt_filter.h>
Go through all the network packet filter rules and call callback for each of them.
| cb | User-supplied callback function to call |
| user_data | User specified data |
|
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