public class AX25Frame extends java.lang.Object implements java.io.Serializable, AX25FrameSource, java.lang.Comparable<AX25Frame>
Modifier and Type | Field and Description |
---|---|
byte[] |
body
Byte array containing the higher-level protocol payload for I and UI frames.
|
byte |
ctl
Bitmask identifying the frame type and subtype, and windowing position for connection-oriented
I and S frames.
|
byte |
ctl2
Extension of ctl when using 128-segment windowing.
|
AX25Callsign |
dest
Callsign of the destination station, or some broadcast code with an alternate meaning (such as
APRS tocalls and Mic-E encoded latitude and status values).
|
AX25Callsign[] |
digipeaters
Optional array of digipeater callsigns and aliases, if this frame should be digipeated.
|
static int |
FRAMETYPE_I
Numeric code for information (I) frame type.
|
static int |
FRAMETYPE_S
Numeric code for supervisory (S) frame type.
|
static int |
FRAMETYPE_U
Numeric code for unnumbered (U) frame type.
|
static int |
MASK_FRAMETYPE
The bitmask to extract the frametype bits from the ctl byte of the frame.
|
static int |
MASK_STYPE
Bitmask to extract supervisory (S) frame subtype from the ctl byte.
|
static int |
MASK_U_P
Bitmask to extract poll/final bit from unnumbered (U) frame ctl byte, mod 8 format.
|
static int |
MASK_U_P128
Bitmask to extract poll/final bit from I/S frame 2nd ctl byte, mod 128 format.
|
static int |
MASK_UTYPE
Bitmask to extract unnumbered (U) frame subtype from the ctl byte.
|
static int |
MAX_DIGIS
Maximum number of digipeat addresses allowed in an AX.25 frame, according to the AX.25 spec.
|
boolean |
mod128
Indicates whether 128-segment windowing is used for I frame connections.
|
AX25Message |
parsedAX25Msg
The decoded APRS (or other protocol) message (if the AX25Frame contains a higher-level protocol).
|
byte |
pid
The one-byte code identifying how to interpret the body of I and UI frames.
|
static byte |
PID_AARP
Protocol ID for Appletalk Address Resolution Protocol (ARP).
|
static byte |
PID_ATALK
Protocol ID for Appletalk.
|
static byte |
PID_ESCAPE
Protocol ID for escape code indicating second byte of PID (not supported).
|
static byte |
PID_FLEXNET
Protocol ID for FlexNet.
|
static byte |
PID_IARP
Protocol ID for ARPA Internet Address Resolution Protocol (ARP).
|
static byte |
PID_IP
Protocol ID for ARPA Internet Protocol.
|
static byte |
PID_LQP
Protocol ID for Link Quality Protocol.
|
static byte |
PID_NETROM
Protocol ID for NET/ROM.
|
static byte |
PID_NOLVL3
Protocol ID for no level 3 protocol (also used for APRS).
|
static byte |
PID_OPENTRAC
Protocol ID for OpenTRAC.
|
static byte |
PID_SEG_FRAG
Protocol ID for AX.25 segmentation fragment.
|
static byte |
PID_TEXNET
Protocol ID for TEXNET datagram.
|
static byte |
PID_VJC_TCPIP
Protocol ID for Van Jacobson compressed TCP/IP packet, per RFC 1144.
|
static byte |
PID_VJUC_TCPIP
Protocol ID for Van Jacobson uncompressed TCP/IP packet, per RFC 1144.
|
static byte |
PID_X25_PLP
Protocol ID for CCITT X.25 PLP (also used by the ROSE network).
|
static java.util.Map<java.lang.Byte,java.lang.String> |
PTYPES_S
Hashmap of Information (I) or Unnumbered Information (UI) frame protocol ID to protocol name strings.
|
long |
rcptTime
The time when this message was received in Java milliseconds since midnight, Jan 1 1970 UTC.
|
AX25Callsign |
sender
Callsign of the transmitting station (not of any intermediate digipeaters).
|
static int |
SHIFT_STYPE
Bit shift to get least significant bit of S frame subtype into least significant bit of integer.
|
static int |
SHIFT_UTYPE
Bit shift to get least significant bit of U frame subtype into least significant bit of integer.
|
Connector |
sourcePort
Pointer to the I/O port from which this frame was received.
|
static int |
STYPE_REJ
Unshifted S frame subtype for Reject frame.
|
static int |
STYPE_RNR
Unshifted S frame subtype for Receive Not Ready frame.
|
static int |
STYPE_RR
Unshifted S frame subtype for Receive Ready frame.
|
static int |
STYPE_SREJ
Unshifted S frame subtype for Selective Reject frame.
|
static int |
UTYPE_DISC
Unshifted U frame subtype for Disconnect (DISC).
|
static int |
UTYPE_DM
Unshifted U frame subtype for Disconnected Mode (DM).
|
static int |
UTYPE_FRMR
Deprecated.
2.0
|
static int |
UTYPE_SABM
Unshifted U frame subtype for Set Asynchronous Balanced Mode (SABM).
|
static int |
UTYPE_SABME
Unshifted U frame subtype for Set Asynchronous Balanced Mode Extended (SABME).
|
static int |
UTYPE_TEST
Unshifted U frame subtype for Test (TEST).
|
static int |
UTYPE_UA
Unshifted U frame subtype for Unnumbered Acknowledge (UA).
|
static int |
UTYPE_UI
Unshifted U frame subtype for Unnumbered Information (UI).
|
static int |
UTYPE_XID
Unshifted U frame subtype for Exchange Identification (XID).
|
NO_FRAMES
Constructor and Description |
---|
AX25Frame()
Create an empty AX25Frame initialized for a UI frame containing an APRS packet.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(AX25Frame o)
Compares this object with the specified object for order.
|
static AX25Frame |
decodeFrame(byte[] buf,
int offset,
int length)
Create a AX25Frame from a byte array presumed to contain an AX.25 protocol sequence.
|
AX25Frame |
dup()
Create a deep copy of this frame.
|
AX25Frame |
dupOnlyHeader()
Create a deep copy of this frame, excluding the body.
|
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.
|
static int |
findSTypeByName(java.lang.String sTypeName)
Given a string name, get the numeric S-type value for that type of AX.25 frame.
|
static int |
findUTypeByName(java.lang.String uTypeName)
Given a string name, get the numeric U-type value for that type of AX.25 frame.
|
java.lang.String |
getAsciiFrame()
Produce an ASCIIfied version of frame body.
|
int |
getChecksum()
Compute a checksum for this frame to allow efficiently identifying
duplicate frames.
|
Connector |
getConnector()
Specify the Connector this message should be transmitted through.
|
int |
getEstimatedBitCount()
Estimate the number of bits needed to transmit this frame over RF in AX.25 standard physical layer (HDLC).
|
static java.lang.String |
getFirstDigi(AX25Callsign[] digipeaters)
Get the first actual digipeated digipeater station callsign in the digipeater sequence.
|
AX25Frame[] |
getFrames(boolean incrementXmtCount,
ProtocolFamily protocolId,
java.lang.String senderCallsign)
Get the frames associated with this FrameSource (in this case, itself).
|
int |
getFrameType()
Get the type of this frame, as stored in the ctl byte.
|
java.lang.String |
getFrameTypeString()
Generate a string describing the type of the frame.
|
static java.lang.String |
getLastDigi(AX25Callsign[] digipeaters)
Find the last callsign through which a frame has been digipeated.
|
int |
getNR()
Get the reception sequence number.
|
int |
getNS()
Get the transmission sequence number.
|
static java.lang.String |
getNthDigi(AX25Callsign[] digipeaters,
int index)
Get the Nth digipeated digipeater station callsign in the digipeater sequence.
|
int |
getNumTransmitsBeforeDecay()
Get number of times frame will be retransmitted before inter-packet delay is increased.
|
boolean |
getP()
Get poll bit.
|
java.util.Set<ProtocolFamily> |
getProtocols()
Get the protocol family or families that this message corresponds to, so
ports that don't support all protocols will not forward inappropriate packets.
|
int |
getSType()
Get the Supervisory frame subtype.
|
int |
getUType()
Get Unordered frame subtype.
|
int |
hashCode()
Returns a hash code value for the object.
|
static void |
initializeCmd(AX25Frame f)
Properly set the isCmd flag of a frame based on the
AX25Callsign.h_c bits in
the sender and destination addresses. |
boolean |
isDirect()
Test if this message was sent directly (without any relay station).
|
boolean |
isDuplicate(AX25Frame other)
Test if this frame has the same contents (at least as regards duplicate checking)
as the provided older frame.
|
static boolean |
isRealCallsign(java.lang.String callsign)
Test if a callsign looks like a real callsign (at least one digit somewhere other than
the last character, all letters uppercase).
|
java.lang.Boolean |
isRf(int maxDigis)
Test if this AX25Frame came from an RF connection.
|
boolean |
isValid()
Report whether this packet is strictly valid according to the AX.25 protocol specification,
|
void |
setCmd(boolean isCmd)
Set the command bits in the sender and destination fields.
|
java.lang.String |
toString()
Return a String representing this AX25Frame object.
|
void |
write(java.io.OutputStream os)
Transmit this AX25Frame to an output byte stream.
|
public static final int MAX_DIGIS
public AX25Callsign sender
public AX25Callsign dest
public AX25Callsign[] digipeaters
public transient Connector sourcePort
public byte ctl
getFrameType()
,
getUType()
,
getSType()
public byte pid
PID_X25_PLP
,
PID_VJC_TCPIP
,
PID_VJUC_TCPIP
,
PID_SEG_FRAG
,
PID_OPENTRAC
,
PID_TEXNET
,
PID_LQP
,
PID_ATALK
,
PID_AARP
,
PID_IP
,
PID_IARP
,
PID_FLEXNET
,
PID_NETROM
,
PID_NOLVL3
,
PID_ESCAPE
public byte[] body
public boolean mod128
public long rcptTime
public AX25Message parsedAX25Msg
public static final int MASK_FRAMETYPE
ctl
,
Constant Field Valuespublic static final int FRAMETYPE_I
public static final int FRAMETYPE_S
public static final int FRAMETYPE_U
public static final int MASK_STYPE
ctl
,
Constant Field Valuespublic static final int SHIFT_STYPE
public static final int STYPE_RR
MASK_STYPE
,
Constant Field Valuespublic static final int STYPE_RNR
MASK_STYPE
,
Constant Field Valuespublic static final int STYPE_REJ
MASK_STYPE
,
Constant Field Valuespublic static final int STYPE_SREJ
MASK_STYPE
,
Constant Field Valuespublic static final int MASK_UTYPE
ctl
,
Constant Field Valuespublic static final int MASK_U_P
ctl
,
Constant Field Valuespublic static final int MASK_U_P128
ctl2
,
Constant Field Valuespublic static final int SHIFT_UTYPE
public static final int UTYPE_UI
public static final int UTYPE_DM
public static final int UTYPE_SABM
public static final int UTYPE_DISC
public static final int UTYPE_UA
public static final int UTYPE_SABME
public static final int UTYPE_FRMR
public static final int UTYPE_XID
public static final int UTYPE_TEST
public static final byte PID_X25_PLP
public static final byte PID_VJC_TCPIP
public static final byte PID_VJUC_TCPIP
public static final byte PID_SEG_FRAG
public static final byte PID_OPENTRAC
public static final byte PID_TEXNET
public static final byte PID_LQP
public static final byte PID_ATALK
public static final byte PID_AARP
public static final byte PID_IP
public static final byte PID_IARP
public static final byte PID_FLEXNET
public static final byte PID_NETROM
public static final byte PID_NOLVL3
public static final byte PID_ESCAPE
public static final java.util.Map<java.lang.Byte,java.lang.String> PTYPES_S
pid
public AX25Frame()
public static AX25Frame decodeFrame(byte[] buf, int offset, int length)
buf
- byte array to read frame fromoffset
- zero-based index into the array where the frame startslength
- number of bytes making up the framepublic static void initializeCmd(AX25Frame f)
AX25Callsign.h_c
bits in
the sender and destination addresses.f
- AX25Frame to setpublic java.lang.String getFrameTypeString()
public int getFrameType()
FRAMETYPE_I
,
FRAMETYPE_S
,
FRAMETYPE_U
public int getNS()
java.lang.IllegalStateException
- if this is not an I framepublic int getNR()
java.lang.IllegalStateException
- if this is not an I framepublic int getSType()
STYPE_RR
,
STYPE_RNR
,
STYPE_REJ
,
STYPE_SREJ
public static int findSTypeByName(java.lang.String sTypeName)
sTypeName
- String name of frame typepublic boolean getP()
public static int findUTypeByName(java.lang.String uTypeName)
uTypeName
- String name of frame typepublic int getUType()
UTYPE_UI
,
UTYPE_DM
,
UTYPE_SABM
,
UTYPE_DISC
,
UTYPE_UA
,
UTYPE_SABME
,
UTYPE_FRMR
,
UTYPE_XID
,
UTYPE_TEST
public void write(java.io.OutputStream os) throws java.io.IOException
os
- OutputStream to write the frame tojava.io.IOException
- if writing failspublic AX25Frame dup()
public AX25Frame dupOnlyHeader()
public AX25Frame[] getFrames(boolean incrementXmtCount, ProtocolFamily protocolId, java.lang.String senderCallsign)
getFrames
in interface AX25FrameSource
incrementXmtCount
- indicate whether the transmit counter (used to cycle through
proportional pathing) should be incrementedprotocolId
- indicate the protocol to generate this frame for (not relevant for
digipeated frames)senderCallsign
- local sending callsign (ignored if frame already has
the callsign filled in)public int getNumTransmitsBeforeDecay()
getNumTransmitsBeforeDecay
in interface AX25FrameSource
public Connector getConnector()
getConnector
in interface AX25FrameSource
Connector.CAP_XMT_PACKET_DATA
public static boolean isRealCallsign(java.lang.String callsign)
callsign
- String callsign to testpublic static java.lang.String getFirstDigi(AX25Callsign[] digipeaters)
digipeaters
- array of AX25Callsigns for digipeating a messagepublic static java.lang.String getNthDigi(AX25Callsign[] digipeaters, int index)
digipeaters
- array of AX25Callsigns for digipeating a messageindex
- zero-based index of digipeater to reportpublic static java.lang.String getLastDigi(AX25Callsign[] digipeaters)
digipeaters
- array of digipeater callsignspublic java.lang.Boolean isRf(int maxDigis)
maxDigis
- int maximum number of digipeat hops before we're not going to count itpublic boolean isDirect()
public void setCmd(boolean isCmd)
isCmd
- boolean true if this is a command frame, false if a responsepublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getAsciiFrame()
public int getChecksum()
public int compareTo(AX25Frame o)
compareTo
in interface java.lang.Comparable<AX25Frame>
o
- the object to be compared.java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
equals(Object)
public boolean isDuplicate(AX25Frame other)
other
- AX25Frame to compare payloads withpublic int getEstimatedBitCount()
public boolean isValid()
public java.util.Set<ProtocolFamily> getProtocols()