From c17abcf77a1866ea6f25f0a4ba05c18d94033b02 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 25 Jul 2015 14:47:57 -0500 Subject: [PATCH] Implement patty_ax25_socket() --- src/ax25.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/ax25.c b/src/ax25.c index 47843da..4fdf85a 100644 --- a/src/ax25.c +++ b/src/ax25.c @@ -65,3 +65,25 @@ error_dict_set: error_get_if: return -1; } + +int patty_ax25_socket(patty_ax25 *ax25) { + patty_ax25_sock *sock; + + if ((sock = malloc(sizeof(*sock))) == NULL) { + goto error_malloc_sock; + } + + memset(sock, '\0', sizeof(*sock)); + + if (patty_dict_set(ax25->fd_lookup, &ax25->fd, sizeof(ax25->fd), sock) == NULL) { + goto error_dict_set; + } + + return ax25->fd++; + +error_dict_set: + free(sock); + +error_malloc_sock: + return -1; +}