Skip to content

Commit

Permalink
Merge pull request f4exb#2180 from srcejon/freq_scanner
Browse files Browse the repository at this point in the history
AIS: Validate message length. Fixes f4exb#2125
  • Loading branch information
f4exb committed Jun 20, 2024
2 parents 9e4dc83 + 5f0fc8f commit 4837d3a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 18 deletions.
26 changes: 14 additions & 12 deletions plugins/channelrx/demodais/aisdemod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,20 @@ bool AISDemod::handleMessage(const Message& cmd)

// Decode the message
ais = AISMessage::decode(report.getMessage());

m_logStream << report.getDateTime().date().toString() << ","
<< report.getDateTime().time().toString() << ","
<< report.getMessage().toHex() << ","
<< QString("%1").arg(ais->m_mmsi, 9, 10, QChar('0')) << ","
<< ais->getType() << ","
<< "\"" << ais->toString() << "\"" << ","
<< "\"" << ais->toNMEA() << "\"" << ","
<< report.getSlot() << ","
<< report.getSlots() << "\n";

delete ais;
if (ais)
{
m_logStream << report.getDateTime().date().toString() << ","
<< report.getDateTime().time().toString() << ","
<< report.getMessage().toHex() << ","
<< QString("%1").arg(ais->m_mmsi, 9, 10, QChar('0')) << ","
<< ais->getType() << ","
<< "\"" << ais->toString() << "\"" << ","
<< "\"" << ais->toNMEA() << "\"" << ","
<< report.getSlot() << ","
<< report.getSlots() << "\n";

delete ais;
}
}

return true;
Expand Down
3 changes: 3 additions & 0 deletions plugins/channelrx/demodais/aisdemodgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ void AISDemodGUI::messageReceived(const QByteArray& message, const QDateTime& da

// Decode the message
ais = AISMessage::decode(message);
if (!ais) {
return;
}

// Is scroll bar at bottom
QScrollBar *sb = ui->messages->verticalScrollBar();
Expand Down
2 changes: 1 addition & 1 deletion plugins/channelrx/demodais/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This plugin can be used to demodulate AIS (Automatic Identification System) mess

AIS is broadcast globally on 25kHz channels at 161.975MHz and 162.025MHz, with other frequencies being used regionally or for special purposes. This demodulator is single channel, so if you wish to decode multiple channels simultaneously, you will need to add one AIS demodulator per frequency. As most AIS messages are on 161.975MHz and 162.025MHz, you can set the center frequency as 162MHz, with a sample rate of 100k+Sa/s, with one AIS demod with an input offset -25kHz and another at +25kHz.

The AIS demodulators can send received messages to the [AIS feature](../../feature/ais/readme.md), which displays a table combining the latest data for vessels amalgamated from multiple demodulators and sends their positions to the [Map Feature](../../feature/map/readme.ais) for display in 2D or 3D.
The AIS demodulators can send received messages to the [AIS feature](../../feature/ais/readme.md), which displays a table combining the latest data for vessels amalgamated from multiple demodulators and sends their positions to the [Map Feature](../../feature/map/readme.md) for display in 2D or 3D.

AIS uses GMSK/FM modulation at a baud rate of 9,600, with a modulation index of 0.5. The demodulator works at a sample rate of 57,600Sa/s.

Expand Down
4 changes: 3 additions & 1 deletion plugins/feature/ais/aisgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ bool AISGUI::handleMessage(const Message& message)
// Decode the message
AISMessage *ais = AISMessage::decode(report.getPacket());
// Update table
updateVessels(ais, report.getDateTime());
if (ais) {
updateVessels(ais, report.getDateTime());
}
}

return false;
Expand Down
4 changes: 4 additions & 0 deletions sdrbase/util/ais.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ QString AISMessage::typeToString(quint8 type)

AISMessage* AISMessage::decode(const QByteArray ba)
{
if (ba.size() < 1) {
return nullptr;
}

int id = (ba[0] >> 2) & 0x3f;

if ((id == 1) || (id == 2) || (id == 3)) {
Expand Down
6 changes: 4 additions & 2 deletions sdrgui/gui/configurationsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void ConfigurationsDialog::populateTree()
return;
}

sortConfigurations();

QList<Configuration*>::const_iterator it = m_configurations->begin();
int middleIndex = m_configurations->size() / 2;
QTreeWidgetItem *treeItem;
Expand Down Expand Up @@ -445,14 +447,14 @@ void ConfigurationsDialog::on_configurationImport_clicked()
}
}

void ConfigurationsDialog::on_configurationTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
void ConfigurationsDialog::on_configurationsTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
(void) current;
(void) previous;
updateConfigurationControls();
}

void ConfigurationsDialog::on_configurationTree_itemActivated(QTreeWidgetItem *item, int column)
void ConfigurationsDialog::on_configurationsTree_itemActivated(QTreeWidgetItem *item, int column)
{
(void) item;
(void) column;
Expand Down
4 changes: 2 additions & 2 deletions sdrgui/gui/configurationsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ private slots:
void on_configurationImport_clicked();
void on_configurationDelete_clicked();
void on_configurationLoad_clicked();
void on_configurationTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void on_configurationTree_itemActivated(QTreeWidgetItem *item, int column);
void on_configurationsTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void on_configurationsTree_itemActivated(QTreeWidgetItem *item, int column);
void accept() override;

signals:
Expand Down

0 comments on commit 4837d3a

Please sign in to comment.