diff options
-rw-r--r-- | include/internal/qlog.h | 1 | ||||
-rw-r--r-- | ssl/quic/qlog.c | 27 | ||||
-rw-r--r-- | test/quic_qlog_test.c | 4 | ||||
-rwxr-xr-x | test/recipes/70-test_quic_multistream_data/verify-qlog.py | 11 |
4 files changed, 38 insertions, 5 deletions
diff --git a/include/internal/qlog.h b/include/internal/qlog.h index 80c806d2a4..f6960ec1cc 100644 --- a/include/internal/qlog.h +++ b/include/internal/qlog.h @@ -35,6 +35,7 @@ typedef struct qlog_trace_info_st { OSSL_TIME (*now_cb)(void *arg); void *now_cb_arg; uint64_t override_process_id; + const char *override_impl_name; } QLOG_TRACE_INFO; QLOG *ossl_qlog_new(const QLOG_TRACE_INFO *info); diff --git a/ssl/quic/qlog.c b/ssl/quic/qlog.c index bad124b86d..ef0946d905 100644 --- a/ssl/quic/qlog.c +++ b/ssl/quic/qlog.c @@ -67,15 +67,20 @@ QLOG *ossl_qlog_new(const QLOG_TRACE_INFO *info) if (info->title != NULL && (qlog->info.title = OPENSSL_strdup(info->title)) == NULL) - goto err; + goto err; if (info->description != NULL && (qlog->info.description = OPENSSL_strdup(info->description)) == NULL) - goto err; + goto err; if (info->group_id != NULL && (qlog->info.group_id = OPENSSL_strdup(info->group_id)) == NULL) - goto err; + goto err; + + if (info->override_impl_name != NULL + && (qlog->info.override_impl_name + = OPENSSL_strdup(info->override_impl_name)) == NULL) + goto err; if (!ossl_json_init(&qlog->json, NULL, OSSL_JSON_FLAG_IJSON | OSSL_JSON_FLAG_SEQ)) @@ -91,6 +96,7 @@ err: OPENSSL_free((char *)qlog->info.title); OPENSSL_free((char *)qlog->info.description); OPENSSL_free((char *)qlog->info.group_id); + OPENSSL_free((char *)qlog->info.override_impl_name); OPENSSL_free(qlog); } return NULL; @@ -162,6 +168,7 @@ void ossl_qlog_free(QLOG *qlog) OPENSSL_free((char *)qlog->info.title); OPENSSL_free((char *)qlog->info.description); OPENSSL_free((char *)qlog->info.group_id); + OPENSSL_free((char *)qlog->info.override_impl_name); OPENSSL_free(qlog); } @@ -323,9 +330,23 @@ static void qlog_event_seq_header(QLOG *qlog) ossl_json_key(&qlog->json, "vantage_point"); ossl_json_object_begin(&qlog->json); { + char buf[128]; + const char *p = buf; + + if (qlog->info.override_impl_name != NULL) { + p = qlog->info.override_impl_name; + } else { + snprintf(buf, sizeof(buf), "OpenSSL/%s (%s)", + OpenSSL_version(OPENSSL_FULL_VERSION_STRING), + OpenSSL_version(OPENSSL_PLATFORM) + 10); + } + ossl_json_key(&qlog->json, "type"); ossl_json_str(&qlog->json, qlog->info.is_server ? "server" : "client"); + + ossl_json_key(&qlog->json, "name"); + ossl_json_str(&qlog->json, p); } /* vantage_point */ ossl_json_object_end(&qlog->json); } /* trace */ diff --git a/test/quic_qlog_test.c b/test/quic_qlog_test.c index bad9bbbc46..fb94531733 100644 --- a/test/quic_qlog_test.c +++ b/test/quic_qlog_test.c @@ -15,7 +15,8 @@ static const char expected[] = "\"test title\",\"description\":\"test description\",\"trace\":{" "\"common_fields\":{\"time_format\":\"delta\",\"protocol_type\":" "[\"QUIC\"],\"group_id\":\"test group ID\",\"system_info\":{" - "\"process_id\":123}},\"vantage_point\":{\"type\":\"client\"}}}\n" + "\"process_id\":123}},\"vantage_point\":{\"type\":\"client\"," + "\"name\":\"OpenSSL/x.y.z\"}}}\n" "\x1e{\"name\":\"transport:packet_sent\",\"data\":{\"field1\":\"foo\"," "\"field2\":\"bar\",\"field3\":42,\"field4\":\"1152921504606846976\"," @@ -59,6 +60,7 @@ static int test_qlog(void) qti.group_id = "test group ID"; qti.override_process_id = 123; qti.now_cb = now; + qti.override_impl_name = "OpenSSL/x.y.z"; if (!TEST_ptr(qlog = ossl_qlog_new(&qti))) goto err; diff --git a/test/recipes/70-test_quic_multistream_data/verify-qlog.py b/test/recipes/70-test_quic_multistream_data/verify-qlog.py index 08702410a3..b5e2519b43 100755 --- a/test/recipes/70-test_quic_multistream_data/verify-qlog.py +++ b/test/recipes/70-test_quic_multistream_data/verify-qlog.py @@ -6,7 +6,9 @@ # this file except in compliance with the License. You can obtain a copy # in the file LICENSE in the source distribution or at # https://www.openssl.org/source/license.html -import sys, os, os.path, glob, json +import sys, os, os.path, glob, json, re + +re_version = re.compile(r'''^OpenSSL/[0-9]+\.[0-9]\.[0-9](-[^ ]+)? ([^)]+)''') class Unexpected(Exception): def __init__(self, filename, msg): @@ -46,6 +48,13 @@ def check_header(filename, hdr): if hdr_trace["vantage_point"].get('type') not in ('client', 'server'): raise Unexpected(filename, "unexpected vantage_point") + vp_name = hdr_trace["vantage_point"].get('name') + if type(vp_name) != str: + raise Unexpected(filename, "expected vantage_point name") + + if not re_version.match(vp_name): + raise Unexpected(filename, "expected correct vantage_point format") + hdr_common_fields = hdr_trace["common_fields"] if hdr_common_fields.get("time_format") != "delta": raise Unexpected(filename, "must have expected time_format") |