Target Communication Framework Services - PortForward

PortForward Service

Version History

Version Date Change
0.1 2016-07-10 Initial contribution

Overview

PortForward service is an interface to provide ability to connect a TCF stream to a device port (TCP port, UDP port, serial line...)

The service supports:

When a PortForward creation command is receive, the connection is established to the specified device port and when the connection is established two TCF streams are created and allow to read and write to the port. Any data written by the client to the "OuptutStream" is automatically written to the device port and any data read from the device port is automatically sent to the "InputStream". Reading and writing to/from TCF streams is done using the TCF "Streams" service. The PortFoward configuration is not persistent, when the connection to the device port is lost or if the channel is closed, the PortForward configuration is automatically removed and has to be created again if you want to re-instantiate the connection.

Command are encoded as zero terminated JSON strings.

The service uses standard format for error reports, see Error Report Format.

Commands

getConfig


C • <token> • PortForward • getConfig • <string: Port Forward ID> •

The command retrieves information for given Port Forward configuration ID.

Reply:

R • <token> • <error report> • <Port Forward properties> • <port forward properties>

Port Forward properties consists of a list of status properties.

Predefined properties are:

list

C • <token> • PortForward • list•

The command list available Port Forward configurations

Reply:


<array of Port Forward IDs>
    ⇒ null
    ⇒ [ ]
    ⇒ [ <Port Forwards ID list> ]

<Port Forwards ID list><string: Port Forward ID>Port Forward ID list> , <string: Port Forward ID>

create


C • <token> • PortForward • create • <Port Forward configuration> •

<
Port Forward configuration><object>

The command adds a Port Forward connection with specified properties. The connection to the device port is done automatically when the "create" command is issued; reply is sent only when the connection to the port is established or when an error was detected. If

Predefined properties are:


The following syntax is supported for the port forward "Config" string:

The following syntax is supported for the port forward "Params" string when specified device is a serial line (unused in other cases):

"<baud rate>:<data bits>:<parity>:<stop bits>:<flow control>"
"Params" string can be of the form:
"9600" - Only specify baud rate, keep default for everything else
":7" - Only specify number of data bits, keep default for everything else
"::::S" - Set flow control to XON/XOFF, keep default for everything else
"9600:8:N:1:S" - set barud rate to 9600, 8 data bits, no parity, 1 stop bit and space parity

Reply:

R • <token> • <error report> • <port properties> •
<port properties>
    ⇒ null
    ⇒ <object>

Port properties are the same as returned by the getConfig command.

delete


C • <token> • PortForward • delete • <string: PortForward ID> •

The command deletes a previously created Port Foward connection.

Reply:


R • <token> • <error report> •

getCapabilities


C • <token> • PortForward • getCapabilities • <string: PortForward ID> •

This command retrieves PortForward service capabilities to clients so they can adjust to different implementations of the service. Currently, only a null ("") PortForward ID is supported.

Reply:

R • <token> • <error report> • <service capabilities> •

<service capabilities>

    ⇒ <object>

Service capabilities consist of a list of properties. All properties are optional. Tools and targets can define additional properties. Predefined properties are:

Events

PortForward service events are sent to notify clients about PortFoward configurations created ordeleted. The purpose of these events is to let all clients know about PortForward connections that were created by other clients.


E • PortForward • configAdded • <PortForward connection properties> •
E • PortForward • configRemoved • <PortForward connection ID> •
configAdded
Is sent when a new PortForward connection is created and established.The configAdded event contains the same information as returned by the getConfig command. Note that the event is sent only when the connection to the device port has been established.
configRemoved
Is sent when a PortForward connection is removed.