net_response_check.h 1002 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. //
  5. #ifndef RLZ_LIB_NET_RESPONSE_CHECK_H_
  6. #define RLZ_LIB_NET_RESPONSE_CHECK_H_
  7. #include <stddef.h>
  8. #include "rlz/lib/rlz_api.h"
  9. // Checksum validation convenience call for RLZ network responses.
  10. namespace rlz_lib {
  11. // The maximum length of a ping response we will parse in bytes. If the response
  12. // is bigger, please break it up into separate calls.
  13. constexpr size_t kMaxPingResponseLength = 0x4000; // 16K
  14. // Checks if a ping response is valid - ie. it has a checksum line which
  15. // is the CRC-32 checksum of the message up to the checksum. If
  16. // checksum_idx is not NULL, it will get the index of the checksum, i.e. -
  17. // the effective end of the message.
  18. // Access: No restrictions.
  19. bool RLZ_LIB_API IsPingResponseValid(const char* response, int* checksum_idx);
  20. } // namespace rlz_lib
  21. #endif // RLZ_LIB_NET_RESPONSE_CHECK_H_