Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
include/qb/qbipcc.h | 19 +++++++++++++++++++
lib/ipc_int.h | 1 +
lib/ipcc.c | 17 +++++++++++++++++
3 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/include/qb/qbipcc.h b/include/qb/qbipcc.h
index 6227e0f..a55848f 100644
--- a/include/qb/qbipcc.h
+++ b/include/qb/qbipcc.h
@@ -162,6 +162,25 @@ ssize_t qb_ipcc_sendv_recv(qb_ipcc_connection_t *c,
ssize_t qb_ipcc_event_recv(qb_ipcc_connection_t* c, void *msg_ptr,
size_t msg_len, int32_t ms_timeout);
+/**
+ * Associate a "user" pointer with this connection.
+ *
+ * @param context the point to associate with this connection.
+ * @param c connection instance
+ * @see qb_ipcc_context_get()
+ */
+void qb_ipcc_context_set(qb_ipcc_connection_t *c, void *context);
+
+/**
+ * Get the context (set previously)
+ *
+ * @param c connection instance
+ * @return the context
+ * @see qb_ipcc_context_set()
+ */
+void *qb_ipcc_context_get(qb_ipcc_connection_t *c);
+
+
/* *INDENT-OFF* */
#ifdef __cplusplus
}
diff --git a/lib/ipc_int.h b/lib/ipc_int.h
index 7f37038..67093fc 100644
--- a/lib/ipc_int.h
+++ b/lib/ipc_int.h
@@ -113,6 +113,7 @@ struct qb_ipcc_connection {
struct qb_ipc_request_header *receive_buf;
uint32_t fc_enable_max;
int32_t is_connected;
+ void * context;
};
int32_t qb_ipcc_us_setup_connect(struct qb_ipcc_connection *c,
diff --git a/lib/ipcc.c b/lib/ipcc.c
index 5f2d439..6bcc5d5 100644
--- a/lib/ipcc.c
+++ b/lib/ipcc.c
@@ -318,3 +318,20 @@ qb_ipcc_disconnect(struct qb_ipcc_connection *c)
free(c->receive_buf);
free(c);
}
+
+void
+qb_ipcc_context_set(struct qb_ipcc_connection *c, void *context)
+{
+ if (c == NULL) {
+ return;
+ }
+ c->context = context;
+}
+
+void *qb_ipcc_context_get(struct qb_ipcc_connection *c)
+{
+ if (c == NULL) {
+ return NULL;
+ }
+ return c->context;
+}
--
1.7.7.5
Show replies by date