aboutsummaryrefslogtreecommitdiff
path: root/src/libslirp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libslirp.h')
-rw-r--r--src/libslirp.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libslirp.h b/src/libslirp.h
index 546f2f9..8eb47a0 100644
--- a/src/libslirp.h
+++ b/src/libslirp.h
@@ -63,7 +63,8 @@ typedef struct SlirpCb {
void (*guest_error)(const char *msg, void *opaque);
/* Return the virtual clock value in nanoseconds */
int64_t (*clock_get_ns)(void *opaque);
- /* Create a new timer with the given callback and opaque data */
+ /* Create a new timer with the given callback and opaque data. Not
+ * needed if timer_new_opaque is provided. */
void *(*timer_new)(SlirpTimerCb cb, void *cb_opaque, void *opaque);
/* Remove and free a timer */
void (*timer_free)(void *timer, void *opaque);
@@ -76,6 +77,14 @@ typedef struct SlirpCb {
/* Kick the io-thread, to signal that new events may be processed because some TCP buffer
* can now receive more data, i.e. slirp_socket_can_recv will return 1. */
void (*notify)(void *opaque);
+
+ /*
+ * Fields introduced in SlirpConfig version 4 begin
+ */
+
+ /* Create a new timer. When the timer fires, the application passes
+ * the SlirpTimerId and cb_opaque to slirp_handle_timer. */
+ void *(*timer_new_opaque)(SlirpTimerId id, void *cb_opaque, void *opaque);
} SlirpCb;
#define SLIRP_CONFIG_VERSION_MIN 1
@@ -171,6 +180,11 @@ void slirp_pollfds_poll(Slirp *slirp, int select_error,
* guest network, to be interpreted by slirp. */
void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len);
+/* This is called by the application when a timer expires, if it provides
+ * the timer_new_opaque callback. It is not needed if the application only
+ * uses timer_new. */
+void slirp_handle_timer(Slirp *slirp, SlirpTimerId id, void *cb_opaque);
+
/* These set up / remove port forwarding between a host port in the real world
* and the guest network. */
int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,