SysSockSetDefaultGateway (FUN)ΒΆ

FUNCTION SysSockSetDefaultGateway : RTS_IEC_RESULT

Set default gateway address an adapter. It depends on the device, whether the new gateway address is reset during reboot or if it is retained. In general the caller should consider this as volatile. The gateway address = 0.0.0.0 can be used to remove the gateway address from the adapter. After this there is not routing to other subnets possible.

Note

The default gateway can only be changed if the adapter containing the current default gateway is whitelisted in the CODESYSControl.cfg. This function will not change the default gateway of any other adapter.

InOut:

Scope

Name

Type

Comment

Return

SysSockSetDefaultGateway

RTS_IEC_RESULT

Returns the runtime system error code (see CmpErrors.library):
  • ERR_PARAMETER: At least one of the passed pointers is NULL.
    • ERR_OPERATION_DENIED: Adapter is not in white list or the operation was denied by the event EVT_SysSocket_BeforeSetGateway.

    • ERR_NO_OBJECT: Adapter with the specified name does not exist.

    • ERR_NO_CHANGE: There is a default gateway set on an adapter that is not whitelisted.

    • ERR_FAILED: Default gateway could not be set.

    • ERR_OK: Default gateway was set successfully.

Input

wsAdapterName

REFERENCE TO WSTRING

Adapter name provided by SysSockGetFirstAdapter() / SysSockGetNextAdapter()

GatewayAddr

REFERENCE TO INADDR

Ip address of the gateway to set in network byte order.