(Re)implement patty_ax25_sock_reset()

Begin to reimplement patty_ax25_sock_reset() to follow the AX.25 v2.2
Specification, Section 6.5 "Resetting Procedure" indications to set V(S)
and V(R) to 0
This commit is contained in:
XANTRONIX Development 2020-07-26 02:37:17 -04:00 committed by XANTRONIX Industrial
parent df7c0fad38
commit 0aea65487a
3 changed files with 14 additions and 2 deletions

View file

@ -96,6 +96,8 @@ 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_reset(patty_ax25_sock *sock);
int patty_ax25_sock_upgrade(patty_ax25_sock *sock, int patty_ax25_sock_upgrade(patty_ax25_sock *sock,
enum patty_ax25_version version); enum patty_ax25_version version);

View file

@ -1275,7 +1275,7 @@ static int handle_dm(patty_ax25_server *server,
goto error_client_by_sock; goto error_client_by_sock;
} }
patty_ax25_sock_init(sock); patty_ax25_sock_reset(sock);
return respond_connect(client, -1, ECONNREFUSED); return respond_connect(client, -1, ECONNREFUSED);
@ -1423,7 +1423,7 @@ static int handle_xid(patty_ax25_server *server,
goto error_client_by_sock; goto error_client_by_sock;
} }
patty_ax25_sock_init(remote); patty_ax25_sock_reset(remote);
return respond_connect(client, -1, errno); return respond_connect(client, -1, errno);
} }

View file

@ -176,6 +176,16 @@ void patty_ax25_sock_destroy(patty_ax25_sock *sock) {
free(sock); free(sock);
} }
/*
* AX.25 v2.2 Specification, Section 6.5 "Resetting Procedure"
*/
int patty_ax25_sock_reset(patty_ax25_sock *sock) {
sock->seq_send = 0;
sock->seq_recv = 0;
return 0;
}
int patty_ax25_sock_upgrade(patty_ax25_sock *sock, int patty_ax25_sock_upgrade(patty_ax25_sock *sock,
enum patty_ax25_version version) { enum patty_ax25_version version) {
if (sock->version >= version) { if (sock->version >= version) {