aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/core/select.h2
-rw-r--r--src/select.c12
2 files changed, 14 insertions, 0 deletions
diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h
index b6b9e82..b9e3b51 100644
--- a/include/osmocom/core/select.h
+++ b/include/osmocom/core/select.h
@@ -39,4 +39,6 @@ int osmo_fd_register(struct osmo_fd *fd);
void osmo_fd_unregister(struct osmo_fd *fd);
int osmo_select_main(int polling);
+struct osmo_fd *osmo_fd_get_by_fd(int fd);
+
/*! @} */
diff --git a/src/select.c b/src/select.c
index 5421c77..477ff66 100644
--- a/src/select.c
+++ b/src/select.c
@@ -170,6 +170,18 @@ restart:
return work;
}
+/*! \brief find an osmo_fd based on the integer fd */
+struct osmo_fd *osmo_fd_get_by_fd(int fd)
+{
+ struct osmo_fd *ofd;
+
+ llist_for_each_entry(ofd, &osmo_fds, list) {
+ if (ofd->fd == fd)
+ return ofd;
+ }
+ return NULL;
+}
+
/*! @} */
#endif /* _HAVE_SYS_SELECT_H */