From 548c7149fb1bb1f9b7a050ad1b2858d600a7acf1 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 9 Jun 2020 01:12:59 -0400 Subject: [PATCH] Rework socket calls to use patty_ax25_addr --- include/patty/ax25.h | 6 ++---- src/ax25.c | 18 ++++-------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/include/patty/ax25.h b/include/patty/ax25.h index bdc43cd..d735839 100644 --- a/include/patty/ax25.h +++ b/include/patty/ax25.h @@ -106,16 +106,14 @@ int patty_ax25_socket(patty_ax25 *ax25); int patty_ax25_bind(patty_ax25 *ax25, int socket, - const char *callsign, - uint8_t ssid); + patty_ax25_addr *addr); int patty_ax25_listen(patty_ax25 *ax25, int socket); int patty_ax25_connect(patty_ax25 *ax25, int socket, - const char *callsign, - uint8_t ssid); + patty_ax25_addr *addr); int patty_ax25_accept(patty_ax25 *ax25, int socket); diff --git a/src/ax25.c b/src/ax25.c index 0d3d54a..a57fcb8 100644 --- a/src/ax25.c +++ b/src/ax25.c @@ -294,8 +294,7 @@ error_malloc_sock: int patty_ax25_bind(patty_ax25 *ax25, int socket, - const char *callsign, - uint8_t ssid) { + patty_ax25_addr *addr) { patty_ax25_sock *sock; if ((sock = sock_get_fd(ax25, socket)) == NULL) { @@ -312,13 +311,10 @@ int patty_ax25_bind(patty_ax25 *ax25, goto error_exists; } - if (patty_ax25_pton(callsign, ssid, &sock->local) < 0) { - goto error_pton; - } + memcpy(&sock->local, addr, sizeof(*addr)); return 0; -error_pton: error_exists: error_sock_get_fd: return -1; @@ -349,8 +345,7 @@ error_sock_get_fd: int patty_ax25_connect(patty_ax25 *ax25, int socket, - const char *callsign, - uint8_t ssid) { + patty_ax25_addr *addr) { patty_ax25_sock *sock; if ((sock = sock_get_fd(ax25, socket)) == NULL) { @@ -363,15 +358,10 @@ int patty_ax25_connect(patty_ax25 *ax25, goto error_exists; } - if (patty_ax25_pton(callsign, ssid, &sock->remote) < 0) { - errno = EINVAL; - - goto error_pton; - } + memcpy(&sock->remote, addr, sizeof(*addr)); return 0; -error_pton: error_exists: error_sock_get_fd: return -1;