core: Add TX/RX API that exposes message tag and tag owner

MCTP received packets can carry a message tag and tag owner bit
which is set by a remote MCTP endpoint. This can be used by the
remote MCTP endpoint to track the responses. Thus, libmctp should
provide a mechanism for the upper layer MCTP applications to
respond with the same message tag.

This patchset extends TX and RX API with message tag and
tag owner bits.

Signed-off-by: Sumanth Bhat <sumanth.bhat@linux.intel.com>
Change-Id: I6d07eafa86c653abdd4313ab7cc77e5a93124477
diff --git a/utils/mctp-astlpc-daemon.c b/utils/mctp-astlpc-daemon.c
index f782d4c..3852bd4 100644
--- a/utils/mctp-astlpc-daemon.c
+++ b/utils/mctp-astlpc-daemon.c
@@ -28,11 +28,12 @@
 	type = len > 0 ? *(uint8_t *)(msg) : 0x00;
 
 	fprintf(stderr, "TX: dest EID 0x%02x: %zd bytes, first byte [0x%02x]\n",
-			eid, len, type);
-	mctp_message_tx(ctx->mctp, eid, msg, len);
+		eid, len, type);
+	mctp_message_tx(ctx->mctp, eid, 0, MCTP_MESSAGE_TO_SRC, msg, len);
 }
 
-static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
+static void rx_message(uint8_t eid, uint8_t msg_tag, bool tag_owner, void *data,
+		       void *msg, size_t len)
 {
 	struct ctx *ctx = data;
 	uint8_t type;
diff --git a/utils/mctp-demux-daemon.c b/utils/mctp-demux-daemon.c
index d7ab9bc..aeb2de0 100644
--- a/utils/mctp-demux-daemon.c
+++ b/utils/mctp-demux-daemon.c
@@ -84,7 +84,7 @@
 {
 	int rc;
 
-	rc = mctp_message_tx(ctx->mctp, eid, msg, len);
+	rc = mctp_message_tx(ctx->mctp, eid, MCTP_MESSAGE_TO_SRC, 0, msg, len);
 	if (rc)
 		warnx("Failed to send message: %d", rc);
 }
@@ -107,7 +107,9 @@
 	}
 }
 
-static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
+static void
+rx_message(uint8_t eid, bool tag_owner __unused, uint8_t msg_tag __unused,
+	   void *data, void *msg, size_t len)
 {
 	struct ctx *ctx = data;
 	struct iovec iov[2];
@@ -410,7 +412,8 @@
 
 
 	if (eid == ctx->local_eid)
-		rx_message(eid, ctx, ctx->buf + 1, rc - 1);
+		rx_message(eid, MCTP_MESSAGE_TO_DST, 0, ctx, ctx->buf + 1,
+			   rc - 1);
 	else
 		tx_message(ctx, eid, ctx->buf + 1, rc - 1);
 
diff --git a/utils/mctp-in.c b/utils/mctp-in.c
index eff4abf..d4987ce 100644
--- a/utils/mctp-in.c
+++ b/utils/mctp-in.c
@@ -12,11 +12,11 @@
 #include <sys/poll.h>
 #include <sys/socket.h>
 
-static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
+static void
+rx_message(uint8_t eid __unused, bool tag_owner __unused,
+	   uint8_t msg_tag __unused, void *data __unused, void *msg, size_t len)
 {
 	ssize_t rc;
-	(void)eid;
-	(void)data;
 
 	rc = write(STDOUT_FILENO, msg, len);
 	if (rc < 0)
diff --git a/utils/mctp-pipe.c b/utils/mctp-pipe.c
index ad466fb..12da74f 100644
--- a/utils/mctp-pipe.c
+++ b/utils/mctp-pipe.c
@@ -12,11 +12,11 @@
 #include <sys/poll.h>
 #include <sys/socket.h>
 
-static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
+static void
+rx_message(uint8_t eid __unused, bool tag_owner __unused,
+	   uint8_t msg_tag __unused, void *data __unused, void *msg, size_t len)
 {
 	ssize_t rc;
-	(void)eid;
-	(void)data;
 
 	rc = write(STDOUT_FILENO, msg, len);
 	if (rc < 0)
@@ -91,7 +91,9 @@
 			} else if (rc < 0) {
 				err(EXIT_FAILURE, "read");
 			} else {
-				mctp_message_tx(mctp[0], eids[1], buf, rc);
+				mctp_message_tx(mctp[0], eids[1],
+						MCTP_MESSAGE_TO_SRC, 0, buf,
+						rc);
 			}
 		}
 
diff --git a/utils/mctp-test-client.c b/utils/mctp-test-client.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/utils/mctp-test-client.c