From 6c33ae2605b038391a80dd5defb76a5fabb5dd2b Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 19 Mar 2016 21:17:58 +0100 Subject: Add new osmo_fd_get_by_fd() function This function can be used to obtain the osmo_fd corresponding to a given fd. The latter can be useful when integrating libosmocore main loop with other libraries. --- src/select.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/select.c') diff --git a/src/select.c b/src/select.c index 5421c773..477ff662 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 */ -- cgit v1.2.3