Commit graph

448 commits

Author SHA1 Message Date
XANTRONIX Development
9dd27b5924 Remove useless expression from patty_client_ping() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
54d6324dea Fix invalid return in patty_ax25_aprs_is_send()
Fix invalid return in patty_ax25_aprs_is_send() wherein the number of
bytes written to APRS-IS was returned, rather than the number of AX.25
packet bytes; the number of bytes read is the more important value as it
is used later for repeating the frame to promiscuous mode SOCK_RAW
sockets
2024-03-01 00:20:47 -05:00
XANTRONIX Development
9f6f775ee4 Simplify handle_sock_raw() in src/server.c 2024-03-01 00:20:47 -05:00
XANTRONIX Development
e053d6cdbc Drop patty_kiss_tnc_recv() from handle_sock_raw()
Refactor handle_sock_raw() in src/server.c to remove usage of
patty_kiss_tnc_recv() in favor of its component methods:

    * patty_kiss_tnc_fill()
    * patty_kiss_tnc_drain()
    * patty_kiss_tnc_ready()
    * patty_kiss_tnc_flush()
2024-03-01 00:20:47 -05:00
XANTRONIX Development
50eaef806d Reset TNC command state on frame end 2024-03-01 00:20:47 -05:00
XANTRONIX Development
26716a5b2a Fix handling of SOCK_RAW frames
Fix issue handling SOCK_RAW frames wherein patty_ax25_sock_send() is
used instead of patty_ax25_if_send() to send frames through the
interface bound to the socket
2024-03-01 00:20:47 -05:00
XANTRONIX Development
3cf9d4093a Add patty_client_read(), patty_client_write()
Add patty_client_read(), patty_client_write() to allow direct I/O with
a pattyd(8) process from a patty_client object
2024-03-01 00:20:47 -05:00
XANTRONIX Development
df84f68678 Prevent server dying on invalid client requests 2024-03-01 00:20:47 -05:00
XANTRONIX Development
84a4815708 Whitespace tweaks 2024-03-01 00:20:47 -05:00
XANTRONIX Development
b2789a4d56 Implement patty_ax25_if_recv()
Implement patty_ax25_if_recv() as a utility function to allow one to
use when instantiating a network interface without a full network stack
2024-03-01 00:20:47 -05:00
XANTRONIX Development
c8c00c994c Handle non-DATA KISS commands in src/tnc.c
Handle non-DATA KISS commands in src/tnc.c, rather than simply returning
-1 setting errno to EIO
2024-03-01 00:20:47 -05:00
XANTRONIX Development
bcc1c69d45 Increase print_addr() buffer size in src/print.c
Increase print_addr() buffer size in src/print.c to allow for a nul
terminator
2024-03-01 00:20:47 -05:00
XANTRONIX Development
fbefda6103 Avoid connecting to APRS-IS via UDP
Avoid connecting to APRS-IS via UDP by filtering out getaddrinfo()
results of SOCK_DGRAM type
2024-03-01 00:20:47 -05:00
XANTRONIX Development
7172863a1a Close sockets on failure to write, don't die 2024-03-01 00:20:47 -05:00
XANTRONIX Development
dfd0978113 Move patty_ax25_if_stats accounting into drivers
Move patty_ax25_if_stats accounting into drivers to help provide a more
consistent interface for accessing and incrementing interface statistics
2024-03-01 00:20:47 -05:00
XANTRONIX Development
9a1b163954 Add APRS-IS link resilience for some frame errors
Add APRS-IS link resilience for some errors encoding APRS-IS TNC2 format
frames as AX.25 by simply dropping the frame and moving on to the next
2024-03-01 00:20:47 -05:00
XANTRONIX Development
78f42b02ea Prevent SSIDs >15 in patty_ax25_pton() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
02033990a6 Remove usage of snprintf() from patty_ax25_ntop()
Remove usage of snprintf() from patty_ax25_ntop() to gain better control
over the behavior of how the 'len' argument and nul terminator are
handled
2024-03-01 00:20:47 -05:00
XANTRONIX Development
c98d07e876 Rename struct members, variables
Rename struct members, variables for better visual appeal
2024-03-01 00:20:47 -05:00
XANTRONIX Development
70d112eb91 Implement patty_ax25_aprs_is_send()
Implement patty_ax25_aprs_is_send() to be able to encode any outbound UI
frames in TNC2 format, and to send them to a remote APRS-IS server

Other changes:

    * Remove unimplemented patty_ax25_aprs_is_printf() declaration

    * Remove unimplemented patty_ax25_aprs_is_readline() declaration
2024-03-01 00:20:47 -05:00
XANTRONIX Development
34e5629bc9 Use const qualifier in src/frame.c where proper 2024-03-01 00:20:47 -05:00
XANTRONIX Development
d1b507e81f Rename patty_error_isset() to patty_error_set()
Rename patty_error_isset() to patty_error_set() in src/error.c (for now)
2024-03-01 00:20:47 -05:00
XANTRONIX Development
606237606d Move APRS-IS connection code to aprs_is_connect()
Move APRS-IS connection code to aprs_is_connect() in src/aprs_is.c
2024-03-01 00:20:47 -05:00
XANTRONIX Development
52350ad0e8 patty_ax25_pton(): Make calls ending in - invalid 2024-03-01 00:20:47 -05:00
XANTRONIX Development
8f01ab1cd4 Make patty_print_header() use TNC2 format
Make patty_print_header() use TNC2 format for representing source,
destination and repeater addresses
2024-03-01 00:20:47 -05:00
XANTRONIX Development
77bb1bf030 s/PATTY_AX25_CALLSIGN_LEN/PATTY_AX25_CALLSTRLEN/g 2024-03-01 00:20:47 -05:00
XANTRONIX Development
e2796596ac Allow patty_ax25_pton() to accept APRS characters 2024-03-01 00:20:47 -05:00
XANTRONIX Development
a807a9ec9d Implement APRS-IS interface type
Implement an APRS-IS interface type which is capable of receiving all
APRS-IS traffic which can be represented in AX.25 frames; currently,
there are no provisions for handling extended features such as
non-numeric SSIDs, nor a client nor server which facilitate direct
APRS-IS communication.  Presently, APRS-IS traffic cannot be sent from
this interface.

Changes:

    * Add patty_ax25_aprs_is driver type in src/aprs_is.c

    * Implement 'aprs-is' interface configuration type in bin/if.c; make
      separate, smaller state machines for handling base interface
      config, KISS, and APRS-IS interface config
2024-03-01 00:20:47 -05:00
XANTRONIX Development
29fbea2e18 Use snprintf() to format SSID in patty_ax25_ntop() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
7041b73e0e Simplify patty_ax25_pton() state machine
Simplify patty_ax25_pton() state machine to remove the unnecessary
ADDR_NONE state
2024-03-01 00:20:47 -05:00
XANTRONIX Development
eaa3a3a06a Use PATTY_AX25_ADDRSTRLEN in patty_ax25_pton() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
b8c19ea6cd Fix address padding bug in patty_ax25_pton()
Fix address padding bug in patty_ax25_pton() wherein a literal space was
filled into an address field, rather than a space (0x20) shifted left by
one
2024-03-01 00:20:47 -05:00
XANTRONIX Development
d5e2062dea Split patty_ax25_if_recv() into specific parts
Split patty_ax25_if_recv() into the following parts:

    * patty_ax25_if_fill(), to fill the internal PHY buffer

    * patty_ax25_if_drain(), to drain the internal PHY buffer and decode
      any data present in the buffer

    * patty_ax25_if_ready(), to test if a complete frame has been
      decoded

    * patty_ax25_if_flush(), to return the final number of bytes decoded
      in the PHY buffer and reset the decoding state

Other changes:

    * Implement a finite state machine for decoding KISS traffic in
      src/tnc.c, patty_ax25_kiss_drain()

    * Refactor src/server.c, handle_iface() to use the aforementioned
      frame receive/decode methods
2024-03-01 00:20:47 -05:00
XANTRONIX Development
2f5c877762 Fix uninitialized memory in patty_kiss_tnc_driver() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
4b1e0ff46d Better variable name in patty_kiss_tnc_recv() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
16b46168b2 Remove unneeded variable in patty_kiss_tnc_recv() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
bd1238e0bd Improve frame encoding error handling, reporting
Changes:

    * Improve error detection in patty_ax25_frame_encode()

    * Make patty_ax25_frame_encode() set EOVERFLOW when encoding beyond
      the caller specified limit

    * Make patty_ax25_frame_encode_reply_to() set EOVERFLOW when
      encoding beyond the caller specified limit
2024-03-01 00:20:47 -05:00
XANTRONIX Development
30b17d337b Fix #include cycle in include/patty/kiss/tnc.h 2024-03-01 00:20:47 -05:00
XANTRONIX Development
00fd626757 Fix patty_conf_read() backslash escape bug
Fix patty_conf_read() bug wherein backslash escapes simply did not
work as intended
2024-03-01 00:20:47 -05:00
XANTRONIX Development
cb33d799ff Implement patty_ax25_if_driver
Changes:

    * Implement patty_ax25_if_driver type, providing a vtable with
      pointers to methods implementing an AX.25 interface PHY

    * Implement patty_ax25_if_name() to return a pointer to the name
      string of an AX.25 interface

    * Decouple patty_kiss_tnc from src/if.c using patty_ax25_if_driver

    * Remove port input/output arguments from patty_kiss_tnc_send()
      and patty_kiss_tnc_recv(), respectively; use 0 as the default,
      but keep the port argument in patty_kiss_frame_send()

    * Implement patty_ax25_if_fd() to return file descriptor backing a
      PHY; use this rather than patty_kiss_tnc_fd() in src/server.c to
      further decouple interfaces from their implementation

    * Remove 'enum patty_ax25_if_type' type; refactor constructor
      patty_ax25_if_new() to no longer take this as an argument, but
      rather a patty_ax25_if_driver to use to instantiate the PHY
      with the information pointer passed

    * Break out patty_kiss_tnc code from src/kiss.c into src/tnc.c,
      leaving only patty_kiss_frame_send() in the original; this is
      needed to prevent a cyclic dependency within patty_ax25_sock and
      other areas

    * Rename patty_bin_if_config() to patty_bin_if_create(); a separate
      patty_bin_if_config() will likely be created later as necessary
      to change an existing interface

    * Split PHY-specific interface configuration code into separate
      delegates in bin/if.c

    * Implement usage of patty_error to better capture internal error
      states not currently representable with semantic error numbers
      while configuring and instantiating PHYs

    * Pass patty_error object to patty_bin_kiss_config() to receive
      detailed error information
2024-03-01 00:20:47 -05:00
XANTRONIX Development
356b25fd94 Implement src/error.c
Implement src/error.c to provide the patty_error type, to allow easy
error string formatting, error state checking, and error clearing
2024-03-01 00:20:47 -05:00
XANTRONIX Development
2c3a461ee9 PATTY_AX25_ADDRESS_LEN -> PATTY_AX25_ADDRSTRLEN 2024-03-01 00:20:47 -05:00
XANTRONIX Development
188d43f98d Improve error reporting, CLI code reuse
Changes:

    * Move network interface configuration logic from bin/pattyd.c to
      bin/if.c; implement a more robust state machine

    * Move KISS TNC configuration code from bin/pattyd.c to bin/kiss.c

    * Ensure configuration file name, line number, and erroneous part
      of an expression are clearly indicated upon failure

Other changes:

    * Improve bin/Makefile to rebuild objects when accompanying header
      files change

    * Refer to HEADERS_SUBDIR, not HEADER_SUBDIR, in Makefiles
2024-03-01 00:20:47 -05:00
XANTRONIX Development
a1cabeb1e1 Move paths to build/install tools to mk/build.mk 2024-03-01 00:20:47 -05:00
XANTRONIX Development
639ec8beb7 Implement bin/pattyd.c
Changes:

    * Implement src/conf.c, patty_conf_read(), to read a configuration
      file to support a OpenBSD-style configuration file format

    * Implement bin/pattyd.c to use patty_conf_read() to read a
      configuration file and apply its settings to a patty_daemon
      object as it is read; also implement a --standalone|-s flag to
      allow the user to start a patty server without having to write
      a configuration file

    * Refactor patty_daemon_if_add() to accept a patty_ax25_if object;
      this is necessary as bin/pattyd.c needs to be able to validate
      the addresses given in a configuration file 'if' statement

    * Refactor patty_ax25_server_new() to no longer accept a client
      socket path; instead, patty_ax25_server_start() now accepts the
      client socket path

    * Remove the client socket 'path' member from patty_ax25_server in
      src/server.c

    * Refactor patty_kiss_tnc_new() to accept only one argument, a
      patty_kiss_tnc_info object containing flags and settings needed
      to open a device, use an existing file descriptor, or change
      termios settings as appropriate

    * Remove patty_kiss_tnc_new_fd(), as its functionality now exists
      in patty_kiss_tnc_new() itself

    * Add a 'flags' field to patty_kiss_tnc_info; use this bit field
      to determine whether a path or file descriptor is provided by
      the caller

    * Make patty_ax25_if_new() accept an interface name argument, as
      names are explicitly required when declaring new interfaces in
      configuration files

    * Make patty_kiss_tnc_new() able to accept /dev/ptmx as a device
      name, regardless of whether this character device exists on a
      given platform; when provided, a pseudo TTY pair is allocated
      with openpty()

    * Refactor examples/ax25dump.c to use the new patty_kiss_tnc_new()
      calling convention

    * Refactor examples/decode.c to use the new patty_kiss_tnc_new()
      calling convention

    * Remove examples/daemon.c in favor of bin/pattyd.c

    * Rename examples/patty.conf to examples/pattyd.conf; modify to
      provide values which would actually function
2024-03-01 00:20:47 -05:00
XANTRONIX Development
b0e9ae6e0d Improved portability in ./configure
Improved portability in ./configure to add detection for various smaller
items, such as headers necessary for openpty(3), et cetera; improve
overall script structure
2024-03-01 00:20:47 -05:00
XANTRONIX Development
adaeb0d6d2 Use openpty(3) to open PTYs
Use openpty(3) to open PTYs, to achieve compatibility with OpenBSD as
posix_openpty() returns a file descriptor which does not block on
read() nor select()
2024-03-01 00:20:47 -05:00
XANTRONIX Development
8f3bcc3d41 Use posix_openpt() for creating pseudo TTY pairs
Use posix_openpt() for creating pseudo TTY pairs, rather than depending
on the presence of /dev/ptmx, which is not a portable assumption
2024-03-01 00:20:47 -05:00
XANTRONIX Development
854d3bc9a7 Fix bug in patty_ax25_if_addr_add()
Fix bug in patty_ax25_if_addr_add() wherein, due to a typo of memcpy()
rather than memcmp(), the function would never fail to add an address
to an interface, even if it already exists on the interface
2024-03-01 00:20:47 -05:00
XANTRONIX Development
5cb98de5d0 Allow setting baud, flow control for TNCs
Changes:

    * Add argument to patty_kiss_tnc_new(), patty_kiss_tnc_new_fd(),
      a pointer to patty_kiss_tnc_info, to allow specifying baud and
      flow control

    * Rework patty_ax25_if_kiss_tnc_info to hold patty_kiss_tnc_info as
      a hack to allow instantiating a KISS TNC-based network interface
      with desired baud and flow control
2024-03-01 00:20:47 -05:00