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.
-
CLI_CHECKCONFIG
-
Command used in communication with the relay.
-
CLI_CLOSE_SERV
-
Command used in communication with the relay.
-
CLI_DELETE_FILE
-
Command used in communication with the relay.
-
CLI_ERROR
-
Command used in communication with the relay.
-
CLI_ERROR_FILE
-
Command used in communication with the relay.
-
CLI_ERROR_ISCONN
-
Command used in communication with the relay.
-
CLI_ERROR_NOTCONN
-
Command used in communication with the relay.
-
CLI_ERROR_OPENCONN
-
Command used in communication with the relay.
-
CLI_FILE_DATA
-
Command used in communication with the relay.
-
CLI_FILE_TMP_NAME
-
Command used in communication with the relay.
-
CLI_GET_FILE
-
Command used in communication with the relay.
-
CLI_GET_FILE_TMP
-
Command used in communication with the relay.
-
CLI_GET_LOCAL_FILE
-
Command used in communication with the relay.
-
CLI_GET_TEMPNAME
-
Command used in communication with the relay.
-
CLI_KILL_TCP
-
Command used in communication with the relay.
-
CLI_OK
-
Command used in communication with the relay.
-
CLI_OPEN_SERV
-
Command used in communication with the relay.
-
CLI_READ_ADDR
-
Command used in communication with the relay.
-
CLI_READ_RULES
-
Command used in communication with the relay.
-
CLI_READ_TCP
-
Command used in communication with the relay.
-
CLI_READ_VARS
-
Command used in communication with the relay.
-
CLI_RECONFIG
-
Command used in communication with the relay.
-
CLI_RESET_USAGE
-
Command used in communication with the relay.
-
CLI_RESOLVE
-
Command used in communication with the relay.
-
CLI_RESOLVE_IP
-
Command used in communication with the relay.
-
CLI_RESOLVE_PORT
-
Command used in communication with the relay.
-
CLI_RESOLVE_REPLY
-
Command used in communication with the relay.
-
CLI_RESOLVE_SERVICE
-
Command used in communication with the relay.
-
CLI_WAIT
-
Command used in communication with the relay.
-
CLI_WRITE_FILE
-
Command used in communication with the relay.
-
CLI_WRITE_LOCAL_FILE
-
Command used in communication with the relay.
-
CLI_WRITE_STATUS
-
Command used in communication with the relay.
-
COMM_ERROR
- Value of commError: unspecified error
-
COMM_FILEERR
- Value of commError: error handling a local file
-
COMM_IO
- Value of commError: general I/O error (e.g.
-
COMM_NOADDRESS
- Value of commError: The host object passed to the method does not
contain an IP address.
-
COMM_NOCONN
- Value of commError: cannot connect to relay
-
COMM_NOFIREWALL
- Value of commError: The parameter passed to the method does not refer
to a firewall.
-
COMM_OK
- Value of commError: successful operation
-
COMM_OPENCONN
- Value of commError: relay cannot connect to server
-
COMM_RESOLVE
- Value of commError: error resolving hostname, IP address, service name
or port number
-
commError
- The variable commError holds the error code of the last operation
-
in
- Input stream to read from relay
-
out
- Output stream to write to relay;
-
readCommand
- The last command read from the relay is saved in readCommand.
-
readLength
- The last packet data length read from the relay is saved in readLength.
-
relayPort
- TCP port on which the relay is accepting connections
-
Communicator()
-
-
checkConfig(byte[])
- Check generated config file for errors and rename it to firewall.conf
-
closeServer(byte[])
- Close server connection
-
connectRelay()
- Establish connection to sfrelay
-
deleteFile(String)
- Delete local file
-
dispose()
- Close connection to sfrelay and all server connections
-
getTempFile(byte[], String)
- Fetch file from server and store as temporary file
-
getTempName()
- Get temporary local filename from relay.
-
killTcp(byte[], int, int, int)
- Kill TCP connection on firewall
-
openServer(byte[])
- Open server connection
-
readFwConfig(Host)
- Read active firewall configuration
-
readHeader()
- Read header from output stream.
-
readTcpConns(Host)
- Read active TCP connections from firewall
-
reconfig(byte[])
- Reconfigure the firewall
-
requestFile(byte[], String)
- Request file from server.
-
requestLocalFile(String)
- Request local file from relay.
-
resetUsage(byte[])
- Reset usage counter on firewall
-
resolve(String)
- Resolve host name
-
resolveIP(byte[])
- Resolve IP address
-
resolvePort(int, String, boolean)
- Resolve service number
-
resolveService(String, String)
- Resolve service name
-
writeFile(byte[], String)
- Write file to server.
-
writeHeader(int, int)
- Write header to output stream.
-
writeLocalFile(String)
- Write local file to relay.
COMM_OK
public final static int COMM_OK
- Value of commError: successful operation
COMM_ERROR
public final static int COMM_ERROR
- Value of commError: unspecified error
COMM_NOCONN
public final static int COMM_NOCONN
- Value of commError: cannot connect to relay
COMM_IO
public final static int COMM_IO
- Value of commError: general I/O error (e.g. connection aborted)
COMM_OPENCONN
public final static int COMM_OPENCONN
- Value of commError: relay cannot connect to server
COMM_FILEERR
public final static int COMM_FILEERR
- Value of commError: error handling a local file
COMM_RESOLVE
public final static int COMM_RESOLVE
- Value of commError: error resolving hostname, IP address, service name
or port number
COMM_NOFIREWALL
public final static int COMM_NOFIREWALL
- Value of commError: The parameter passed to the method does not refer
to a firewall.
COMM_NOADDRESS
public final static int COMM_NOADDRESS
- Value of commError: The host object passed to the method does not
contain an IP address.
commError
public static int commError
- The variable commError holds the error code of the last operation
relayPort
protected final static int relayPort
- TCP port on which the relay is accepting connections
CLI_OPEN_SERV
protected final static int CLI_OPEN_SERV
- Command used in communication with the relay.
CLI_CLOSE_SERV
protected final static int CLI_CLOSE_SERV
- Command used in communication with the relay.
CLI_GET_FILE_TMP
protected final static int CLI_GET_FILE_TMP
- Command used in communication with the relay.
CLI_FILE_TMP_NAME
protected final static int CLI_FILE_TMP_NAME
- Command used in communication with the relay.
CLI_GET_FILE
protected final static int CLI_GET_FILE
- Command used in communication with the relay.
CLI_FILE_DATA
protected final static int CLI_FILE_DATA
- Command used in communication with the relay.
CLI_DELETE_FILE
protected final static int CLI_DELETE_FILE
- Command used in communication with the relay.
CLI_RESOLVE
protected final static int CLI_RESOLVE
- Command used in communication with the relay.
CLI_RESOLVE_REPLY
protected final static int CLI_RESOLVE_REPLY
- Command used in communication with the relay.
CLI_WRITE_FILE
protected final static int CLI_WRITE_FILE
- Command used in communication with the relay.
CLI_WRITE_STATUS
protected final static int CLI_WRITE_STATUS
- Command used in communication with the relay.
CLI_READ_ADDR
protected final static int CLI_READ_ADDR
- Command used in communication with the relay.
CLI_READ_RULES
protected final static int CLI_READ_RULES
- Command used in communication with the relay.
CLI_READ_VARS
protected final static int CLI_READ_VARS
- Command used in communication with the relay.
CLI_WRITE_LOCAL_FILE
protected final static int CLI_WRITE_LOCAL_FILE
- Command used in communication with the relay.
CLI_RECONFIG
protected final static int CLI_RECONFIG
- Command used in communication with the relay.
CLI_CHECKCONFIG
protected final static int CLI_CHECKCONFIG
- Command used in communication with the relay.
CLI_READ_TCP
protected final static int CLI_READ_TCP
- Command used in communication with the relay.
CLI_KILL_TCP
protected final static int CLI_KILL_TCP
- Command used in communication with the relay.
CLI_RESET_USAGE
protected final static int CLI_RESET_USAGE
- Command used in communication with the relay.
CLI_GET_LOCAL_FILE
protected final static int CLI_GET_LOCAL_FILE
- Command used in communication with the relay.
CLI_GET_TEMPNAME
protected final static int CLI_GET_TEMPNAME
- Command used in communication with the relay.
CLI_RESOLVE_IP
protected final static int CLI_RESOLVE_IP
- Command used in communication with the relay.
CLI_RESOLVE_SERVICE
protected final static int CLI_RESOLVE_SERVICE
- Command used in communication with the relay.
CLI_RESOLVE_PORT
protected final static int CLI_RESOLVE_PORT
- Command used in communication with the relay.
CLI_OK
protected final static int CLI_OK
- Command used in communication with the relay.
CLI_ERROR
protected final static int CLI_ERROR
- Command used in communication with the relay.
CLI_ERROR_ISCONN
protected final static int CLI_ERROR_ISCONN
- Command used in communication with the relay.
CLI_ERROR_OPENCONN
protected final static int CLI_ERROR_OPENCONN
- Command used in communication with the relay.
CLI_ERROR_NOTCONN
protected final static int CLI_ERROR_NOTCONN
- Command used in communication with the relay.
CLI_ERROR_FILE
protected final static int CLI_ERROR_FILE
- Command used in communication with the relay.
CLI_WAIT
protected final static int CLI_WAIT
- Command used in communication with the relay.
in
protected static DataInputStream in
- Input stream to read from relay
out
protected static DataOutputStream out
- Output stream to write to relay;
readCommand
protected static int readCommand
- The last command read from the relay is saved in readCommand.
readLength
protected static int readLength
- The last packet data length read from the relay is saved in readLength.
Communicator
public Communicator()
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
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
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
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
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
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
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
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
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
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
deleteFile
public static synchronized boolean deleteFile(String fname)
- Delete local file
- Parameters:
- fname - filename
- Returns:
- true if successful, commError is set when returning false
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
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
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
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
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
resolveIP
public static synchronized String resolveIP(byte addr[])
- Resolve IP address
- Parameters:
- addr - IP address
- Returns:
- hostname or IP address if not resolvable
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
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
dispose
public static synchronized void dispose()
- Close connection to sfrelay and all server connections
connectRelay
public static synchronized boolean connectRelay()
- Establish connection to sfrelay
- Returns:
- true if successful
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
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