+/* Attempts to guess the content type of a stream whose first few bytes were
+ * the 'size' bytes of 'data'. If this is done successfully, and the guessed
+ * content type is other than 'expected_type', then log a message in vlog
+ * module 'module', naming 'stream_name' as the source, explaining what
+ * content was expected and what was actually received. */
+void
+stream_report_content(const void *data, ssize_t size,
+ enum stream_content_type expected_type,
+ struct vlog_module *module, const char *stream_name)
+{
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);
+ enum stream_content_type actual_type;
+
+ actual_type = stream_guess_content(data, size);
+ if (actual_type != expected_type && actual_type != STREAM_UNKNOWN) {
+ vlog_rate_limit(module, VLL_WARN, &rl,
+ "%s: received %s data on %s channel",
+ stream_name,
+ stream_content_type_to_string(actual_type),
+ stream_content_type_to_string(expected_type));
+ }
+}