diff --git a/src/server.c b/src/server.c index 1379a0d..bc45229 100644 --- a/src/server.c +++ b/src/server.c @@ -1337,13 +1337,18 @@ reply_dm: static int handle_rej(patty_ax25_server *server, patty_ax25_sock *sock, patty_ax25_frame *frame) { - unsigned int i; + unsigned int i, + end = sock->seq_send; if (sock == NULL) { return 0; } - for (i=frame->nr; iseq_send; i++) { + if (frame->nr > end) { + end += (sock->mode == PATTY_AX25_SOCK_SABME)? 128: 8; + } + + for (i=frame->nr; in_window_tx * tx_slot_size(sock); } -static inline void *tx_slot(patty_ax25_sock *sock, size_t i) { - return (void *)((uint8_t *)sock->tx_slots + (i * tx_slot_size(sock))); +static inline void *tx_slot(patty_ax25_sock *sock, size_t seq) { + size_t win = sock->n_window_tx, + i = seq % win; + + return (uint8_t *)sock->tx_slots + (i * tx_slot_size(sock)); } static int init_bufs(patty_ax25_sock *sock) {