core: Add allocated tag expiry, mctp_set_now_op()

Allocated tags expire after 6 seconds, requiring a time source.
The default will use clock_gettime(), though implementations can set
MCTP_DEFAULT_CLOCK_GETTIME=0 and use mctp_set_now_op() for custom
behavior.

Change-Id: Iaacf500bcd458c987f4b79c698bac9ae5ad5a73e
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
diff --git a/core-internal.h b/core-internal.h
index 7608a41..c8e7b25 100644
--- a/core-internal.h
+++ b/core-internal.h
@@ -24,6 +24,13 @@
 #define MCTP_REQ_TAGS MCTP_REASSEMBLY_CTXS
 #endif
 
+#ifndef MCTP_DEFAULT_CLOCK_GETTIME
+#define MCTP_DEFAULT_CLOCK_GETTIME 1
+#endif
+
+/* Tag expiry timeout, in milliseconds */
+static const uint64_t MCTP_TAG_TIMEOUT = 6000;
+
 /* Internal data structures */
 
 enum mctp_bus_state {
@@ -73,6 +80,8 @@
 	mctp_eid_t local;
 	mctp_eid_t remote;
 	uint8_t tag;
+	/* time of tag expiry */
+	uint64_t expiry;
 };
 
 struct mctp {
@@ -102,4 +111,7 @@
 	size_t max_message_size;
 
 	void *alloc_ctx;
+
+	uint64_t (*platform_now)(void *);
+	void *platform_now_ctx;
 };