X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=client.cpp;h=3fdd817db7afb47c2cec6a1cd2cfa8051c3e8562;hp=7c58d515485b03d27e9e26650dacb4c36116781f;hb=a0fe013448d188b324c00383cfd91695d9d3d076;hpb=26fe3ab755034ea3be8321ec0af548670f8c3bd8 diff --git a/client.cpp b/client.cpp index 7c58d51..3fdd817 100644 --- a/client.cpp +++ b/client.cpp @@ -18,14 +18,14 @@ using namespace std; Client::Client(int sock) : sock(sock), state(Client::READING_REQUEST), - stream(NULL), + stream(nullptr), header_or_short_response_bytes_sent(0), stream_pos(0), bytes_sent(0), bytes_lost(0), num_loss_events(0), - tls_context(NULL), - tls_data_to_send(NULL), + tls_context(nullptr), + tls_data_to_send(nullptr), tls_data_left_to_send(0), in_ktls_mode(false) { @@ -49,14 +49,14 @@ Client::Client(int sock) char buf[INET6_ADDRSTRLEN]; if (IN6_IS_ADDR_V4MAPPED(&addr.sin6_addr)) { // IPv4 address, really. - if (inet_ntop(AF_INET, &addr.sin6_addr.s6_addr32[3], buf, sizeof(buf)) == NULL) { + if (inet_ntop(AF_INET, &addr.sin6_addr.s6_addr32[3], buf, sizeof(buf)) == nullptr) { log_perror("inet_ntop"); remote_addr = ""; } else { remote_addr = buf; } } else { - if (inet_ntop(addr.sin6_family, &addr.sin6_addr, buf, sizeof(buf)) == NULL) { + if (inet_ntop(addr.sin6_family, &addr.sin6_addr, buf, sizeof(buf)) == nullptr) { log_perror("inet_ntop"); remote_addr = ""; } else { @@ -81,7 +81,7 @@ Client::Client(const ClientProto &serialized, Stream *stream) bytes_lost(serialized.bytes_lost()), num_loss_events(serialized.num_loss_events()) { - if (stream != NULL) { + if (stream != nullptr) { if (setsockopt(sock, SOL_SOCKET, SO_MAX_PACING_RATE, &stream->pacing_rate, sizeof(stream->pacing_rate)) == -1) { if (stream->pacing_rate != ~0U) { log_perror("setsockopt(SO_MAX_PACING_RATE)"); @@ -96,7 +96,7 @@ Client::Client(const ClientProto &serialized, Stream *stream) tls_context = tls_import_context( reinterpret_cast(serialized.tls_context().data()), serialized.tls_context().size()); - if (tls_context == NULL) { + if (tls_context == nullptr) { log(WARNING, "tls_import_context() failed, TLS client might not survive across restart"); } else { tls_data_to_send = tls_get_write_buffer(tls_context, &tls_data_left_to_send); @@ -104,7 +104,7 @@ Client::Client(const ClientProto &serialized, Stream *stream) assert(serialized.tls_output_bytes_already_consumed() <= tls_data_left_to_send); if (serialized.tls_output_bytes_already_consumed() >= tls_data_left_to_send) { tls_buffer_clear(tls_context); - tls_data_to_send = NULL; + tls_data_to_send = nullptr; } else { tls_data_to_send += serialized.tls_output_bytes_already_consumed(); tls_data_left_to_send -= serialized.tls_output_bytes_already_consumed(); @@ -112,7 +112,7 @@ Client::Client(const ClientProto &serialized, Stream *stream) in_ktls_mode = serialized.in_ktls_mode(); } } else { - tls_context = NULL; + tls_context = nullptr; } } @@ -135,9 +135,9 @@ ClientProto Client::serialize() const serialized.set_bytes_lost(bytes_lost); serialized.set_num_loss_events(num_loss_events); - if (tls_context != NULL) { + if (tls_context != nullptr) { bool small_version = false; - int required_size = tls_export_context(tls_context, NULL, 0, small_version); + int required_size = tls_export_context(tls_context, nullptr, 0, small_version); if (required_size <= 0) { // Can happen if we're in the middle of the key exchange, unfortunately. // We'll get an error fairly fast, and this client hasn't started playing @@ -164,8 +164,8 @@ ClientProto Client::serialize() const // currently serialize in-progress key exchanges. unsigned base_tls_data_left_to_send; const unsigned char *base_tls_data_to_send = tls_get_write_buffer(tls_context, &base_tls_data_left_to_send); - if (base_tls_data_to_send == NULL) { - assert(tls_data_to_send == NULL); + if (base_tls_data_to_send == nullptr) { + assert(tls_data_to_send == nullptr); } else { assert(tls_data_to_send + tls_data_left_to_send == base_tls_data_to_send + base_tls_data_left_to_send); }