diff --git a/include/patty/ax25.h b/include/patty/ax25.h index 8f8239a..37dcd55 100644 --- a/include/patty/ax25.h +++ b/include/patty/ax25.h @@ -59,6 +59,8 @@ struct _patty_ax25 { patty_list * ifaces; patty_list * socks; + fd_set unix_fds; + patty_dict * fd_lookup; int fd; }; diff --git a/include/patty/ax25/if.h b/include/patty/ax25/if.h index f3df5ea..09cd200 100644 --- a/include/patty/ax25/if.h +++ b/include/patty/ax25/if.h @@ -34,8 +34,6 @@ patty_ax25_if *patty_ax25_if_create(int opts, void *info); void patty_ax25_if_destroy(patty_ax25_if *iface); -patty_kiss_tnc *patty_ax25_if_tnc(patty_ax25_if *iface); - int patty_ax25_if_each_address(patty_ax25_if *iface, int (*callback)(patty_ax25_address *, void *), void *ctx); diff --git a/src/ax25.c b/src/ax25.c index 1d8465b..664c4f0 100644 --- a/src/ax25.c +++ b/src/ax25.c @@ -188,47 +188,6 @@ error_fd_lookup: return -1; } -static int event_fd_set(patty_ax25 *ax25, fd_set *set) { - patty_list_iterator *ifaces; - patty_ax25_if *iface; - - FD_ZERO(set); - - if ((ifaces = patty_list_start(ax25->ifaces)) == NULL) { - goto error_list_start; - } - - while ((iface = patty_list_next(ifaces)) != NULL) { - patty_kiss_tnc *tnc; - int fd; - - if ((tnc = patty_ax25_if_tnc(iface)) == NULL) { - goto error_if_tnc; - } - - if ((fd = patty_kiss_tnc_fd_unix(tnc)) < 0) { - goto error_kiss_tnc_fd_unix; - } - - FD_SET(fd, set); - } - - patty_list_finish(ifaces); - - return 0; - -error_kiss_tnc_fd_unix: -error_if_tnc: - patty_list_finish(ifaces); - -error_list_start: - return -1; -} - int patty_ax25_next_event(patty_ax25 *ax25, enum patty_ax25_event *ev) { - fd_set fds; - - event_fd_set(ax25, &fds); - return 0; } diff --git a/src/if.c b/src/if.c index 0d32d3c..486da4d 100644 --- a/src/if.c +++ b/src/if.c @@ -79,10 +79,6 @@ void patty_ax25_if_destroy(patty_ax25_if *iface) { } } -patty_kiss_tnc *patty_ax25_if_tnc(patty_ax25_if *iface) { - return iface->tnc; -} - int patty_ax25_if_each_address(patty_ax25_if *iface, int (*callback)(patty_ax25_address *, void *), void *ctx) { patty_list_iterator *iter; patty_ax25_address *address; @@ -240,13 +236,22 @@ error_list_start: } int patty_ax25_add_if(patty_ax25 *ax25, patty_ax25_if *iface) { + int fd; + + if ((fd = patty_kiss_tnc_fd_unix(iface->tnc)) < 0) { + goto error_kiss_tnc_fd_unix; + } + if (patty_list_append(ax25->ifaces, iface) == NULL) { goto error_list_append; } + FD_SET(fd, &ax25->unix_fds); + return 0; error_list_append: +error_kiss_tnc_fd_unix: return -1; }