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; +}