目录

TrafficFilter

Overview

This module implements network traffic filtering and redirection. Traffic filtering intercepts network data packets in the kernel network protocol stack of the system and allows or discards packets based on preset rules. It applies to scenarios such as firewalls, parental controls, and application traffic management.

Traffic redirection forwards TCP traffic that matches rules to a specified proxy server. It applies to scenarios such as enterprise network auditing, content filtering proxies, and VPN transparent proxies.

To use this module, first create a controller or redirector instance, then add filtering or redirection rules to manage network traffic. After use, call the corresponding destroy API to release resources.

Since: 26.0.0

File Summary

Name Description
net_trafficfilter.h

Declares the C APIs for network traffic filtering and redirection. This header file provides the APIs for creating and destroying a packet controller, registering packet callbacks, adding and clearing filtering rules, as well as creating and destroying a traffic redirector, and adding and clearing redirection rules.

It applies to scenarios where network packets need to be intercepted, filtered, and redirected at the system level.

net_trafficfilter_type.h

Declares the common types and error codes required for network traffic filtering and redirection. This header file defines the matching condition structs such as IP addresses, ports, and interfaces used in traffic filtering and redirection, the configuration structs such as packet filtering rules and redirection rules, and the error codes returned by operations.

It applies to constructing parameters and parsing return values when calling APIs such as OH_TrafficFilter_CreateRedirector.