mctp-demux-daemon: sanity check pcap args

Ensure that the apporprate linktype argument is provided whenever
--capture-socket or --capture-binding are enabled.

Change-Id: I8f1294848be2e5bbf191295f1bd23ebe3be0424c
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/utils/mctp-demux-daemon.c b/utils/mctp-demux-daemon.c
index 0fa5041..968079f 100644
--- a/utils/mctp-demux-daemon.c
+++ b/utils/mctp-demux-daemon.c
@@ -594,7 +594,9 @@
 	ctx->local_eid = local_eid_default;
 	ctx->verbose = false;
 	ctx->pcap.binding.path = NULL;
+	ctx->pcap.binding.linktype = -1;
 	ctx->pcap.socket.path = NULL;
+	ctx->pcap.socket.linktype = -1;
 
 	for (;;) {
 		rc = getopt_long(argc, argv, "b:es::v", options, NULL);
@@ -631,6 +633,18 @@
 		return EXIT_FAILURE;
 	}
 
+	if (ctx->pcap.binding.linktype < 0 && ctx->pcap.binding.path) {
+		fprintf(stderr, "missing binding-linktype argument\n");
+		usage(argv[0]);
+		return EXIT_FAILURE;
+	}
+
+	if (ctx->pcap.socket.linktype < 0 && ctx->pcap.socket.path) {
+		fprintf(stderr, "missing socket-linktype argument\n");
+		usage(argv[0]);
+		return EXIT_FAILURE;
+	}
+
 	/* setup initial buffer */
 	ctx->buf_size = 4096;
 	ctx->buf = malloc(ctx->buf_size);