Commit graph

563 commits

Author SHA1 Message Date
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
0fecccd7c3 Missed a spot with patty_ax25_pton() fix 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
5edb889471 Use tcflush() before tcsetattr() in src/kiss.c 2024-03-01 00:20:47 -05:00
XANTRONIX Development
6bb71a37ff Fix segfault in patty_ax25_if_addr_match() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
fb982742f5 Use tx_slots() inline function in src/sock.c 2024-03-01 00:20:47 -05:00
XANTRONIX Development
44ec0040a8 Use Timer T1 retry counter for DISC sequence 2024-03-01 00:20:47 -05:00
XANTRONIX Development
aff5eabff3 More concise 2024-03-01 00:20:47 -05:00
XANTRONIX Development
c04fb3c845 Reset retries when acking pending I frames 2024-03-01 00:20:47 -05:00
XANTRONIX Development
b360d7fc23 Send unacked I frame or RR on Timer T1 expiry 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
5a61a3057a Slight lines-of-code reduction
Slight lines-of-code reduction without any functional changes
2024-03-01 00:20:47 -05:00
XANTRONIX Development
fcef17a8b1 Better management of Timers T1 and T3
Changes:

    * Ensure Timer T1 is stopped when Timer T3 is active

    * Ensure Timer T1 is started when an acknowledgement from the peer
      does not acknowledge all I frames previously sent
2024-03-01 00:20:47 -05:00
XANTRONIX Development
25f2a0abe9 Make patty_ax25_sock_ack() return 1 if N(R) = V(A)
Make patty_ax25_sock_ack() return 1 if N(R) = V(A), to provide a
convenient means of verifying that an acknowledgement from the peer is
at least valid for current sequence variables, even if no new frames are
acknowledged; patty_ax25_sock_ack_pending() can always be used to
determine when frames are still pending acknowledgement
2024-03-01 00:20:47 -05:00
XANTRONIX Development
582c7f04d6 Don't stop Timer T3 only when stopping I transmit 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
ec9066167b Stop flow before sending last I frame in window
Stop flow before sending last I frame in window; furthermore, this last
I frame will have the P/F flag set to 1, to implicitly request a RR, RNR
or REJ response as appropriate
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
df9efb8b3a Start Timer T3 when starting Timer T1 after expiry
Start Timer T3 when starting Timer T1 after expiry, to avoid a situation
wherein two RR command polling frames may be sent within close proximity
of one another
2024-03-01 00:20:47 -05:00
XANTRONIX Development
99a48af087 Stop Timer T2 when sending RR on k/2 unacked
When handling I frames, stop Timer T2 if the number of unacknowledged
frames has reached k/2

Other changes:

    * Provide annotations from the AX.25 v2.2 standards document

    * Improve implementation of I frame reception P/F procedure
2024-03-01 00:20:47 -05:00
XANTRONIX Development
3b1e341851 Fix switch case fallthrough bugs in src/server.c
Fix switch case fallthrough bugs in src/server.c in the following
functions:

    * handle_rr()

    * handle_rnr()

    * handle_rej()
2024-03-01 00:20:47 -05:00
XANTRONIX Development
c6af57b245 Only set P/F flag on I frames when window is hit
Changes:

    * In src/sock.c, inline function control_i(), only set the P/F flag
      when the window of the peer has just received up to its window
2024-03-01 00:20:47 -05:00
XANTRONIX Development
b619fffb32 Always send RR when Timer T3 runs out
Always send RR when Timer T3 runs out, as we are not likely (with modern
hardware with MMUs) to be unable to receive; furthermore, RNR would have
only been sent erroneously if the outward flow of traffic had been
stopped
2024-03-01 00:20:47 -05:00
XANTRONIX Development
609a7271e5 Minor formatting tweaks for searchability 2024-03-01 00:20:47 -05:00
XANTRONIX Development
d88e8512b8 Adhere to P/F procedure on I frames 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
f41ce994f4 Make patty_ax25_sock_resend() send with V(R)
Changes:

    * Make TX slots only large enough to hold the info field of an I
      frame; do not save header information

    * Fix issue wherein patty_ax25_sock_resend() would resend the N(R)
      value of an I frame as it was originally sent, even if this is
      incorrect for a given situation

    * Make control_i() in src/sock.c accept a V(S) sequence argument, as
      this can sometimes be independent of the socket current V(S) value

    * Declare control field functions as inline in src/sock.c
2024-03-01 00:20:47 -05:00
XANTRONIX Development
3db8c9cef3 Better handling, response to FRMR, SABM, and SABME
Changes:

    * Use patty_ax25_sock_reset() when receiving a FRMR, SABM, or SABME
      frame

    * Reply to an SABM or SABME frame with a UA when received by an
      ESTABLISHED socket
2024-03-01 00:20:47 -05:00
XANTRONIX Development
645e2a465f Reset Timer T1, TX slots w/patty_ax25_sock_reset()
Make patty_ax25_sock_reset() reset Timer T1 and zero out the len and ack
fields of each TX slot
2024-03-01 00:20:47 -05:00
XANTRONIX Development
56b8b90727 Minor code deduplication in src/sock.c
Minor code deduplication in src/sock.c for handling SABM vs SABME
sequence numbers
2024-03-01 00:20:47 -05:00
XANTRONIX Development
697ade0afa Reset socket retry counter for each frame acked 2024-03-01 00:20:47 -05:00
XANTRONIX Development
06ddf1bbaf Fix uninintialized frame ack field
Fix uninintialized frame ack field when initializing TX slots
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
6e8099b6ae Add .gitignore 2024-03-01 00:20:47 -05:00
XANTRONIX Development
cd943f5c9c Minor syntax change, patty_ax25_sock_ack_pending() 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
e34713c766 Send the right rejection packets 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
301e58c6e9 Send RR Response, not Command, on Timer T2 timeout 2024-03-01 00:20:47 -05:00
XANTRONIX Development
4d84ed183e Adhere better to P/F bit procedure for I frames 2024-03-01 00:20:47 -05:00
XANTRONIX Development
6027a71e28 Use O_NOCTTY in patty_kiss_tnc_open() 2024-03-01 00:20:47 -05:00
XANTRONIX Development
d43d24a934 Poll with RR when V(S) = V(A) + k 2024-03-01 00:20:47 -05:00
XANTRONIX Development
a5d74ecf2e Initial flow control improvements 2024-03-01 00:20:47 -05:00