diff options
author | amine ahd <amine.ahd@gmail.com> | 2016-12-19 10:30:36 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2016-12-24 14:31:04 +0100 |
commit | df088f03c02aebba304a371486f09e95ed34bf5f (patch) | |
tree | 63e86f91a703ace2ff688c6c1c1015e69a408a8c /libubus.h | |
parent | 5ca6bae3a27ca02e304339ed0d94a8baa461b609 (diff) | |
download | ubus-df088f03c02aebba304a371486f09e95ed34bf5f.tar.gz |
Allow sending a fd along a ubus_request
Signed-off-by: amine.ahd <amine.ahd@gmail.com>
Diffstat (limited to 'libubus.h')
-rw-r--r-- | libubus.h | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -188,6 +188,7 @@ struct ubus_request_data { /* internal use */ bool deferred; int fd; + int req_fd; /* fd received from the initial request */ }; struct ubus_request { @@ -208,6 +209,8 @@ struct ubus_request { ubus_fd_handler_t fd_cb; ubus_complete_handler_t complete_cb; + int fd; + struct ubus_context *ctx; void *priv; }; @@ -336,6 +339,14 @@ int ubus_invoke(struct ubus_context *ctx, uint32_t obj, const char *method, int ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method, struct blob_attr *msg, struct ubus_request *req); +int ubus_invoke_fd(struct ubus_context *ctx, uint32_t obj, const char *method, + struct blob_attr *msg, ubus_data_handler_t cb, void *priv, + int timeout, int fd); + +/* asynchronous version of ubus_invoke() */ +int ubus_invoke_async_fd(struct ubus_context *ctx, uint32_t obj, const char *method, + struct blob_attr *msg, struct ubus_request *req, int fd); + /* send a reply to an incoming object method call */ int ubus_send_reply(struct ubus_context *ctx, struct ubus_request_data *req, struct blob_attr *msg); @@ -356,6 +367,14 @@ static inline void ubus_request_set_fd(struct ubus_context *ctx, req->fd = fd; } +static inline int ubus_request_get_caller_fd(struct ubus_request_data *req) +{ + int fd = req->req_fd; + req->req_fd = -1; + + return fd; +} + void ubus_complete_deferred_request(struct ubus_context *ctx, struct ubus_request_data *req, int ret); |