Fortinet white logo
Fortinet white logo

TCP commands

TCP commands

TCP commands can be used in HTTP and TCP events.

TCP:local_port()

Return local TCP port of the connection. The value is integer.

Example
when HTTP_REQUEST {
    print_ips("HTTP_REQUEST", TCP, IP)
}
function print_ips(event, TCP, IP)
    debug("%s: version: %s, local: %s:%s, remote: %s:%s, client: %s:%s, server: %s:%s\n",
        event, IP:version(),
        IP:local_addr(), TCP:local_port(),
        IP:remote_addr(), TCP:remote_port(),
        IP:client_addr(), TCP:client_port(),
        IP:server_addr(), TCP:server_port())
end

TCP:remote_port()

Return remote TCP port of the connection. The value is integer.

Example
when HTTP_REQUEST {
    print_ips("HTTP_REQUEST", TCP, IP)
}
function print_ips(event, TCP, IP)
    debug("%s: version: %s, local: %s:%s, remote: %s:%s, client: %s:%s, server: %s:%s\n",
        event, IP:version(),
        IP:local_addr(), TCP:local_port(),
        IP:remote_addr(), TCP:remote_port(),
        IP:client_addr(), TCP:client_port(),
        IP:server_addr(), TCP:server_port())
end

TCP:client_port()

Return client TCP port of the connection. The value is integer.

Example
when HTTP_REQUEST {|
    print_ips("HTTP_REQUEST", TCP, IP)
}
function print_ips(event, TCP, IP)
    debug("%s: version: %s, local: %s:%s, remote: %s:%s, client: %s:%s, server: %s:%s\n",
        event, IP:version(),
        IP:local_addr(), TCP:local_port(),
        IP:remote_addr(), TCP:remote_port(),
        IP:client_addr(), TCP:client_port(),
        IP:server_addr(), TCP:server_port())
end

TCP:server_port()

Return server TCP port of the connection. The value is integer. If the server is not connected, return nil.

Example
when HTTP_REQUEST {
    print_ips("HTTP_REQUEST", TCP, IP)
}
function print_ips(event, TCP, IP)
    debug("%s: version: %s, local: %s:%s, remote: %s:%s, client: %s:%s, server: %s:%s\n",
        event, IP:version(),
        IP:local_addr(), TCP:local_port(),
        IP:remote_addr(), TCP:remote_port(),
        IP:client_addr(), TCP:client_port(),
        IP:server_addr(), TCP:server_port())
end

TCP:close()

Close current TCP connection and disable its TCP events. This function can only be used in event SERVER_CONNECTED.

Example
when SERVER_CONNECTED {
    debug("TCP_CLOSE")
    TCP:close()
}

TCP commands

TCP commands

TCP commands can be used in HTTP and TCP events.

TCP:local_port()

Return local TCP port of the connection. The value is integer.

Example
when HTTP_REQUEST {
    print_ips("HTTP_REQUEST", TCP, IP)
}
function print_ips(event, TCP, IP)
    debug("%s: version: %s, local: %s:%s, remote: %s:%s, client: %s:%s, server: %s:%s\n",
        event, IP:version(),
        IP:local_addr(), TCP:local_port(),
        IP:remote_addr(), TCP:remote_port(),
        IP:client_addr(), TCP:client_port(),
        IP:server_addr(), TCP:server_port())
end

TCP:remote_port()

Return remote TCP port of the connection. The value is integer.

Example
when HTTP_REQUEST {
    print_ips("HTTP_REQUEST", TCP, IP)
}
function print_ips(event, TCP, IP)
    debug("%s: version: %s, local: %s:%s, remote: %s:%s, client: %s:%s, server: %s:%s\n",
        event, IP:version(),
        IP:local_addr(), TCP:local_port(),
        IP:remote_addr(), TCP:remote_port(),
        IP:client_addr(), TCP:client_port(),
        IP:server_addr(), TCP:server_port())
end

TCP:client_port()

Return client TCP port of the connection. The value is integer.

Example
when HTTP_REQUEST {|
    print_ips("HTTP_REQUEST", TCP, IP)
}
function print_ips(event, TCP, IP)
    debug("%s: version: %s, local: %s:%s, remote: %s:%s, client: %s:%s, server: %s:%s\n",
        event, IP:version(),
        IP:local_addr(), TCP:local_port(),
        IP:remote_addr(), TCP:remote_port(),
        IP:client_addr(), TCP:client_port(),
        IP:server_addr(), TCP:server_port())
end

TCP:server_port()

Return server TCP port of the connection. The value is integer. If the server is not connected, return nil.

Example
when HTTP_REQUEST {
    print_ips("HTTP_REQUEST", TCP, IP)
}
function print_ips(event, TCP, IP)
    debug("%s: version: %s, local: %s:%s, remote: %s:%s, client: %s:%s, server: %s:%s\n",
        event, IP:version(),
        IP:local_addr(), TCP:local_port(),
        IP:remote_addr(), TCP:remote_port(),
        IP:client_addr(), TCP:client_port(),
        IP:server_addr(), TCP:server_port())
end

TCP:close()

Close current TCP connection and disable its TCP events. This function can only be used in event SERVER_CONNECTED.

Example
when SERVER_CONNECTED {
    debug("TCP_CLOSE")
    TCP:close()
}