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:
Denny Sheirer
2018-12-24 09:08:34 -05:00
committed by GitHub
parent 735fca16d6
commit b67d4d92dc
869 changed files with 64776 additions and 45233 deletions

View File

@@ -0,0 +1,54 @@
/*
* ******************************************************************************
* 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.identifier;
/**
* Identifier form. Indicates the type of identifier.
*/
public enum Form
{
ALIAS_LIST,
CHANNEL,
CHANNEL_DESCRIPTOR,
CHANNEL_NAME,
CHANNEL_FREQUENCY,
DECODER_TYPE,
ENCRYPTION_KEY,
ESN,
IPV4_ADDRESS,
LOCATION_REGISTRATION_AREA,
LOJACK,
NEIGHBOR_SITE,
NETWORK_ACCESS_CODE,
PATCH_GROUP,
RF_SUBSYSTEM,
SHORT_DATA_MESSAGE,
SITE,
STATE,
SYSTEM,
TALKGROUP,
TELEPHONE_NUMBER,
UNIT_IDENTIFIER,
UNIT_STATUS,
USER_STATUS,
UNIQUE_ID,
WACN,
ANY;
}

View File

@@ -0,0 +1,125 @@
/*******************************************************************************
* sdr-trunk
* 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.identifier;
import io.github.dsheirer.protocol.Protocol;
import java.util.Objects;
/**
* Identifier base class.
*
* Note: Identifiers are intended to be immutable.
*/
public abstract class Identifier<T>
{
private T mValue;
private IdentifierClass mIdentifierClass;
private Form mForm;
private Role mRole;
public Identifier(T value, IdentifierClass identifierClass, Form form, Role role)
{
mValue = value;
mIdentifierClass = identifierClass;
mForm = form;
mRole = role;
}
public String debug()
{
StringBuilder sb = new StringBuilder();
sb.append("CLASS:").append(getIdentifierClass());
sb.append(" FORM:").append(getForm());
sb.append(" VALUE:").append(getValue());
sb.append(" VALUE CLASS:").append(getValue().getClass());
sb.append(" CLASS:").append(getClass());
return sb.toString();
}
/**
* Validity test for the identifier. This method always returns true unless a subclass
* implementation overrides the value for a specific validity test implementation.
*/
public boolean isValid()
{
return true;
}
/**
* Value of the identifier
*/
public T getValue()
{
return mValue;
}
/**
* Class/type of identifier
*/
public IdentifierClass getIdentifierClass()
{
return mIdentifierClass;
}
public Form getForm()
{
return mForm;
}
/**
* Role of the identifier in the communications
*/
public Role getRole()
{
return mRole;
}
/**
* Protocol that produces this identifier
*/
public abstract Protocol getProtocol();
@Override
public String toString()
{
return getValue().toString();
}
@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(o == null || getClass() != o.getClass())
{
return false;
}
Identifier<?> that = (Identifier<?>)o;
return Objects.equals(getValue(), that.getValue()) &&
getIdentifierClass() == that.getIdentifierClass() &&
getForm() == that.getForm() &&
getRole() == that.getRole();
}
@Override
public int hashCode()
{
return Objects.hash(getValue(), getIdentifierClass(), getForm(), getRole());
}
}

View File

@@ -0,0 +1,34 @@
/*******************************************************************************
* sdr-trunk
* 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.identifier;
/**
* Identifier form. Indicates the type of identifier.
*/
public enum IdentifierClass
{
//Decoder configuration detail
CONFIGURATION,
//Decoder state or information
DECODER,
//Communication network identifier
NETWORK,
//Communication user identifier
USER;
}

View File

@@ -0,0 +1,296 @@
/*
* ******************************************************************************
* 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.identifier;
import io.github.dsheirer.identifier.configuration.AliasListConfigurationIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* (Immutable) Collection of identifiers with convenient accessor methods
*
* @see MutableIdentifierCollection for the mutable version of this class
*/
public class IdentifierCollection
{
private final static Logger mLog = LoggerFactory.getLogger(IdentifierCollection.class);
protected List<Identifier> mIdentifiers = new ArrayList<>();
protected AliasListConfigurationIdentifier mAliasListConfigurationIdentifier;
private boolean mUpdated = false;
/**
* Constructs an empty identifier collection
*/
public IdentifierCollection()
{
}
public IdentifierCollection(Collection<Identifier> identifiers)
{
for(Identifier identifier: identifiers)
{
if(identifier == null)
{
throw new IllegalArgumentException("Identifier cannot be null");
}
mIdentifiers.add(identifier);
if(identifier instanceof AliasListConfigurationIdentifier)
{
mAliasListConfigurationIdentifier = (AliasListConfigurationIdentifier)identifier;
}
}
}
public IdentifierCollection(Identifier identifier)
{
if(identifier == null)
{
throw new IllegalArgumentException("Identifier cannot be null");
}
mIdentifiers.add(identifier);
}
/**
* Indicates if this identifier collection contains an updated list of identifiers.
*/
public boolean isUpdated()
{
return mUpdated;
}
protected void setUpdated(boolean updated)
{
mUpdated = updated;
}
/**
* Alias List configuration identifier containing the name of the alias list for this collection.
* @return alias list or null
*/
public AliasListConfigurationIdentifier getAliasListConfiguration()
{
return mAliasListConfigurationIdentifier;
}
/**
* Indicates if this collection has an alias list specified.
*/
public boolean hasAliasListConfiguration()
{
return mAliasListConfigurationIdentifier != null;
}
/**
* Immutable list of identifiers contained in this collection
*/
public List<Identifier> getIdentifiers()
{
return Collections.unmodifiableList(mIdentifiers);
}
/**
* Get a list of identifiers by identifier class from this collection.
*
* @param identifierClass to match
* @return list of zero or more identifiers
*/
public List<Identifier> getIdentifiers(IdentifierClass identifierClass)
{
List<Identifier> identifiers = new ArrayList<>();
for(Identifier identifier : mIdentifiers)
{
if(identifier.getIdentifierClass() == identifierClass)
{
identifiers.add(identifier);
}
}
return identifiers;
}
/**
* Get a list of identifiers by form from this collection.
*
* @param form to match
* @return list of zero or more identifiers
*/
public List<Identifier> getIdentifiers(Form form)
{
List<Identifier> identifiers = new ArrayList<>();
for(Identifier identifier : mIdentifiers)
{
if(identifier.getForm() == form)
{
identifiers.add(identifier);
}
}
return identifiers;
}
/**
* Get a list of identifiers by role from this collection.
*
* @param role to match
* @return list of zero or more identifiers
*/
public List<Identifier> getIdentifiers(Role role)
{
List<Identifier> identifiers = new ArrayList<>();
for(Identifier identifier : mIdentifiers)
{
try
{
if(identifier.getRole() == role)
{
identifiers.add(identifier);
}
}
catch(NullPointerException npe)
{
StringBuilder sb = new StringBuilder();
for(Identifier i : mIdentifiers)
{
if(i == null)
{
sb.append("Identifier: (null)").append("\n");
}
else
{
sb.append("Identifier: ").append(i).append(" Class:").append(i.getClass()).append("\n");
}
}
mLog.warn("An identifier in a collection is somehow null ...\n" + sb.toString());
}
}
return identifiers;
}
/**
* Get a list of identifiers by identifier class and role from this collection.
*
* @param identifierClass to match
* @param role to match
* @return list of zero or more identifiers
*/
public List<Identifier> getIdentifiers(IdentifierClass identifierClass, Role role)
{
List<Identifier> identifiers = new ArrayList<>();
for(Identifier identifier : mIdentifiers)
{
if(identifier.getIdentifierClass() == identifierClass && identifier.getRole() == role)
{
identifiers.add(identifier);
}
}
return identifiers;
}
/**
* Get a list of identifiers by identifier class and form from this collection.
*
* @param identifierClass to match
* @param form to match
* @return list of zero or more identifiers
*/
public List<Identifier> getIdentifiers(IdentifierClass identifierClass, Form form)
{
List<Identifier> identifiers = new ArrayList<>();
for(Identifier identifier : mIdentifiers)
{
if(identifier.getIdentifierClass() == identifierClass && identifier.getForm() == form)
{
identifiers.add(identifier);
}
}
return identifiers;
}
/**
* Get the single identifier by identifier class, form and role from this collection.
*
* @param identifierClass to match
* @param form to match
* @param role to match
* @return matching identifier or null
*/
public Identifier getIdentifier(IdentifierClass identifierClass, Form form, Role role)
{
for(Identifier identifier : mIdentifiers)
{
if(identifier.getIdentifierClass() == identifierClass &&
identifier.getForm() == form &&
identifier.getRole() == role)
{
return identifier;
}
}
return null;
}
/**
* Returns the first identifier in this collection that is assigned a FROM role
*/
public Identifier getFromIdentifier()
{
List<Identifier> fromIdentifiers = getIdentifiers(Role.FROM);
if(!fromIdentifiers.isEmpty())
{
return fromIdentifiers.get(0);
}
return null;
}
/**
* Returns the first identifier in this collection that is assigned a FROM role
*/
public Identifier getToIdentifier()
{
List<Identifier> toIdentifiers = getIdentifiers(Role.TO);
if(!toIdentifiers.isEmpty())
{
return toIdentifiers.get(0);
}
return null;
}
}

View File

@@ -0,0 +1,30 @@
/*
* ******************************************************************************
* 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.identifier;
import io.github.dsheirer.sample.Listener;
/**
* Interface for receiving identifier update notifications
*/
public interface IdentifierUpdateListener
{
Listener<IdentifierUpdateNotification> getIdentifierUpdateListener();
}

View File

@@ -0,0 +1,87 @@
/*
* ******************************************************************************
* 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.identifier;
/**
* Request to add or update an identifier
*/
public class IdentifierUpdateNotification
{
private Identifier<?> mIdentifier;
private Operation mOperation;
/**
* Constructs an identifier update notification
* @param identifier that has been updated
*/
public IdentifierUpdateNotification(Identifier<?> identifier, Operation operation)
{
mIdentifier = identifier;
mOperation = operation;
}
public Identifier<?> getIdentifier()
{
return mIdentifier;
}
public Operation getOperation()
{
return mOperation;
}
public boolean isAdded()
{
return mOperation == Operation.ADD;
}
public boolean isRemoved()
{
return mOperation == Operation.REMOVE;
}
/**
* Indicates that this update should not be rebroadcast by any of the consumers.
*/
public boolean isSilentAdd()
{
return mOperation == Operation.SILENT_ADD;
}
/**
* Indicates that this update should not be rebroadcast by any of the consumers.
*/
public boolean isSilentRemove()
{
return mOperation == Operation.SILENT_REMOVE;
}
@Override
public String toString()
{
return mOperation.name() + " - " + mIdentifier;
}
public enum Operation
{
ADD, REMOVE, SILENT_ADD, SILENT_REMOVE;
}
}

View File

@@ -0,0 +1,29 @@
/*
* ******************************************************************************
* 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.identifier;
import io.github.dsheirer.sample.Listener;
public interface IdentifierUpdateProvider
{
void setIdentifierUpdateListener(Listener<IdentifierUpdateNotification> listener);
void removeIdentifierUpdateListener();
}

View File

@@ -0,0 +1,399 @@
/*
* ******************************************************************************
* 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.identifier;
import io.github.dsheirer.identifier.configuration.AliasListConfigurationIdentifier;
import io.github.dsheirer.sample.Listener;
import java.util.Collection;
import java.util.Iterator;
/**
* Identifier collection with methods for changing or updating managed identifiers
*/
public class MutableIdentifierCollection extends IdentifierCollection implements IdentifierUpdateProvider,
Listener<IdentifierUpdateNotification>
{
private Listener<IdentifierUpdateNotification> mListener;
public MutableIdentifierCollection()
{
}
public MutableIdentifierCollection(Collection<Identifier> identifiers)
{
for(Identifier identifier: identifiers)
{
update(identifier);
}
}
/**
* Broadcasts all of the currently held identifiers to the registered listener
*/
public void broadcastIdentifiers()
{
for(Identifier identifier : getIdentifiers())
{
notifyAdd(identifier);
}
}
/**
* Registers a listener to be notified when identifiers are added to or removed from this collection
*/
@Override
public void setIdentifierUpdateListener(Listener<IdentifierUpdateNotification> listener)
{
mListener = listener;
}
/**
* Unregisters the listener from receiving identifier update notifications
*/
@Override
public void removeIdentifierUpdateListener()
{
mListener = null;
}
/**
* Notifies a registered listener that the identifier has been added to this collection
*/
private void notifyAdd(Identifier identifier)
{
setUpdated(true);
if(mListener != null)
{
mListener.receive(new IdentifierUpdateNotification(identifier, IdentifierUpdateNotification.Operation.ADD));
}
}
/**
* Notifies a registered listener that the identifier has been removed from this collection
*/
private void notifyRemove(Identifier identifier)
{
setUpdated(true);
if(mListener != null)
{
mListener.receive(new IdentifierUpdateNotification(identifier,
IdentifierUpdateNotification.Operation.REMOVE));
}
}
/**
* Adds the identifier to this collection if not already contained in this collection.
*
* @param identifier to add
*/
private void add(Identifier identifier)
{
if(identifier.isValid() && !mIdentifiers.contains(identifier))
{
mIdentifiers.add(identifier);
notifyAdd(identifier);
}
//Retain a reference to the alias list identifier separately so that it can be accessed quickly.
if(identifier instanceof AliasListConfigurationIdentifier)
{
mAliasListConfigurationIdentifier = (AliasListConfigurationIdentifier)identifier;
}
}
/**
* Adds the identifier to this collection if not already contained in this collection. Does NOT broadcast an
* update notification.
*
* @param identifier to add
*/
private void silentAdd(Identifier identifier)
{
if(identifier.isValid() && !mIdentifiers.contains(identifier))
{
mIdentifiers.add(identifier);
}
//Retain a reference to the alias list identifier separately so that it can be accessed quickly.
if(identifier instanceof AliasListConfigurationIdentifier)
{
mAliasListConfigurationIdentifier = (AliasListConfigurationIdentifier)identifier;
}
}
/**
* Removes the identifier from this collection
*/
public void remove(Identifier identifier)
{
if(mIdentifiers.remove(identifier))
{
notifyRemove(identifier);
}
//Remove the reference to the alias list identifier.
if(identifier instanceof AliasListConfigurationIdentifier)
{
mAliasListConfigurationIdentifier = null;
}
}
/**
* Removes the identifier from this collection and does NOT broadcast an update notification
*/
public void silentRemove(Identifier identifier)
{
mIdentifiers.remove(identifier);
//Remove the reference to the alias list identifier.
if(identifier instanceof AliasListConfigurationIdentifier)
{
mAliasListConfigurationIdentifier = null;
}
}
/**
* Adds the identifier only if the value is different from the existing identifiers(s). If
* there are multiple matching identifiers, then they are all removed and replaced by this
* single identifier.
*
* @param identifier
*/
public void update(Identifier identifier)
{
if(identifier != null)
{
Identifier existing = getIdentifier(identifier.getIdentifierClass(),
identifier.getForm(), identifier.getRole());
if(existing != null)
{
if(!existing.equals(identifier))
{
remove(existing);
add(identifier);
}
}
else
{
add(identifier);
}
}
}
/**
* Adds the identifier only if the value is different from the existing identifiers(s). If
* there are multiple matching identifiers, then they are all removed and replaced by this
* single identifier.
*
* @param identifier
*/
public void silentUpdate(Identifier identifier)
{
if(identifier != null)
{
Identifier existing = getIdentifier(identifier.getIdentifierClass(), identifier.getForm(), identifier.getRole());
if(existing != null)
{
if(!existing.equals(identifier))
{
silentRemove(existing);
silentAdd(identifier);
}
}
else
{
silentAdd(identifier);
}
}
}
/**
* Updates all identifiers
*/
public void update(Collection<Identifier> identifiers)
{
for(Identifier identifier : identifiers)
{
update(identifier);
}
}
/**
* Removes/clears all identifiers from the collection
*/
public void clear()
{
Iterator<Identifier> it = mIdentifiers.iterator();
while(it.hasNext())
{
notifyRemove(it.next());
it.remove();
}
}
/**
* Removes all identifiers of the specified identifier class
*/
public void remove(IdentifierClass identifierClass)
{
Iterator<Identifier> it = mIdentifiers.iterator();
Identifier next = null;
while(it.hasNext())
{
next = it.next();
if(next.getIdentifierClass() == identifierClass)
{
it.remove();
notifyRemove(next);
}
}
}
/**
* Removes all identifiers of the specified form
*/
public void remove(Form form)
{
Iterator<Identifier> it = mIdentifiers.iterator();
Identifier next = null;
while(it.hasNext())
{
next = it.next();
if(next.getForm() == form)
{
it.remove();
notifyRemove(next);
}
}
}
/**
* Removes all identifiers of the specified role
*/
public void remove(Role role)
{
Iterator<Identifier> it = mIdentifiers.iterator();
Identifier next = null;
while(it.hasNext())
{
next = it.next();
if(next.getRole() == role)
{
it.remove();
notifyRemove(next);
}
}
}
/**
* Removes all identifiers of the specified identifier class, form and role
*/
public void remove(IdentifierClass identifierClass, Form form, Role role)
{
Iterator<Identifier> it = mIdentifiers.iterator();
Identifier next = null;
while(it.hasNext())
{
next = it.next();
if(next.getIdentifierClass() == identifierClass && next.getForm() == form && next.getRole() == role)
{
it.remove();
notifyRemove(next);
}
}
}
/**
* Removes all identifiers of the specified identifier class and role
*/
public void remove(IdentifierClass identifierClass, Role role)
{
Iterator<Identifier> it = mIdentifiers.iterator();
Identifier next = null;
while(it.hasNext())
{
next = it.next();
if(next.getIdentifierClass() == identifierClass && next.getRole() == role)
{
it.remove();
notifyRemove(next);
}
}
}
/**
* Implements the listener interface to receive notifications of identifier updates. This allows an
* identifier collection to maintain a synchronized state with a remote identifier collection.
*
* @param identifierUpdateNotification to add or remove an identifier
*/
@Override
public void receive(IdentifierUpdateNotification identifierUpdateNotification)
{
if(identifierUpdateNotification.isAdded())
{
update(identifierUpdateNotification.getIdentifier());
}
else if(identifierUpdateNotification.isRemoved())
{
remove(identifierUpdateNotification.getIdentifier());
}
else if(identifierUpdateNotification.isSilentAdd())
{
silentUpdate(identifierUpdateNotification.getIdentifier());
}
else if(identifierUpdateNotification.isSilentRemove())
{
silentRemove(identifierUpdateNotification.getIdentifier());
}
}
/**
* Creates a copy of this collection and resets the updated flag so that future invocations of this
* method will return a copy with the updated flag set to false.
*/
public IdentifierCollection copyOf()
{
IdentifierCollection copy = new IdentifierCollection(getIdentifiers());
copy.setUpdated(isUpdated());
setUpdated(false);
return copy;
}
}

View File

@@ -0,0 +1,29 @@
/*******************************************************************************
* sdr-trunk
* 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.identifier;
/**
* Identifier role. Indicates the role of the entity in the communication.
*/
public enum Role
{
BROADCAST,
FROM,
IDENTIFIER,
STATUS,
TO,
ANY;
}

View File

@@ -0,0 +1,45 @@
/*
* ******************************************************************************
* 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.identifier.configuration;
import io.github.dsheirer.identifier.Form;
/**
* User specified alias list name for a decode configuration.
*/
public class AliasListConfigurationIdentifier extends ConfigurationStringIdentifier
{
public AliasListConfigurationIdentifier(String value)
{
super(value, Form.ALIAS_LIST);
}
@Override
public boolean isValid()
{
return getValue() != null && !getValue().isEmpty();
}
public static AliasListConfigurationIdentifier create(String value)
{
return new AliasListConfigurationIdentifier(value);
}
}

View File

@@ -0,0 +1,57 @@
/*
* ******************************************************************************
* 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.identifier.configuration;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.protocol.Protocol;
/**
* Configuration identifier that identifies a channel descriptor. This is primarily used to broadcast the channel
* descriptor for a traffic channel so that it is aware of what channel number and frequency it is decoding.
*/
public class ChannelDescriptorConfigurationIdentifier extends Identifier<IChannelDescriptor>
{
/**
* Constructs a channel descriptor configuration identifier
*/
public ChannelDescriptorConfigurationIdentifier(IChannelDescriptor value)
{
super(value, IdentifierClass.CONFIGURATION, Form.CHANNEL_DESCRIPTOR, Role.ANY);
}
/**
* Protocol for the channel descriptor and the enclosing identifier instance.
*/
@Override
public Protocol getProtocol()
{
if(getValue() != null)
{
return getValue().getProtocol();
}
return Protocol.UNKNOWN;
}
}

View File

@@ -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.identifier.configuration;
import io.github.dsheirer.identifier.Form;
/**
* User specified channel name for a decode configuration.
*/
public class ChannelNameConfigurationIdentifier extends ConfigurationStringIdentifier
{
public ChannelNameConfigurationIdentifier()
{
this(null);
}
public ChannelNameConfigurationIdentifier(String value)
{
super(value, Form.CHANNEL);
}
@Override
public boolean isValid()
{
return getValue() != null && !getValue().isEmpty();
}
public static ChannelNameConfigurationIdentifier create(String value)
{
return new ChannelNameConfigurationIdentifier(value);
}
}

View File

@@ -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.identifier.configuration;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.longnumber.LongIdentifier;
import io.github.dsheirer.protocol.Protocol;
/**
* Decoder channel configuration identifier.
*/
public class ConfigurationLongIdentifier extends LongIdentifier
{
public ConfigurationLongIdentifier(Long value, Form form)
{
super(value, IdentifierClass.CONFIGURATION, form, Role.ANY);
}
@Override
public Protocol getProtocol()
{
return Protocol.UNKNOWN;
}
}

View File

@@ -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.identifier.configuration;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.string.StringIdentifier;
import io.github.dsheirer.protocol.Protocol;
/**
* Decoder channel configuration identifier.
*/
public class ConfigurationStringIdentifier extends StringIdentifier
{
public ConfigurationStringIdentifier(String value, Form form)
{
super(value, IdentifierClass.CONFIGURATION, form, Role.ANY);
}
@Override
public Protocol getProtocol()
{
return Protocol.UNKNOWN;
}
}

View File

@@ -0,0 +1,56 @@
/*
* ******************************************************************************
* 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.identifier.configuration;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.protocol.Protocol;
public class DecoderTypeConfigurationIdentifier extends Identifier<DecoderType>
{
public DecoderTypeConfigurationIdentifier(DecoderType value)
{
super(value, IdentifierClass.CONFIGURATION, Form.DECODER_TYPE, Role.ANY);
}
@Override
public Protocol getProtocol()
{
return Protocol.UNKNOWN;
}
/**
* Creates a decoder state identifier from the decoder state value
*/
public static DecoderTypeConfigurationIdentifier create(DecoderType decoderType)
{
return new DecoderTypeConfigurationIdentifier(decoderType);
}
@Override
public String toString()
{
return getValue().getShortDisplayString();
}
}

View File

@@ -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.identifier.configuration;
import io.github.dsheirer.identifier.Form;
/**
* Channel tuned frequency configuration identifier
*/
public class FrequencyConfigurationIdentifier extends ConfigurationLongIdentifier
{
public FrequencyConfigurationIdentifier(Long value)
{
super(value, Form.CHANNEL_FREQUENCY);
}
public static FrequencyConfigurationIdentifier create(Long value)
{
return new FrequencyConfigurationIdentifier(value);
}
}

View File

@@ -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.identifier.configuration;
import io.github.dsheirer.identifier.Form;
/**
* User specified site name for a decode configuration.
*/
public class SiteConfigurationIdentifier extends ConfigurationStringIdentifier
{
public SiteConfigurationIdentifier()
{
this(null);
}
public SiteConfigurationIdentifier(String value)
{
super(value, Form.SITE);
}
@Override
public boolean isValid()
{
return getValue() != null && !getValue().isEmpty();
}
public static SiteConfigurationIdentifier create(String value)
{
return new SiteConfigurationIdentifier(value);
}
}

View File

@@ -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.identifier.configuration;
import io.github.dsheirer.identifier.Form;
/**
* User specified system name for a decode configuration.
*/
public class SystemConfigurationIdentifier extends ConfigurationStringIdentifier
{
public SystemConfigurationIdentifier()
{
this(null);
}
public SystemConfigurationIdentifier(String value)
{
super(value, Form.SYSTEM);
}
@Override
public boolean isValid()
{
return getValue() != null && !getValue().isEmpty();
}
public static SystemConfigurationIdentifier create(String value)
{
return new SystemConfigurationIdentifier(value);
}
}

View File

@@ -0,0 +1,52 @@
/*
* ******************************************************************************
* 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.identifier.decoder;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.string.StringIdentifier;
import io.github.dsheirer.protocol.Protocol;
public class DecoderLogicalChannelNameIdentifier extends StringIdentifier
{
private Protocol mProtocol;
public DecoderLogicalChannelNameIdentifier(String name, Protocol protocol)
{
super(name, IdentifierClass.DECODER, Form.CHANNEL_NAME, Role.BROADCAST);
mProtocol = protocol;
}
@Override
public Protocol getProtocol()
{
return mProtocol;
}
/**
* Creates a decoder state identifier from the decoder state value
*/
public static DecoderLogicalChannelNameIdentifier create(String name, Protocol protocol)
{
return new DecoderLogicalChannelNameIdentifier(name, protocol);
}
}

View File

@@ -0,0 +1,66 @@
/*
* ******************************************************************************
* 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.identifier.decoder;
import io.github.dsheirer.channel.state.State;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.protocol.Protocol;
public class DecoderStateIdentifier extends Identifier<State>
{
public static final DecoderStateIdentifier ACTIVE = DecoderStateIdentifier.create(State.ACTIVE);
public static final DecoderStateIdentifier CALL = DecoderStateIdentifier.create(State.CALL);
public static final DecoderStateIdentifier CONTROL = DecoderStateIdentifier.create(State.CONTROL);
public static final DecoderStateIdentifier DATA = DecoderStateIdentifier.create(State.DATA);
public static final DecoderStateIdentifier ENCRYPTED = DecoderStateIdentifier.create(State.ENCRYPTED);
public static final DecoderStateIdentifier FADE = DecoderStateIdentifier.create(State.FADE);
public static final DecoderStateIdentifier IDLE = DecoderStateIdentifier.create(State.IDLE);
public static final DecoderStateIdentifier TEARDOWN = DecoderStateIdentifier.create(State.TEARDOWN);
public static final DecoderStateIdentifier RESET = DecoderStateIdentifier.create(State.RESET);
public DecoderStateIdentifier(State value)
{
super(value, IdentifierClass.DECODER, Form.STATE, Role.ANY);
}
@Override
public Protocol getProtocol()
{
return Protocol.UNKNOWN;
}
/**
* Creates a decoder state identifier from the decoder state value
*/
public static DecoderStateIdentifier create(State state)
{
return new DecoderStateIdentifier(state);
}
@Override
public String toString()
{
return getValue().getDisplayValue();
}
}

View File

@@ -0,0 +1,93 @@
/*
* ******************************************************************************
* 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.identifier.encryption;
import java.util.Objects;
public class EncryptionKey implements Comparable<EncryptionKey>
{
private int mAlgorithm;
private int mKey;
public EncryptionKey(int algorithm, int key)
{
mAlgorithm = algorithm;
mKey = key;
}
public boolean isEncrypted()
{
return mAlgorithm != 0x80;
}
public int getAlgorithm()
{
return mAlgorithm;
}
public int getKey()
{
return mKey;
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ALGORITHM:").append(getAlgorithm());
sb.append(" KEY:").append(getKey());
return sb.toString();
}
@Override
public int compareTo(EncryptionKey other)
{
if(getAlgorithm() == other.getKey())
{
return Integer.compare(getKey(), other.getKey());
}
else
{
return Integer.compare(getAlgorithm(), other.getAlgorithm());
}
}
@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(o == null || getClass() != o.getClass())
{
return false;
}
EncryptionKey that = (EncryptionKey)o;
return getAlgorithm() == that.getAlgorithm() &&
getKey() == that.getKey();
}
@Override
public int hashCode()
{
return Objects.hash(getAlgorithm(), getKey());
}
}

View File

@@ -0,0 +1,36 @@
/*
* ******************************************************************************
* 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.identifier.encryption;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
public abstract class EncryptionKeyIdentifier extends Identifier<EncryptionKey>
{
public EncryptionKeyIdentifier(EncryptionKey value, IdentifierClass identifierClass, Form form, Role role)
{
super(value, identifierClass, form, role);
}
}

View File

@@ -0,0 +1,66 @@
/*
* ******************************************************************************
* 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.identifier.esn;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.string.StringIdentifier;
import io.github.dsheirer.protocol.Protocol;
public class ESNIdentifier extends StringIdentifier implements Comparable<ESNIdentifier>
{
private Protocol mProtocol;
public ESNIdentifier(String esn, Protocol protocol, Role role)
{
super(esn, IdentifierClass.USER, Form.ESN, role);
mProtocol = protocol;
}
@Override
public Protocol getProtocol()
{
return mProtocol;
}
public static ESNIdentifier create(String esn, Protocol protocol, Role role)
{
return new ESNIdentifier(esn, protocol, role);
}
@Override
public int compareTo(ESNIdentifier o)
{
if(getValue() == null)
{
return 1;
}
else if(o.getValue() == null)
{
return -1;
}
else
{
return getValue().compareTo(o.getValue());
}
}
}

View File

@@ -0,0 +1,66 @@
/*
* ******************************************************************************
* 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.identifier.integer;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import java.util.Objects;
/**
* Integer identifier base class.
*/
public abstract class IntegerIdentifier extends Identifier<Integer>
{
public IntegerIdentifier(int value, IdentifierClass identifierClass, Form form, Role role)
{
super(value, identifierClass, form, role);
}
@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(o == null || getClass() != o.getClass())
{
return false;
}
IntegerIdentifier that = (IntegerIdentifier)o;
return (getValue().intValue() == that.getValue().intValue()) &&
getIdentifierClass() == that.getIdentifierClass() &&
getForm() == that.getForm() &&
getRole() == that.getRole();
}
@Override
public int hashCode()
{
return Objects.hash(getValue(), getIdentifierClass(), getForm(), getRole());
}
}

View File

@@ -0,0 +1,93 @@
/*
* ******************************************************************************
* 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.identifier.ipv4;
import java.util.Objects;
/**
* IPV4 Address
*/
public class IPV4Address
{
private int mIPAddress;
public IPV4Address(int ipAddress)
{
mIPAddress = ipAddress;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append(getOctet(0));
sb.append(".");
sb.append(getOctet(1));
sb.append(".");
sb.append(getOctet(2));
sb.append(".");
sb.append(getOctet(3));
return sb.toString();
}
/**
* Extracts the octet value from the IP address
* @param index of the octet where 0 is the MSB and 3 is the LSB
* @return octet value
*/
private int getOctet(int index)
{
switch(index)
{
case 0:
return ((mIPAddress & 0xFF000000) >> 24) & 0xFF;
case 1:
return ((mIPAddress & 0xFF0000) >> 16);
case 2:
return ((mIPAddress & 0xFF00) >> 8);
case 3:
return ((mIPAddress & 0xFF));
default:
throw new IllegalArgumentException("Invalid Octet index: " + index);
}
}
@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(o == null || getClass() != o.getClass())
{
return false;
}
IPV4Address that = (IPV4Address)o;
return mIPAddress == that.mIPAddress;
}
@Override
public int hashCode()
{
return Objects.hash(mIPAddress);
}
}

View File

@@ -0,0 +1,34 @@
/*
* ******************************************************************************
* 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.identifier.ipv4;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
public abstract class IPV4Identifier extends Identifier<IPV4Address>
{
public IPV4Identifier(IPV4Address value, Role role)
{
super(value, IdentifierClass.USER, Form.IPV4_ADDRESS, role);
}
}

View File

@@ -0,0 +1,66 @@
/*
* ******************************************************************************
* 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.identifier.longnumber;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import java.util.Objects;
/**
* Long identifier base class.
*/
public abstract class LongIdentifier extends Identifier<Long>
{
public LongIdentifier(Long value, IdentifierClass identifierClass, Form form, Role role)
{
super(value, identifierClass, form, role);
}
@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(o == null || getClass() != o.getClass())
{
return false;
}
LongIdentifier that = (LongIdentifier)o;
return (getValue().longValue() == that.getValue().longValue()) &&
getIdentifierClass() == that.getIdentifierClass() &&
getForm() == that.getForm() &&
getRole() == that.getRole();
}
@Override
public int hashCode()
{
return Objects.hash(getValue(), getIdentifierClass(), getForm(), getRole());
}
}

View File

@@ -0,0 +1,101 @@
/*
* ******************************************************************************
* 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.identifier.patch;
import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class PatchGroup
{
// private final static Logger mLog = LoggerFactory.getLogger(PatchGroup.class);
private TalkgroupIdentifier mPatchGroupIdentifier;
private List<TalkgroupIdentifier> mPatchedGroupIdentifiers = new ArrayList<>();
public PatchGroup(TalkgroupIdentifier patchGroupIdentifier)
{
mPatchGroupIdentifier = patchGroupIdentifier;
}
public TalkgroupIdentifier getPatchGroup()
{
return mPatchGroupIdentifier;
}
public void addPatchedGroup(TalkgroupIdentifier patchedGroupIdentifier)
{
mPatchedGroupIdentifiers.add(patchedGroupIdentifier);
}
public void addPatchedGroups(List<TalkgroupIdentifier> patchedGroupIdentifiers)
{
for(TalkgroupIdentifier identifier : patchedGroupIdentifiers)
{
if(!mPatchedGroupIdentifiers.contains(identifier))
{
mPatchedGroupIdentifiers.add(identifier);
}
}
}
public List<TalkgroupIdentifier> getPatchedGroupIdentifiers()
{
return mPatchedGroupIdentifiers;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("P:").append(getPatchGroup());
if(!getPatchedGroupIdentifiers().isEmpty())
{
sb.append(" ").append(getPatchedGroupIdentifiers());
}
return sb.toString();
}
@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(o == null || getClass() != o.getClass())
{
return false;
}
PatchGroup that = (PatchGroup)o;
return Objects.equals(mPatchGroupIdentifier, that.mPatchGroupIdentifier);
}
@Override
public int hashCode()
{
return Objects.hash(mPatchGroupIdentifier);
}
}

View File

@@ -0,0 +1,34 @@
/*
* ******************************************************************************
* 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.identifier.patch;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
public abstract class PatchGroupIdentifier extends Identifier<PatchGroup>
{
public PatchGroupIdentifier(PatchGroup value)
{
super(value, IdentifierClass.USER, Form.PATCH_GROUP, Role.TO);
}
}

View File

@@ -0,0 +1,184 @@
/*
* ******************************************************************************
* 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.identifier.patch;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Manager for (temporary) patch groups and related identifiers.
*/
public class PatchGroupManager
{
// private final static Logger mLog = LoggerFactory.getLogger(PatchGroupManager.class);
private Map<Integer,Long> mPatchGroupLastUpdatedMap = new HashMap<>();
private Map<Integer,PatchGroupIdentifier> mPatchGroupMap = new HashMap<>();
public PatchGroupManager()
{
}
/**
* Adds the patch group identifier to the set of managed patch groups. If the patch group is already being
* managed, the new identifier is checked for additional patched talkgroups and they are added to the existing
* managed patch group.
*
* @param patchGroupIdentifier to add or update
*/
public synchronized void addPatchGroup(PatchGroupIdentifier patchGroupIdentifier)
{
PatchGroup update = patchGroupIdentifier.getValue();
if(update.getPatchGroup().getValue() > 0)
{
if(mPatchGroupMap.containsKey(update.getPatchGroup().getValue()))
{
PatchGroup current = mPatchGroupMap.get(update.getPatchGroup().getValue()).getValue();
current.addPatchedGroups(update.getPatchedGroupIdentifiers());
}
else
{
mPatchGroupMap.put(update.getPatchGroup().getValue(), patchGroupIdentifier);
}
}
}
/**
* Adds any patch group identifiers contained in the list.
*/
public synchronized void addPatchGroups(List<Identifier> identifiers)
{
for(Identifier identifier : identifiers)
{
if(identifier instanceof PatchGroupIdentifier)
{
addPatchGroup((PatchGroupIdentifier)identifier);
}
}
}
/**
* Removes the patch group from this manager if it is currently being managed.
*
* @param patchGroupIdentifier to remove
*/
public synchronized void removePatchGroup(PatchGroupIdentifier patchGroupIdentifier)
{
int id = patchGroupIdentifier.getValue().getPatchGroup().getValue();
mPatchGroupMap.remove(id);
mPatchGroupLastUpdatedMap.remove(id);
}
/**
* Removes any patch group identifiers contained in the list.
*/
public synchronized void removePatchGroups(List<Identifier> identifiers)
{
for(Identifier identifier : identifiers)
{
if(identifier instanceof PatchGroupIdentifier)
{
removePatchGroup((PatchGroupIdentifier)identifier);
}
}
}
/**
* Updates the list of identifiers by replacing any talkgroups or patch groups with the current
* version of the patch group and a complete listing of the patched talkgroups.
* @param identifiers to update
* @return list of identifiers
*/
public List<Identifier> update(List<Identifier> identifiers)
{
List<Identifier> updated = new ArrayList<>();
for(Identifier identifier: identifiers)
{
updated.add(update(identifier));
}
return updated;
}
/**
* Checks the TALKGROUP or PATCH GROUP identifier and replaces the identifier with the current patch group
* if the identifier matches a currently managed patch group.
*
* @param identifier for a talkgroup or a patch group.
* @return current patch group or the original identifier
*/
public Identifier update(Identifier identifier)
{
if(identifier == null)
{
return identifier;
}
if(identifier.getIdentifierClass() == IdentifierClass.USER && identifier.getRole() == Role.TO)
{
switch(identifier.getForm())
{
case TALKGROUP:
if(identifier instanceof TalkgroupIdentifier)
{
TalkgroupIdentifier tgi = (TalkgroupIdentifier)identifier;
if(tgi.isGroup())
{
int talkgroupId = ((TalkgroupIdentifier)identifier).getValue();
if(mPatchGroupMap.containsKey(talkgroupId))
{
return mPatchGroupMap.get(talkgroupId);
}
}
}
break;
case PATCH_GROUP:
if(identifier instanceof PatchGroupIdentifier)
{
PatchGroupIdentifier patchGroupIdentifier = (PatchGroupIdentifier)identifier;
int patchGroupId = patchGroupIdentifier.getValue().getPatchGroup().getValue();
if(mPatchGroupMap.containsKey(patchGroupId))
{
return mPatchGroupMap.get(patchGroupId);
}
else
{
addPatchGroup(patchGroupIdentifier);
}
}
break;
}
}
return identifier;
}
}

View File

@@ -0,0 +1,65 @@
/*
* ******************************************************************************
* 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.identifier.string;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import java.util.Objects;
/**
* String identifier base class
*/
public abstract class StringIdentifier extends Identifier<String>
{
public StringIdentifier(String value, IdentifierClass identifierClass, Form form, Role role)
{
super(value, identifierClass, form, role);
}
@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(o == null || getClass() != o.getClass())
{
return false;
}
StringIdentifier that = (StringIdentifier)o;
return (getValue().equals(that.getValue())) &&
getIdentifierClass() == that.getIdentifierClass() &&
getForm() == that.getForm() &&
getRole() == that.getRole();
}
@Override
public int hashCode()
{
return Objects.hash(getValue(), getIdentifierClass(), getForm(), getRole());
}
}

View File

@@ -0,0 +1,79 @@
/*
* ******************************************************************************
* 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.identifier.talkgroup;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.protocol.Protocol;
/**
* LTR talkgroup identifier
*/
public class LTRTalkgroup extends TalkgroupIdentifier implements Comparable<LTRTalkgroup>
{
public LTRTalkgroup(Integer talkgroup, Role role)
{
super(talkgroup, role, true);
}
@Override
public Protocol getProtocol()
{
return Protocol.LTR_NET;
}
/**
* This identifier formatted as HH:GGG where H=home channel and G=group
*/
public String formatted()
{
return String.format("%02d-%03d", getHomeChannel(), getTalkgroup());
}
/**
* Home channel for the identifier
*/
public int getHomeChannel()
{
return (getValue() >> 8) & 0x1F;
}
/**
* Talkgroup
*/
public int getTalkgroup()
{
return getValue() & 0xFF;
}
/**
* Creates an LTR-Net identifier from the integer value that contains both the fleet and the ident with a TO role
*/
public static LTRTalkgroup create(int talkgroup)
{
return new LTRTalkgroup(talkgroup, Role.TO);
}
@Override
public int compareTo(LTRTalkgroup o)
{
return getValue().compareTo(o.getValue());
}
}

View File

@@ -0,0 +1,51 @@
/*
* ******************************************************************************
* 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.identifier.talkgroup;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.integer.IntegerIdentifier;
public abstract class TalkgroupIdentifier extends IntegerIdentifier
{
private boolean mIsGroup;
public TalkgroupIdentifier(Integer value, Role role, boolean isGroup)
{
super(value, IdentifierClass.USER, Form.TALKGROUP, role);
mIsGroup = isGroup;
}
@Override
public boolean isValid()
{
return getValue() > 0;
}
/**
* Indicates if this is a group or individual identifier
*/
public boolean isGroup()
{
return mIsGroup;
}
}