Rename timers to their documented T1, T2, T3 names

This commit is contained in:
XANTRONIX Development 2020-07-29 00:22:51 -04:00 committed by XANTRONIX Industrial
parent 8632e7ccb8
commit 1060ff6ab8
3 changed files with 34 additions and 40 deletions

View file

@ -62,9 +62,9 @@ typedef struct _patty_ax25_sock {
n_ack, n_ack,
n_retry; n_retry;
struct timeval timer_ack, /* Timer T1 */ struct timeval timer_t1,
timer_response, timer_t2,
timer_keepalive; timer_t3;
uint32_t flags_classes, uint32_t flags_classes,
flags_hdlc; flags_hdlc;
@ -98,15 +98,15 @@ patty_ax25_sock *patty_ax25_sock_new(enum patty_ax25_proto proto,
void patty_ax25_sock_destroy(patty_ax25_sock *sock); void patty_ax25_sock_destroy(patty_ax25_sock *sock);
int patty_ax25_sock_timer_ack_expired(patty_ax25_sock *sock); int patty_ax25_sock_timer_t1_expired(patty_ax25_sock *sock);
void patty_ax25_sock_timer_ack_cancel(patty_ax25_sock *sock); void patty_ax25_sock_timer_t1_cancel(patty_ax25_sock *sock);
void patty_ax25_sock_timer_ack_start(patty_ax25_sock *sock, void patty_ax25_sock_timer_t1_start(patty_ax25_sock *sock,
struct timeval *timer); struct timeval *timer);
void patty_ax25_sock_timer_ack_sub(patty_ax25_sock *sock, void patty_ax25_sock_timer_t1_sub(patty_ax25_sock *sock,
struct timeval *elapsed); struct timeval *elapsed);
int patty_ax25_sock_reset(patty_ax25_sock *sock); int patty_ax25_sock_reset(patty_ax25_sock *sock);

View file

@ -829,7 +829,7 @@ static int server_connect(patty_ax25_server *server,
return respond_connect(client, -1, errno); return respond_connect(client, -1, errno);
} }
patty_ax25_sock_timer_ack_start(sock, &server->timer); patty_ax25_sock_timer_t1_start(sock, &server->timer);
/* /*
* At this point, we will wait for a DM, FRMR or XID response, which * At this point, we will wait for a DM, FRMR or XID response, which
@ -1152,7 +1152,7 @@ static int handle_frmr(patty_ax25_server *server,
if (sock->status == PATTY_AX25_SOCK_PENDING_CONNECT) { if (sock->status == PATTY_AX25_SOCK_PENDING_CONNECT) {
int ret = patty_ax25_sock_send_sabm(sock, PATTY_AX25_FRAME_POLL); int ret = patty_ax25_sock_send_sabm(sock, PATTY_AX25_FRAME_POLL);
patty_ax25_sock_timer_ack_start(sock, &server->timer); patty_ax25_sock_timer_t1_start(sock, &server->timer);
return ret; return ret;
} }
@ -1250,7 +1250,7 @@ static int handle_ua(patty_ax25_server *server,
return reply_dm(iface, frame, PATTY_AX25_FRAME_FINAL); return reply_dm(iface, frame, PATTY_AX25_FRAME_FINAL);
} }
patty_ax25_sock_timer_ack_cancel(sock); patty_ax25_sock_timer_t1_cancel(sock);
sock->status = PATTY_AX25_SOCK_ESTABLISHED; sock->status = PATTY_AX25_SOCK_ESTABLISHED;
@ -1452,7 +1452,7 @@ static int handle_xid(patty_ax25_server *server,
ret = patty_ax25_sock_send_sabm(remote, PATTY_AX25_FRAME_POLL); ret = patty_ax25_sock_send_sabm(remote, PATTY_AX25_FRAME_POLL);
patty_ax25_sock_timer_ack_start(remote, &server->timer); patty_ax25_sock_timer_t1_start(remote, &server->timer);
return ret; return ret;
} }
@ -1629,11 +1629,11 @@ static int handle_sock(uint32_t key,
ssize_t len; ssize_t len;
if (sock->status == PATTY_AX25_SOCK_PENDING_CONNECT) { if (sock->status == PATTY_AX25_SOCK_PENDING_CONNECT) {
if (patty_ax25_sock_timer_ack_expired(sock)) { if (patty_ax25_sock_timer_t1_expired(sock)) {
if (sock->retries) { if (sock->retries) {
int ret = patty_ax25_sock_send_sabm(sock, PATTY_AX25_FRAME_POLL); int ret = patty_ax25_sock_send_sabm(sock, PATTY_AX25_FRAME_POLL);
patty_ax25_sock_timer_ack_start(sock, &server->timer); patty_ax25_sock_timer_t1_start(sock, &server->timer);
return ret; return ret;
} else { } else {
@ -1642,7 +1642,7 @@ static int handle_sock(uint32_t key,
return sock_close(server, sock); return sock_close(server, sock);
} }
} else { } else {
patty_ax25_sock_timer_ack_sub(sock, &server->elapsed); patty_ax25_sock_timer_t1_sub(sock, &server->elapsed);
} }
goto done; goto done;

View file

@ -116,12 +116,6 @@ void patty_ax25_sock_init(patty_ax25_sock *sock) {
sock->n_window_rx = PATTY_AX25_SOCK_DEFAULT_WINDOW; sock->n_window_rx = PATTY_AX25_SOCK_DEFAULT_WINDOW;
sock->n_ack = PATTY_AX25_SOCK_DEFAULT_ACK; sock->n_ack = PATTY_AX25_SOCK_DEFAULT_ACK;
sock->n_retry = PATTY_AX25_SOCK_DEFAULT_RETRY; sock->n_retry = PATTY_AX25_SOCK_DEFAULT_RETRY;
sock->seq_send = 0;
sock->seq_recv = 0;
timerclear(&sock->timer_ack);
timerclear(&sock->timer_response);
timerclear(&sock->timer_keepalive);
} }
patty_ax25_sock *patty_ax25_sock_new(enum patty_ax25_proto proto, patty_ax25_sock *patty_ax25_sock_new(enum patty_ax25_proto proto,
@ -179,39 +173,39 @@ void patty_ax25_sock_destroy(patty_ax25_sock *sock) {
free(sock); free(sock);
} }
int patty_ax25_sock_timer_ack_expired(patty_ax25_sock *sock) { int patty_ax25_sock_timer_t1_expired(patty_ax25_sock *sock) {
return (sock->timer_ack.tv_sec <= 0 && sock->timer_ack.tv_usec == 0)? 1: 0; return (sock->timer_t1.tv_sec <= 0 && sock->timer_t1.tv_usec == 0)? 1: 0;
} }
void patty_ax25_sock_timer_ack_cancel(patty_ax25_sock *sock) { void patty_ax25_sock_timer_t1_cancel(patty_ax25_sock *sock) {
sock->timer_ack.tv_sec = 0; sock->timer_t1.tv_sec = 0;
sock->timer_ack.tv_usec = 0; sock->timer_t1.tv_usec = 0;
} }
/* /*
* AX.25 v2.2 Specification, Section 6.3.1 "AX.25 Link Connection Establishment" * AX.25 v2.2 Specification, Section 6.3.1 "AX.25 Link Connection Establishment"
*/ */
void patty_ax25_sock_timer_ack_start(patty_ax25_sock *sock, void patty_ax25_sock_timer_t1_start(patty_ax25_sock *sock,
struct timeval *timer) { struct timeval *timer) {
sock->timer_ack.tv_sec = sock->n_ack / 1000; sock->timer_t1.tv_sec = sock->n_ack / 1000;
sock->timer_ack.tv_usec = (sock->n_ack % 1000) * 1000; sock->timer_t1.tv_usec = (sock->n_ack % 1000) * 1000;
if (timercmp(&sock->timer_ack, timer, >)) { if (timercmp(&sock->timer_t1, timer, >)) {
struct timeval res; struct timeval res;
timeradd(timer, &sock->timer_ack, &res); timeradd(timer, &sock->timer_t1, &res);
memcpy(timer, &res, sizeof(*timer)); memcpy(timer, &res, sizeof(*timer));
} }
} }
void patty_ax25_sock_timer_ack_sub(patty_ax25_sock *sock, void patty_ax25_sock_timer_t1_sub(patty_ax25_sock *sock,
struct timeval *elapsed) { struct timeval *elapsed) {
struct timeval res; struct timeval res;
timersub(&sock->timer_ack, elapsed, &res); timersub(&sock->timer_t1, elapsed, &res);
memcpy(&sock->timer_ack, &res, sizeof(sock->timer_ack)); memcpy(&sock->timer_t1, &res, sizeof(sock->timer_t1));
} }
/* /*
@ -222,9 +216,9 @@ int patty_ax25_sock_reset(patty_ax25_sock *sock) {
sock->seq_recv = 0; sock->seq_recv = 0;
sock->retries = sock->n_retry; sock->retries = sock->n_retry;
memset(&sock->timer_ack, '\0', sizeof(sock->timer_ack)); timerclear(&sock->timer_t1);
memset(&sock->timer_response, '\0', sizeof(sock->timer_response)); timerclear(&sock->timer_t2);
memset(&sock->timer_keepalive, '\0', sizeof(sock->timer_keepalive)); timerclear(&sock->timer_t3);
return 0; return 0;
} }