SystemInterface Library Functions

Overview

You can configure the firewall during runtime using SystemInterface library functions.

Functions of the SystemInterface Library

The following functions of the SystemInterface library can be used to configure the firewall non-persistent during runtime:

Function

Description

FC_OpenIncomingFirewallPort

Open incoming firewall port during runtime.

FC_CloseIncomingFirewallPort

Close incoming firewall port during runtime.

FC_LoadDefaultPortRules

Load port rules from configuration file.

If the file does not exist, a new configuration file with a default set of rules is created. If the configuration file is invalid, the default set of rules is loaded dynamically (non-persistent).

FC_FirewallSetActive

Activate / deactivate the firewall.

Code Example

IF xFirstRun THEN
    (* Allow incoming TCP traffic on port 8000 from anywhere to PLC ('me') *)
    FC_OpenIncomingFirewallPort(i_etProtocol := ET_Protocol.TCP, i_uiPort := 8000, i_sSource := 'any', i_sDestination := 'me');

    (* Remove the previously given permission *)
    FC_CloseIncomingFirewallPort(i_etProtocol := ET_Protocol.TCP, i_uiPort := 8000, i_sSource := 'any', i_sDestination := 'me');

    (* Load the default rules into the firewall *)
    FC_LoadDefaultPortRules();

    IF 0 <> FC_FirewallIsActive() THEN
         (* Enable the firewall *)
         FC_FirewallSetActive(i_xActive := TRUE);

    END_IF

    xFirstRun := FALSE;
END_IF