Expression Engine

The expression engine is a powerful matching and filtering system used throughout Netify Agent to define network policies, network intelligence rules, and classification criteria. It enables network administrators and integrators to craft sophisticated rules that match flows based on dozens of attributes.

Two syntax modes are available for creating flow expressions: a compact syntax optimized for simple use cases, and a full-featured standard syntax for more advanced logic.

Compact Syntax
Streamlined syntax for matching applications, protocols, and categories using short tags and identifiers.
Standard Syntax
Full-featured syntax with comparison operators, booleans, regular expressions, and dozens of flow attributes.

Compact Syntax

Introduced in Netify 5.2, the compact syntax provides a streamlined way to define flow classification rules for common and straightforward use cases. Compact rules are especially useful when building quick classifications, prototyping policies, or implementing well-defined matching logic without the overhead of full rule definitions.

A key feature of the compact syntax is the ability to invert any flow criterion using the logical NOT operator ! . This makes it easy to exclude specific matches or define negative conditions without restructuring the rule.

Compact Example - Flow Actions

"social": {
  "criteria": "ac:social-media",
  "targets": [
    "ctmark.low-priority"
  ]
}

Applications and Protocols

The ai prefix can be used for application matching and the pi prefix can be used for protocol matching.

Examples: Applications and Protocols
ai:facebook
Facebook application short tag
ai:netify.facebook
Facebook application full tag
ai:119
Facebook application ID
pi:5
DNS protocol ID

Application and Protocol Categories

For categories, the ac prefix can be specified for application categories, and the pc prefix for protocol categories.

Examples: Categories
ac:adult
Adult application category tag
ac:2
Adult application category ID
pc:database
Database protocol category tag
pc:2
Database protocol category ID

Standard Syntax

The standard syntax provides the most flexible and expressive way to define flow classification rules in Netify. It supports full logical expressions that can evaluate a wide range of flow attributes, including application, protocol, IP and MAC addresses, ports, and category metadata.

Unlike the compact syntax, standard expressions are designed for more advanced use cases where precise control, compound conditions, or layered logic is required. This makes it the preferred approach for production policies, complex filtering, and fine-grained traffic classification.

Comparison Operators

==
Equal to
!=
Not equal to
>
Greater than
>=
Greater than or equal to
<
Less than
<=
Less than or equal to

Boolean Operators

!
Not
&&
And
and
And
||
Or
or
Or

Regular Expressions

Introduced in 5.2, string type attributes support regular expressions using the rx: prefix. For example, if you wanted to match on the detected_hostname property:

"criteria": "detected_hostname == 'rx:.*xxx';"

Precedence

Use parentheses to explicitly define evaluation order. By grouping expressions within round brackets ( ), you override default operator precedence.

"criteria": "(a || b) && c;"

Lists

Multiple expressions can be joined in an implicit OR statement by setting the criteria to an array.

"criteria": [
    "application == 'youtube';",
    "protocol_id == 20;",
    "protocol == 'icmp';",
    "category == 'adult';",
    "application == 'netify.linkedin';"
]

Match All / Wildcard

The simplest form of criteria is match all flows, accomplished with the use of the asterisk (*). An interface filter and/or exemptions can still be used to filter out flows when using a wildcard for the flow criteria.

...
"criteria": "*"
"interface": "br0",
...

Configlets

Specifying the criteria as a folder pathname causes individual configlets within the folder to be parsed and used as the criteria.

"criteria": "${path_state_persistent}/nfa-priority.d"

In this case, we could drop in the following configlet to define individual games we might want to prioritize:

/etc/netifyd/nfa-priority.d/10-server-games.conf

app == 'netify.rockstar-games';
app == 'netify.epic-games';
app == 'netify.ea-games';

Criteria Reference

Data Types

The data types used in the expression engine are detailed below. The address attribute is a flexible format that supports IPs, CIDRs, MACs and address groups.

Type Description
address IP, CIDR, MAC or address group
hex A hexadecimal value
integer A standard integer value
string A regular string, quotes required
mixed An integer or string
boolean Boolean value
constant Defined expression constant

Only strings and mixed types are enclosed in single quotes. The Netify Agent will return an error when initializing the Flow Actions plugin on any deviation.

Attributes

application

mixed
The detected application tag or ID. The netify prefix can be omitted from the application tag.
Aliases:
application_id app app_id

application_category

string
The detected application category tag.
Aliases:
app_category

application_category_id

integer
The detected application category ID.
Aliases:
app_category_id

category

string
The detected application category tag in an application, domain, category list, overlay, or network intelligence domain categorization.
Aliases:
cat

category_id

integer
The detected application category ID in an application, domain, category list, overlay, or network intelligence domain categorization.
Aliases:
cat_id

conntrack_id

integer
The connection tracking ID.
Aliases:
ct_id

conntrack_mark

integer
The connection tracking mark.
Aliases:
ct_mark

ct_reply_dst_ip

address
The connection tracking destination IP.

ct_reply_src_ip

address
The connection tracking source IP.

detected_hostname

string
The detected hostname, which can be extracted from a variety of protocols.

detection_complete

boolean
Flag to indicate classification has been completed, typically in fewer than 32 packets.

detection_guessed

boolean
If the protocol could not be determined via packet analysis, an attempt to 'guess' the protocol is made using various methods such as the port address(es).

detection_init

boolean
Flag to indicate initial application and/or protocol has been detected.

detection_updated

boolean
Flag to indicate flow metadata has been extracted (e.g., TLS certificate info) leading to the possible application being refined.

dhc_hit

boolean
Flag to indicate a hit in the DNS hint cache (DHC).

dns_hostname

string
Hostname extracted from DNS queries.

domain_category

string
The detected category tag from custom category lists.
Aliases:
dom_category

domain_category_id

integer
The detected category ID from custom category lists.
Aliases:
dom_category_id

dst_ip

address
Destination IP address.

dst_mac

address
Destination MAC address.

dst_network_category

string
Destination network category tag.
Aliases:
dst_net_category

dst_network_category_id

integer
Destination network category ID.
Aliases:
dst_net_category_id

dst_port

integer
Destination port number.

expired

boolean
Flag indicating the flow has expired.

expiring

boolean
Flag indicating the flow is nearing expiration.

fhc_hit

boolean
Flag to indicate a hit in the flow hash cache (FHC).

iface

string
Network interface name (or index).

iface_nfq_dst

string
NFQUEUE destination interface name.

iface_nfq_src

string
NFQUEUE source interface name.

intel_*

string
Intel metadata fields with dynamic suffixes (matches tokens starting with 'intel_').

ip

address
Any IP address: local_ip or other_ip.

ip_dscp

integer
Differentiated Services Code Point (DSCP) value.

ip_nat

boolean
The NAT flag is set if the flow is found in the connection tracking table on a WAN. Linux only.

ip_protocol

integer
Internet protocol ID. For example, 6 for TCP.

ip_version

integer
IP version.
Values:
4 6

local_ip

address
Local IP address.

local_mac

address
Local MAC address.

local_network_category

string
Local network category tag.
Aliases:
local_net_category

local_network_category_id

integer
Local network category ID.
Aliases:
local_net_category_id

local_port

integer
Local port, when applicable, depending on ip_protocol.

mac

address
Any MAC address (local or other).

network_category

string
Network category tag.
Aliases:
net_category

network_category_id

integer
Network category ID.
Aliases:
net_category_id

origin

constant
The origin end-point of the flow (which side, local or other, initiated the packet flow).
Values:
origin_local origin_other origin_unknown

other_ip

address
Other IP address.

other_mac

address
Other MAC address.

other_network_category

string
Other network category tag.
Aliases:
other_net_category

other_network_category_id

integer
Other network category ID.
Aliases:
other_net_category_id

other_port

integer
Other port, when applicable, depending on ip_protocol.

other_type

constant
The flow other type.
Values:
other_local other_multicast other_remote other_broadcast other_unknown other_unsupported other_error

port

integer
Any port number, local or other.

protocol

mixed
The detected protocol ID.
Aliases:
protocol_id proto proto_id

protocol_category

string
The detected protocol category tag.
Aliases:
proto_category

protocol_category_id

integer
The detected protocol category ID.
Aliases:
proto_category_id

soft_dissector

boolean
Flag indicating a soft dissector was used for classification.

src_ip

address
Source IP address.

src_mac

address
Source MAC address.

src_network_category

string
Source network category tag.
Aliases:
src_net_category

src_network_category_id

integer
Source network category ID.
Aliases:
src_net_category_id

src_port

integer
Source port number.

tag

string
Custom tag defined in the overlay feature.
Reference: See Overlay feature.

tag_category

string
Custom tag category defined in the overlay feature.
Reference: See Overlay feature.

tag_category_id

integer
Custom tag category ID defined in the overlay feature.
Reference: See Overlay feature.

tls_cipher

hex
The TLS negotiated cipher.
Reference: See IANA reference
Aliases:
ssl_cipher

tls_ech

hex
TLS ECH (Encrypted Client Hello) version.

tls_ja4

string
JA4 TLS fingerprint or identifier.

tls_version

hex
The TLS version. The values are usually represented using hexadecimal values, for example, TLS v1.3 would be: 0x0303.
Aliases:
ssl_version

tunnel_type

constant
If the flow contains encapsulated data that could be identified and extracted (not encrypted), such as GTP, the tunnel_type will be set.
Values:
tunnel_none tunnel_gtp

vlan_id

integer
Virtual LAN (VLAN) ID.