summaryrefslogtreecommitdiff
path: root/libndp/libndp.c
diff options
context:
space:
mode:
Diffstat (limited to 'libndp/libndp.c')
-rw-r--r--libndp/libndp.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libndp/libndp.c b/libndp/libndp.c
index 661c729..1b38907 100644
--- a/libndp/libndp.c
+++ b/libndp/libndp.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <ctype.h>
#include <sys/socket.h>
+#include <sys/select.h>
#include <netinet/in.h>
#include <netinet/icmp6.h>
#include <arpa/inet.h>
@@ -1697,6 +1698,39 @@ int ndp_call_eventfd_handler(struct ndp *ndp)
return ndp_sock_recv(ndp);
}
+/**
+ * ndp_callall_eventfd_handler:
+ * @ndp: libndp library context
+ *
+ * Call all pending events on eventfd handler.
+ *
+ * Returns: zero on success or negative number in case of an error.
+ **/
+NDP_EXPORT
+int ndp_callall_eventfd_handler(struct ndp *ndp)
+{
+ fd_set rfds;
+ int fdmax;
+ struct timeval tv;
+ int fd = ndp_get_eventfd(ndp);
+ int ret;
+ int err;
+
+ memset(&tv, 0, sizeof(tv));
+ FD_ZERO(&rfds);
+ FD_SET(fd, &rfds);
+ fdmax = fd + 1;
+ while (true) {
+ ret = select(fdmax, &rfds, NULL, NULL, &tv);
+ if (ret == -1)
+ return -errno;
+ if (!FD_ISSET(fd, &rfds))
+ return 0;
+ err = ndp_call_eventfd_handler(ndp);
+ if (err)
+ return err;
+ }
+}
/**
* SECTION: Exported context functions