2015-07-21 21:49:53 +00:00
|
|
|
#include <stdio.h>
|
2015-07-20 23:21:45 -05:00
|
|
|
#include <stdlib.h>
|
2015-07-20 22:33:59 -05:00
|
|
|
#include <string.h>
|
2015-07-20 23:21:45 -05:00
|
|
|
#include <errno.h>
|
2015-07-20 22:33:59 -05:00
|
|
|
|
|
|
|
#include <patty/ax25.h>
|
|
|
|
|
|
|
|
int patty_ax25_init(patty_ax25 *ax25) {
|
|
|
|
memset(ax25, '\0', sizeof(*ax25));
|
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
if ((ax25->ifaces = patty_list_new()) == NULL) {
|
|
|
|
goto error_list_new_ifaces;
|
2015-07-20 22:33:59 -05:00
|
|
|
}
|
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
if ((ax25->ports = patty_list_new()) == NULL) {
|
|
|
|
goto error_list_new_ports;
|
2015-07-20 22:33:59 -05:00
|
|
|
}
|
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
if ((ax25->links = patty_list_new()) == NULL) {
|
|
|
|
goto error_list_new_links;
|
2015-07-20 22:33:59 -05:00
|
|
|
}
|
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
if ((ax25->fd_lookup = patty_dict_new()) == NULL) {
|
|
|
|
goto error_dict_new_fd_lookup;
|
2015-07-21 21:49:53 +00:00
|
|
|
}
|
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
ax25->fd = 0;
|
2015-07-21 21:49:53 +00:00
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
return 0;
|
2015-07-21 21:49:53 +00:00
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
error_dict_new_fd_lookup:
|
|
|
|
patty_list_destroy(ax25->links);
|
2015-07-21 21:49:53 +00:00
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
error_list_new_links:
|
|
|
|
patty_list_destroy(ax25->ports);
|
2015-07-21 21:49:53 +00:00
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
error_list_new_ports:
|
|
|
|
patty_list_destroy(ax25->ifaces);
|
2015-07-21 21:49:53 +00:00
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
error_list_new_ifaces:
|
|
|
|
return -1;
|
2015-07-21 21:49:53 +00:00
|
|
|
}
|
2015-07-21 23:01:49 -05:00
|
|
|
|
2015-07-24 21:34:11 -05:00
|
|
|
void patty_ax25_stop(patty_ax25 *ax25) {
|
|
|
|
patty_dict_destroy(ax25->fd_lookup);
|
|
|
|
patty_list_destroy(ax25->links);
|
|
|
|
patty_list_destroy(ax25->ports);
|
|
|
|
patty_list_destroy(ax25->ifaces);
|
2015-07-21 23:01:49 -05:00
|
|
|
}
|