Commit graph

569 commits

Author SHA1 Message Date
5b59b163d2 Bring interfaces down when an error is encountered
Modify src/server.c to bring interfaces down when an I/O error is
encountered
2024-03-01 00:20:47 -05:00
8e118a3b56 Implement interface statuses in src/if.c
Implement interface statuses in src/if.c to represent interfaces that
are down, up, or in an erroneous condition
2024-03-01 00:20:47 -05:00
6148977adf Fix bug parsing KISS frames not for port 0
Fix bug parsing KISS frames not for port 0 in patty_kiss_tnc_drain();
furthermore, ensure frames are only handled when they are indeed for
port 0
2024-03-01 00:20:47 -05:00
14354337cc Ensure dropped packets are not counted as RXed
Ensure dropped packets are not counted as RXed in the following
interface drivers:

    * src/tnc.c
    * src/aprs_is.c
2024-03-01 00:20:47 -05:00
f127bd2fc2 Track received frames, bytes in src/aprs_is.c 2024-03-01 00:20:47 -05:00
986f329dd7 Track received frames, bytes in src/tnc.c 2024-03-01 00:20:47 -05:00
59fce6bdf9 Track sent frames, bytes in src/aprs_is.c 2024-03-01 00:20:47 -05:00
1e3d919fd5 Track dropped frames in src/aprs_is.c 2024-03-01 00:20:47 -05:00
675e6cf727 Implement patty_ax25_if_addr_set()
Changes:

    * Remove the initial address argument from patty_ax25_if_new()

    * Implement patty_ax25_if_addr_set() to set the AX.25 address of an
      interface at any time
2024-03-01 00:20:47 -05:00
7415ef8573 Add arg names to functions in patty/ax25/aprs_is.h 2024-03-01 00:20:47 -05:00
2b931ec357 Implement patty_ax25_if_ready()
Implement patty_ax25_if_ready() to provide a means of testing an
interface's readiness for performing I/O; this may also be used in the
future for some interface drivers which may require occasional keepalive
timers to maintain a link
2024-03-01 00:20:47 -05:00
4604cccdb4 Rename patty_ax25_sock_assembler_ready()
Rename patty_ax25_sock_assembler_ready() to assembler_pending() to
better fit naming conventions; ready() is meant more for "does this
channel have any I/O readiness conditions", whereas pending() is best
suited for "does this state machine have a frame pending receipt"
2024-03-01 00:20:47 -05:00
80469ac535 Rename patty_ax25_if_ready() to if_pending()
Rename patty_ax25_if_ready() to if_pending() in src/if.c, as well as in
each driver implementing this method and any direct invocations of said
driver methods
2024-03-01 00:20:47 -05:00
b97b927e0c Remove unused patty_ax25_if_pending()
Remove unused patty_ax25_if_pending() from src/if.c, as well as from all
drivers implementing this method
2024-03-01 00:20:47 -05:00
50d0af3f35 Remove unused patty_ax25_sock_recv_pending() 2024-03-01 00:20:47 -05:00
92164908aa Remove declaration of unimplemented method
Remove declaration of unimplemented method from include/patty/kiss/tnc.h
2024-03-01 00:20:47 -05:00
530d2a4555 Add bin/tncd.8 2024-03-01 00:20:47 -05:00
65ae821342 Re-establish broken APRS-IS connections
Re-establish broken APRS-IS connections in src/aprs_is.c; when read() or
write() sets errno to EIO, attempt at most 3 times to re-establish the
APRS-IS connection per read()/write() failure; if the maximum number of
attempts is met, the I/O operation is considered a total failure
2024-03-01 00:20:47 -05:00
88743a5754 Decouple interface names from patty_ax25_if
Changes:

    * Remove interface name argument from patty_ax25_if_new()

    * Add interface name argument to patty_ax25_server_if_add()

    * Add interface name argument to patty_daemon_if_add()

    * In src/server.c, implement 'struct if_entry' to hold the interface
      name, file descriptor, and pointer to a patty_ax25_if object, to
      recouple names to their respective interfaces

    * Add a return argument to patty_bin_if_create() to store a pointer
      to a new interface name created from a declaration
2024-03-01 00:20:47 -05:00
61c17f8026 Skip non-SOCK_STREAM in aprs_is_connect() 2024-03-01 00:20:47 -05:00
fa34ba9e7c Attempt to set raw attributes on new socket PTYs
Attempt to set raw attributes on new socket PTYs to fix an issue on
Linux wherein any data written to a socket before the PTY subordinate
has been opened would be looped back in canonical mode, causing
frame errors; if tcsetattr() fails (usually on a non-Linux platform),
set errno to 0
2024-03-01 00:20:47 -05:00
9dd27b5924 Remove useless expression from patty_client_ping() 2024-03-01 00:20:47 -05:00
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
9f6f775ee4 Simplify handle_sock_raw() in src/server.c 2024-03-01 00:20:47 -05:00
754491b692 Update .gitignore 2024-03-01 00:20:47 -05:00
62f4f2ca7c Improve bin/tncd.c
Changes:

    * Ensure TNC PTYs are closed on error

    * Instead of waiting indefinitely, use patty_client_ping() to poll
      the status of the patty daemon to exit in a timely manner
2024-03-01 00:20:47 -05:00
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
50eaef806d Reset TNC command state on frame end 2024-03-01 00:20:47 -05:00
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
bec778de7b Implement bin/tncd.c
Implement bin/tncd.c to expose a network interface as a KISS TNC device
over a PTY
2024-03-01 00:20:47 -05:00
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
df84f68678 Prevent server dying on invalid client requests 2024-03-01 00:20:47 -05:00
9709cef6dc Fix patty_client_socket_response struct name 2024-03-01 00:20:47 -05:00
84a4815708 Whitespace tweaks 2024-03-01 00:20:47 -05:00
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
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
0b568435e9 Use fflush() after printing pty in bin/pattyd.c 2024-03-01 00:20:47 -05:00
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
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
7172863a1a Close sockets on failure to write, don't die 2024-03-01 00:20:47 -05:00
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
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
78f42b02ea Prevent SSIDs >15 in patty_ax25_pton() 2024-03-01 00:20:47 -05:00
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
c98d07e876 Rename struct members, variables
Rename struct members, variables for better visual appeal
2024-03-01 00:20:47 -05:00
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
34e5629bc9 Use const qualifier in src/frame.c where proper 2024-03-01 00:20:47 -05:00
e40f2ded36 Add error reporting for APRS-IS interface failures 2024-03-01 00:20:47 -05:00
7eca9a09c9 Use patty_error_fmt() for errors in pattyd(8) 2024-03-01 00:20:47 -05:00
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