Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1416 P25-P1 ICMP & Unknown Packet Handling #1417

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 Dennis Sheirer
* *****************************************************************************
* Copyright (C) 2014-2023 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
Expand All @@ -15,7 +14,7 @@
*
* 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.event;
Expand Down Expand Up @@ -50,6 +49,7 @@ public enum DecodeEventType
EMERGENCY("EMERGENCY"),
FUNCTION("Function"),
GPS("GPS"),
ICMP_PACKET("ICMP Packet"),
ID_ANI("ANI"),
ID_UNIQUE("Unique ID"),
IP_PACKET("IP Packet"),
Expand All @@ -66,6 +66,7 @@ public enum DecodeEventType
STATION_ID("Station ID"),
STATUS("Status"),
UDP_PACKET("UDP/IP Packet"),
UNKNOWN_PACKET("Unknown Packet"),
UNKNOWN("Unknown");

private String mLabel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
* Copyright (C) 2014-2023 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
Expand Down Expand Up @@ -43,8 +43,10 @@
import io.github.dsheirer.module.decode.event.DecodeEventType;
import io.github.dsheirer.module.decode.event.PlottableDecodeEvent;
import io.github.dsheirer.module.decode.ip.IPacket;
import io.github.dsheirer.module.decode.ip.UnknownPacket;
import io.github.dsheirer.module.decode.ip.ars.ARSPacket;
import io.github.dsheirer.module.decode.ip.cellocator.MCGPPacket;
import io.github.dsheirer.module.decode.ip.icmp.ICMPPacket;
import io.github.dsheirer.module.decode.ip.ipv4.IPV4Packet;
import io.github.dsheirer.module.decode.ip.lrrp.LRRPPacket;
import io.github.dsheirer.module.decode.ip.udp.UDPPacket;
Expand Down Expand Up @@ -87,7 +89,6 @@
import io.github.dsheirer.module.decode.p25.phase1.message.pdu.ambtc.osp.AMBTCUnitToUnitVoiceServiceChannelGrant;
import io.github.dsheirer.module.decode.p25.phase1.message.pdu.ambtc.osp.AMBTCUnitToUnitVoiceServiceChannelGrantUpdate;
import io.github.dsheirer.module.decode.p25.phase1.message.pdu.packet.PacketMessage;
import io.github.dsheirer.module.decode.p25.phase1.message.pdu.packet.sndcp.SNDCPMessage;
import io.github.dsheirer.module.decode.p25.phase1.message.pdu.packet.sndcp.SNDCPPacketMessage;
import io.github.dsheirer.module.decode.p25.phase1.message.pdu.umbtc.isp.UMBTCTelephoneInterconnectRequestExplicitDialing;
import io.github.dsheirer.module.decode.p25.phase1.message.tdu.TDULinkControlMessage;
Expand Down Expand Up @@ -139,12 +140,11 @@
import io.github.dsheirer.protocol.Protocol;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.util.PacketUtil;
import java.util.List;
import org.jdesktop.swingx.mapviewer.GeoPosition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
* Decoder state for an APCO25 channel. Maintains the call/data/idle state of the channel and produces events by
* monitoring the decoded message stream.
Expand Down Expand Up @@ -877,54 +877,54 @@ private void processPacketData(P25Message message)

if(message instanceof SNDCPPacketMessage)
{
SNDCPPacketMessage sndcp = (SNDCPPacketMessage)message;
SNDCPPacketMessage sndcp = (SNDCPPacketMessage) message;
getIdentifierCollection().update(sndcp.getIdentifiers());
}
else if(message instanceof PacketMessage)
{
PacketMessage packetMessage = (PacketMessage)message;
PacketMessage packetMessage = (PacketMessage) message;
getIdentifierCollection().remove(IdentifierClass.USER);
getIdentifierCollection().update(packetMessage.getIdentifiers());

IPacket packet = packetMessage.getPacket();

if(packet instanceof IPV4Packet)
{
IPV4Packet ipv4 = (IPV4Packet)packet;
IPV4Packet ipv4 = (IPV4Packet) packet;

IPacket ipPayload = ipv4.getPayload();

if(ipPayload instanceof UDPPacket)
{
UDPPacket udpPacket = (UDPPacket)ipPayload;
UDPPacket udpPacket = (UDPPacket) ipPayload;

IPacket udpPayload = udpPacket.getPayload();

if(udpPayload instanceof ARSPacket)
{
ARSPacket arsPacket = (ARSPacket)udpPayload;
ARSPacket arsPacket = (ARSPacket) udpPayload;

MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
for(Identifier identifier: packet.getIdentifiers())
for(Identifier identifier : packet.getIdentifiers())
{
ic.update(identifier);
}

DecodeEvent packetEvent = P25DecodeEvent.builder(message.getTimestamp())
.channel(getCurrentChannel())
.eventDescription(DecodeEventType.AUTOMATIC_REGISTRATION_SERVICE.toString())
.identifiers(ic)
.details(arsPacket.toString() + " " + ipv4.toString())
.build();
.channel(getCurrentChannel())
.eventDescription(DecodeEventType.AUTOMATIC_REGISTRATION_SERVICE.toString())
.identifiers(ic)
.details(arsPacket.toString() + " " + ipv4.toString())
.build();

broadcast(packetEvent);
}
else if(udpPayload instanceof MCGPPacket)
{
MCGPPacket mcgpPacket = (MCGPPacket)udpPayload;
MCGPPacket mcgpPacket = (MCGPPacket) udpPayload;

MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
for(Identifier identifier: packet.getIdentifiers())
for(Identifier identifier : packet.getIdentifiers())
{
ic.update(identifier);
}
Expand Down Expand Up @@ -954,7 +954,7 @@ else if(udpPayload instanceof LRRPPacket lrrpPacket)

GeoPosition geoPosition = PacketUtil.extractGeoPosition(lrrpPacket);

if (geoPosition != null)
if(geoPosition != null)
{
PlottableDecodeEvent plottableDecodeEvent = PlottableDecodeEvent.plottableBuilder(message.getTimestamp())
.channel(getCurrentChannel())
Expand All @@ -970,40 +970,87 @@ else if(udpPayload instanceof LRRPPacket lrrpPacket)
else
{
MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
for(Identifier identifier: packet.getIdentifiers())
for(Identifier identifier : packet.getIdentifiers())
{
ic.update(identifier);
}

DecodeEvent packetEvent = P25DecodeEvent.builder(message.getTimestamp())
.channel(getCurrentChannel())
.eventDescription(DecodeEventType.UDP_PACKET.toString())
.identifiers(ic)
.details(ipv4.toString())
.build();

broadcast(packetEvent);
}
}
else if(ipPayload instanceof ICMPPacket)
{
MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
for(Identifier identifier : packet.getIdentifiers())
{
ic.update(identifier);
}

DecodeEvent packetEvent = P25DecodeEvent.builder(message.getTimestamp())
.channel(getCurrentChannel())
.eventDescription(DecodeEventType.UDP_PACKET.toString())
.eventDescription(DecodeEventType.ICMP_PACKET.toString())
.identifiers(ic)
.details(ipv4.toString())
.build();

broadcast(packetEvent);
broadcast(packetEvent);
}
else
{
MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
for(Identifier identifier : packet.getIdentifiers())
{
ic.update(identifier);
}

DecodeEvent packetEvent = P25DecodeEvent.builder(message.getTimestamp())
.channel(getCurrentChannel())
.eventDescription(DecodeEventType.IP_PACKET.toString())
.identifiers(ic)
.details(ipv4.toString())
.build();

broadcast(packetEvent);
}
}
else if(packet instanceof UnknownPacket)
{
MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
for(Identifier identifier : packet.getIdentifiers())
{
ic.update(identifier);
}

DecodeEvent packetEvent = P25DecodeEvent.builder(message.getTimestamp())
.channel(getCurrentChannel())
.eventDescription(DecodeEventType.UNKNOWN_PACKET.toString())
.identifiers(ic)
.details(packet.toString())
.build();

broadcast(packetEvent);
}
}
}

/**
* Sub-Network Dependent Convergence Protocol (SNDCP)
*
* @param message
* @param message to process
*/
private void processSNDCP(P25Message message)
{
broadcast(new DecoderStateEvent(this, Event.DECODE, State.DATA));

if(message.isValid() && message instanceof SNDCPPacketMessage)
if(message.isValid() && message instanceof SNDCPPacketMessage sndcpPacket)
{
SNDCPPacketMessage sndcpPacket = (SNDCPPacketMessage)message;

SNDCPMessage sndcpMessage = sndcpPacket.getSNDCPMessage();

MutableIdentifierCollection ic = getMutableIdentifierCollection(sndcpPacket.getIdentifiers());

switch(sndcpPacket.getSNDCPPacketHeader().getPDUType())
Expand Down