Skip to content
Open
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
Expand Up @@ -39,7 +39,7 @@ public class AirborneOperationalStatusV1Msg extends ExtendedSquitter implements

protected int capability_class_code; // actually 16 bit unsigned
protected int operational_mode_code; // actually 16 bit unsigned
private byte version;
protected byte version;
private boolean nic_suppl; // may be passed to position messages
private byte nac_pos; // navigational accuracy category - position
private byte sil; // surveillance integrity level
Expand Down Expand Up @@ -101,6 +101,9 @@ public AirborneOperationalStatusV1Msg(ExtendedSquitter squitter) throws BadForma
operational_mode_code = b.readInt(25, 40);
version = b.readByte(41, 43);

if (version < 1)
throw new BadFormatException("Unsupported operational status version " + version);

if ((capability_class_code & 0xC000) != 0)
throw new BadFormatException("Unknown capability class code!");
if ((operational_mode_code & 0xC000) != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public AirborneOperationalStatusV2Msg(ExtendedSquitter squitter) throws BadForma

byte[] msg = this.getMessage();

if ((byte) (msg[5] >>> 5) != 2)
throw new BadFormatException("Not a DO-260B/version 2 status message.");
if (version < 2)
throw new BadFormatException("Unsupported operational status version " + version);

geometric_vertical_accuracy = baq;
// Bit 55
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class SurfaceOperationalStatusV1Msg extends ExtendedSquitter implements S

protected int capability_class_code; // actually 16 bit unsigned
protected int operational_mode_code; // actually 16 bit unsigned
private byte airplane_len_width; // only for surface messages
private byte version;
private byte airplane_len_width; // length / width code
protected byte version;
private boolean nic_suppl; // may be passed to position messages
private byte nac_pos; // navigational accuracy category - position
private byte sil; // surveillance integrity level
Expand Down Expand Up @@ -101,6 +101,9 @@ public SurfaceOperationalStatusV1Msg(ExtendedSquitter squitter) throws BadFormat
operational_mode_code = b.readInt(25, 40);
version = b.readByte(41, 43);

if (version < 1)
throw new BadFormatException("Unsupported operational status version " + version);

if ((capability_class_code & 0xC00) != 0)
throw new BadFormatException("Unknown capability class code!");
if ((operational_mode_code & 0xC000) != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public SurfaceOperationalStatusV2Msg(ExtendedSquitter squitter) throws BadFormat

byte[] msg = this.getMessage();

if ((byte) (msg[5] >>> 5) != 2)
throw new BadFormatException("Not a DO-260B/version 2 status message.");
if (version < 2)
throw new BadFormatException("Unsupported operational status version " + version);

sil_supplement = ((msg[6] & 0x2) != 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,12 @@ public void testValidVersion1Message() throws Exception {
assertEquals(1, status.getVersion());
assertEquals(9, status.getNACp());
}

@Test
public void testRejectVersion0Message() throws Exception {
byte[] msg = Tools.hexStringToByteArray("8D000000F8000200492900000000");
msg[9] = 0x09;

assertThrows(BadFormatException.class, () -> new AirborneOperationalStatusV1Msg(msg));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package de.serosystems.lib1090.msgs.adsb;

import de.serosystems.lib1090.Tools;
import de.serosystems.lib1090.exceptions.BadFormatException;
import de.serosystems.lib1090.exceptions.UnspecifiedFormatError;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -89,4 +90,20 @@ public void testDecodeSurfaceOpstat() throws UnspecifiedFormatError, BadFormatEx
assertEquals(0, opstat.getSystemDesignAssurance());
assertFalse(opstat.hasSILSupplement());
}

@Test
public void testRejectAirborneVersion1AsV2() throws Exception {
byte[] msg = Tools.hexStringToByteArray(A_OPSTAT_V2);
msg[9] = 0x29;

assertThrows(BadFormatException.class, () -> new AirborneOperationalStatusV2Msg(msg));
}

@Test
public void testRejectSurfaceVersion1AsV2() throws Exception {
byte[] msg = Tools.hexStringToByteArray(S_OPSTAT_V2);
msg[9] = 0x20;

assertThrows(BadFormatException.class, () -> new SurfaceOperationalStatusV2Msg(msg));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public void testValidVersion1Message() throws Exception {
assertEquals(1, status.getVersion());
}

@Test
public void testRejectVersion0Message() throws Exception {
byte[] msg = Tools.hexStringToByteArray("8D000000F9000000002000000000");
msg[9] = 0x00;

assertThrows(BadFormatException.class, () -> new SurfaceOperationalStatusV1Msg(msg));
}

@Test
public void testOperationalModeCodeWithHighByte() throws Exception {
byte[] msg = Tools.hexStringToByteArray("8D000000F9000080002000000000");
Expand Down
Loading