Class ConnState

java.lang.Object
org.ka2ddo.ax25.ConnState
All Implemented Interfaces:
Closeable, AutoCloseable, AX25FrameSource

public class ConnState extends Object implements AX25FrameSource, Closeable
This class keeps track of the state of one AX.25 connection-oriented session.
Author:
Andrew Pavlin, KA2DDO
  • Field Details

    • src

      public final AX25Callsign src
      Originator of session.
    • dst

      public final AX25Callsign dst
      Recipient of session.
    • transition

      public ConnState.ConnTransition transition
      The current state of this session.
    • via

      public AX25Callsign[] 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

      public Object 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

      public ConnState.ConnType getConnType()
      Get the connection windowing type.
      Returns:
      ConnType enum describing the sliding window mode
    • setConnType

      public void setConnType(ConnState.ConnType connType)
      Set the connection windowing type.
      Parameters:
      connType - ConnType enum describing the sliding window mode
    • getInputStream

      public InputStream getInputStream() throws IOException
      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

      public OutputStream getOutputStream() throws IOException
      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

      public AX25Callsign getSrc()
      Get the callsign of the station that originated this connection session.
      Returns:
      AX25Callsign of originating station
    • getDst

      public AX25Callsign getDst()
      Get the callsign of the station that received this connection session.
      Returns:
      AX25Callsign of receiving station
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.
    • getStateOfConn

      public String getStateOfConn()
      Provide textual description of connection state.
      Returns:
      String connection state text
    • setResendableFrame

      public 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.
      Parameters:
      frame - AX25Frame that was transmitted and is expecting a response
      retryCount - 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 interface AX25FrameSource
      Parameters:
      incrementXmtCount - indicate whether the transmit counter (used to cycle through proportional pathing) should be incremented
      protocolId - indicate the protocol to generate this frame for
      senderCallsign - 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 interface AX25FrameSource
      Returns:
      transmission count before interval increase
    • getConnector

      public Connector getConnector()
      Report the Connector this message should be transmitted through.
      Specified by:
      getConnector in interface AX25FrameSource
      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

      public void setConnector(TransmittingConnector connector)
      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 interface AutoCloseable
      Specified by:
      close in interface Closeable
    • 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.