From: Hugo Landau Date: Tue, 1 Aug 2023 09:02:08 +0000 (+0100) Subject: QUIC: Move string conversion functions into a source file X-Git-Tag: openssl-3.2.0-alpha1~273 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=398922463fd2fb0df52443932ca3e140554e5334;p=thirdparty%2Fopenssl.git QUIC: Move string conversion functions into a source file Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/21547) --- diff --git a/include/internal/quic_error.h b/include/internal/quic_error.h index 9495c3e67d9..46bda1376d7 100644 --- a/include/internal/quic_error.h +++ b/include/internal/quic_error.h @@ -46,33 +46,7 @@ # define QUIC_ERR_CRYPTO_NO_APP_PROTO \ QUIC_ERR_CRYPTO_ERR(TLS1_AD_NO_APPLICATION_PROTOCOL) -static ossl_inline ossl_unused const char * -ossl_quic_err_to_string(uint64_t error_code) -{ - switch (error_code) { -#define X(name) case QUIC_ERR_##name: return #name; - X(NO_ERROR) - X(INTERNAL_ERROR) - X(CONNECTION_REFUSED) - X(FLOW_CONTROL_ERROR) - X(STREAM_LIMIT_ERROR) - X(STREAM_STATE_ERROR) - X(FINAL_SIZE_ERROR) - X(FRAME_ENCODING_ERROR) - X(TRANSPORT_PARAMETER_ERROR) - X(CONNECTION_ID_LIMIT_ERROR) - X(PROTOCOL_VIOLATION) - X(INVALID_TOKEN) - X(APPLICATION_ERROR) - X(CRYPTO_BUFFER_EXCEEDED) - X(KEY_UPDATE_ERROR) - X(AEAD_LIMIT_REACHED) - X(NO_VIABLE_PATH) -#undef X - default: - return NULL; - } -} +const char *ossl_quic_err_to_string(uint64_t error_code); # endif diff --git a/include/internal/quic_wire.h b/include/internal/quic_wire.h index 4f059120b36..f9f80fbc449 100644 --- a/include/internal/quic_wire.h +++ b/include/internal/quic_wire.h @@ -87,47 +87,7 @@ # define OSSL_QUIC_FRAME_TYPE_IS_CONN_CLOSE(x) \ (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT) -static ossl_unused ossl_inline const char * -ossl_quic_frame_type_to_string(uint64_t frame_type) -{ - switch (frame_type) { -#define X(name) case OSSL_QUIC_FRAME_TYPE_##name: return #name; - X(PADDING) - X(PING) - X(ACK_WITHOUT_ECN) - X(ACK_WITH_ECN) - X(RESET_STREAM) - X(STOP_SENDING) - X(CRYPTO) - X(NEW_TOKEN) - X(MAX_DATA) - X(MAX_STREAM_DATA) - X(MAX_STREAMS_BIDI) - X(MAX_STREAMS_UNI) - X(DATA_BLOCKED) - X(STREAM_DATA_BLOCKED) - X(STREAMS_BLOCKED_BIDI) - X(STREAMS_BLOCKED_UNI) - X(NEW_CONN_ID) - X(RETIRE_CONN_ID) - X(PATH_CHALLENGE) - X(PATH_RESPONSE) - X(CONN_CLOSE_TRANSPORT) - X(CONN_CLOSE_APP) - X(HANDSHAKE_DONE) - X(STREAM) - X(STREAM_FIN) - X(STREAM_LEN) - X(STREAM_LEN_FIN) - X(STREAM_OFF) - X(STREAM_OFF_FIN) - X(STREAM_OFF_LEN) - X(STREAM_OFF_LEN_FIN) -#undef X - default: - return NULL; - } -} +const char *ossl_quic_frame_type_to_string(uint64_t frame_type); static ossl_unused ossl_inline int ossl_quic_frame_type_is_ack_eliciting(uint64_t frame_type) diff --git a/ssl/quic/quic_wire.c b/ssl/quic/quic_wire.c index 7ad7f8b4420..748596d506f 100644 --- a/ssl/quic/quic_wire.c +++ b/ssl/quic/quic_wire.c @@ -12,6 +12,7 @@ #include "internal/quic_ssl.h" #include "internal/quic_vlint.h" #include "internal/quic_wire.h" +#include "internal/quic_error.h" OSSL_SAFE_MATH_UNSIGNED(uint64_t, uint64_t) @@ -991,3 +992,72 @@ int ossl_quic_wire_decode_transport_param_preferred_addr(PACKET *pkt, p->cid.id_len = (unsigned char)cidl; return 1; } + +const char * +ossl_quic_frame_type_to_string(uint64_t frame_type) +{ + switch (frame_type) { +#define X(name) case OSSL_QUIC_FRAME_TYPE_##name: return #name; + X(PADDING) + X(PING) + X(ACK_WITHOUT_ECN) + X(ACK_WITH_ECN) + X(RESET_STREAM) + X(STOP_SENDING) + X(CRYPTO) + X(NEW_TOKEN) + X(MAX_DATA) + X(MAX_STREAM_DATA) + X(MAX_STREAMS_BIDI) + X(MAX_STREAMS_UNI) + X(DATA_BLOCKED) + X(STREAM_DATA_BLOCKED) + X(STREAMS_BLOCKED_BIDI) + X(STREAMS_BLOCKED_UNI) + X(NEW_CONN_ID) + X(RETIRE_CONN_ID) + X(PATH_CHALLENGE) + X(PATH_RESPONSE) + X(CONN_CLOSE_TRANSPORT) + X(CONN_CLOSE_APP) + X(HANDSHAKE_DONE) + X(STREAM) + X(STREAM_FIN) + X(STREAM_LEN) + X(STREAM_LEN_FIN) + X(STREAM_OFF) + X(STREAM_OFF_FIN) + X(STREAM_OFF_LEN) + X(STREAM_OFF_LEN_FIN) +#undef X + default: + return NULL; + } +} + +const char *ossl_quic_err_to_string(uint64_t error_code) +{ + switch (error_code) { +#define X(name) case QUIC_ERR_##name: return #name; + X(NO_ERROR) + X(INTERNAL_ERROR) + X(CONNECTION_REFUSED) + X(FLOW_CONTROL_ERROR) + X(STREAM_LIMIT_ERROR) + X(STREAM_STATE_ERROR) + X(FINAL_SIZE_ERROR) + X(FRAME_ENCODING_ERROR) + X(TRANSPORT_PARAMETER_ERROR) + X(CONNECTION_ID_LIMIT_ERROR) + X(PROTOCOL_VIOLATION) + X(INVALID_TOKEN) + X(APPLICATION_ERROR) + X(CRYPTO_BUFFER_EXCEEDED) + X(KEY_UPDATE_ERROR) + X(AEAD_LIMIT_REACHED) + X(NO_VIABLE_PATH) +#undef X + default: + return NULL; + } +}