Add --net-verbatim, which forwards the original uncorrected message to net clients,

not the corrected version. Then the client can make its own policy decisions about
whether to accept and correct the damaged messages.
This commit is contained in:
Oliver Jowett 2015-01-22 19:56:38 +00:00
parent a59077a370
commit 008ae926e7
4 changed files with 14 additions and 3 deletions

View file

@ -514,6 +514,7 @@ void showHelp(void) {
"--net-ro-interval <rate> TCP output memory flush rate in seconds (default: 0)\n"
"--net-heartbeat <rate> TCP heartbeat rate in seconds (default: 60 sec; 0 to disable)\n"
"--net-buffer <n> TCP buffer size 64Kb * (2^n) (default: n=0, 64Kb)\n"
"--net-verbatim Do not apply CRC corrections to messages we forward; send unchanged\n"
"--lat <latitude> Reference/receiver latitude for surface posn (opt)\n"
"--lon <longitude> Reference/receiver longitude for surface posn (opt)\n"
"--max-range <distance> Absolute maximum range for position decoding (in nm, default: 300)\n"
@ -826,6 +827,8 @@ int main(int argc, char **argv) {
Modes.net_output_sbs_port = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--net-buffer") && more) {
Modes.net_sndbuf_size = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--net-verbatim")) {
Modes.net_verbatim = 1;
} else if (!strcmp(argv[j],"--onlyaddr")) {
Modes.onlyaddr = 1;
} else if (!strcmp(argv[j],"--metric")) {

View file

@ -349,6 +349,7 @@ struct { // Internal state
int net_http_port; // HTTP port
int net_fatsv_port; // FlightAware TSV port
int net_sndbuf_size; // TCP output buffer size (64Kb * 2^n)
int net_verbatim; // if true, send the original message, not the CRC-corrected one
int quiet; // Suppress stdout
int interactive; // Interactive mode
int interactive_rows; // Interactive mode: max number of rows
@ -394,6 +395,7 @@ struct { // Internal state
struct modesMessage {
// Generic fields
unsigned char msg[MODES_LONG_MSG_BYTES]; // Binary message.
unsigned char verbatim[MODES_LONG_MSG_BYTES]; // Binary message, as originally received before correction
int msgbits; // Number of bits in message
int msgtype; // Downlink format #
uint32_t crc; // Message CRC

View file

@ -417,8 +417,12 @@ static char *ais_charset = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./01
int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
{
// Work on our local copy
// Work on our local copy.
memcpy(mm->msg, msg, MODES_LONG_MSG_BYTES);
if (Modes.net_verbatim) {
// Preserve the original uncorrected copy for later forwarding
memcpy(mm->verbatim, msg, MODES_LONG_MSG_BYTES);
}
msg = mm->msg;
// Get the message type ASAP as other operations depend on this

View file

@ -273,6 +273,7 @@ void modesSendBeastOutput(struct modesMessage *mm) {
char * pTimeStamp;
char ch;
int j;
unsigned char *msg = (Modes.net_verbatim ? mm->verbatim : mm->msg);
if (!p)
return;
@ -297,7 +298,7 @@ void modesSendBeastOutput(struct modesMessage *mm) {
if (0x1A == ch) {*p++ = ch; }
for (j = 0; j < msgLen; j++) {
*p++ = (ch = mm->msg[j]);
*p++ = (ch = msg[j]);
if (0x1A == ch) {*p++ = ch; }
}
@ -314,6 +315,7 @@ void modesSendRawOutput(struct modesMessage *mm) {
char *p = prepareWrite(&Modes.raw_out, msgLen*2 + 15);
int j;
unsigned char * pTimeStamp;
unsigned char *msg = (Modes.net_verbatim ? mm->verbatim : mm->msg);
if (!p)
return;
@ -329,7 +331,7 @@ void modesSendRawOutput(struct modesMessage *mm) {
*p++ = '*';
for (j = 0; j < msgLen; j++) {
sprintf(p, "%02X", mm->msg[j]);
sprintf(p, "%02X", msg[j]);
p += 2;
}