From 3e0fad3aa5f9f36566ac2815a54288d214e58689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 17 Jan 2019 15:43:58 +0400 Subject: slirp: pass opaque to all callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is friendlier for FFI bindings. Signed-off-by: Marc-André Lureau Signed-off-by: Samuel Thibault --- net/slirp.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'net') diff --git a/net/slirp.c b/net/slirp.c index a85e42f..7a16d8d 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -161,44 +161,51 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; -static void net_slirp_guest_error(const char *msg) +static void net_slirp_guest_error(const char *msg, void *opaque) { qemu_log_mask(LOG_GUEST_ERROR, "%s", msg); } -static int64_t net_slirp_clock_get_ns(void) +static int64_t net_slirp_clock_get_ns(void *opaque) { return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); } -static void *net_slirp_timer_new(SlirpTimerCb cb, void *opaque) +static void *net_slirp_timer_new(SlirpTimerCb cb, + void *cb_opaque, void *opaque) { return timer_new_full(NULL, QEMU_CLOCK_VIRTUAL, SCALE_MS, QEMU_TIMER_ATTR_EXTERNAL, - cb, opaque); + cb, cb_opaque); } -static void net_slirp_timer_free(void *timer) +static void net_slirp_timer_free(void *timer, void *opaque) { timer_del(timer); timer_free(timer); } -static void net_slirp_timer_mod(void *timer, int64_t expire_timer) +static void net_slirp_timer_mod(void *timer, int64_t expire_timer, + void *opaque) { timer_mod(timer, expire_timer); } -static void net_slirp_register_poll_fd(int fd) +static void net_slirp_register_poll_fd(int fd, void *opaque) { qemu_fd_register(fd); } -static void net_slirp_unregister_poll_fd(int fd) +static void net_slirp_unregister_poll_fd(int fd, void *opaque) { /* no qemu_fd_unregister */ } +static void net_slirp_notify(void *opaque) +{ + qemu_notify_event(); +} + static const SlirpCb slirp_cb = { .send_packet = net_slirp_send_packet, .guest_error = net_slirp_guest_error, @@ -208,7 +215,7 @@ static const SlirpCb slirp_cb = { .timer_mod = net_slirp_timer_mod, .register_poll_fd = net_slirp_register_poll_fd, .unregister_poll_fd = net_slirp_unregister_poll_fd, - .notify = qemu_notify_event, + .notify = net_slirp_notify, }; static int slirp_poll_to_gio(int events) -- cgit v1.1