mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
Everywhere: Debug macros instead of constexpr.
This was done with the following script: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
This commit is contained in:
parent
bb483f7ef4
commit
8465683dcf
98 changed files with 414 additions and 972 deletions
|
@ -39,12 +39,12 @@ void TLSv12::write_packet(ByteBuffer& packet)
|
|||
m_context.tls_buffer.append(packet.data(), packet.size());
|
||||
if (m_context.connection_status > ConnectionStatus::Disconnected) {
|
||||
if (!m_has_scheduled_write_flush) {
|
||||
dbgln<debug_tls>("Scheduling write of {}", m_context.tls_buffer.size());
|
||||
dbgln<TLS_DEBUG>("Scheduling write of {}", m_context.tls_buffer.size());
|
||||
deferred_invoke([this](auto&) { write_into_socket(); });
|
||||
m_has_scheduled_write_flush = true;
|
||||
} else {
|
||||
// multiple packet are available, let's flush some out
|
||||
dbgln<debug_tls>("Flushing scheduled write of {}", m_context.tls_buffer.size());
|
||||
dbgln<TLS_DEBUG>("Flushing scheduled write of {}", m_context.tls_buffer.size());
|
||||
write_into_socket();
|
||||
// the deferred invoke is still in place
|
||||
m_has_scheduled_write_flush = true;
|
||||
|
@ -216,7 +216,7 @@ ByteBuffer TLSv12::hmac_message(const ReadonlyBytes& buf, const Optional<Readonl
|
|||
auto digest = hmac.digest();
|
||||
auto mac = ByteBuffer::copy(digest.immutable_data(), digest.data_length());
|
||||
|
||||
if constexpr (debug_tls) {
|
||||
if constexpr (TLS_DEBUG) {
|
||||
dbgln("HMAC of the block for sequence number {}", sequence_number);
|
||||
print_buffer(mac);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
size_t header_size = res;
|
||||
ssize_t payload_res = 0;
|
||||
|
||||
dbgln<debug_tls>("buffer size: {}", buffer.size());
|
||||
dbgln<TLS_DEBUG>("buffer size: {}", buffer.size());
|
||||
|
||||
if (buffer.size() < 5) {
|
||||
return (i8)Error::NeedMoreData;
|
||||
|
@ -241,7 +241,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
|
||||
// FIXME: Read the version and verify it
|
||||
|
||||
if constexpr (debug_tls) {
|
||||
if constexpr (TLS_DEBUG) {
|
||||
auto version = (Version) * (const u16*)buffer.offset_pointer(buffer_position);
|
||||
dbgln("type={}, version={}", (u8)type, (u16)version);
|
||||
}
|
||||
|
@ -249,21 +249,21 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
buffer_position += 2;
|
||||
|
||||
auto length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(buffer_position));
|
||||
dbgln<debug_tls>("record length: {} at offset: {}", length, buffer_position);
|
||||
dbgln<TLS_DEBUG>("record length: {} at offset: {}", length, buffer_position);
|
||||
buffer_position += 2;
|
||||
|
||||
if (buffer_position + length > buffer.size()) {
|
||||
dbgln<debug_tls>("record length more than what we have: {}", buffer.size());
|
||||
dbgln<TLS_DEBUG>("record length more than what we have: {}", buffer.size());
|
||||
return (i8)Error::NeedMoreData;
|
||||
}
|
||||
|
||||
dbgln<debug_tls>("message type: {}, length: {}", (u8)type, length);
|
||||
dbgln<TLS_DEBUG>("message type: {}, length: {}", (u8)type, length);
|
||||
auto plain = buffer.slice(buffer_position, buffer.size() - buffer_position);
|
||||
|
||||
ByteBuffer decrypted;
|
||||
|
||||
if (m_context.cipher_spec_set && type != MessageType::ChangeCipher) {
|
||||
if constexpr (debug_tls) {
|
||||
if constexpr (TLS_DEBUG) {
|
||||
dbgln("Encrypted: ");
|
||||
print_buffer(buffer.slice(header_size, length));
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
auto packet = build_alert(true, (u8)AlertDescription::UnexpectedMessage);
|
||||
write_packet(packet);
|
||||
} else {
|
||||
dbgln<debug_tls>("application data message of size {}", plain.size());
|
||||
dbgln<TLS_DEBUG>("application data message of size {}", plain.size());
|
||||
|
||||
m_context.application_buffer.append(plain.data(), plain.size());
|
||||
}
|
||||
|
@ -414,9 +414,9 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
}
|
||||
break;
|
||||
case MessageType::Alert:
|
||||
dbgln<debug_tls>("alert message of length {}", length);
|
||||
dbgln<TLS_DEBUG>("alert message of length {}", length);
|
||||
if (length >= 2) {
|
||||
if constexpr (debug_tls)
|
||||
if constexpr (TLS_DEBUG)
|
||||
print_buffer(plain);
|
||||
|
||||
auto level = plain[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue