mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Identifier Framework and Message/Event Processing Overhaul (#455)
* WIP on new P25 message framer. * WIP on new P25 message framer. * Adds new 1/2 and 3/4 rate trellis decoders. Still trying to chase down why there is a sync pattern mismatch in the NID buffer queue. * WIP - new p25 message framer works correctly now. PDU's are dectected and decoded using the 1/2 and 3/4 rate trellis decoders. Packet Sequences are assembled. Need to add a new packet sequence message factory that can detect Motorola Auto Registration Service (ARS) formatted UDP/ID packets and SNDCP command packets. * WIP - removes nullify on channel results queue. * WIP - updates message framer for TSBK 1/2/3 processing. * WIP removing P25 sync pattern and nid bits from all message parsers. * WIP - merges identifier framework branch changes into this branch. * WIP on updating link control words to new format and identifier framework. * WIP - implements rest of link control words for extended formats * WIP - initial work on ISP/OSP TSBK message restructuring. * WIP - adds more TSBK ISP and OSP messages * WIP - finished updating most of the TSBK ISP and OSP messages. Converted all messages to no longer include the NID (nac + dataunitID) so that each message can simply hold the parsed values. Removed AliasList as an argument to each message and updated all messges to use the new IIdentifer and IAPCO25Channel interfaces. Removed legacy TDU and LDU link control messages and replaced with a single LinkControlWord class hierarchy. P25 decoder state is not yet updated for the new message structure. PDU message parsing is not fully implemented. * WIP - adds some Multi-Block trunking control messages with Alternate and Unconfirmed formats. * WIP - Fully implements AMBTC and UMBTC PDU message parsers. Some package restructuring. * WIP - Resolves Link control parsing in LDU1 and 2 messages. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. Adds support for moto ARS service, IPV4 decoding, and UDP/IP packets. * WIP - finishes SNDCP packet data with header parsing. Compressed IP or UDP headers are not yet supported, but are logged as such. * WIP - converts all talkgroup identifiers to integers and updates alias list to create a per-protocol map of talkgroup id's to alias. Inserts a legacy talkgroup (ltr, p25, passport, mpt1327, mdc, etc.) conversion utility to convert existing legacy (string) talkgroups to new integer talkgroup format. Creates an audio packet manager to insert metadata into audio packets before streaming packets for playback, recording, and/or streaming. Creates identifier collection to manage current identifiers in each of the channel and decoder states. Creates simplified channel metadata to maintain the now playing display. Moves channel attributes (alias list, system, site, name) as configuration identifiers in the channel state. Many other refactoring and updates. * WIP - numerous updates to push use of identifier collection throughout the system. Updates the channel metadata and audio packet processing logic. Implements a large portion of the P25 decode state processing. Updates traffic channel management. Adds user preferences for timestamp and identifier formatting, however doesn't add a user interface yet. * WIP - initial implementation of user preferences editor window. * WIP - updates preferences editor window to close and dispose window but retain javafx event thread running. * WIP - fully updates p25 decoder state and traffic channel processing to use the new identifier framework. Cleans up channel event processing and removes channel model as the sole broadcaster of channel events. Channel processing manager now listens for all start/stop events and requestors dispatch event directly to the channel processing manager. Resolves issue in airspy that was causing user interface to lock-up. The issue appears to occur when the dongle is plugged into a usb port that can't fully support the data rate. sdrtrunk now recognizes these errors and warns the user that they should use another usb port. * WIP - updates alias action manager and adds new talkgroup range alias identifier. Updates playlist to incorporate a version number so that the playlist updater only runs when needed, to update a playlist to the correct version format. Updates user preferences to use the google event bus to broadcast preference update notifications to remove the need for listeners to register directly on the user preferences instance. * WIP - updates alias id editors to flag invalid values and moves legacy alias ids to legacy package. Updates event logging configuration to add traffic channel decode events and decoded message logging. Removes binary message logging since that is now replaced with demodulated bitstream recording. * Removes system properties from user preferences. Preferences are stored in the OS-dependent settings store (windows - registry) * Updates MapService to use new PlottableDecodeEvent instead of monitoring all of the decoded messages. Updates Fleetsync decoder and related messages to identifier framework. * Updates LTR-Net, Fleetsync and LJ1200 decoders to new identifier framework and adds support for user preferences for formatting of LTR-Net and fleetsync talkgroup identifiers. Breaks LTR-Net messages into various message types and uses a new message factory. Removes alias list from message processing for ltr-net, fleetsync and lj1200. * Updates LTR-Standard messages to Identifier framework. * Removes Plottable and IPlottable from codebase. * wip * WIP on MPT-1327 messages. * Updates MPT1327 decoder to identifier framework and new traffic channel manager. This decoder still needs to be updated with a new message parser factory and a sync detector like what is now used for P25. * Updates MDC1200 decoder and message to identifier framework. * Updates Tait1200 and Passport decoders to identifier framework. * Merges changes from master branch. * Removes legacy alias support classes. Updates passport message processor to only pass valid messages. Adds support to playlist updater for converting passport mobile ids to become passport talkgroup values. * Updates P25 decoder state and channel state to better track allocated traffic channels. Resolves issue in timestamp manager for trackig message timestamps. Resolves issue in airspy tuner that was causing the tuner to stop sending samples to the application. * Update P25 Decoder state to process SNDCP management messages and PDU messages. Updates P25 activity summary to display network and site details. Resolves issue with overlay panel that prevented enabled channels from rendering correctly when zoomed in. * Creates a new FilePreferences as part of the user preferences to begin the transition of SystemProperties over to user preferences and consolidate file preferences in one location. Updates playlist manager to use the new file preferences and to use default.xml as the new default playlist name, following conversion of a playlist_v2.xml format to the new format. In the near future, the user will be able to edit file locations and to create/use other playlists. Resolved an issue with all decoder states where not all identifiers were being included in decode events.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public abstract class Header implements IHeader
|
||||
{
|
||||
private BinaryMessage mMessage;
|
||||
private int mOffset;
|
||||
private boolean mValid = true;
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public Header(BinaryMessage message, int offset)
|
||||
{
|
||||
mMessage = message;
|
||||
mOffset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Underlying message that contains this header
|
||||
*/
|
||||
public BinaryMessage getMessage()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to this header in the underlying message
|
||||
*/
|
||||
public int getOffset()
|
||||
{
|
||||
return mOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this header is valid
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return mValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the valid flag for this header
|
||||
*/
|
||||
protected void setValid(boolean valid)
|
||||
{
|
||||
mValid = valid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip;
|
||||
|
||||
/**
|
||||
* Data Packet Header
|
||||
*/
|
||||
public interface IHeader
|
||||
{
|
||||
/**
|
||||
* Indicates that this header is valid and that it meets the length requirements.
|
||||
*/
|
||||
boolean isValid();
|
||||
|
||||
/**
|
||||
* Indicates the length of this header. An implicit understanding is that any data that follows
|
||||
* the header (ie payload) starts after the header length.
|
||||
* @return length of this header in bytes.
|
||||
*/
|
||||
int getLength();
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip;
|
||||
|
||||
public enum IPProtocol
|
||||
{
|
||||
HOPOPT( 0, "IPV6 HOP-BY-HOP" ),
|
||||
ICMP( 1, "ICMP" ),
|
||||
IGMP( 2, "IGMP" ),
|
||||
GGP( 3, "GGP" ),
|
||||
IPinIP( 4, "IPinIP" ),
|
||||
ST( 5, "ST" ),
|
||||
TCP( 6, "TCP" ),
|
||||
CBT( 7, "CBT" ),
|
||||
EGP( 8, "EGP" ),
|
||||
IGP( 9, "IGP" ),
|
||||
BBN( 10, "BBN" ),
|
||||
NVP( 11, "NVP" ),
|
||||
PUP( 12, "PUP" ),
|
||||
ARGUS( 13, "ARGUS" ),
|
||||
EMCON( 14, "EMCON" ),
|
||||
XNET( 15, "XNET" ),
|
||||
CHAOS( 16, "CHAOS" ),
|
||||
UDP( 17, "UDP" ),
|
||||
MUX( 18, "MUX" ),
|
||||
DCN( 19, "DCN" ),
|
||||
HMP( 20, "HMP" ),
|
||||
PRM( 21, "PRM" ),
|
||||
XNS_IDP( 22, "XNS-IDP" ),
|
||||
TRUNK_1( 23, "TRUNK-1" ),
|
||||
TRUNK_2( 24, "TRUNK-2" ),
|
||||
LEAF_1( 25, "LEAF-1" ),
|
||||
LEAF_2( 26, "LEAF-2" ),
|
||||
RDP( 27, "RDP" ),
|
||||
IRTP( 28, "IRTP" ),
|
||||
ISO_TP4( 29, "ISO-TP4" ),
|
||||
NETBLT( 30, "NETBLT" ),
|
||||
MFE_NSP( 31, "MFE-NSP" ),
|
||||
MERIT_INP( 32, "MERIT-INP" ),
|
||||
DCCP( 33, "DCCP" ),
|
||||
_3PC( 34, "3PC" ),
|
||||
IDPR( 35, "IDPR" ),
|
||||
XTP( 36, "XTP" ),
|
||||
DDP( 37, "DDP" ),
|
||||
IDPR_CMTP( 38, "IDPR-CMTP" ),
|
||||
TPPP( 39, "TP++" ),
|
||||
IL( 40, "IL" ),
|
||||
IPV6( 41, "IPV6" ),
|
||||
SDRP( 42, "SDRP" ),
|
||||
IPV6_ROUTE( 43, "IPV6-ROUTE" ),
|
||||
IPV6_FRAG( 44, "IPV6-FRAG" ),
|
||||
IDRP( 45, "IDRP" ),
|
||||
RSVP( 46, "RSVP" ),
|
||||
GRE( 47, "GRE" ),
|
||||
MHRP( 48, "MHRP" ),
|
||||
BNA( 49, "BNA" ),
|
||||
ESP( 50, "ESP" ),
|
||||
AH( 51, "AH" ),
|
||||
INLSP( 52, "I-NLSP" ),
|
||||
SWIPE( 53, "SWIPE" ),
|
||||
NARP( 54, "NARP" ),
|
||||
MOBILE( 55, "MOBILE" ),
|
||||
TLSP( 56, "TLSP" ),
|
||||
SKIP( 57, "SKIP" ),
|
||||
IPV6_ICMP( 58, "IPV6-ICMP" ),
|
||||
IPV6_NONXT( 59, "IPV6-NoNXT" ),
|
||||
IPV6_OPTS( 60, "IPV6-OPTS" ),
|
||||
ANY_HOST( 61, "ANY HOST" ),
|
||||
CFTP( 62, "CFTP" ),
|
||||
ANY_NETWORK( 63, "ANY NETWORK" ),
|
||||
SAT_EXPAK( 64, "SAT_EXPAK" ),
|
||||
KRYPTOLAN( 65, "KRYPTOLAN" ),
|
||||
RVD( 66, "RVD" ),
|
||||
IPPC( 67, "IPPC" ),
|
||||
ANY_DIST( 68, "ANY DISTRIBUTED" ),
|
||||
SAT_MON( 69, "SAT-MON" ),
|
||||
VISA( 70, "VISA" ),
|
||||
IPCU( 71, "IPCU" ),
|
||||
CPNX( 72, "CPNX" ),
|
||||
CPHB( 73, "CPHB" ),
|
||||
WSN( 74, "WSN" ),
|
||||
PVP( 75, "PVP" ),
|
||||
BR_SAT_MON( 76, "BR-SAT-MON" ),
|
||||
SUN_ND( 77, "SUN-ND" ),
|
||||
WB_MON( 78, "WB-MON" ),
|
||||
WB_EXPAK( 79, "WB-EXPAK" ),
|
||||
ISO_IP( 80, "ISO-IP" ),
|
||||
VMTP( 81, "VMTP" ),
|
||||
SECURE_VMTP( 82, "SECURE-VMTP" ),
|
||||
VINES( 83, "VINES" ),
|
||||
TTP( 84, "TTP" ),
|
||||
NSFNET_IGP( 85, "NSFNET-IGP" ),
|
||||
DGP( 86, "DGP" ),
|
||||
TCF( 87, "TCF" ),
|
||||
EIGRP( 88, "EIGRP" ),
|
||||
OSPF( 89, "OSPF" ),
|
||||
SPRITE_RPC( 90, "SPRITE-RPC" ),
|
||||
LARP( 91, "LARP" ),
|
||||
MTP( 92, "MTP" ),
|
||||
AX25( 93, "AX-25" ),
|
||||
IPIP( 94, "IPIP" ),
|
||||
MICP( 95, "MICP" ),
|
||||
SCC_SP( 96, "SCC-SP" ),
|
||||
ETHERIP( 97, "ETHER-IP" ),
|
||||
ENCAP( 98, "ENCAP" ),
|
||||
ANY_PRIVATE( 99, "ANY PRIVATE" ),
|
||||
GMTP( 100, "GMTP" ),
|
||||
IFMP( 101, "IFMP" ),
|
||||
PNNI( 102, "PNNI" ),
|
||||
PIM( 103, "PIM" ),
|
||||
ARIS( 104, "ARIS" ),
|
||||
SCPS( 105, "SCPS" ),
|
||||
QNX( 106, "QNX" ),
|
||||
A_N( 107, "A-N" ),
|
||||
IPCOMP( 108, "IPCOMP" ),
|
||||
SNP( 109, "SNP" ),
|
||||
COMPAQ_PEER( 110, "COMPAQ-PEER" ),
|
||||
IPXinIP( 111, "IPX-in-IP" ),
|
||||
VRRP( 112, "VRRP" ),
|
||||
PGM( 113, "PGM" ),
|
||||
ANY_0_HOP( 114, "ANY 0-HOP" ),
|
||||
L2TP( 115, "L2TP" ),
|
||||
DDX( 116, "DDX" ),
|
||||
IATP( 117, "IATP" ),
|
||||
STP( 118, "STP" ),
|
||||
SRP( 119, "SRP" ),
|
||||
UTI( 120, "UTI" ),
|
||||
SMP( 121, "SMP" ),
|
||||
SM( 122, "SM" ),
|
||||
PTP( 123, "PTP" ),
|
||||
ISIS( 124, "IS-IS OVER IPV4" ),
|
||||
FIRE( 125, "FIRE" ),
|
||||
CRTP( 126, "CRTP" ),
|
||||
CRUDP( 127, "CRUDP" ),
|
||||
SSCOPMCE( 128, "SSCOPMCE" ),
|
||||
IPLT( 129, "IPLT" ),
|
||||
SPS( 130, "SPS" ),
|
||||
PIPE( 131, "PIPE" ),
|
||||
SCTP( 132, "SCTP" ),
|
||||
FC( 133, "FC" ),
|
||||
RSVP_E2E( 134, "RSVP E2E" ),
|
||||
MOBILITY( 135, "MOBILITY HDR" ),
|
||||
UDPLITE( 136, "UDP LITE" ),
|
||||
MPLSinIP( 137, "MPLS-IN-IP" ),
|
||||
MANET( 138, "MANET" ),
|
||||
HIP( 139, "HIP" ),
|
||||
SHIM6( 140, "SHIM6" ),
|
||||
WESP( 141, "WESP" ),
|
||||
ROHC( 142, "ROHC" ),
|
||||
UNKNOWN( -1, "UNKNOWN" );
|
||||
|
||||
private int mValue;
|
||||
private String mLabel;
|
||||
|
||||
private IPProtocol( int value, String label )
|
||||
{
|
||||
mValue = value;
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
public static IPProtocol fromValue( int value )
|
||||
{
|
||||
if( 0 <= value && value <= 142 )
|
||||
{
|
||||
return values()[ value ];
|
||||
}
|
||||
|
||||
return IPProtocol.UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip;
|
||||
|
||||
/**
|
||||
* Data packet interface
|
||||
*/
|
||||
public interface IPacket
|
||||
{
|
||||
/**
|
||||
* Header for the data packet.
|
||||
*/
|
||||
public IHeader getHeader();
|
||||
|
||||
/**
|
||||
* Optional payload for the packet
|
||||
* @return null if there is no payload
|
||||
*/
|
||||
public IPacket getPayload();
|
||||
|
||||
/**
|
||||
* Indicates if this packet contains an optional payload
|
||||
*/
|
||||
public boolean hasPayload();
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public abstract class Packet implements IPacket
|
||||
{
|
||||
private BinaryMessage mMessage;
|
||||
private int mOffset;
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
* @param message containing the packet
|
||||
* @param offset to the packet within the message
|
||||
*/
|
||||
public Packet(BinaryMessage message, int offset)
|
||||
{
|
||||
mMessage = message;
|
||||
mOffset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Underlying message that contains this packet
|
||||
*/
|
||||
public BinaryMessage getMessage()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to this packet in the underlying message
|
||||
*/
|
||||
public int getOffset()
|
||||
{
|
||||
return mOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPayload()
|
||||
{
|
||||
return getPayload() != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.module.decode.ip.ars.ARSPacket;
|
||||
import io.github.dsheirer.module.decode.ip.ipv4.IPV4Header;
|
||||
import io.github.dsheirer.module.decode.ip.ipv4.IPV4Packet;
|
||||
import io.github.dsheirer.module.decode.ip.udp.UDPPacket;
|
||||
import io.github.dsheirer.module.decode.p25.message.pdu.packet.sndcp.SNDCPPacketHeader;
|
||||
import io.github.dsheirer.module.decode.p25.reference.IPHeaderCompression;
|
||||
|
||||
/**
|
||||
* Message parser factory for packet based binary sequences.
|
||||
*/
|
||||
public class PacketMessageFactory
|
||||
{
|
||||
/**
|
||||
* Creates an IP packet message parser
|
||||
*
|
||||
* @param message containing an IP packet
|
||||
* @param offset to the IP packet within the message
|
||||
* @return constructed packet message parser
|
||||
*/
|
||||
public static IPacket create(SNDCPPacketHeader sndcpPacketHeader, BinaryMessage message, int offset)
|
||||
{
|
||||
if(sndcpPacketHeader.getIPHeaderCompression() == IPHeaderCompression.NONE)
|
||||
{
|
||||
int version = IPV4Header.getIPVersion(message, offset);
|
||||
|
||||
switch(version)
|
||||
{
|
||||
case 4:
|
||||
return new IPV4Packet(message, offset);
|
||||
default:
|
||||
return new UnknownPacket(message, offset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new UnknownCompressedHeaderPacket(sndcpPacketHeader, message, offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an IP packet protocol payload message parser.
|
||||
*
|
||||
* @param protocol of the IP packet payload
|
||||
* @param binaryMessage containing the IP packet and payload
|
||||
* @param offset to the start of the IP packet payload
|
||||
* @return constructed packet message parser
|
||||
*/
|
||||
public static IPacket create(IPProtocol protocol, BinaryMessage binaryMessage, int offset)
|
||||
{
|
||||
switch(protocol)
|
||||
{
|
||||
case UDP:
|
||||
return new UDPPacket(binaryMessage, offset);
|
||||
default:
|
||||
return new UnknownPacket(binaryMessage, offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a UDP/IP packet payload parser
|
||||
*
|
||||
* @param destinationPort for the packet (to identify the protocol/format)
|
||||
* @param binaryMessage containing the IP/UDP payload
|
||||
* @param offset in the message to the start of the payload
|
||||
* @return constructed packet messge parser
|
||||
*/
|
||||
public static IPacket createUDPPayload(int destinationPort, BinaryMessage binaryMessage, int offset)
|
||||
{
|
||||
switch(destinationPort)
|
||||
{
|
||||
case 4001: //Location Service
|
||||
break;
|
||||
case 4004: //XCMP Service
|
||||
break;
|
||||
case 4005: //Automatic Registration Service
|
||||
return new ARSPacket(binaryMessage, offset);
|
||||
case 4007: //Text Message Service
|
||||
break;
|
||||
case 4008: //Telemetry Service
|
||||
break;
|
||||
}
|
||||
|
||||
return new UnknownPacket(binaryMessage, offset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.module.decode.p25.message.pdu.packet.sndcp.SNDCPPacketHeader;
|
||||
|
||||
public class UnknownCompressedHeaderPacket implements IPacket
|
||||
{
|
||||
private SNDCPPacketHeader mSNDCPPacketHeader;
|
||||
private BinaryMessage mMessage;
|
||||
private int mOffset;
|
||||
|
||||
public UnknownCompressedHeaderPacket(SNDCPPacketHeader SNDCPPacketHeader, BinaryMessage message, int offset)
|
||||
{
|
||||
mSNDCPPacketHeader = SNDCPPacketHeader;
|
||||
mMessage = message;
|
||||
mOffset = offset;
|
||||
}
|
||||
|
||||
public SNDCPPacketHeader getSNDCPHeader()
|
||||
{
|
||||
return mSNDCPPacketHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getSNDCPHeader());
|
||||
sb.append(" PACKET:");
|
||||
|
||||
if(getMessage().size() > getOffset())
|
||||
{
|
||||
sb.append(mMessage.getSubMessage(getOffset(), getMessage().size()).toHexString());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("(EMPTY)");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public BinaryMessage getMessage()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
public int getOffset()
|
||||
{
|
||||
return mOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHeader getHeader()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket getPayload()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPayload()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class UnknownPacket implements IPacket
|
||||
{
|
||||
private BinaryMessage mMessage;
|
||||
private int mOffset;
|
||||
|
||||
public UnknownPacket(BinaryMessage message, int offset)
|
||||
{
|
||||
mMessage = message;
|
||||
mOffset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("PACKET:");
|
||||
|
||||
if(getMessage().size() > getOffset())
|
||||
{
|
||||
sb.append(mMessage.getSubMessage(getOffset(), getMessage().size()).toHexString());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("(EMPTY)");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public BinaryMessage getMessage()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
public int getOffset()
|
||||
{
|
||||
return mOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHeader getHeader()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket getPayload()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPayload()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.module.decode.ip.Header;
|
||||
|
||||
public class ARSHeader extends Header
|
||||
{
|
||||
private static final int[] LENGTH = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
private static final int HEADER_EXTENSION_FLAG = 16;
|
||||
private static final int ACKNOWLEDGEMENT_FLAG = 17;
|
||||
private static final int PRIORITY_FLAG = 18;
|
||||
private static final int CONTROL_USER_FLAG = 19;
|
||||
private static final int[] PDU_TYPE = {20, 21, 22, 23};
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public ARSHeader(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ARS ").append(getPDUType());
|
||||
|
||||
if(getPDUType() == ARSPDUType.UNKNOWN)
|
||||
{
|
||||
sb.append(" PACKET:").append(getMessage().toHexString());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the underlying message is long enough to contain the PDU
|
||||
*/
|
||||
private void checkValid()
|
||||
{
|
||||
setValid(getMessage().size() >= (getOffset() + getLength() + getPayloadLength()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the type of ARS PDU
|
||||
*/
|
||||
public ARSPDUType getPDUType()
|
||||
{
|
||||
return getPDUType(getMessage(), getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the type of ARS PDU contained in the message starting at the offset index.
|
||||
*/
|
||||
public static ARSPDUType getPDUType(BinaryMessage message, int offset)
|
||||
{
|
||||
return ARSPDUType.fromValue(message.getInt(PDU_TYPE, offset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this message has a header extension byte
|
||||
*/
|
||||
public boolean hasHeaderExtension()
|
||||
{
|
||||
return getMessage().get(HEADER_EXTENSION_FLAG + getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this is an acknowledgement type PDU
|
||||
*/
|
||||
public boolean isAcknowledge()
|
||||
{
|
||||
return getMessage().get(ACKNOWLEDGEMENT_FLAG + getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this PDU was sent with the priority flag
|
||||
*/
|
||||
public boolean isPriority()
|
||||
{
|
||||
return getMessage().get(PRIORITY_FLAG + getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this packet is a control packet (true) or a user packet (false).
|
||||
*/
|
||||
public boolean isControl()
|
||||
{
|
||||
return getMessage().get(CONTROL_USER_FLAG + getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Length of the payload
|
||||
* @return
|
||||
*/
|
||||
public int getPayloadLength()
|
||||
{
|
||||
return getMessage().getInt(LENGTH, getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Length of this header in bits
|
||||
*
|
||||
* Note this length value includes the first 2 bytes of the message that indicates the overall
|
||||
* message length and the length of the PDU header byte(s).
|
||||
*
|
||||
* This method may need to be overridden if there is more than 1 extension header in a PDU.
|
||||
*/
|
||||
@Override
|
||||
public int getLength()
|
||||
{
|
||||
if(hasHeaderExtension())
|
||||
{
|
||||
return 16 + 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 16 + 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class ARSHeaderFactory
|
||||
{
|
||||
public static ARSHeader create(ARSPDUType pduType, BinaryMessage message, int offset)
|
||||
{
|
||||
switch(pduType)
|
||||
{
|
||||
case DEVICE_REGISTRATION:
|
||||
return new DeviceRegistration(message, offset);
|
||||
case DEVICE_DEREGISTRATION:
|
||||
return new DeviceDeRegistration(message, offset);
|
||||
case QUERY:
|
||||
return new QueryMessage(message, offset);
|
||||
case USER_REGISTRATION:
|
||||
return new UserRegistration(message, offset);
|
||||
case USER_DEREGISTRATION:
|
||||
return new UserDeRegistration(message, offset);
|
||||
case USER_REGISTRATION_ACKNOWLEDGEMENT:
|
||||
return new UserRegistrationAcknowledge(message, offset);
|
||||
case REGISTRATION_ACKNOWLEDGEMENT:
|
||||
return new RegistrationAcknowledgement(message, offset);
|
||||
case UNKNOWN:
|
||||
default:
|
||||
return new ARSHeader(message, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
public enum ARSPDUType
|
||||
{
|
||||
DEVICE_REGISTRATION(0x0),
|
||||
DEVICE_DEREGISTRATION(0x1),
|
||||
QUERY(0x4),
|
||||
USER_REGISTRATION(0x5),
|
||||
USER_DEREGISTRATION(0x6),
|
||||
USER_REGISTRATION_ACKNOWLEDGEMENT(0x7),
|
||||
REGISTRATION_ACKNOWLEDGEMENT(0xF),
|
||||
UNKNOWN(-1);
|
||||
|
||||
private int mValue;
|
||||
|
||||
ARSPDUType(int value)
|
||||
{
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
public static ARSPDUType fromValue(int value)
|
||||
{
|
||||
switch(value)
|
||||
{
|
||||
case 0x0:
|
||||
return DEVICE_REGISTRATION;
|
||||
case 0x1:
|
||||
return DEVICE_DEREGISTRATION;
|
||||
case 0x4:
|
||||
return QUERY;
|
||||
case 0x5:
|
||||
return USER_REGISTRATION;
|
||||
case 0x6:
|
||||
return USER_DEREGISTRATION;
|
||||
case 0x7:
|
||||
return USER_REGISTRATION_ACKNOWLEDGEMENT;
|
||||
case 0xF:
|
||||
return REGISTRATION_ACKNOWLEDGEMENT;
|
||||
}
|
||||
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.module.decode.ip.IPacket;
|
||||
import io.github.dsheirer.module.decode.ip.Packet;
|
||||
|
||||
public class ARSPacket extends Packet
|
||||
{
|
||||
private ARSHeader mHeader;
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the packet
|
||||
* @param offset to the packet within the message
|
||||
*/
|
||||
public ARSPacket(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ARS ").append(getHeader());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ARSHeader getHeader()
|
||||
{
|
||||
if(mHeader == null)
|
||||
{
|
||||
ARSPDUType pduType = ARSHeader.getPDUType(getMessage(), getOffset());
|
||||
mHeader = ARSHeaderFactory.create(pduType, getMessage(), getOffset());
|
||||
}
|
||||
|
||||
return mHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket getPayload()
|
||||
{
|
||||
//There are no payloads for ARS packets ... the header parses all of the information.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class DeviceDeRegistration extends ARSHeader
|
||||
{
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public DeviceDeRegistration(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ARS DEVICE/USER DE-REGISTRATION");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class DeviceRegistration extends ARSHeader
|
||||
{
|
||||
private static final int SECOND_HEADER_EXTENSION_FLAG = 24;
|
||||
private static final int[] EVENT = {25, 26};
|
||||
private static final int[] ENCODING = {27, 28, 29, 30, 31};
|
||||
private static final int DEVICE_IDENTIFIER_START = 24;
|
||||
private static final int DEVICE_IDENTIFIER_START_EXTENDED_HEADER = 32;
|
||||
|
||||
private static final int[] BYTE_VALUE = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public DeviceRegistration(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("DEVICE REGISTRATION");
|
||||
|
||||
if(isValid())
|
||||
{
|
||||
if(hasHeaderExtension())
|
||||
{
|
||||
sb.append(isInitialEvent() ? "-INITIAL " : "-REFRESH ");
|
||||
}
|
||||
|
||||
sb.append(" ").append(getPayload());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(" - ERROR INVALID MESSAGE LENGTH");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this is an initial registration event (true) or refresh event (false)
|
||||
*/
|
||||
public boolean isInitialEvent()
|
||||
{
|
||||
return getMessage().getInt(EVENT, getOffset()) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Device, user and password values contained in the registration packet.
|
||||
*/
|
||||
public String getPayload()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("DEVICE:");
|
||||
|
||||
int pointer = getOffset();
|
||||
|
||||
if(hasHeaderExtension())
|
||||
{
|
||||
pointer += DEVICE_IDENTIFIER_START_EXTENDED_HEADER;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer += DEVICE_IDENTIFIER_START;
|
||||
}
|
||||
|
||||
int identifierSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
|
||||
|
||||
if(identifierSize > 0)
|
||||
{
|
||||
for(int x = 0; x < identifierSize; x++)
|
||||
{
|
||||
sb.append(getCharacter(pointer += 8));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("(none)");
|
||||
}
|
||||
|
||||
sb.append(" USER:");
|
||||
|
||||
int userIdentifierSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
|
||||
|
||||
if(userIdentifierSize > 0)
|
||||
{
|
||||
for(int x = 0; x < userIdentifierSize; x++)
|
||||
{
|
||||
sb.append(getCharacter(pointer += 8));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("(none)");
|
||||
}
|
||||
|
||||
sb.append(" PASSWORD:");
|
||||
|
||||
int passwordSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
|
||||
|
||||
if(passwordSize > 0)
|
||||
{
|
||||
for(int x = 0; x < passwordSize; x++)
|
||||
{
|
||||
sb.append(getCharacter(pointer += 8));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("(none)");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a UTF-8 encoded character that starts at the specified offset
|
||||
*
|
||||
* @param offset of the start of the 8-bit UTF-8 encoded character
|
||||
* @return character
|
||||
*/
|
||||
private char getCharacter(int offset)
|
||||
{
|
||||
return (char)getMessage().getByte(BYTE_VALUE, offset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class DeviceRegistrationAcknowledge extends ARSHeader
|
||||
{
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public DeviceRegistrationAcknowledge(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("DEVICE REGISTRATION ACKNOWLEDGED");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class QueryMessage extends ARSHeader
|
||||
{
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public QueryMessage(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ARS QUERY MESSAGE");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class RegistrationAcknowledgement extends ARSHeader
|
||||
{
|
||||
private static final int[] TIMER_OR_REASON = {25, 26, 27, 28, 29, 30, 31};
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public RegistrationAcknowledgement(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if(isValid())
|
||||
{
|
||||
sb.append("REGISTRATION ");
|
||||
|
||||
if(isSuccessful())
|
||||
{
|
||||
sb.append("SUCCESS");
|
||||
|
||||
int units = getPayloadValue();
|
||||
|
||||
sb.append(" REFRESH IN:").append(units * 30).append("mins");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("FAIL");
|
||||
|
||||
int units = getPayloadValue();
|
||||
|
||||
if(units == 0)
|
||||
{
|
||||
sb.append(" - UNAUTHORIZED DEVICE");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(" REASON:").append(units);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("REGISTRATION ACKNOWLEDGE - ERROR - INVALID MESSAGE LENGTH");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the registration succeeded (true) or failed (false)
|
||||
*/
|
||||
public boolean isSuccessful()
|
||||
{
|
||||
return !isAcknowledge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Payload value. If successful, this is the number of 30 minute units until a registration
|
||||
* refresh is required. If unsuccessful, this is the reason (0-unauthorized device).
|
||||
*/
|
||||
public int getPayloadValue()
|
||||
{
|
||||
return getMessage().getInt(TIMER_OR_REASON, getOffset());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class UserDeRegistration extends ARSHeader
|
||||
{
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public UserDeRegistration(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ARS USER DE-REGISTRATION");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class UserDeRegistrationAcknowledge extends ARSHeader
|
||||
{
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public UserDeRegistrationAcknowledge(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ARS USER DE-REGISTRATION ACKNOWLEDGED");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class UserRegistration extends ARSHeader
|
||||
{
|
||||
private static final int HEADER_EXTENSION_FLAG = 24;
|
||||
private static final int[] EVENT = {25, 26};
|
||||
private static final int[] ENCODING = {27, 28, 29, 30, 31};
|
||||
private static final int DEVICE_IDENTIFIER_START = 24;
|
||||
private static final int DEVICE_IDENTIFIER_START_EXTENDED_HEADER = 32;
|
||||
|
||||
private static final int[] BYTE_VALUE = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public UserRegistration(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("USER REGISTRATION");
|
||||
|
||||
if(isValid())
|
||||
{
|
||||
sb.append(" ").append(getPayload());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(" - ERROR INVALID MESSAGE LENGTH");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Device, user and password values contained in the registration packet.
|
||||
*/
|
||||
public String getPayload()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("DEVICE:");
|
||||
|
||||
int pointer = getOffset();
|
||||
|
||||
if(hasHeaderExtension())
|
||||
{
|
||||
pointer += DEVICE_IDENTIFIER_START_EXTENDED_HEADER;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer += DEVICE_IDENTIFIER_START;
|
||||
}
|
||||
|
||||
int identifierSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
|
||||
|
||||
if(identifierSize > 0)
|
||||
{
|
||||
for(int x = 0; x < identifierSize; x++)
|
||||
{
|
||||
sb.append(getCharacter(pointer += 8));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("(none)");
|
||||
}
|
||||
|
||||
sb.append(" USER:");
|
||||
|
||||
int userIdentifierSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
|
||||
|
||||
if(userIdentifierSize > 0)
|
||||
{
|
||||
for(int x = 0; x < userIdentifierSize; x++)
|
||||
{
|
||||
sb.append(getCharacter(pointer += 8));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("(none)");
|
||||
}
|
||||
|
||||
sb.append(" PASSWORD:");
|
||||
|
||||
int passwordSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
|
||||
|
||||
if(passwordSize > 0)
|
||||
{
|
||||
for(int x = 0; x < passwordSize; x++)
|
||||
{
|
||||
sb.append(getCharacter(pointer += 8));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("(none)");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a UTF-8 encoded character that starts at the specified offset
|
||||
*
|
||||
* @param offset of the start of the 8-bit UTF-8 encoded character
|
||||
* @return character
|
||||
*/
|
||||
private char getCharacter(int offset)
|
||||
{
|
||||
return (char)getMessage().getByte(BYTE_VALUE, offset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ars;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
|
||||
public class UserRegistrationAcknowledge extends ARSHeader
|
||||
{
|
||||
private static final int[] SESSION_TIME_OR_REASON = {25, 26, 27, 28, 29, 30, 31};
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public UserRegistrationAcknowledge(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(isSuccessful())
|
||||
{
|
||||
sb.append("USER REGISTRATION SUCCESS - SESSION TIME:").append(getSessionTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("USER REGISTRATION FAILED - REASON:").append(getFailureReason());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public boolean isSuccessful()
|
||||
{
|
||||
return !isAcknowledge();
|
||||
}
|
||||
|
||||
public int getSessionTime()
|
||||
{
|
||||
if(hasHeaderExtension())
|
||||
{
|
||||
return getMessage().getInt(SESSION_TIME_OR_REASON, getOffset());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getFailureReason()
|
||||
{
|
||||
if(hasHeaderExtension())
|
||||
{
|
||||
int reason = getMessage().getInt(SESSION_TIME_OR_REASON, getOffset());
|
||||
|
||||
switch(reason)
|
||||
{
|
||||
case 0x01:
|
||||
return "USER VALIDATION FAILED";
|
||||
case 0x02:
|
||||
return "USER VALIDATION TIMEOUT";
|
||||
default:
|
||||
return "TRANSMISSION FAILURE";
|
||||
}
|
||||
}
|
||||
|
||||
return "NONE";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ipv4;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.identifier.ipv4.IPV4Identifier;
|
||||
import io.github.dsheirer.module.decode.ip.Header;
|
||||
import io.github.dsheirer.module.decode.ip.IPProtocol;
|
||||
import io.github.dsheirer.module.decode.p25.identifier.ipv4.APCO25IpAddress;
|
||||
|
||||
public class IPV4Header extends Header
|
||||
{
|
||||
private static final int[] VERSION = {0, 1, 2, 3};
|
||||
private static final int[] HEADER_LENGTH = {4, 5, 6, 7};
|
||||
private static final int[] TOTAL_LENGTH = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
private static final int[] PROTOCOL = {72, 73, 74, 75, 76, 77, 78, 79};
|
||||
private static final int[] FROM_ADDRESS = {96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
|
||||
111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127};
|
||||
private static final int[] TO_ADDRESS = {128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
|
||||
143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159};
|
||||
|
||||
private IPV4Identifier mFromAddress;
|
||||
private IPV4Identifier mToAddress;
|
||||
|
||||
public IPV4Header(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
checkValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs simple header and packet length validations relative to the packet offset within the binary message.
|
||||
*/
|
||||
private void checkValid()
|
||||
{
|
||||
int headerLength = getLength();
|
||||
|
||||
if(headerLength < 40)
|
||||
{
|
||||
setValid(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(getMessage().size() < headerLength + getOffset())
|
||||
{
|
||||
setValid(false);
|
||||
return;
|
||||
}
|
||||
|
||||
int totalLength = getTotalLength();
|
||||
|
||||
if(totalLength < headerLength)
|
||||
{
|
||||
setValid(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(getMessage().size() < totalLength + getOffset())
|
||||
{
|
||||
setValid(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("IP FROM:").append(getFromAddress());
|
||||
sb.append(" TO:").append(getToAddress());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the IP version of the packet that starts at the indicated offset within the binary message.
|
||||
*
|
||||
* @param message message containing an IP packet
|
||||
* @param offset to the start of the packet within the binary message
|
||||
* @return
|
||||
*/
|
||||
public static int getIPVersion(BinaryMessage message, int offset)
|
||||
{
|
||||
return message.getInt(VERSION, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Version of this packet
|
||||
*/
|
||||
public int getIPVersion()
|
||||
{
|
||||
return getIPVersion(getMessage(), getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Length of this IPV4 header in bits (NOT BYTES)
|
||||
*/
|
||||
public int getLength()
|
||||
{
|
||||
return getMessage().getInt(HEADER_LENGTH, getOffset()) * 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* Total Length of this IPV4 packet in bits (NOT BYTES)
|
||||
*/
|
||||
public int getTotalLength()
|
||||
{
|
||||
return getMessage().getInt(TOTAL_LENGTH, getOffset()) * 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protocol for the payload being carried by this IP packet
|
||||
*/
|
||||
public IPProtocol getProtocol()
|
||||
{
|
||||
return IPProtocol.fromValue(getMessage().getInt(PROTOCOL, getOffset()));
|
||||
}
|
||||
|
||||
/**
|
||||
* From IP Address
|
||||
*/
|
||||
public IPV4Identifier getFromAddress()
|
||||
{
|
||||
if(mFromAddress == null)
|
||||
{
|
||||
mFromAddress = APCO25IpAddress.createFrom(getMessage().getInt(FROM_ADDRESS, getOffset()));
|
||||
}
|
||||
|
||||
return mFromAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* To IP Address
|
||||
*/
|
||||
public IPV4Identifier getToAddress()
|
||||
{
|
||||
if(mToAddress == null)
|
||||
{
|
||||
mToAddress = APCO25IpAddress.createTo(getMessage().getInt(TO_ADDRESS, getOffset()));
|
||||
}
|
||||
|
||||
return mToAddress;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.ipv4;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.module.decode.ip.IPacket;
|
||||
import io.github.dsheirer.module.decode.ip.Packet;
|
||||
import io.github.dsheirer.module.decode.ip.PacketMessageFactory;
|
||||
import io.github.dsheirer.module.decode.ip.UnknownPacket;
|
||||
|
||||
/**
|
||||
* IPV4 packet
|
||||
*/
|
||||
public class IPV4Packet extends Packet
|
||||
{
|
||||
private IPV4Header mHeader;
|
||||
private IPacket mPayload;
|
||||
|
||||
/**
|
||||
* Constructs an IPV4 packet parser
|
||||
*
|
||||
* @param message containing an IPV4 packet
|
||||
* @param offset to the start of the packet within the binary message
|
||||
*/
|
||||
public IPV4Packet(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(getHeader().isValid())
|
||||
{
|
||||
sb.append(getHeader());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("IPV4 - INVALID HEADER");
|
||||
sb.append(" HDR:").append(getHeader().getMessage().toHexString());
|
||||
}
|
||||
|
||||
if(hasPayload())
|
||||
{
|
||||
if(getPayload() instanceof UnknownPacket)
|
||||
{
|
||||
sb.append(" PROTOCOL:").append(getHeader().getProtocol());
|
||||
}
|
||||
|
||||
sb.append(" ").append(getPayload().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(" NO PAYLOAD!");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPV4Header getHeader()
|
||||
{
|
||||
if(mHeader == null)
|
||||
{
|
||||
mHeader = new IPV4Header(getMessage(), getOffset());
|
||||
}
|
||||
|
||||
return mHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Payload packet for this IP packet.
|
||||
*
|
||||
* @return payload packet or null
|
||||
*/
|
||||
@Override
|
||||
public IPacket getPayload()
|
||||
{
|
||||
if(mPayload == null)
|
||||
{
|
||||
if(getHeader().isValid())
|
||||
{
|
||||
mPayload = PacketMessageFactory.create(getHeader().getProtocol(), getMessage(),
|
||||
getOffset() + getHeader().getLength());
|
||||
}
|
||||
else
|
||||
{
|
||||
mPayload = new UnknownPacket(getMessage(), getOffset());
|
||||
}
|
||||
}
|
||||
|
||||
return mPayload;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.udp;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.module.decode.ip.Header;
|
||||
|
||||
public class UDPHeader extends Header
|
||||
{
|
||||
private static final int[] SOURCE_PORT = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
private static final int[] DESTINATION_PORT = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the header
|
||||
* @param offset to the header within the message
|
||||
*/
|
||||
public UDPHeader(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
checkValid();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("UDP PORT FROM:").append(getSourcePort());
|
||||
sb.append(" TO:").append(getDestinationPort());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void checkValid()
|
||||
{
|
||||
setValid(getMessage().size() >= getOffset() + getLength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLength()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Source UDP port number
|
||||
* @return
|
||||
*/
|
||||
public int getSourcePort()
|
||||
{
|
||||
return getMessage().getInt(SOURCE_PORT, getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Destination UDP port number
|
||||
*/
|
||||
public int getDestinationPort()
|
||||
{
|
||||
return getMessage().getInt(DESTINATION_PORT, getOffset());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ip.udp;
|
||||
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.module.decode.ip.IPacket;
|
||||
import io.github.dsheirer.module.decode.ip.Packet;
|
||||
import io.github.dsheirer.module.decode.ip.PacketMessageFactory;
|
||||
import io.github.dsheirer.module.decode.ip.UnknownPacket;
|
||||
|
||||
public class UDPPacket extends Packet
|
||||
{
|
||||
private UDPHeader mHeader;
|
||||
private IPacket mPayload;
|
||||
|
||||
/**
|
||||
* Constructs a parser for a header contained within a binary message starting at the offset.
|
||||
*
|
||||
* @param message containing the packet
|
||||
* @param offset to the packet within the message
|
||||
*/
|
||||
public UDPPacket(BinaryMessage message, int offset)
|
||||
{
|
||||
super(message, offset);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(getHeader().isValid())
|
||||
{
|
||||
sb.append(getHeader());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("INVALID HEADER");
|
||||
}
|
||||
|
||||
sb.append(" ").append(getPayload());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UDPHeader getHeader()
|
||||
{
|
||||
if(mHeader == null)
|
||||
{
|
||||
mHeader = new UDPHeader(getMessage(), getOffset());
|
||||
}
|
||||
|
||||
return mHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket getPayload()
|
||||
{
|
||||
if(mPayload == null && getHeader().isValid())
|
||||
{
|
||||
mPayload = PacketMessageFactory.createUDPPayload(getHeader().getDestinationPort(), getMessage(), getOffset() + getHeader().getLength());
|
||||
}
|
||||
else
|
||||
{
|
||||
//Set the offset to the message offset plus 64 bits for UDP header
|
||||
mPayload = new UnknownPacket(getMessage(), getOffset() + 64);
|
||||
}
|
||||
|
||||
return mPayload;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user