Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Macros

#define NPF_TCP_SRC_PORT_MATCH(_name, _port)
 Statically define a "TCP source port match" packet filter condition.
#define NPF_TCP_DST_PORT_MATCH(_name, _port)
 Statically define a "TCP destination port match" packet filter condition.
#define NPF_TCP_FLAGS_MATCH(_name, _mask, _flags)
 Statically define a "TCP flags match" packet filter condition.

TCP header flags

Flags for the mask and the flags of NPF_TCP_FLAGS_MATCH().

#define NPF_TCP_FLAG_FIN   BIT(0)
 No more data from the sender.
#define NPF_TCP_FLAG_SYN   BIT(1)
 Synchronize the sequence numbers.
#define NPF_TCP_FLAG_RST   BIT(2)
 Reset the connection.
#define NPF_TCP_FLAG_PSH   BIT(3)
 Push the data to the application.
#define NPF_TCP_FLAG_ACK   BIT(4)
 The acknowledgment number is valid.
#define NPF_TCP_FLAG_URG   BIT(5)
 The urgent pointer is valid.
#define NPF_TCP_FLAG_ECE   BIT(6)
 Explicit congestion notification echo.
#define NPF_TCP_FLAG_CWR   BIT(7)
 Congestion window reduced.

Detailed Description

Since
4.6
Version
0.1.0

These conditions are for the rules of npf_local_in_recv_rules. They rely on what the IP input stores in a packet while it processes the IP headers, so their result is not defined in the other rule lists.

Macro Definition Documentation

◆ NPF_TCP_DST_PORT_MATCH

#define NPF_TCP_DST_PORT_MATCH ( _name,
_port )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_port _name = { \
.proto = NET_IPPROTO_TCP, \
.port = net_htons(_port), \
.test.fn = npf_dst_port_match, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "tcp dst port", \
.test.type = NPF_TEST_TYPE_TCP_DST_PORT_MATCH,)) \
}
#define net_htons(x)
Convert 16-bit value from host to network byte order.
Definition net_ip.h:125
@ NET_IPPROTO_TCP
TCP protocol.
Definition net_ip.h:70

Statically define a "TCP destination port match" packet filter condition.

This tests if the packet is a TCP segment with the given destination port.

Parameters
_nameName of the condition
_portDestination port to match

◆ NPF_TCP_FLAG_ACK

#define NPF_TCP_FLAG_ACK   BIT(4)

#include <zephyr/net/net_pkt_filter.h>

The acknowledgment number is valid.

◆ NPF_TCP_FLAG_CWR

#define NPF_TCP_FLAG_CWR   BIT(7)

#include <zephyr/net/net_pkt_filter.h>

Congestion window reduced.

◆ NPF_TCP_FLAG_ECE

#define NPF_TCP_FLAG_ECE   BIT(6)

#include <zephyr/net/net_pkt_filter.h>

Explicit congestion notification echo.

◆ NPF_TCP_FLAG_FIN

#define NPF_TCP_FLAG_FIN   BIT(0)

#include <zephyr/net/net_pkt_filter.h>

No more data from the sender.

◆ NPF_TCP_FLAG_PSH

#define NPF_TCP_FLAG_PSH   BIT(3)

#include <zephyr/net/net_pkt_filter.h>

Push the data to the application.

◆ NPF_TCP_FLAG_RST

#define NPF_TCP_FLAG_RST   BIT(2)

#include <zephyr/net/net_pkt_filter.h>

Reset the connection.

◆ NPF_TCP_FLAG_SYN

#define NPF_TCP_FLAG_SYN   BIT(1)

#include <zephyr/net/net_pkt_filter.h>

Synchronize the sequence numbers.

◆ NPF_TCP_FLAG_URG

#define NPF_TCP_FLAG_URG   BIT(5)

#include <zephyr/net/net_pkt_filter.h>

The urgent pointer is valid.

◆ NPF_TCP_FLAGS_MATCH

#define NPF_TCP_FLAGS_MATCH ( _name,
_mask,
_flags )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_tcp_flags _name = { \
.mask = (_mask), \
.flags = (_flags) + ZERO_OR_COMPILE_ERROR(((_flags) & ~(_mask)) == 0), \
.test.fn = npf_tcp_flags_match, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "tcp flags", \
.test.type = NPF_TEST_TYPE_TCP_FLAGS_MATCH,)) \
}
#define ZERO_OR_COMPILE_ERROR(cond)
0 if cond is true-ish; causes a compile error otherwise.
Definition util.h:77
flags
Definition parser.h:86

Statically define a "TCP flags match" packet filter condition.

This tests if the packet is a TCP segment in which, of the flags in _mask, exactly the ones in _flags are set. The flags that are not in _mask are not tested.

For example, the mask NPF_TCP_FLAG_SYN | NPF_TCP_FLAG_ACK with the flags NPF_TCP_FLAG_SYN matches the segment that requests a connection, but neither the answer to it nor any later segment.

Parameters
_nameName of the condition
_maskFlags to test, a combination of the NPF_TCP_FLAG values
_flagsFlags that have to be set, the other flags of _mask have to be clear. A flag that is not in _mask is a build error.

◆ NPF_TCP_SRC_PORT_MATCH

#define NPF_TCP_SRC_PORT_MATCH ( _name,
_port )

#include <zephyr/net/net_pkt_filter.h>

Value:
struct npf_test_port _name = { \
.proto = NET_IPPROTO_TCP, \
.port = net_htons(_port), \
.test.fn = npf_src_port_match, \
IF_ENABLED(NPF_TEST_ENABLE_NAME, \
(.test.name = "tcp src port", \
.test.type = NPF_TEST_TYPE_TCP_SRC_PORT_MATCH,)) \
}

Statically define a "TCP source port match" packet filter condition.

This tests if the packet is a TCP segment with the given source port.

Parameters
_nameName of the condition
_portSource port to match