Implement patty_ax25_socket()

This commit is contained in:
XANTRONIX Development 2015-07-25 14:47:57 -05:00 committed by XANTRONIX Industrial
parent 87ec27dd92
commit c17abcf77a

View file

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