Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Ethernet Filter Conditions

Macros

#define NPF_ETH_SRC_ADDR_MATCH(_name, _addr_array)
 Statically define a "source address match" packet filter condition.
 
#define NPF_ETH_SRC_ADDR_UNMATCH(_name, _addr_array)
 Statically define a "source address unmatch" packet filter condition.
 
#define NPF_ETH_DST_ADDR_MATCH(_name, _addr_array)
 Statically define a "destination address match" packet filter condition.
 
#define NPF_ETH_DST_ADDR_UNMATCH(_name, _addr_array)
 Statically define a "destination address unmatch" packet filter condition.
 
#define NPF_ETH_SRC_ADDR_MASK_MATCH(_name, _addr_array, ...)
 Statically define a "source address match with mask" packet filter condition.
 
#define NPF_ETH_DST_ADDR_MASK_MATCH(_name, _addr_array, ...)
 Statically define a "destination address match with mask" packet filter condition.
 
#define NPF_ETH_TYPE_MATCH(_name, _type)
 Statically define an "Ethernet type match" packet filter condition.
 
#define NPF_ETH_TYPE_UNMATCH(_name, _type)
 Statically define an "Ethernet type unmatch" packet filter condition.
 
#define NPF_ETH_VLAN_TYPE_MATCH(_name, _type)
 Statically define an "Ethernet VLAN header type match" packet filter condition.
 
#define NPF_ETH_VLAN_TYPE_UNMATCH(_name, _type)
 Statically define an "Ethernet VLAN header type unmatch" packet filter condition.
 

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_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.
 

Detailed Description

Since
3.0
Version
0.8.0

Macro Definition Documentation

◆ NPF_ETH_DST_ADDR_MASK_MATCH

#define NPF_ETH_DST_ADDR_MASK_MATCH ( _name,
_addr_array,
... )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_addr _name = { \
.addresses = (_addr_array), \
.nb_addresses = ARRAY_SIZE(_addr_array), \
.mask.addr = { __VA_ARGS__ }, \
.test.fn = npf_eth_dst_addr_match, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "eth dst mask", \
.test.type = NPF_TEST_TYPE_ETH_DST_ADDR_MASK_MATCH,)) \
}
#define ARRAY_SIZE(array)
Number of elements in the given array.
Definition util.h:121

Statically define a "destination address match with mask" packet filter condition.

This tests if the packet destination address matches any of the Ethernet addresses contained in the provided set after applying specified mask.

Parameters
_nameName of the condition
_addr_arrayArray of struct net_eth_addr items to test against
...up to 6 mask bytes

◆ NPF_ETH_DST_ADDR_MATCH

#define NPF_ETH_DST_ADDR_MATCH ( _name,
_addr_array )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_addr _name = { \
.addresses = (_addr_array), \
.nb_addresses = ARRAY_SIZE(_addr_array), \
.test.fn = npf_eth_dst_addr_match, \
.mask.addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "eth dst", \
.test.type = NPF_TEST_TYPE_ETH_DST_ADDR_MATCH,)) \
}

Statically define a "destination address match" packet filter condition.

This tests if the packet destination address matches any of the Ethernet addresses contained in the provided set.

Parameters
_nameName of the condition
_addr_arrayArray of struct net_eth_addr items to test against

◆ NPF_ETH_DST_ADDR_UNMATCH

#define NPF_ETH_DST_ADDR_UNMATCH ( _name,
_addr_array )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_addr _name = { \
.addresses = (_addr_array), \
.nb_addresses = ARRAY_SIZE(_addr_array), \
.test.fn = npf_eth_dst_addr_unmatch, \
.mask.addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "!eth dst", \
.test.type = NPF_TEST_TYPE_ETH_DST_ADDR_UNMATCH,)) \
}

Statically define a "destination address unmatch" packet filter condition.

This tests if the packet destination address matches none of the Ethernet addresses contained in the provided set.

Parameters
_nameName of the condition
_addr_arrayArray of struct net_eth_addr items to test against

◆ NPF_ETH_SRC_ADDR_MASK_MATCH

#define NPF_ETH_SRC_ADDR_MASK_MATCH ( _name,
_addr_array,
... )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_addr _name = { \
.addresses = (_addr_array), \
.nb_addresses = ARRAY_SIZE(_addr_array), \
.mask.addr = { __VA_ARGS__ }, \
.test.fn = npf_eth_src_addr_match, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "eth src mask", \
.test.type = NPF_TEST_TYPE_ETH_SRC_ADDR_MASK_MATCH,)) \
}

Statically define a "source address match with mask" packet filter condition.

This tests if the packet source address matches any of the Ethernet addresses contained in the provided set after applying specified mask.

Parameters
_nameName of the condition
_addr_arrayArray of struct net_eth_addr items to test against
...up to 6 mask bytes

◆ NPF_ETH_SRC_ADDR_MATCH

#define NPF_ETH_SRC_ADDR_MATCH ( _name,
_addr_array )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_addr _name = { \
.addresses = (_addr_array), \
.nb_addresses = ARRAY_SIZE(_addr_array), \
.test.fn = npf_eth_src_addr_match, \
.mask.addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "eth src", \
.test.type = NPF_TEST_TYPE_ETH_SRC_ADDR_MATCH,)) \
}

Statically define a "source address match" packet filter condition.

This tests if the packet source address matches any of the Ethernet addresses contained in the provided set.

Parameters
_nameName of the condition
_addr_arrayArray of struct net_eth_addr items to test against

◆ NPF_ETH_SRC_ADDR_UNMATCH

#define NPF_ETH_SRC_ADDR_UNMATCH ( _name,
_addr_array )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_addr _name = { \
.addresses = (_addr_array), \
.nb_addresses = ARRAY_SIZE(_addr_array), \
.test.fn = npf_eth_src_addr_unmatch, \
.mask.addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "!eth src", \
.test.type = NPF_TEST_TYPE_ETH_SRC_ADDR_UNMATCH,)) \
}

Statically define a "source address unmatch" packet filter condition.

This tests if the packet source address matches none of the Ethernet addresses contained in the provided set.

Parameters
_nameName of the condition
_addr_arrayArray of struct net_eth_addr items to test against

◆ NPF_ETH_TYPE_MATCH

#define NPF_ETH_TYPE_MATCH ( _name,
_type )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_type _name = { \
.type = htons(_type), \
.test.fn = npf_eth_type_match, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "eth type", \
.test.type = NPF_TEST_TYPE_ETH_TYPE_MATCH,)) \
}
#define htons(x)
Convert 16-bit value from host to network byte order.
Definition net_ip.h:124

Statically define an "Ethernet type match" packet filter condition.

Parameters
_nameName of the condition
_typeEthernet type to match

◆ NPF_ETH_TYPE_UNMATCH

#define NPF_ETH_TYPE_UNMATCH ( _name,
_type )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_type _name = { \
.type = htons(_type), \
.test.fn = npf_eth_type_unmatch, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "!eth type", \
.test.type = NPF_TEST_TYPE_ETH_TYPE_UNMATCH,)) \
}

Statically define an "Ethernet type unmatch" packet filter condition.

Parameters
_nameName of the condition
_typeEthernet type to exclude

◆ NPF_ETH_VLAN_TYPE_MATCH

#define NPF_ETH_VLAN_TYPE_MATCH ( _name,
_type )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_type _name = { \
.type = htons(_type), \
.test.fn = npf_eth_vlan_type_match, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "eth vlan type", \
.test.type = NPF_TEST_TYPE_ETH_VLAN_TYPE_MATCH,)) \
}

Statically define an "Ethernet VLAN header type match" packet filter condition.

Parameters
_nameName of the condition
_typeEthernet VLAN header type to match

◆ NPF_ETH_VLAN_TYPE_UNMATCH

#define NPF_ETH_VLAN_TYPE_UNMATCH ( _name,
_type )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_eth_type _name = { \
.type = htons(_type), \
.test.fn = npf_eth_vlan_type_unmatch, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "!eth vlan type", \
.test.type = NPF_TEST_TYPE_ETH_VLAN_TYPE_UNMATCH,)) \
}

Statically define an "Ethernet VLAN header type unmatch" packet filter condition.

Parameters
_nameName of the condition
_typeEthernet VLAN header type to exclude

Typedef Documentation

◆ npf_rule_cb_t

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.

Parameters
rulePointer to current network packet filter rule
typeType of the rule (rx, tx, local_in, IPv4 or IPv6)
user_dataA valid pointer to user data or NULL

Enumeration Type Documentation

◆ npf_rule_type

#include <zephyr/net/net_pkt_filter.h>

Type of the packet filter rule.

Enumerator
NPF_RULE_TYPE_UNKNOWN 

Unknown rule type.

NPF_RULE_TYPE_SEND 

Rule for outgoing packets.

NPF_RULE_TYPE_RECV 

Rule for incoming packets.

NPF_RULE_TYPE_LOCAL_IN_RECV 

Rule for local incoming packets.

NPF_RULE_TYPE_IPV4_RECV 

Rule for IPv4 incoming packets.

NPF_RULE_TYPE_IPV6_RECV 

Rule for IPv6 incoming packets.

Function Documentation

◆ npf_rules_foreach()

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.

Parameters
cbUser-supplied callback function to call
user_dataUser specified data