Package org.ka2ddo.ax25
Class ConnState
java.lang.Object
org.ka2ddo.ax25.ConnState
- All Implemented Interfaces:
Closeable
,AutoCloseable
,AX25FrameSource
This class keeps track of the state of one AX.25 connection-oriented session.
- Author:
- Andrew Pavlin, KA2DDO
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum identifying the transitional condition of the connection.static enum
Enumeration specifying the different types of connection-oriented AX.25 sessions. -
Field Summary
Modifier and TypeFieldDescriptionfinal AX25Callsign
Recipient of session.Listener to be asynchronously informed of state changes in the session.Arbitrary identifier for a particular connected-mode session.final AX25Callsign
Originator of session.The current state of this session.Digipeater path to use for transmitting from source to destination station.Fields inherited from interface org.ka2ddo.ax25.AX25FrameSource
NO_FRAMES
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Cancel an outstanding resendable frame's timer.void
close()
Closes this connection and releases any system resources associated with it.Report the Connector this message should be transmitted through.Get the connection windowing type.getDst()
Get the callsign of the station that received this connection session.getFrames
(boolean incrementXmtCount, ProtocolFamily protocolId, String senderCallsign) Get one or more AX25Frames of the data to transmit.Get a Java-style InputStream associated with this connection.long
Report the last time this connected-mode session was updated.int
Get number of times frame will be retransmitted before inter-packet delay is increased.Get a Java-style OutputStream for writing to this connection.getSrc()
Get the callsign of the station that originated this connection session.Provide textual description of connection state.boolean
isOpen()
Get the current state of this connection.void
setConnector
(TransmittingConnector connector) Set the Connector through which frames for this connected-mode session should be transmitted.void
setConnType
(ConnState.ConnType connType) Set the connection windowing type.void
setResendableFrame
(AX25Frame frame, int retryCount) Specify that this transmitted unconnected frame needs a timeout timer in case the appropriate response does not come back.toString()
Returns a string representation of the object.void
Update the last-updated timestamp of this session.
-
Field Details
-
src
Originator of session. -
dst
Recipient of session. -
transition
The current state of this session. -
via
Digipeater path to use for transmitting from source to destination station. Only meaningful when source is the local station. -
listener
Listener to be asynchronously informed of state changes in the session. -
sessionIdentifier
Arbitrary identifier for a particular connected-mode session.
-
-
Method Details
-
isOpen
public boolean isOpen()Get the current state of this connection.- Returns:
- boolean true if connection is up and operating
-
getConnType
Get the connection windowing type.- Returns:
- ConnType enum describing the sliding window mode
-
setConnType
Set the connection windowing type.- Parameters:
connType
- ConnType enum describing the sliding window mode
-
getInputStream
Get a Java-style InputStream associated with this connection.- Returns:
- InputStream for the connection
- Throws:
IOException
- if session not to or from this station
-
getOutputStream
Get a Java-style OutputStream for writing to this connection.- Returns:
- OutputStream to this connection
- Throws:
IOException
- if session not to or from this station
-
getSrc
Get the callsign of the station that originated this connection session.- Returns:
- AX25Callsign of originating station
-
getDst
Get the callsign of the station that received this connection session.- Returns:
- AX25Callsign of receiving station
-
toString
Returns a string representation of the object. -
getStateOfConn
Provide textual description of connection state.- Returns:
- String connection state text
-
setResendableFrame
Specify that this transmitted unconnected frame needs a timeout timer in case the appropriate response does not come back.- Parameters:
frame
- AX25Frame that was transmitted and is expecting a responseretryCount
- int number of times this frame should be retried before giving up on a response and failing whatever condition the frame was trying to set up
-
clearResendableFrame
public void clearResendableFrame()Cancel an outstanding resendable frame's timer. This is due to either receiving a valid response for the frame, or timing out for the last retry attempt and giving up. -
getFrames
public AX25Frame[] getFrames(boolean incrementXmtCount, ProtocolFamily protocolId, String senderCallsign) Get one or more AX25Frames of the data to transmit. Note this should only be used for AX.25 connections with one end terminated at the local station; Man-In-The-Middle (MitM) attacks are not friendly behavior.- Specified by:
getFrames
in interfaceAX25FrameSource
- Parameters:
incrementXmtCount
- indicate whether the transmit counter (used to cycle through proportional pathing) should be incrementedprotocolId
- indicate the protocol to generate this frame forsenderCallsign
- String of local callsign sending this message (may be ignored if digipeating a message from another station)- Returns:
- array of AX25Frame objects to transmit (may be zero-length)
-
getNumTransmitsBeforeDecay
public int getNumTransmitsBeforeDecay()Get number of times frame will be retransmitted before inter-packet delay is increased.- Specified by:
getNumTransmitsBeforeDecay
in interfaceAX25FrameSource
- Returns:
- transmission count before interval increase
-
getConnector
Report the Connector this message should be transmitted through.- Specified by:
getConnector
in interfaceAX25FrameSource
- Returns:
- a specific Connector instance to transmit through, or null for all applicable ports (Connector.CAP_XMT_PACKET_DATA and not rejecting this specific packet [such as IGateConnectors shouldn't re-transmit something received from the IGate])
- See Also:
-
setConnector
Set the Connector through which frames for this connected-mode session should be transmitted.- Parameters:
connector
- Connector that is capable of transmitting AX.25 frames
-
close
public void close()Closes this connection and releases any system resources associated with it. If the connection is already closed then invoking this method has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getLastUpdateInSession
public long getLastUpdateInSession()Report the last time this connected-mode session was updated.- Returns:
- time (in milliseconds since epoch) of the last update to this session
-
updateSessionTime
public void updateSessionTime()Update the last-updated timestamp of this session.
-