pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/38479?usp=email )
Change subject: core/tun: Add API osmo_tundev_get_fd ......................................................................
core/tun: Add API osmo_tundev_get_fd
Change-Id: Ia8a7e7ec6d96c7aebc80528236a0e0d035e7f38d --- M TODO-RELEASE M include/osmocom/core/tun.h M src/core/libosmocore.map M src/core/tun.c 4 files changed, 13 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/79/38479/1
diff --git a/TODO-RELEASE b/TODO-RELEASE index 8a1e0dc..b3e4742 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -9,3 +9,4 @@ #library what description / commit summary line gb ADD add bssgp_parse_cell_id2/bssgp_create_cell_id2 gsm ADD add osmo_rai_to_gprs/gprs_rai_to_osmo +core ADD add API osmo_tundev_get_fd() \ No newline at end of file diff --git a/include/osmocom/core/tun.h b/include/osmocom/core/tun.h index 86bd8df..21e7703 100644 --- a/include/osmocom/core/tun.h +++ b/include/osmocom/core/tun.h @@ -29,6 +29,8 @@
const char *osmo_tundev_get_name(const struct osmo_tundev *tundev);
+int osmo_tundev_get_fd(const struct osmo_tundev *tundev); + int osmo_tundev_set_dev_name(struct osmo_tundev *tundev, const char *dev_name); const char *osmo_tundev_get_dev_name(const struct osmo_tundev *tundev);
diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map index c5ab6e3..c48a2b9 100644 --- a/src/core/libosmocore.map +++ b/src/core/libosmocore.map @@ -569,6 +569,7 @@ osmo_tundev_close; osmo_tundev_free; osmo_tundev_get_dev_name; +osmo_tundev_get_fd; osmo_tundev_get_name; osmo_tundev_get_netdev; osmo_tundev_get_netns_name; diff --git a/src/core/tun.c b/src/core/tun.c index ec68a96..04a1972 100644 --- a/src/core/tun.c +++ b/src/core/tun.c @@ -489,6 +489,15 @@ return tundev->name; }
+/*! Get FD associated to the tundev object. + * \param[in] tundev The tundev object from where to retrieve the field + * \returns The fd of the currently open tundev, negative otherwise + */ +int osmo_tundev_get_fd(const struct osmo_tundev *tundev) +{ + return tundev->wqueue.bfd.fd; +} + /*! Set name used to name the tunnel interface created by the tundev object. * \param[in] tundev The tundev object where the field is set * \param[in] dev_name The tunnel interface name to use