From 04176659ec1be3f0e1eb4d2de2a90af255ed29ba Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Wed, 5 Aug 2020 22:53:26 -0400 Subject: [PATCH] Allow changing socket ack timer with setsockopt() Allow changing socket ack timer with patty_client_setsockopt() --- include/patty/ax25/sock.h | 2 ++ include/patty/client.h | 2 ++ src/server.c | 7 +++++-- src/sock.c | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/patty/ax25/sock.h b/include/patty/ax25/sock.h index 68bf94f..05ebf92 100644 --- a/include/patty/ax25/sock.h +++ b/include/patty/ax25/sock.h @@ -130,6 +130,8 @@ void patty_ax25_sock_reset(patty_ax25_sock *sock); void patty_ax25_sock_mtu_set(patty_ax25_sock *sock, size_t mtu); +void patty_ax25_sock_ack_set(patty_ax25_sock *sock, time_t ack); + void patty_ax25_sock_window_set(patty_ax25_sock *sock, size_t window); void patty_ax25_sock_params_upgrade(patty_ax25_sock *sock); diff --git a/include/patty/client.h b/include/patty/client.h index 8a3d948..1a8bccd 100644 --- a/include/patty/client.h +++ b/include/patty/client.h @@ -59,6 +59,8 @@ typedef struct _patty_client_setsockopt_request { typedef struct _patty_client_setsockopt_params { size_t mtu, window; + + time_t ack; } patty_client_setsockopt_params; typedef struct _patty_client_setsockopt_if { diff --git a/src/server.c b/src/server.c index 19ee9ac..5667fb3 100644 --- a/src/server.c +++ b/src/server.c @@ -599,9 +599,12 @@ static int server_setsockopt(patty_ax25_server *server, if (data.mtu) patty_ax25_sock_mtu_set(sock, data.mtu); if (data.window) patty_ax25_sock_window_set(sock, data.window); + if (data.ack) patty_ax25_sock_ack_set(sock, data.ack); - if (patty_ax25_sock_realloc_bufs(sock) < 0) { - goto error_realloc_bufs; + if (data.mtu || data.window) { + if (patty_ax25_sock_realloc_bufs(sock) < 0) { + goto error_realloc_bufs; + } } break; diff --git a/src/sock.c b/src/sock.c index 0bf35c5..db6fd27 100644 --- a/src/sock.c +++ b/src/sock.c @@ -231,6 +231,10 @@ void patty_ax25_sock_mtu_set(patty_ax25_sock *sock, size_t mtu) { sock->n_maxlen_tx = mtu; } +void patty_ax25_sock_ack_set(patty_ax25_sock *sock, time_t ack) { + sock->n_ack = (time_t)ack; +} + void patty_ax25_sock_window_set(patty_ax25_sock *sock, size_t window) { sock->n_window_tx = window; }