# baecun baecun is a Rust-based command-line tool that constructs and sends specially formatted frames to an AGWPE server over TCP. It supports unproto frames with and without digipeaters and provides some validation for IP addresses, ports, callsigns, and channel numbers. This tool was written as an exercise to both learn and be able to teach the building blocks of both Rust idomatic programming and writing a simple unproto AGWPE TX client. ## Features - IP and Port Validation: Ensures the provided IP address is valid and the port is greater than zero. - Callsign Validation: Validates that callsigns are 9 characters or less and contain only alphanumeric characters or dashes. - Channel Support: Verifies that the AGWPE channel number is within the valid range (0–255). - Flexible Message Input: Accepts the message to send either via a command-line flag or from standard input (stdin). - Frame Construction: Builds either an 'M' frame (without digipeaters) or a 'V' frame (with digipeaters) based on the provided arguments. - TCP Transmission: Sends the constructed frame to the AGWPE server over a TCP connection. ## Prerequisites - Rust https://www.rust-lang.org/tools/install (version 1.XX or later) - Cargo package manager (included with Rust) ## Installation Clone the repository: ```bash git clone https://gitea.farpn.net/n6cta/baecun.git cd baecun ``` Build the project in release mode: ```bash cargo build –-release ``` The compiled executable will be located in the `target/release` directory. ## Usage Run the executable with the required arguments: ```bash baecun -i -p -f -t -m “” [OPTIONS] ``` ### Command-Line Arguments - `-i, –ip ` The IP address of the AGWPE server. Example: `127.0.0.1` - `-p, –port ` The port number of the AGWPE server (must be greater than 0). Example: `8000` - `-f, –from_call ` The sender's callsign (up to 9 alphanumeric characters or dashes). Example: `N0CALL` - `-t, –to_call ` The recipient's callsign (up to 9 alphanumeric characters or dashes). Example: `DEST` - `-m, –message ` The message to be sent. If omitted, the message is read from standard input (stdin). - `-c, –channel ` The AGWPE channel number (default is `0`). Must be between `0` and `255`. - `-d, –digis …` A list of digipeater callsigns (up to 7). If provided, a 'V' frame is constructed. Each callsign must follow the same rules as `from_call` and `to_call`. ## Examples ### Sending a Simple Message Send a message directly from the command line: ```bash baecun -i 127.0.0.1 -p 8000 -f N0CALL -t DEST -m “Hello, world!” ``` ### Sending a Message with Digipeaters Send a message that includes two digipeaters by piping the message through stdin: ```bash echo “Test message via digipeaters” | baecun -i 127.0.0.1 -p 8000 -f N0CALL -t DEST -d DIGI1 DIGI2 ``` ## Code Overview - Validation Functions: - `validate_ip` checks that the provided IP address is in a correct format. - `validate_port` ensures that the port number is non-zero. - `validate_callsign` and `validate_channel` enforce the proper format and length for callsigns and channel numbers. - Frame Construction: - M Frame: Used when no digipeaters are provided. - V Frame: Used when one or more digipeater callsigns are provided. Both frames include necessary fields like reserved bytes, data kind, and encoded callsigns. - TCP Communication: The function `send_frame` connects to the AGWPE server and transmits the constructed frame over TCP. ## Binary Releases Binary releases are provided for the following targets for your convinience. They were generated using using Cross. - aarch64-unknown-linux-gnu - aarch64-apple-darwin - x86_64-unknown-linux-gnu - armv7-unknown-linux-gnueabihf - arm-unknown-linux-gnueabihf ## Contributing Contributions are welcome! Feel free to fork this repository and submit pull requests. For major changes, please open an issue first to discuss your ideas.