From 6731f53a91363959bb7c5d1534d23939c52fcfaf Mon Sep 17 00:00:00 2001 From: Rajan Patel Date: Mon, 16 Sep 2024 22:26:27 -0400 Subject: [PATCH] add imsl/irdm (#328) * add imsl/irdm * add freq stats * readme --- Cargo.lock | 11 +- Cargo.toml | 4 +- Dockerfile | 14 +- Dockerfile.build_binary | 2 +- Dockerfile.local | 14 +- README.md | 50 +++++-- rootfs/etc/s6-overlay/scripts/acars_router | 80 ++++++++++++ rust/libraries/acars_config/src/lib.rs | 122 ++++++++++++++++++ .../acars_connection_manager/Cargo.toml | 3 +- .../acars_connection_manager/src/lib.rs | 4 + .../src/message_handler.rs | 42 ++++++ .../src/service_init.rs | 98 ++++++++++++++ 12 files changed, 423 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 50cd598c..69af0098 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acars_config" -version = "1.2.0" +version = "1.3.0" dependencies = [ "clap", "log", @@ -13,7 +13,7 @@ dependencies = [ [[package]] name = "acars_connection_manager" -version = "1.2.0" +version = "1.3.0" dependencies = [ "acars_config", "acars_vdlm2_parser", @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "acars_router" -version = "1.2.0" +version = "1.3.0" dependencies = [ "acars_config", "acars_connection_manager", @@ -43,9 +43,10 @@ dependencies = [ [[package]] name = "acars_vdlm2_parser" -version = "0.2.1" -source = "git+https://github.com/fredclausen/acars_vdlm2_parser?branch=hfdl-and-dependency-updates#8bea595eff65544624ede1b08c803b29738e51c8" +version = "0.4.0" +source = "git+https://github.com/rpatel3001/acars_vdlm2_parser?branch=add_imsl_irdm" dependencies = [ + "chrono", "log", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index c2a467c2..a46cbd54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,9 @@ resolver = "2" [workspace.package] edition = "2021" -version = "1.2.0" +version = "1.3.0" authors = ["Fred Clausen", "Mike Nye", "Alex Austin"] -description = "ACARS Router: A Utility to ingest ACARS/VDLM2/HFDL from many sources, process, and feed out to many consumers." +description = "ACARS Router: A Utility to ingest ACARS/VDLM2/HFDL/IMSL/IRDM from many sources, process, and feed out to many consumers." documentation = "https://github.com/sdr-enthusiasts/acars_router" homepage = "https://github.com/sdr-enthusiasts/acars_router" repository = "https://github.com/sdr-enthusiasts/acars_router" diff --git a/Dockerfile b/Dockerfile index 6d7aaea2..917e965d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,19 +6,31 @@ ENV AR_LISTEN_UDP_ACARS=5550 \ AR_LISTEN_TCP_VDLM2=5555 \ AR_LISTEN_UDP_HFDL=5556 \ AR_LISTEN_TCP_HFDL=5556 \ + AR_LISTEN_UDP_IMSL=5557 \ + AR_LISTEN_TCP_IMSL=5557 \ + AR_LISTEN_UDP_IRDM=5558 \ + AR_LISTEN_TCP_IRDM=5558 \ AR_LISTEN_ZMQ_ACARS=35550 \ AR_LISTEN_ZMQ_VDLM2=35555 \ AR_LISTEN_ZMQ_HFDL=35556 \ + AR_LISTEN_ZMQ_IMSL=35557 \ + AR_LISTEN_ZMQ_IRDM=35558 \ AR_SERVE_TCP_ACARS=15550 \ AR_SERVE_TCP_VDLM2=15555 \ AR_SERVE_TCP_HFDL=15556 \ + AR_SERVE_TCP_IMSL=15557 \ + AR_SERVE_TCP_IRDM=15558 \ AR_SERVE_ZMQ_ACARS=45550 \ AR_SERVE_ZMQ_VDLM2=45555 \ AR_SERVE_ZMQ_HFDL=45556 \ + AR_SERVE_ZMQ_IMSL=45557 \ + AR_SERVE_ZMQ_IRDM=45558 \ AR_ADD_PROXY_ID=true \ AR_DISABLE_ACARS=false \ AR_DISABLE_VDLM2=false \ - AR_DISABLE_HFDL=false + AR_DISABLE_HFDL=false \ + AR_DISABLE_IMSL=false \ + AR_DISABLE_IRDM=false SHELL ["/bin/bash", "-o", "pipefail", "-c"] COPY ./rootfs / diff --git a/Dockerfile.build_binary b/Dockerfile.build_binary index 78ae90f9..a4b50b2a 100644 --- a/Dockerfile.build_binary +++ b/Dockerfile.build_binary @@ -1,4 +1,4 @@ -FROM rust:1.81.0 as builder +FROM rust:1.81.0 AS builder ENV CARGO_NET_GIT_FETCH_WITH_CLI=true WORKDIR /tmp/acars_router # hadolint ignore=DL3008,DL3003,SC1091,DL3009 diff --git a/Dockerfile.local b/Dockerfile.local index 31699693..b0af16a0 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -16,19 +16,31 @@ ENV AR_LISTEN_UDP_ACARS=5550 \ AR_LISTEN_TCP_VDLM2=5555 \ AR_LISTEN_UDP_HFDL=5556 \ AR_LISTEN_TCP_HFDL=5556 \ + AR_LISTEN_UDP_IMSL=5557 \ + AR_LISTEN_TCP_IMSL=5557 \ + AR_LISTEN_UDP_IRDM=5558 \ + AR_LISTEN_TCP_IRDM=5558 \ AR_LISTEN_ZMQ_ACARS=35550 \ AR_LISTEN_ZMQ_VDLM2=35555 \ AR_LISTEN_ZMQ_HFDL=35556 \ + AR_LISTEN_ZMQ_IMSL=35557 \ + AR_LISTEN_ZMQ_IRDM=35558 \ AR_SERVE_TCP_ACARS=15550 \ AR_SERVE_TCP_VDLM2=15555 \ AR_SERVE_TCP_HFDL=15556 \ + AR_SERVE_TCP_IMSL=15557 \ + AR_SERVE_TCP_IRDM=15558 \ AR_SERVE_ZMQ_ACARS=45550 \ AR_SERVE_ZMQ_VDLM2=45555 \ AR_SERVE_ZMQ_HFDL=45556 \ + AR_SERVE_ZMQ_IMSL=45557 \ + AR_SERVE_ZMQ_IRDM=45558 \ AR_ADD_PROXY_ID=true \ AR_DISABLE_ACARS=false \ AR_DISABLE_VDLM2=false \ - AR_DISABLE_HFDL=false + AR_DISABLE_HFDL=false \ + AR_DISABLE_IMSL=false \ + AR_DISABLE_IRDM=false SHELL ["/bin/bash", "-o", "pipefail", "-c"] COPY rootfs / diff --git a/README.md b/README.md index a61360ef..a3f3ffd5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # sdr-enthusiasts/acars_router -`acars_router` receives, validates, deduplicates, modifies and routes ACARS and VDLM2 JSON messages. +`acars_router` receives, validates, deduplicates, modifies and routes ACARS/VDLM2/HFDL/IMSL/IRDM JSON messages. ## Example Feeder `docker-compose.yml` @@ -67,21 +67,31 @@ All ports are configurable. By default, the following ports will be used: | Port | Protocol | Description | | ------- | -------- | -------------------------------------------------------------------------------- | -| `5550` | `UDP` | ACARS injest. Clients will send acars data to this port via UDP. | -| `5550` | `TCP` | ACARS injest. Clients will send acars data to this port via TCP. | -| `5555` | `UDP` | VDLM2 injest. Clients will send VDLM2 data to this port via UDP. | -| `5555` | `TCP` | VDLM2 injest. Clients will send VDLM2 data to this port via TCP. | -| `5556` | `UDP` | HFDL injest. Clients will send HFDL data to this port via UDP. | -| `5556` | `TCP` | HFDL injest. Clients will send HFDL data to this port via TCP. | +| `5550` | `UDP` | ACARS ingest. Clients will send ACARS data to this port via UDP. | +| `5550` | `TCP` | ACARS ingest. Clients will send ACARS data to this port via TCP. | +| `5555` | `UDP` | VDLM2 ingest. Clients will send VDLM2 data to this port via UDP. | +| `5555` | `TCP` | VDLM2 ingest. Clients will send VDLM2 data to this port via TCP. | +| `5556` | `UDP` | HFDL ingest. Clients will send HFDL data to this port via UDP. | +| `5556` | `TCP` | HFDL ingest. Clients will send HFDL data to this port via TCP. | +| `5557` | `UDP` | IMSL ingest. Clients will send IMSL data to this port via UDP. | +| `5557` | `TCP` | IMSL ingest. Clients will send IMSL data to this port via TCP. | +| `5558` | `UDP` | IRDM ingest. Clients will send IRDM data to this port via UDP. | +| `5558` | `TCP` | IRDM ingest. Clients will send IRDM data to this port via TCP. | | `15550` | `TCP` | ACARS server. Can be used for other clients to connect and get messages | | `15555` | `TCP` | VDLM2 server. Can be used for other clients to connect and get messages | | `15556` | `TCP` | HFDL server. Can be used for other clients to connect and get messages | -| `35550` | `ZMQ` | ACARS injest. Clients will connect to this port and send acars messages over ZMQ | -| `35555` | `ZMQ` | VDLM2 injest. Clients will connect to this port and send VDLM2 messages over ZMQ | -| `35556` | `ZMQ` | HFDL injest. Clients will connect to this port and send HFDL messages over ZMQ | +| `15557` | `TCP` | IMSL server. Can be used for other clients to connect and get messages | +| `15558` | `TCP` | IRDM server. Can be used for other clients to connect and get messages | +| `35550` | `ZMQ` | ACARS ingest. Clients will connect to this port and send ACARS messages over ZMQ | +| `35555` | `ZMQ` | VDLM2 ingest. Clients will connect to this port and send VDLM2 messages over ZMQ | +| `35556` | `ZMQ` | HFDL ingest. Clients will connect to this port and send HFDL messages over ZMQ | +| `35557` | `ZMQ` | IMSL ingest. Clients will connect to this port and send IMSL messages over ZMQ | +| `35558` | `ZMQ` | IRDM ingest. Clients will connect to this port and send IRDM messages over ZMQ | | `45550` | `ZMQ` | ACARS server. Can be used for other ZMQ clients to connect and get messages | | `45555` | `ZMQ` | VDLM2 server. Can be used for other ZMQ clients to connect and get messages | | `45556` | `ZMQ` | HFDL server. Can be used for other ZMQ clients to connect and get messages | +| `45557` | `ZMQ` | IMSL server. Can be used for other ZMQ clients to connect and get messages | +| `45558` | `ZMQ` | IRDM server. Can be used for other ZMQ clients to connect and get messages | If you want any port(s) to be exposed outside of the docker network, please be sure to append them to the ports section of the `docker-compose.yml` file. @@ -110,15 +120,23 @@ The nomenclature for the environment variables is as follows: | AR_SEND_UDP_ACARS | --send-udp-acars | `unset` | UDP host:port to send ACARS messages to | | AR_SEND_UDP_VDLM2 | --send-udp-vdlm2 | `unset` | UDP host:port to send VDLM2 messages to | | AR_SEND_UDP_HFDL | --send-udp-hfdl | `unset` | UDP host:port to send HFDL messages to | +| AR_SEND_UDP_IMSL | --send-udp-imsl | `unset` | UDP host:port to send IMSL messages to | +| AR_SEND_UDP_IRDM | --send-udp-irdm | `unset` | UDP host:port to send IRDM messages to | | AR_SEND_TCP_ACARS | --send-tcp-acars | `unset` | TCP host:port to send ACARS messages to | | AR_SEND_TCP_VDLM2 | --send-tcp-vdlm2 | `unset` | TCP host:port to send VDLM2 messages to | | AR_SEND_TCP_HFDL | --send-tcp-hfdl | `unset` | TCP host:port to send HFDL messages to | +| AR_SEND_TCP_IMSL | --send-tcp-imsl | `unset` | TCP host:port to send IMSL messages to | +| AR_SEND_TCP_IRDM | --send-tcp-irdm | `unset` | TCP host:port to send IRDM messages to | | AR_SERVE_TCP_ACARS | --serve-tcp-acars | `15550` | TCP port to serve ACARS messages to | | AR_SERVE_TCP_VDLM2 | --serve-tcp-vdlm2 | `15555` | TCP port to serve VDLM2 messages to | | AR_SERVE_TCP_HFDL | --serve-tcp-hfdl | `15556` | TCP port to serve HFDL messages to | +| AR_SERVE_TCP_IMSL | --serve-tcp-imsl | `15557` | TCP port to serve IMSL messages to | +| AR_SERVE_TCP_IRDM | --serve-tcp-irdm | `15558` | TCP port to serve IRDM messages to | | AR_SERVE_ZMQ_ACARS | --serve-zmq-acars | `45550` | ZMQ port to serve ACARS messages to | | AR_SERVE_ZMQ_VDLM2 | --serve-zmq-vdlm2 | `45555` | ZMQ port to serve VDLM2 messages to | | AR_SERVE_ZMQ_HFDL | --serve-zmq-hfdl | `45556` | ZMQ port to serve HFDL messages to | +| AR_SERVE_ZMQ_IMSL | --serve-zmq-imsl | `45557` | ZMQ port to serve IMSL messages to | +| AR_SERVE_ZMQ_IRDM | --serve-zmq-irdm | `45558` | ZMQ port to serve IRDM messages to | ### Inbound data @@ -127,18 +145,28 @@ The nomenclature for the environment variables is as follows: | AR_RECV_ZMQ_ACARS | --recv-zmq-acars | `unset` | ZMQ host:port to receive ACARS messages from | | AR_RECV_ZMQ_VDLM2 | --recv-zmq-vdlm2 | `unset` | ZMQ host:port to receive VDLM2 messages from | | AR_RECV_ZMQ_HFDL | --recv-zmq-hfdl | `unset` | ZMQ host:port to receive HFDL messages from | +| AR_RECV_ZMQ_IMSL | --recv-zmq-imsl | `unset` | ZMQ host:port to receive IMSL messages from | +| AR_RECV_ZMQ_IRDM | --recv-zmq-irdm | `unset` | ZMQ host:port to receive IRDM messages from | | AR_RECV_TCP_ACARS | --recv-tcp-acars | `unset` | TCP host:port to receive ACARS messages from | | AR_RECV_TCP_VDLM2 | --recv-tcp-vdlm2 | `unset` | TCP host:port to receive VDLM2 messages from | | AR_RECV_TCP_HFDL | --recv-tcp-hfdl | `unset` | TCP host:port to receive HFDL messages from | +| AR_RECV_TCP_IMSL | --recv-tcp-imsl | `unset` | TCP host:port to receive IMSL messages from | +| AR_RECV_TCP_IRDM | --recv-tcp-irdm | `unset` | TCP host:port to receive IRDM messages from | | AR_LISTEN_TCP_ACARS | --listen-tcp-acars | `5550` | TCP port to listen for ACARS messages from | | AR_LISTEN_TCP_VDLM2 | --listen-tcp-vdlm2 | `5555` | TCP port to listen for VDLM2 messages from | | AR_LISTEN_TCP_HFDL | --listen-tcp-hfdl | `5556` | TCP port to listen for HFDL messages from | +| AR_LISTEN_TCP_IMSL | --listen-tcp-imsl | `5557` | TCP port to listen for IMSL messages from | +| AR_LISTEN_TCP_IRDM | --listen-tcp-irdm | `5558` | TCP port to listen for IRDM messages from | | AR_LISTEN_UDP_ACARS | --listen-udp-acars | `5550` | UDP port to listen for ACARS messages from | | AR_LISTEN_UDP_VDLM2 | --listen-udp-vdlm2 | `5555` | UDP port to listen for VDLM2 messages from | | AR_LISTEN_UDP_HFDL | --listen-udp-hfdl | `5556` | UDP port to listen for HFDL messages from | +| AR_LISTEN_UDP_IMSL | --listen-udp-imsl | `5557` | UDP port to listen for IMSL messages from | +| AR_LISTEN_UDP_IRDM | --listen-udp-irdm | `5558` | UDP port to listen for IRDM messages from | | AR_LISTEN_ZMQ_ACARS | --listen-zmq-acars | `35550` | ZMQ port to listen for ACARS messages from | | AR_LISTEN_ZMQ_VDLM2 | --listen-zmq-vdlm2 | `35555` | ZMQ port to listen for VDLM2 messages from | | AR_LISTEN_ZMQ_HFDL | --listen-zmq-hfdl | `35556` | ZMQ port to listen for HFDL messages from | +| AR_LISTEN_ZMQ_IMSL | --listen-zmq-imsl | `35557` | ZMQ port to listen for IMSL messages from | +| AR_LISTEN_ZMQ_IRDM | --listen-zmq-irdm | `35558` | ZMQ port to listen for IRDM messages from | ### General Options @@ -157,3 +185,5 @@ The nomenclature for the environment variables is as follows: | AR_DISABLE_ACARS | --disable-acars | `false` | Disable ACARS processing. Valid values are `true` or `false` | | AR_DISABLE_VDLM2 | --disable-vdlm | `false` | Disable VDLM processing. Valid values are `true` or `false` | | AR_DISABLE_HFDL | --disable-hfdl | `false` | Disable HFDL processing. Valid values are `true` or `false` | +| AR_DISABLE_IMSL | --disable-imsl | `false` | Disable IMSL processing. Valid values are `true` or `false` | +| AR_DISABLE_IRDM | --disable-irdm | `false` | Disable IRDM processing. Valid values are `true` or `false` | diff --git a/rootfs/etc/s6-overlay/scripts/acars_router b/rootfs/etc/s6-overlay/scripts/acars_router index e856e965..4d3e56b2 100755 --- a/rootfs/etc/s6-overlay/scripts/acars_router +++ b/rootfs/etc/s6-overlay/scripts/acars_router @@ -69,6 +69,50 @@ if [[ -n $AR_RECV_ZMQ_HFDL ]]; then AR_COMMAND+=("--receive-zmq-hfdl" "$AR_RECV_ZMQ_HFDL") fi +# IMSL input + +if [[ -n $AR_LISTEN_UDP_IMSL ]]; then + AR_COMMAND+=("--listen-udp-imsl" "$AR_LISTEN_UDP_IMSL") +fi + +if [[ -n $AR_LISTEN_TCP_IMSL ]]; then + AR_COMMAND+=("--listen-tcp-imsl" "$AR_LISTEN_TCP_IMSL") +fi + +if [[ -n $AR_LISTEN_ZMQ_IMSL ]]; then + AR_COMMAND+=("--listen-zmq-imsl" "$AR_LISTEN_ZMQ_IMSL") +fi + +if [[ -n $AR_RECV_TCP_IMSL ]]; then + AR_COMMAND+=("--receive-tcp-imsl" "$AR_RECV_TCP_IMSL") +fi + +if [[ -n $AR_RECV_ZMQ_IMSL ]]; then + AR_COMMAND+=("--receive-zmq-imsl" "$AR_RECV_ZMQ_IMSL") +fi + +# IRDM input + +if [[ -n $AR_LISTEN_UDP_IRDM ]]; then + AR_COMMAND+=("--listen-udp-irdm" "$AR_LISTEN_UDP_IRDM") +fi + +if [[ -n $AR_LISTEN_TCP_IRDM ]]; then + AR_COMMAND+=("--listen-tcp-irdm" "$AR_LISTEN_TCP_IRDM") +fi + +if [[ -n $AR_LISTEN_ZMQ_IRDM ]]; then + AR_COMMAND+=("--listen-zmq-irdm" "$AR_LISTEN_ZMQ_IRDM") +fi + +if [[ -n $AR_RECV_TCP_IRDM ]]; then + AR_COMMAND+=("--receive-tcp-irdm" "$AR_RECV_TCP_IRDM") +fi + +if [[ -n $AR_RECV_ZMQ_IRDM ]]; then + AR_COMMAND+=("--receive-zmq-irdm" "$AR_RECV_ZMQ_IRDM") +fi + # ACARS Output if [[ -n $AR_SEND_UDP_ACARS ]]; then @@ -123,4 +167,40 @@ if [[ -n $AR_SERVE_ZMQ_HFDL ]]; then AR_COMMAND+=("--serve-zmq-hfdl" "$AR_SERVE_ZMQ_HFDL") fi +# IMSL Output + +if [[ -n $AR_SEND_UDP_IMSL ]]; then + AR_COMMAND+=("--send-udp-imsl" "$AR_SEND_UDP_IMSL") +fi + +if [[ -n $AR_SEND_TCP_IMSL ]]; then + AR_COMMAND+=("--send-tcp-imsl" "$AR_SEND_TCP_IMSL") +fi + +if [[ -n $AR_SERVE_TCP_IMSL ]]; then + AR_COMMAND+=("--serve-tcp-imsl" "$AR_SERVE_TCP_IMSL") +fi + +if [[ -n $AR_SERVE_ZMQ_IMSL ]]; then + AR_COMMAND+=("--serve-zmq-imsl" "$AR_SERVE_ZMQ_IMSL") +fi + +# IRDM Output + +if [[ -n $AR_SEND_UDP_IRDM ]]; then + AR_COMMAND+=("--send-udp-irdm" "$AR_SEND_UDP_IRDM") +fi + +if [[ -n $AR_SEND_TCP_IRDM ]]; then + AR_COMMAND+=("--send-tcp-irdm" "$AR_SEND_TCP_IRDM") +fi + +if [[ -n $AR_SERVE_TCP_IRDM ]]; then + AR_COMMAND+=("--serve-tcp-irdm" "$AR_SERVE_TCP_IRDM") +fi + +if [[ -n $AR_SERVE_ZMQ_IRDM ]]; then + AR_COMMAND+=("--serve-zmq-irdm" "$AR_SERVE_ZMQ_IRDM") +fi + /opt/acars_router "${AR_COMMAND[@]}" diff --git a/rust/libraries/acars_config/src/lib.rs b/rust/libraries/acars_config/src/lib.rs index 7ed54cb3..a9401791 100644 --- a/rust/libraries/acars_config/src/lib.rs +++ b/rust/libraries/acars_config/src/lib.rs @@ -70,6 +70,12 @@ pub struct Input { /// Disable HFDL input #[clap(long, env = "AR_DISABLE_HFDL", value_parser)] pub disable_hfdl: bool, + /// Disable IMSL input + #[clap(long, env = "AR_DISABLE_IMSL", value_parser)] + pub disable_imsl: bool, + /// Disable IRDM input + #[clap(long, env = "AR_DISABLE_IRDM", value_parser)] + pub disable_irdm: bool, // Input Options @@ -139,6 +145,50 @@ pub struct Input { #[clap(long, value_parser, value_delimiter = ';')] pub receive_zmq_hfdl: Option>, + // IMSL + /// ACARS Router will listen for IMSL messages on the specified UDP ports. + /// Semi-Colon separated list of arguments. ie 5555;5556;5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub listen_udp_imsl: Option>, + /// ACARS Router will listen for connections from a client for IMSL messages on the specified TCP ports. + /// Semi-Colon separated list of arguments. ie 5555;5556;5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub listen_tcp_imsl: Option>, + /// ACARS Router will listen for connections from a client for IMSL messages on the specified ZMQ ports. + /// Semi-Colon separated list of arguments. ie 5555;5556;5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub listen_zmq_imsl: Option>, + /// ACARS Router will connect to the specified hosts for IMSL messages over TCP. + /// Semi-Colon separated list of arguments. ie host:5550;host:5551;host:5552 + #[clap(long, value_parser, value_delimiter = ';')] + pub receive_tcp_imsl: Option>, + /// ACARS Router will connect to the specified hosts for IMSL messages in ZMQ format. + /// Semi-Colon separated list of arguments. ie host:5550;host:5551;host:5552 + #[clap(long, value_parser, value_delimiter = ';')] + pub receive_zmq_imsl: Option>, + + // IRDM + /// ACARS Router will listen for IRDM messages on the specified UDP ports. + /// Semi-Colon separated list of arguments. ie 5555;5556;5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub listen_udp_irdm: Option>, + /// ACARS Router will listen for connections from a client for IRDM messages on the specified TCP ports. + /// Semi-Colon separated list of arguments. ie 5555;5556;5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub listen_tcp_irdm: Option>, + /// ACARS Router will listen for connections from a client for IRDM messages on the specified ZMQ ports. + /// Semi-Colon separated list of arguments. ie 5555;5556;5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub listen_zmq_irdm: Option>, + /// ACARS Router will connect to the specified hosts for IRDM messages over TCP. + /// Semi-Colon separated list of arguments. ie host:5550;host:5551;host:5552 + #[clap(long, value_parser, value_delimiter = ';')] + pub receive_tcp_irdm: Option>, + /// ACARS Router will connect to the specified hosts for IRDM messages in ZMQ format. + /// Semi-Colon separated list of arguments. ie host:5550;host:5551;host:5552 + #[clap(long, value_parser, value_delimiter = ';')] + pub receive_zmq_irdm: Option>, + // JSON Output options // ACARS @@ -182,6 +232,34 @@ pub struct Input { /// Semi-Colon separated list of arguments. ie 5550;5551;5552 #[clap(long, value_parser, value_delimiter = ';')] pub serve_zmq_hfdl: Option>, + + // IMSL + /// Semi-Colon separated list of arguments. ie host:5555;host:5556;host:5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub send_udp_imsl: Option>, + /// Semi-Colon separated list of arguments. ie host:5555;host:5556;host:5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub send_tcp_imsl: Option>, + /// Semi-Colon separated list of arguments. ie 5550;5551;5552 + #[clap(long, value_parser, value_delimiter = ';')] + pub serve_tcp_imsl: Option>, + /// Semi-Colon separated list of arguments. ie 5550;5551;5552 + #[clap(long, value_parser, value_delimiter = ';')] + pub serve_zmq_imsl: Option>, + + // IRDM + /// Semi-Colon separated list of arguments. ie host:5555;host:5556;host:5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub send_udp_irdm: Option>, + /// Semi-Colon separated list of arguments. ie host:5555;host:5556;host:5557 + #[clap(long, value_parser, value_delimiter = ';')] + pub send_tcp_irdm: Option>, + /// Semi-Colon separated list of arguments. ie 5550;5551;5552 + #[clap(long, value_parser, value_delimiter = ';')] + pub serve_tcp_irdm: Option>, + /// Semi-Colon separated list of arguments. ie 5550;5551;5552 + #[clap(long, value_parser, value_delimiter = ';')] + pub serve_zmq_irdm: Option>, } impl Input { @@ -224,9 +302,29 @@ impl Input { debug!("AR_LISTEN_ZMQ_ACARS: {:?}", self.listen_zmq_acars); debug!("AR_LISTEN_ZMQ_VDLM2: {:?}", self.listen_zmq_vdlm2); debug!("AR_LISTEN_ZMQ_HFDL: {:?}", self.listen_zmq_hfdl); + debug!("AR_LISTEN_UDP_IMSL: {:?}", self.listen_udp_imsl); + debug!("AR_LISTEN_TCP_IMSL: {:?}", self.listen_tcp_imsl); + debug!("AR_RECV_TCP_IMSL: {:?}", self.receive_tcp_imsl); + debug!("AR_RECV_ZMQ_IMSL: {:?}", self.receive_zmq_imsl); + debug!("AR_SEND_UDP_IMSL: {:?}", self.send_udp_imsl); + debug!("AR_SEND_TCP_IMSL: {:?}", self.send_tcp_imsl); + debug!("AR_SERVE_TCP_IMSL: {:?}", self.serve_tcp_imsl); + debug!("AR_SERVE_ZMQ_IMSL: {:?}", self.serve_zmq_imsl); + debug!("AR_LISTEN_ZMQ_IMSL: {:?}", self.listen_zmq_imsl); + debug!("AR_LISTEN_UDP_IRDM: {:?}", self.listen_udp_irdm); + debug!("AR_LISTEN_TCP_IRDM: {:?}", self.listen_tcp_irdm); + debug!("AR_RECV_TCP_IRDM: {:?}", self.receive_tcp_irdm); + debug!("AR_RECV_ZMQ_IRDM: {:?}", self.receive_zmq_irdm); + debug!("AR_SEND_UDP_IRDM: {:?}", self.send_udp_irdm); + debug!("AR_SEND_TCP_IRDM: {:?}", self.send_tcp_irdm); + debug!("AR_SERVE_TCP_IRDM: {:?}", self.serve_tcp_irdm); + debug!("AR_SERVE_ZMQ_IRDM: {:?}", self.serve_zmq_irdm); + debug!("AR_LISTEN_ZMQ_IRDM: {:?}", self.listen_zmq_irdm); debug!("AR_DISABLE_ACARS: {:?}", self.disable_acars); debug!("AR_DISABLE_VDLM2: {:?}", self.disable_vdlm2); debug!("AR_DISABLE_HFDL: {:?}", self.disable_hfdl); + debug!("AR_DISABLE_IMSL: {:?}", self.disable_imsl); + debug!("AR_DISABLE_IRDM: {:?}", self.disable_irdm); } pub fn acars_configured(&self) -> bool { @@ -264,4 +362,28 @@ impl Input { || self.serve_tcp_hfdl.is_some() || self.serve_zmq_hfdl.is_some()) } + + pub fn imsl_configured(&self) -> bool { + !self.disable_imsl + && (self.receive_tcp_imsl.is_some() + || self.listen_udp_imsl.is_some() + || self.listen_tcp_imsl.is_some() + || self.receive_zmq_imsl.is_some() + || self.send_udp_imsl.is_some() + || self.send_tcp_imsl.is_some() + || self.serve_tcp_imsl.is_some() + || self.serve_zmq_imsl.is_some()) + } + + pub fn irdm_configured(&self) -> bool { + !self.disable_irdm + && (self.receive_tcp_irdm.is_some() + || self.listen_udp_irdm.is_some() + || self.listen_tcp_irdm.is_some() + || self.receive_zmq_irdm.is_some() + || self.send_udp_irdm.is_some() + || self.send_tcp_irdm.is_some() + || self.serve_tcp_irdm.is_some() + || self.serve_zmq_irdm.is_some()) + } } diff --git a/rust/libraries/acars_connection_manager/Cargo.toml b/rust/libraries/acars_connection_manager/Cargo.toml index c188b0dc..4116320f 100644 --- a/rust/libraries/acars_connection_manager/Cargo.toml +++ b/rust/libraries/acars_connection_manager/Cargo.toml @@ -17,5 +17,6 @@ async-trait = "0.1.82" zmq = "0.10.0" tmq = "0.4.0" #acars_vdlm2_parser = { git = "https://github.com/jcdeimos/acars_vdlm2_parser", version = "0.2.1" } -acars_vdlm2_parser = { git = "https://github.com/fredclausen/acars_vdlm2_parser", branch = "hfdl-and-dependency-updates" } +#acars_vdlm2_parser = { git = "https://github.com/fredclausen/acars_vdlm2_parser", branch = "hfdl-and-dependency-updates" } +acars_vdlm2_parser = { git = "https://github.com/rpatel3001/acars_vdlm2_parser", branch = "add_imsl_irdm" } acars_config = { path = "../acars_config" } diff --git a/rust/libraries/acars_connection_manager/src/lib.rs b/rust/libraries/acars_connection_manager/src/lib.rs index 605b6fc9..1d418196 100644 --- a/rust/libraries/acars_connection_manager/src/lib.rs +++ b/rust/libraries/acars_connection_manager/src/lib.rs @@ -70,6 +70,8 @@ pub(crate) enum ServerType { Acars, Vdlm2, Hfdl, + Imsl, + Irdm, } #[derive(Debug, Clone, Default)] @@ -140,6 +142,8 @@ impl fmt::Display for ServerType { ServerType::Acars => write!(f, "ACARS"), ServerType::Vdlm2 => write!(f, "VDLM"), ServerType::Hfdl => write!(f, "HFDL"), + ServerType::Imsl => write!(f, "IMSL"), + ServerType::Irdm => write!(f, "IRDM"), } } } diff --git a/rust/libraries/acars_connection_manager/src/message_handler.rs b/rust/libraries/acars_connection_manager/src/message_handler.rs index f3211058..e51e9329 100644 --- a/rust/libraries/acars_connection_manager/src/message_handler.rs +++ b/rust/libraries/acars_connection_manager/src/message_handler.rs @@ -218,6 +218,48 @@ impl MessageHandlerConfig { all_frequencies_logged.lock().await.push(new_frequency); } } + AcarsVdlm2Message::ImslMessage(m) => { + // get the freq from ImslMessage + if let Some(frequency) = &m.freq { + let mut found: bool = false; + for freq in all_frequencies_logged.lock().await.iter_mut() { + if freq.freq == *frequency.to_string() { + freq.count += 1; + found = true; + break; + } + } + + if !found { + let new_frequency: FrequencyCount = FrequencyCount { + freq: frequency.to_string(), + count: 1, + }; + all_frequencies_logged.lock().await.push(new_frequency); + } + } + } + AcarsVdlm2Message::IrdmMessage(m) => { + // get the freq from IrdmMessage + if let Some(frequency) = &m.freq { + let mut found: bool = false; + for freq in all_frequencies_logged.lock().await.iter_mut() { + if freq.freq == *frequency.to_string() { + freq.count += 1; + found = true; + break; + } + } + + if !found { + let new_frequency: FrequencyCount = FrequencyCount { + freq: frequency.to_string(), + count: 1, + }; + all_frequencies_logged.lock().await.push(new_frequency); + } + } + } } let get_message_time: Option = message.get_time(); diff --git a/rust/libraries/acars_connection_manager/src/service_init.rs b/rust/libraries/acars_connection_manager/src/service_init.rs index 7b3c1527..c6c055d3 100644 --- a/rust/libraries/acars_connection_manager/src/service_init.rs +++ b/rust/libraries/acars_connection_manager/src/service_init.rs @@ -198,6 +198,104 @@ pub async fn start_processes(args: Input) { ); } + if args.imsl_configured() { + let message_handler_config_imsl: MessageHandlerConfig = + MessageHandlerConfig::new(&args, "IMSL"); + // IMSL + // Create the input channel all receivers will send their data to. + let (tx_receivers_imsl, rx_receivers_imsl) = mpsc::channel(32); + // Create the input channel processed messages will be sent to + let (tx_processed_imsl, rx_processed_imsl) = mpsc::channel(32); + + let imsl_input_config: OutputServerConfig = OutputServerConfig::new( + &args.listen_udp_imsl, + &args.listen_tcp_imsl, + &args.listen_zmq_imsl, + &args.receive_tcp_imsl, + &args.receive_zmq_imsl, + &args.reassembly_window, + ServerType::Imsl, + ); + + tokio::spawn(async move { + imsl_input_config.start_listeners(tx_receivers_imsl); + }); + + info!("Starting IMSL Output Servers"); + let imsl_output_config: SenderServerConfig = SenderServerConfig::new( + &args.send_udp_imsl, + &args.send_tcp_imsl, + &args.serve_tcp_imsl, + &args.serve_zmq_imsl, + &args.max_udp_packet_size, + ); + + tokio::spawn(async move { + imsl_output_config + .start_senders(rx_processed_imsl, "IMSL") + .await; + }); + + tokio::spawn(async move { + message_handler_config_imsl + .watch_message_queue(rx_receivers_imsl, tx_processed_imsl) + .await; + }); + } else { + info!( + "Not starting the IMSL message handler task. No input and/or output sources specified." + ); + } + + if args.irdm_configured() { + let message_handler_config_irdm: MessageHandlerConfig = + MessageHandlerConfig::new(&args, "IRDM"); + // IRDM + // Create the input channel all receivers will send their data to. + let (tx_receivers_irdm, rx_receivers_irdm) = mpsc::channel(32); + // Create the input channel processed messages will be sent to + let (tx_processed_irdm, rx_processed_irdm) = mpsc::channel(32); + + let irdm_input_config: OutputServerConfig = OutputServerConfig::new( + &args.listen_udp_irdm, + &args.listen_tcp_irdm, + &args.listen_zmq_irdm, + &args.receive_tcp_irdm, + &args.receive_zmq_irdm, + &args.reassembly_window, + ServerType::Irdm, + ); + + tokio::spawn(async move { + irdm_input_config.start_listeners(tx_receivers_irdm); + }); + + info!("Starting IRDM Output Servers"); + let irdm_output_config: SenderServerConfig = SenderServerConfig::new( + &args.send_udp_irdm, + &args.send_tcp_irdm, + &args.serve_tcp_irdm, + &args.serve_zmq_irdm, + &args.max_udp_packet_size, + ); + + tokio::spawn(async move { + irdm_output_config + .start_senders(rx_processed_irdm, "IRDM") + .await; + }); + + tokio::spawn(async move { + message_handler_config_irdm + .watch_message_queue(rx_receivers_irdm, tx_processed_irdm) + .await; + }); + } else { + info!( + "Not starting the IRDM message handler task. No input and/or output sources specified." + ); + } + trace!("Starting the sleep loop"); loop {