From dfa2ff547abea59ebe6db550cb3af93713c3ae3b Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sun, 23 Aug 2020 00:26:17 -0500 Subject: [PATCH] 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 --- include/patty/ax25/sock.h | 2 ++ src/sock.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/patty/ax25/sock.h b/include/patty/ax25/sock.h index 6d1306f..13351c0 100644 --- a/include/patty/ax25/sock.h +++ b/include/patty/ax25/sock.h @@ -200,6 +200,8 @@ void patty_ax25_sock_vs_incr(patty_ax25_sock *sock); void patty_ax25_sock_vr_incr(patty_ax25_sock *sock); +int patty_ax25_sock_flow_left(patty_ax25_sock *sock); + int patty_ax25_sock_flow_full(patty_ax25_sock *sock); /* diff --git a/src/sock.c b/src/sock.c index 1f94bb1..6661ebf 100644 --- a/src/sock.c +++ b/src/sock.c @@ -535,6 +535,14 @@ void *patty_ax25_sock_assembler_read(patty_ax25_sock *sock, return buf + 1; } +int patty_ax25_sock_flow_left(patty_ax25_sock *sock) { + if (sock->n_window_tx == 1) { + return 1; + } + + return sock->vs - tx_seq(sock, sock->va + sock->n_window_tx); +} + int patty_ax25_sock_flow_full(patty_ax25_sock *sock) { /* * 6.4.1 Sending I Frames @@ -644,11 +652,7 @@ error_invalid_type: } static inline uint16_t control_i(patty_ax25_sock *sock, int ns) { - int flag = 0; - - if (sock->vs == tx_seq(sock, sock->va + sock->n_window_tx - 1)) { - flag = 1; - } + int flag = patty_ax25_sock_flow_left(sock) == 1? 1: 0; switch (sock->mode) { case PATTY_AX25_SOCK_SABM: