Commit graph

248 commits

Author SHA1 Message Date
XANTRONIX Development
4fb64760b6 Change names of sock, PID file #defines
Change names of sock, PID file #defines in include/patty/daemon.h
2024-03-01 00:20:47 -05:00
XANTRONIX Development
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
XANTRONIX Development
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
XANTRONIX Development
7415ef8573 Add arg names to functions in patty/ax25/aprs_is.h 2024-03-01 00:20:47 -05:00
XANTRONIX Development
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
XANTRONIX Development
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
XANTRONIX Development
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
XANTRONIX Development
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
XANTRONIX Development
50d0af3f35 Remove unused patty_ax25_sock_recv_pending() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
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
XANTRONIX Development
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
XANTRONIX Development
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
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
9709cef6dc Fix patty_client_socket_response struct name 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
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
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
77bb1bf030 s/PATTY_AX25_CALLSIGN_LEN/PATTY_AX25_CALLSTRLEN/g 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
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
30b17d337b Fix #include cycle in include/patty/kiss/tnc.h 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
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
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
XANTRONIX Development
9734c97f35 Implement src/daemon.c
Implement src/daemon.c to provide a high level method to instantiate a
patty server

Changes:

    * Refactor src/server.c, src/route.c, src/if.c methods which accept
      callsign arguments to use a patty_ax25_addr pointer instead; this
      has significantly reduced the number of redundant calls to
      patty_ax25_pton()

    * Decouple patty_ax25_addr from patty_ax25_if_info types when
      creating new interfaces with patty_ax25_if_new(); instead, take a
      separate patty_ax25_addr argument

    * Split patty_ax25_server_run() into the following methods:

          - patty_ax25_server_start()
          - patty_ax25_server_stop()
          - patty_ax25_server_event_handle()

      This is intended to allow possible integration into other event
      loops.

    * Implement src/daemon.c to allow quick instantiation of a server,
      interfaces, and routes, and to encapsulate the setting of
      configuration variables; callsigns and interface names are handled
      as character strings

    * Rename examples/server.c to examples/daemon.c; reimplement in
      terms of the patty_daemon code

    *
2024-03-01 00:20:47 -05:00
XANTRONIX Development
116bf788d5 Implement patty_client_ping()
Implement patty_client_ping() to provide a means of testing if a client
connection is still active
2024-03-01 00:20:47 -05:00
XANTRONIX Development
2e360976bf Rename patty_ax25_sock.rx_buf to io_buf
Rename patty_ax25_sock.rx_buf to io_buf, as the buffer is not used for
receiving frames from an interface, but rather from reading local data
to write to a remote peer

Other changes:

    * Fix issue wherein patty_ax25_sock.n_maxlen_tx was not used for
      reading local data when sending I frames
2024-03-01 00:20:47 -05:00
XANTRONIX Development
5ccd2efbda Rearrange patty_ax25_sock struct definition
Rearrange patty_ax25_sock struct definition for better readability and
cohesion, and for the sake of future documentation
2024-03-01 00:20:47 -05:00
XANTRONIX Development
826653f0d9 Remove unused patty_ax25_sock_flow_full()
Remove unused patty_ax25_sock_flow_full(), in favor of the previously
implemented patty_ax25_sock_flow_left(), as a better means of
determining what flow control measures to take and how to interrogate
the peer for readiness to receive with minimal overhead
2024-03-01 00:20:47 -05:00
XANTRONIX Development
dfa2ff547a Implement patty_ax25_sock_flow_left()
Implement patty_ax25_sock_flow_left() as a means to determine how many
I frames a peer may receive; this can be used to determine when to set
the P/F bit of outgoing I frames to implicitly require an RR or RNR
acknowledgement
2024-03-01 00:20:47 -05:00
XANTRONIX Development
bdbab9c5e7 Disregard TEST, UA and XID not addressed to iface 2024-03-01 00:20:47 -05:00
XANTRONIX Development
222e51100e Implement SSID suffix stringes in pton()/ntop()
Implement SSID suffix stringes in pton()/ntop() to make it more
straightforward to specify addresses to bind, connect to, or add routes
for

Changes:

    * Implement SSID suffix string formatting in patty_ax25_ntop(); drop
      the 'ssid' pointer argument

    * Implement SSID suffix string parsing in patty_ax25_pton(); drop
      the 'ssid' argument

    * Change all calls to patty_ax25_ntop() and patty_ax25_pton() to use
      their new calling convention
2024-03-01 00:20:47 -05:00
XANTRONIX Development
484981de34 Implement better frame ack strategy
Implement AX.25 v2.2, Section 6.4.6 "Receiving Acknowledgement"
semantics more consistently

Changes:

    * Add frame_ack() method in src/server.c to unify logic for
      acknowledging frames and handling I frame transmission flow
      control

    * Ensure that the Timer T1 retry counter is reset as appropriate
      when Timer T1 is restarted

    * Add excerpts from the AX.25 v2.2 documentation to accompanying
      code to better document the purpose of important aspects of the
      state machine and protocol

    * When receiving an S frame with N(R) acknowledgement of a frame
      sent earlier than indicated by V(S), set V(S) to that N(R) value

    * Implement patty_ax25_sock_resend_pending() as a means to resend
      one frame previously sent which remains unacknowledged; this
      uses V(S) to determine the frame to resend, and increments V(S) if
      there was indeed an unacknowledged frame

    * Call patty_ax25_sock_resend_pending() in src/server.c, method
      handle_sock() to send a single frame previously sent but pending
      acknowledgement
2024-03-01 00:20:47 -05:00
XANTRONIX Development
1fd1be2cb6 Improvements to patty_ax25_sock_ack()
Changes:

    * Make patty_ax25_sock_ack() take a N(R) argument directly, rather
      than having the caller specify N(R)-1

    * Only perform acknowledgement of frames within the range between
      V(A) and N(R)-1
2024-03-01 00:20:47 -05:00
XANTRONIX Development
1819b7fb34 Rename patty_ax25_sock 'pending' to 'rx_pending'
Rename patty_ax25_sock 'pending' to 'rx_pending' to better document its
purpose
2024-03-01 00:20:47 -05:00
XANTRONIX Development
972b04c95f Slight rearrangement 2024-03-01 00:20:47 -05:00
XANTRONIX Development
0fb7d08872 Implement patty_timer_init()
Implement patty_timer_init() to allow the caller to specify a timer
value to use each time patty_timer_start() is called, obviating the need
to pass the same argument redundantly; if the timer value must be
changed, then another call to patty_timer_init() may be used
2024-03-01 00:20:47 -05:00
XANTRONIX Development
4577b5f223 More WIP; please kill me 2024-03-01 00:20:47 -05:00
XANTRONIX Development
f26e977bfc Implement patty_ax25_sock_ack()
Implement patty_ax25_sock_ack() to keep track of I frames sent which
have been successfully acknowledged by a peer
2024-03-01 00:20:47 -05:00
XANTRONIX Development
a5d74ecf2e Initial flow control improvements 2024-03-01 00:20:47 -05:00
XANTRONIX Development
776949b90c Implement frame segmentation/reassembly
Implement frame segmentation/reassembly state machine as per AX.25 v2.2
specifications, as per Section 6.6 "Disassembler/Reassembler" and
associated appendices
2024-03-01 00:20:47 -05:00
XANTRONIX Development
37a03a15c7 Reduced default I frame body to 127 bytes
Reduced default I frame info field to 127 bytes so as to hopefully
better coincide with common TNC firmware; it is suspected (but not
confirmed that they do include the protocol identifier as part of the
info field length
2024-03-01 00:20:47 -05:00
XANTRONIX Development
a5fe9be054 Add comments to include/ax25/sock.h functions
Add comments to include/ax25/sock.h functions to improve readability
2024-03-01 00:20:47 -05:00
XANTRONIX Development
004d5c9ec6 Use default I frame lengths for common TNCs
Use default I frame lengths for common TNCs per version; for AX.25
prior to 2.2, use 128, otherwise, use 255, the maximum for Kenwood and
possibly other Kantronics-style TNCs
2024-03-01 00:20:47 -05:00
XANTRONIX Development
893ddefd57 Use bit fields for setsockopt() SOCK_OPT_PARAMS 2024-03-01 00:20:47 -05:00