Class sfclasses.Communicator
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sfclasses.Communicator

java.lang.Object
   |
   +----sfclasses.Communicator

public class Communicator
extends Object
This class implements the communication with the relay. All methods in this class are static and synchronized.

Variable Index

 o CLI_CHECKCONFIG
Command used in communication with the relay.
 o CLI_CLOSE_SERV
Command used in communication with the relay.
 o CLI_DELETE_FILE
Command used in communication with the relay.
 o CLI_ERROR
Command used in communication with the relay.
 o CLI_ERROR_FILE
Command used in communication with the relay.
 o CLI_ERROR_ISCONN
Command used in communication with the relay.
 o CLI_ERROR_NOTCONN
Command used in communication with the relay.
 o CLI_ERROR_OPENCONN
Command used in communication with the relay.
 o CLI_FILE_DATA
Command used in communication with the relay.
 o CLI_FILE_TMP_NAME
Command used in communication with the relay.
 o CLI_GET_FILE
Command used in communication with the relay.
 o CLI_GET_FILE_TMP
Command used in communication with the relay.
 o CLI_GET_LOCAL_FILE
Command used in communication with the relay.
 o CLI_GET_TEMPNAME
Command used in communication with the relay.
 o CLI_KILL_TCP
Command used in communication with the relay.
 o CLI_OK
Command used in communication with the relay.
 o CLI_OPEN_SERV
Command used in communication with the relay.
 o CLI_READ_ADDR
Command used in communication with the relay.
 o CLI_READ_RULES
Command used in communication with the relay.
 o CLI_READ_TCP
Command used in communication with the relay.
 o CLI_READ_VARS
Command used in communication with the relay.
 o CLI_RECONFIG
Command used in communication with the relay.
 o CLI_RESET_USAGE
Command used in communication with the relay.
 o CLI_RESOLVE
Command used in communication with the relay.
 o CLI_RESOLVE_IP
Command used in communication with the relay.
 o CLI_RESOLVE_PORT
Command used in communication with the relay.
 o CLI_RESOLVE_REPLY
Command used in communication with the relay.
 o CLI_RESOLVE_SERVICE
Command used in communication with the relay.
 o CLI_WAIT
Command used in communication with the relay.
 o CLI_WRITE_FILE
Command used in communication with the relay.
 o CLI_WRITE_LOCAL_FILE
Command used in communication with the relay.
 o CLI_WRITE_STATUS
Command used in communication with the relay.
 o COMM_ERROR
Value of commError: unspecified error
 o COMM_FILEERR
Value of commError: error handling a local file
 o COMM_IO
Value of commError: general I/O error (e.g.
 o COMM_NOADDRESS
Value of commError: The host object passed to the method does not contain an IP address.
 o COMM_NOCONN
Value of commError: cannot connect to relay
 o COMM_NOFIREWALL
Value of commError: The parameter passed to the method does not refer to a firewall.
 o COMM_OK
Value of commError: successful operation
 o COMM_OPENCONN
Value of commError: relay cannot connect to server
 o COMM_RESOLVE
Value of commError: error resolving hostname, IP address, service name or port number
 o commError
The variable commError holds the error code of the last operation
 o in
Input stream to read from relay
 o out
Output stream to write to relay;
 o readCommand
The last command read from the relay is saved in readCommand.
 o readLength
The last packet data length read from the relay is saved in readLength.
 o relayPort
TCP port on which the relay is accepting connections

Constructor Index

 o Communicator()

Method Index

 o checkConfig(byte[])
Check generated config file for errors and rename it to firewall.conf
 o closeServer(byte[])
Close server connection
 o connectRelay()
Establish connection to sfrelay
 o deleteFile(String)
Delete local file
 o dispose()
Close connection to sfrelay and all server connections
 o getTempFile(byte[], String)
Fetch file from server and store as temporary file
 o getTempName()
Get temporary local filename from relay.
 o killTcp(byte[], int, int, int)
Kill TCP connection on firewall
 o openServer(byte[])
Open server connection
 o readFwConfig(Host)
Read active firewall configuration
 o readHeader()
Read header from output stream.
 o readTcpConns(Host)
Read active TCP connections from firewall
 o reconfig(byte[])
Reconfigure the firewall
 o requestFile(byte[], String)
Request file from server.
 o requestLocalFile(String)
Request local file from relay.
 o resetUsage(byte[])
Reset usage counter on firewall
 o resolve(String)
Resolve host name
 o resolveIP(byte[])
Resolve IP address
 o resolvePort(int, String, boolean)
Resolve service number
 o resolveService(String, String)
Resolve service name
 o writeFile(byte[], String)
Write file to server.
 o writeHeader(int, int)
Write header to output stream.
 o writeLocalFile(String)
Write local file to relay.

Variables

 o COMM_OK
  public final static int COMM_OK
Value of commError: successful operation
 o COMM_ERROR
  public final static int COMM_ERROR
Value of commError: unspecified error
 o COMM_NOCONN
  public final static int COMM_NOCONN
Value of commError: cannot connect to relay
 o COMM_IO
  public final static int COMM_IO
Value of commError: general I/O error (e.g. connection aborted)
 o COMM_OPENCONN
  public final static int COMM_OPENCONN
Value of commError: relay cannot connect to server
 o COMM_FILEERR
  public final static int COMM_FILEERR
Value of commError: error handling a local file
 o COMM_RESOLVE
  public final static int COMM_RESOLVE
Value of commError: error resolving hostname, IP address, service name or port number
 o COMM_NOFIREWALL
  public final static int COMM_NOFIREWALL
Value of commError: The parameter passed to the method does not refer to a firewall.
 o COMM_NOADDRESS
  public final static int COMM_NOADDRESS
Value of commError: The host object passed to the method does not contain an IP address.
 o commError
  public static int commError
The variable commError holds the error code of the last operation
 o relayPort
  protected final static int relayPort
TCP port on which the relay is accepting connections
 o CLI_OPEN_SERV
  protected final static int CLI_OPEN_SERV
Command used in communication with the relay.
 o CLI_CLOSE_SERV
  protected final static int CLI_CLOSE_SERV
Command used in communication with the relay.
 o CLI_GET_FILE_TMP
  protected final static int CLI_GET_FILE_TMP
Command used in communication with the relay.
 o CLI_FILE_TMP_NAME
  protected final static int CLI_FILE_TMP_NAME
Command used in communication with the relay.
 o CLI_GET_FILE
  protected final static int CLI_GET_FILE
Command used in communication with the relay.
 o CLI_FILE_DATA
  protected final static int CLI_FILE_DATA
Command used in communication with the relay.
 o CLI_DELETE_FILE
  protected final static int CLI_DELETE_FILE
Command used in communication with the relay.
 o CLI_RESOLVE
  protected final static int CLI_RESOLVE
Command used in communication with the relay.
 o CLI_RESOLVE_REPLY
  protected final static int CLI_RESOLVE_REPLY
Command used in communication with the relay.
 o CLI_WRITE_FILE
  protected final static int CLI_WRITE_FILE
Command used in communication with the relay.
 o CLI_WRITE_STATUS
  protected final static int CLI_WRITE_STATUS
Command used in communication with the relay.
 o CLI_READ_ADDR
  protected final static int CLI_READ_ADDR
Command used in communication with the relay.
 o CLI_READ_RULES
  protected final static int CLI_READ_RULES
Command used in communication with the relay.
 o CLI_READ_VARS
  protected final static int CLI_READ_VARS
Command used in communication with the relay.
 o CLI_WRITE_LOCAL_FILE
  protected final static int CLI_WRITE_LOCAL_FILE
Command used in communication with the relay.
 o CLI_RECONFIG
  protected final static int CLI_RECONFIG
Command used in communication with the relay.
 o CLI_CHECKCONFIG
  protected final static int CLI_CHECKCONFIG
Command used in communication with the relay.
 o CLI_READ_TCP
  protected final static int CLI_READ_TCP
Command used in communication with the relay.
 o CLI_KILL_TCP
  protected final static int CLI_KILL_TCP
Command used in communication with the relay.
 o CLI_RESET_USAGE
  protected final static int CLI_RESET_USAGE
Command used in communication with the relay.
 o CLI_GET_LOCAL_FILE
  protected final static int CLI_GET_LOCAL_FILE
Command used in communication with the relay.
 o CLI_GET_TEMPNAME
  protected final static int CLI_GET_TEMPNAME
Command used in communication with the relay.
 o CLI_RESOLVE_IP
  protected final static int CLI_RESOLVE_IP
Command used in communication with the relay.
 o CLI_RESOLVE_SERVICE
  protected final static int CLI_RESOLVE_SERVICE
Command used in communication with the relay.
 o CLI_RESOLVE_PORT
  protected final static int CLI_RESOLVE_PORT
Command used in communication with the relay.
 o CLI_OK
  protected final static int CLI_OK
Command used in communication with the relay.
 o CLI_ERROR
  protected final static int CLI_ERROR
Command used in communication with the relay.
 o CLI_ERROR_ISCONN
  protected final static int CLI_ERROR_ISCONN
Command used in communication with the relay.
 o CLI_ERROR_OPENCONN
  protected final static int CLI_ERROR_OPENCONN
Command used in communication with the relay.
 o CLI_ERROR_NOTCONN
  protected final static int CLI_ERROR_NOTCONN
Command used in communication with the relay.
 o CLI_ERROR_FILE
  protected final static int CLI_ERROR_FILE
Command used in communication with the relay.
 o CLI_WAIT
  protected final static int CLI_WAIT
Command used in communication with the relay.
 o in
  protected static DataInputStream in
Input stream to read from relay
 o out
  protected static DataOutputStream out
Output stream to write to relay;
 o readCommand
  protected static int readCommand
The last command read from the relay is saved in readCommand.
 o readLength
  protected static int readLength
The last packet data length read from the relay is saved in readLength.

Constructors

 o Communicator
  public Communicator()

Methods

 o openServer
  public static synchronized boolean openServer(byte servAddr[])
Open server connection
Parameters:
servAddr - server address
Returns:
true if successful, commError is set when returning false
 o closeServer
  public static synchronized boolean closeServer(byte servAddr[])
Close server connection
Parameters:
servAddr - server address
Returns:
true if successful, commError is set when returning false
 o checkConfig
  public static synchronized boolean checkConfig(byte servAddr[])
Check generated config file for errors and rename it to firewall.conf
Parameters:
servAddr - Server address
Returns:
true if successful, commError is set when returning false
 o reconfig
  public static synchronized boolean reconfig(byte servAddr[])
Reconfigure the firewall
Parameters:
servAddr - Server Address
Returns:
true if successful, commError is set when returning false
 o getTempFile
  public static synchronized String getTempFile(byte servAddr[],
                                                String fname)
Fetch file from server and store as temporary file
Parameters:
servAddr - server address
fname - filename
Returns:
filename of temporary file, commError is set when returning null
 o requestFile
  public static synchronized boolean requestFile(byte servAddr[],
                                                 String fname)
Request file from server. This method is called from RelayInputStream
Parameters:
servAddr - server address
fname - filename
Returns:
true if successful, commError is set when returning false
See Also:
RelayInputStream
 o requestLocalFile
  public static synchronized boolean requestLocalFile(String fname)
Request local file from relay. This method is called from LocalInputStream
Parameters:
fname - filename
Returns:
true if successful, commError is set when returning false
See Also:
LocalInputStream
 o writeFile
  public static synchronized boolean writeFile(byte servAddr[],
                                               String fname)
Write file to server. This method is called from RelayOutputStream
Parameters:
servAddr - server address
fname - filename
Returns:
true if successful, commError is set when returning false
See Also:
RelayOutputStream
 o writeLocalFile
  public static synchronized boolean writeLocalFile(String fname)
Write local file to relay. This method is called from LocalOutputStream
Parameters:
fname - filename
Returns:
true if successful, commError is set when returning false
See Also:
LocalOutputStream
 o getTempName
  public static synchronized String getTempName()
Get temporary local filename from relay. This method is used to allocate a temporary file name before creating a local file using the LocalOutputStream.
Returns:
filename, commError is set when returning null
 o deleteFile
  public static synchronized boolean deleteFile(String fname)
Delete local file
Parameters:
fname - filename
Returns:
true if successful, commError is set when returning false
 o readTcpConns
  public static synchronized boolean readTcpConns(Host host)
Read active TCP connections from firewall
Parameters:
host - Firewall to read configuration from
Returns:
true if successful, commError is set when returning false
 o killTcp
  public static synchronized boolean killTcp(byte servAddr[],
                                             int id,
                                             int key,
                                             int created)
Kill TCP connection on firewall
Parameters:
servAddr - Server address (firewall)
id - TCP connection ID
key - TCP connection key
created - Creation time of TCP connection
Returns:
true if successful, commError is set when returning false
 o resetUsage
  public static synchronized boolean resetUsage(byte servAddr[])
Reset usage counter on firewall
Parameters:
servAddr - Server address (firewall)
Returns:
true if successful, commError is set when returning false
 o readFwConfig
  public static synchronized boolean readFwConfig(Host host)
Read active firewall configuration
Parameters:
host - Firewall to read configuration from
Returns:
true if successful, commError is set when returning false
 o resolve
  public static synchronized byte[] resolve(String hname)
Resolve host name
Parameters:
hname - hostname or string containing IP address
Returns:
IP address if successful, commError is set when returning null
 o resolveIP
  public static synchronized String resolveIP(byte addr[])
Resolve IP address
Parameters:
addr - IP address
Returns:
hostname or IP address if not resolvable
 o resolveService
  public static synchronized int resolveService(String sname,
                                                String proto)
Resolve service name
Parameters:
sname - service name
proto - protocol
Returns:
service number if successful, -1 otherwise
 o resolvePort
  public static synchronized String resolvePort(int port,
                                                String proto,
                                                boolean privOnly)
Resolve service number
Parameters:
port - service number
proto - protocol
privOnly - resolve only if port < 1024
Returns:
service name or number if not resolvable
 o dispose
  public static synchronized void dispose()
Close connection to sfrelay and all server connections
 o connectRelay
  public static synchronized boolean connectRelay()
Establish connection to sfrelay
Returns:
true if successful
 o writeHeader
  protected static synchronized void writeHeader(int command,
                                                 int length) throws IOException
Write header to output stream. This methods writes the packet header of the control-panel-to-relay protocol to the output stream.
Parameters:
command - Command for the relay
length - Number of bytes following the header
 o readHeader
  protected static synchronized void readHeader() throws IOException, EOFException
Read header from output stream. The read command is stored in readCommand and the number of bytes following the header is stored in readLength.

All Packages  Class Hierarchy  This Package  Previous  Next  Index