// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: stream_out/chromecast/cast_channel.proto

#include "stream_out/chromecast/cast_channel.pb.h"

#include <algorithm>

#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>

PROTOBUF_PRAGMA_INIT_SEG
namespace castchannel {
constexpr CastMessage::CastMessage(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : source_id_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , destination_id_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , namespace__(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , payload_utf8_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , payload_binary_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , protocol_version_(0)

  , payload_type_(0)
{}
struct CastMessageDefaultTypeInternal {
  constexpr CastMessageDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~CastMessageDefaultTypeInternal() {}
  union {
    CastMessage _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CastMessageDefaultTypeInternal _CastMessage_default_instance_;
constexpr AuthChallenge::AuthChallenge(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){}
struct AuthChallengeDefaultTypeInternal {
  constexpr AuthChallengeDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~AuthChallengeDefaultTypeInternal() {}
  union {
    AuthChallenge _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT AuthChallengeDefaultTypeInternal _AuthChallenge_default_instance_;
constexpr AuthResponse::AuthResponse(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : signature_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , client_auth_certificate_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){}
struct AuthResponseDefaultTypeInternal {
  constexpr AuthResponseDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~AuthResponseDefaultTypeInternal() {}
  union {
    AuthResponse _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT AuthResponseDefaultTypeInternal _AuthResponse_default_instance_;
constexpr AuthError::AuthError(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : error_type_(0)
{}
struct AuthErrorDefaultTypeInternal {
  constexpr AuthErrorDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~AuthErrorDefaultTypeInternal() {}
  union {
    AuthError _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT AuthErrorDefaultTypeInternal _AuthError_default_instance_;
constexpr DeviceAuthMessage::DeviceAuthMessage(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : challenge_(nullptr)
  , response_(nullptr)
  , error_(nullptr){}
struct DeviceAuthMessageDefaultTypeInternal {
  constexpr DeviceAuthMessageDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~DeviceAuthMessageDefaultTypeInternal() {}
  union {
    DeviceAuthMessage _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DeviceAuthMessageDefaultTypeInternal _DeviceAuthMessage_default_instance_;
}  // namespace castchannel
namespace castchannel {
bool CastMessage_ProtocolVersion_IsValid(int value) {
  switch (value) {
    case 0:
      return true;
    default:
      return false;
  }
}

static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> CastMessage_ProtocolVersion_strings[1] = {};

static const char CastMessage_ProtocolVersion_names[] =
  "CASTV2_1_0";

static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry CastMessage_ProtocolVersion_entries[] = {
  { {CastMessage_ProtocolVersion_names + 0, 10}, 0 },
};

static const int CastMessage_ProtocolVersion_entries_by_number[] = {
  0, // 0 -> CASTV2_1_0
};

const std::string& CastMessage_ProtocolVersion_Name(
    CastMessage_ProtocolVersion value) {
  static const bool dummy =
      ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
          CastMessage_ProtocolVersion_entries,
          CastMessage_ProtocolVersion_entries_by_number,
          1, CastMessage_ProtocolVersion_strings);
  (void) dummy;
  int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
      CastMessage_ProtocolVersion_entries,
      CastMessage_ProtocolVersion_entries_by_number,
      1, value);
  return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
                     CastMessage_ProtocolVersion_strings[idx].get();
}
bool CastMessage_ProtocolVersion_Parse(
    ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CastMessage_ProtocolVersion* value) {
  int int_value;
  bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
      CastMessage_ProtocolVersion_entries, 1, name, &int_value);
  if (success) {
    *value = static_cast<CastMessage_ProtocolVersion>(int_value);
  }
  return success;
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr CastMessage_ProtocolVersion CastMessage::CASTV2_1_0;
constexpr CastMessage_ProtocolVersion CastMessage::ProtocolVersion_MIN;
constexpr CastMessage_ProtocolVersion CastMessage::ProtocolVersion_MAX;
constexpr int CastMessage::ProtocolVersion_ARRAYSIZE;
#endif  // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
bool CastMessage_PayloadType_IsValid(int value) {
  switch (value) {
    case 0:
    case 1:
      return true;
    default:
      return false;
  }
}

static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> CastMessage_PayloadType_strings[2] = {};

static const char CastMessage_PayloadType_names[] =
  "BINARY"
  "STRING";

static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry CastMessage_PayloadType_entries[] = {
  { {CastMessage_PayloadType_names + 0, 6}, 1 },
  { {CastMessage_PayloadType_names + 6, 6}, 0 },
};

static const int CastMessage_PayloadType_entries_by_number[] = {
  1, // 0 -> STRING
  0, // 1 -> BINARY
};

const std::string& CastMessage_PayloadType_Name(
    CastMessage_PayloadType value) {
  static const bool dummy =
      ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
          CastMessage_PayloadType_entries,
          CastMessage_PayloadType_entries_by_number,
          2, CastMessage_PayloadType_strings);
  (void) dummy;
  int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
      CastMessage_PayloadType_entries,
      CastMessage_PayloadType_entries_by_number,
      2, value);
  return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
                     CastMessage_PayloadType_strings[idx].get();
}
bool CastMessage_PayloadType_Parse(
    ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CastMessage_PayloadType* value) {
  int int_value;
  bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
      CastMessage_PayloadType_entries, 2, name, &int_value);
  if (success) {
    *value = static_cast<CastMessage_PayloadType>(int_value);
  }
  return success;
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr CastMessage_PayloadType CastMessage::STRING;
constexpr CastMessage_PayloadType CastMessage::BINARY;
constexpr CastMessage_PayloadType CastMessage::PayloadType_MIN;
constexpr CastMessage_PayloadType CastMessage::PayloadType_MAX;
constexpr int CastMessage::PayloadType_ARRAYSIZE;
#endif  // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
bool AuthError_ErrorType_IsValid(int value) {
  switch (value) {
    case 0:
    case 1:
      return true;
    default:
      return false;
  }
}

static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> AuthError_ErrorType_strings[2] = {};

static const char AuthError_ErrorType_names[] =
  "INTERNAL_ERROR"
  "NO_TLS";

static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry AuthError_ErrorType_entries[] = {
  { {AuthError_ErrorType_names + 0, 14}, 0 },
  { {AuthError_ErrorType_names + 14, 6}, 1 },
};

static const int AuthError_ErrorType_entries_by_number[] = {
  0, // 0 -> INTERNAL_ERROR
  1, // 1 -> NO_TLS
};

const std::string& AuthError_ErrorType_Name(
    AuthError_ErrorType value) {
  static const bool dummy =
      ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
          AuthError_ErrorType_entries,
          AuthError_ErrorType_entries_by_number,
          2, AuthError_ErrorType_strings);
  (void) dummy;
  int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
      AuthError_ErrorType_entries,
      AuthError_ErrorType_entries_by_number,
      2, value);
  return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
                     AuthError_ErrorType_strings[idx].get();
}
bool AuthError_ErrorType_Parse(
    ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AuthError_ErrorType* value) {
  int int_value;
  bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
      AuthError_ErrorType_entries, 2, name, &int_value);
  if (success) {
    *value = static_cast<AuthError_ErrorType>(int_value);
  }
  return success;
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr AuthError_ErrorType AuthError::INTERNAL_ERROR;
constexpr AuthError_ErrorType AuthError::NO_TLS;
constexpr AuthError_ErrorType AuthError::ErrorType_MIN;
constexpr AuthError_ErrorType AuthError::ErrorType_MAX;
constexpr int AuthError::ErrorType_ARRAYSIZE;
#endif  // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))

// ===================================================================

class CastMessage::_Internal {
 public:
  using HasBits = decltype(std::declval<CastMessage>()._has_bits_);
  static void set_has_protocol_version(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
  static void set_has_source_id(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_destination_id(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_namespace_(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_payload_type(HasBits* has_bits) {
    (*has_bits)[0] |= 64u;
  }
  static void set_has_payload_utf8(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_payload_binary(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
  static bool MissingRequiredFields(const HasBits& has_bits) {
    return ((has_bits[0] & 0x00000067) ^ 0x00000067) != 0;
  }
};

CastMessage::CastMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:castchannel.CastMessage)
}
CastMessage::CastMessage(const CastMessage& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  source_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    source_id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_source_id()) {
    source_id_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_source_id(), 
      GetArenaForAllocation());
  }
  destination_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    destination_id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_destination_id()) {
    destination_id_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_destination_id(), 
      GetArenaForAllocation());
  }
  namespace__.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    namespace__.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_namespace_()) {
    namespace__.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_namespace_(), 
      GetArenaForAllocation());
  }
  payload_utf8_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    payload_utf8_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_payload_utf8()) {
    payload_utf8_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_payload_utf8(), 
      GetArenaForAllocation());
  }
  payload_binary_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    payload_binary_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_payload_binary()) {
    payload_binary_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_payload_binary(), 
      GetArenaForAllocation());
  }
  ::memcpy(&protocol_version_, &from.protocol_version_,
    static_cast<size_t>(reinterpret_cast<char*>(&payload_type_) -
    reinterpret_cast<char*>(&protocol_version_)) + sizeof(payload_type_));
  // @@protoc_insertion_point(copy_constructor:castchannel.CastMessage)
}

inline void CastMessage::SharedCtor() {
source_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  source_id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
destination_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  destination_id_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
namespace__.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  namespace__.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
payload_utf8_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  payload_utf8_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
payload_binary_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  payload_binary_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&protocol_version_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&payload_type_) -
    reinterpret_cast<char*>(&protocol_version_)) + sizeof(payload_type_));
}

CastMessage::~CastMessage() {
  // @@protoc_insertion_point(destructor:castchannel.CastMessage)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void CastMessage::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  source_id_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  destination_id_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  namespace__.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  payload_utf8_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  payload_binary_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}

void CastMessage::ArenaDtor(void* object) {
  CastMessage* _this = reinterpret_cast< CastMessage* >(object);
  (void)_this;
}
void CastMessage::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void CastMessage::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void CastMessage::Clear() {
// @@protoc_insertion_point(message_clear_start:castchannel.CastMessage)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000001fu) {
    if (cached_has_bits & 0x00000001u) {
      source_id_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000002u) {
      destination_id_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000004u) {
      namespace__.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000008u) {
      payload_utf8_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000010u) {
      payload_binary_.ClearNonDefaultToEmpty();
    }
  }
  if (cached_has_bits & 0x00000060u) {
    ::memset(&protocol_version_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&payload_type_) -
        reinterpret_cast<char*>(&protocol_version_)) + sizeof(payload_type_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* CastMessage::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // required .castchannel.CastMessage.ProtocolVersion protocol_version = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
          uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::castchannel::CastMessage_ProtocolVersion_IsValid(val))) {
            _internal_set_protocol_version(static_cast<::castchannel::CastMessage_ProtocolVersion>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields());
          }
        } else
          goto handle_unusual;
        continue;
      // required string source_id = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
          auto str = _internal_mutable_source_id();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // required string destination_id = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
          auto str = _internal_mutable_destination_id();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // required string namespace = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
          auto str = _internal_mutable_namespace_();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // required .castchannel.CastMessage.PayloadType payload_type = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) {
          uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::castchannel::CastMessage_PayloadType_IsValid(val))) {
            _internal_set_payload_type(static_cast<::castchannel::CastMessage_PayloadType>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(5, val, mutable_unknown_fields());
          }
        } else
          goto handle_unusual;
        continue;
      // optional string payload_utf8 = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
          auto str = _internal_mutable_payload_utf8();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional bytes payload_binary = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) {
          auto str = _internal_mutable_payload_binary();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* CastMessage::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:castchannel.CastMessage)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // required .castchannel.CastMessage.ProtocolVersion protocol_version = 1;
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      1, this->_internal_protocol_version(), target);
  }

  // required string source_id = 2;
  if (cached_has_bits & 0x00000001u) {
    target = stream->WriteStringMaybeAliased(
        2, this->_internal_source_id(), target);
  }

  // required string destination_id = 3;
  if (cached_has_bits & 0x00000002u) {
    target = stream->WriteStringMaybeAliased(
        3, this->_internal_destination_id(), target);
  }

  // required string namespace = 4;
  if (cached_has_bits & 0x00000004u) {
    target = stream->WriteStringMaybeAliased(
        4, this->_internal_namespace_(), target);
  }

  // required .castchannel.CastMessage.PayloadType payload_type = 5;
  if (cached_has_bits & 0x00000040u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      5, this->_internal_payload_type(), target);
  }

  // optional string payload_utf8 = 6;
  if (cached_has_bits & 0x00000008u) {
    target = stream->WriteStringMaybeAliased(
        6, this->_internal_payload_utf8(), target);
  }

  // optional bytes payload_binary = 7;
  if (cached_has_bits & 0x00000010u) {
    target = stream->WriteBytesMaybeAliased(
        7, this->_internal_payload_binary(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:castchannel.CastMessage)
  return target;
}

size_t CastMessage::RequiredFieldsByteSizeFallback() const {
// @@protoc_insertion_point(required_fields_byte_size_fallback_start:castchannel.CastMessage)
  size_t total_size = 0;

  if (_internal_has_source_id()) {
    // required string source_id = 2;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
        this->_internal_source_id());
  }

  if (_internal_has_destination_id()) {
    // required string destination_id = 3;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
        this->_internal_destination_id());
  }

  if (_internal_has_namespace_()) {
    // required string namespace = 4;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
        this->_internal_namespace_());
  }

  if (_internal_has_protocol_version()) {
    // required .castchannel.CastMessage.ProtocolVersion protocol_version = 1;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_protocol_version());
  }

  if (_internal_has_payload_type()) {
    // required .castchannel.CastMessage.PayloadType payload_type = 5;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_payload_type());
  }

  return total_size;
}
size_t CastMessage::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:castchannel.CastMessage)
  size_t total_size = 0;

  if (((_has_bits_[0] & 0x00000067) ^ 0x00000067) == 0) {  // All required fields are present.
    // required string source_id = 2;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
        this->_internal_source_id());

    // required string destination_id = 3;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
        this->_internal_destination_id());

    // required string namespace = 4;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
        this->_internal_namespace_());

    // required .castchannel.CastMessage.ProtocolVersion protocol_version = 1;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_protocol_version());

    // required .castchannel.CastMessage.PayloadType payload_type = 5;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_payload_type());

  } else {
    total_size += RequiredFieldsByteSizeFallback();
  }
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000018u) {
    // optional string payload_utf8 = 6;
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
          this->_internal_payload_utf8());
    }

    // optional bytes payload_binary = 7;
    if (cached_has_bits & 0x00000010u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
          this->_internal_payload_binary());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void CastMessage::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const CastMessage*>(
      &from));
}

void CastMessage::MergeFrom(const CastMessage& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:castchannel.CastMessage)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x0000007fu) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_source_id(from._internal_source_id());
    }
    if (cached_has_bits & 0x00000002u) {
      _internal_set_destination_id(from._internal_destination_id());
    }
    if (cached_has_bits & 0x00000004u) {
      _internal_set_namespace_(from._internal_namespace_());
    }
    if (cached_has_bits & 0x00000008u) {
      _internal_set_payload_utf8(from._internal_payload_utf8());
    }
    if (cached_has_bits & 0x00000010u) {
      _internal_set_payload_binary(from._internal_payload_binary());
    }
    if (cached_has_bits & 0x00000020u) {
      protocol_version_ = from.protocol_version_;
    }
    if (cached_has_bits & 0x00000040u) {
      payload_type_ = from.payload_type_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void CastMessage::CopyFrom(const CastMessage& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:castchannel.CastMessage)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool CastMessage::IsInitialized() const {
  if (_Internal::MissingRequiredFields(_has_bits_)) return false;
  return true;
}

void CastMessage::InternalSwap(CastMessage* other) {
  using std::swap;
  auto* lhs_arena = GetArenaForAllocation();
  auto* rhs_arena = other->GetArenaForAllocation();
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &source_id_, lhs_arena,
      &other->source_id_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &destination_id_, lhs_arena,
      &other->destination_id_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &namespace__, lhs_arena,
      &other->namespace__, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &payload_utf8_, lhs_arena,
      &other->payload_utf8_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &payload_binary_, lhs_arena,
      &other->payload_binary_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(CastMessage, payload_type_)
      + sizeof(CastMessage::payload_type_)
      - PROTOBUF_FIELD_OFFSET(CastMessage, protocol_version_)>(
          reinterpret_cast<char*>(&protocol_version_),
          reinterpret_cast<char*>(&other->protocol_version_));
}

std::string CastMessage::GetTypeName() const {
  return "castchannel.CastMessage";
}


// ===================================================================

class AuthChallenge::_Internal {
 public:
};

AuthChallenge::AuthChallenge(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:castchannel.AuthChallenge)
}
AuthChallenge::AuthChallenge(const AuthChallenge& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite() {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  // @@protoc_insertion_point(copy_constructor:castchannel.AuthChallenge)
}

inline void AuthChallenge::SharedCtor() {
}

AuthChallenge::~AuthChallenge() {
  // @@protoc_insertion_point(destructor:castchannel.AuthChallenge)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void AuthChallenge::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}

void AuthChallenge::ArenaDtor(void* object) {
  AuthChallenge* _this = reinterpret_cast< AuthChallenge* >(object);
  (void)_this;
}
void AuthChallenge::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void AuthChallenge::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void AuthChallenge::Clear() {
// @@protoc_insertion_point(message_clear_start:castchannel.AuthChallenge)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  _internal_metadata_.Clear<std::string>();
}

const char* AuthChallenge::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* AuthChallenge::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:castchannel.AuthChallenge)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:castchannel.AuthChallenge)
  return target;
}

size_t AuthChallenge::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:castchannel.AuthChallenge)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void AuthChallenge::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const AuthChallenge*>(
      &from));
}

void AuthChallenge::MergeFrom(const AuthChallenge& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:castchannel.AuthChallenge)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void AuthChallenge::CopyFrom(const AuthChallenge& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:castchannel.AuthChallenge)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool AuthChallenge::IsInitialized() const {
  return true;
}

void AuthChallenge::InternalSwap(AuthChallenge* other) {
  using std::swap;
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
}

std::string AuthChallenge::GetTypeName() const {
  return "castchannel.AuthChallenge";
}


// ===================================================================

class AuthResponse::_Internal {
 public:
  using HasBits = decltype(std::declval<AuthResponse>()._has_bits_);
  static void set_has_signature(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_client_auth_certificate(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static bool MissingRequiredFields(const HasBits& has_bits) {
    return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0;
  }
};

AuthResponse::AuthResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:castchannel.AuthResponse)
}
AuthResponse::AuthResponse(const AuthResponse& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  signature_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    signature_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_signature()) {
    signature_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_signature(), 
      GetArenaForAllocation());
  }
  client_auth_certificate_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    client_auth_certificate_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_client_auth_certificate()) {
    client_auth_certificate_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_client_auth_certificate(), 
      GetArenaForAllocation());
  }
  // @@protoc_insertion_point(copy_constructor:castchannel.AuthResponse)
}

inline void AuthResponse::SharedCtor() {
signature_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  signature_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
client_auth_certificate_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  client_auth_certificate_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}

AuthResponse::~AuthResponse() {
  // @@protoc_insertion_point(destructor:castchannel.AuthResponse)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void AuthResponse::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  signature_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  client_auth_certificate_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}

void AuthResponse::ArenaDtor(void* object) {
  AuthResponse* _this = reinterpret_cast< AuthResponse* >(object);
  (void)_this;
}
void AuthResponse::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void AuthResponse::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void AuthResponse::Clear() {
// @@protoc_insertion_point(message_clear_start:castchannel.AuthResponse)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      signature_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000002u) {
      client_auth_certificate_.ClearNonDefaultToEmpty();
    }
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* AuthResponse::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // required bytes signature = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
          auto str = _internal_mutable_signature();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // required bytes client_auth_certificate = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
          auto str = _internal_mutable_client_auth_certificate();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* AuthResponse::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:castchannel.AuthResponse)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // required bytes signature = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->WriteBytesMaybeAliased(
        1, this->_internal_signature(), target);
  }

  // required bytes client_auth_certificate = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->WriteBytesMaybeAliased(
        2, this->_internal_client_auth_certificate(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:castchannel.AuthResponse)
  return target;
}

size_t AuthResponse::RequiredFieldsByteSizeFallback() const {
// @@protoc_insertion_point(required_fields_byte_size_fallback_start:castchannel.AuthResponse)
  size_t total_size = 0;

  if (_internal_has_signature()) {
    // required bytes signature = 1;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
        this->_internal_signature());
  }

  if (_internal_has_client_auth_certificate()) {
    // required bytes client_auth_certificate = 2;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
        this->_internal_client_auth_certificate());
  }

  return total_size;
}
size_t AuthResponse::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:castchannel.AuthResponse)
  size_t total_size = 0;

  if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) {  // All required fields are present.
    // required bytes signature = 1;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
        this->_internal_signature());

    // required bytes client_auth_certificate = 2;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
        this->_internal_client_auth_certificate());

  } else {
    total_size += RequiredFieldsByteSizeFallback();
  }
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void AuthResponse::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const AuthResponse*>(
      &from));
}

void AuthResponse::MergeFrom(const AuthResponse& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:castchannel.AuthResponse)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_signature(from._internal_signature());
    }
    if (cached_has_bits & 0x00000002u) {
      _internal_set_client_auth_certificate(from._internal_client_auth_certificate());
    }
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void AuthResponse::CopyFrom(const AuthResponse& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:castchannel.AuthResponse)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool AuthResponse::IsInitialized() const {
  if (_Internal::MissingRequiredFields(_has_bits_)) return false;
  return true;
}

void AuthResponse::InternalSwap(AuthResponse* other) {
  using std::swap;
  auto* lhs_arena = GetArenaForAllocation();
  auto* rhs_arena = other->GetArenaForAllocation();
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &signature_, lhs_arena,
      &other->signature_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &client_auth_certificate_, lhs_arena,
      &other->client_auth_certificate_, rhs_arena
  );
}

std::string AuthResponse::GetTypeName() const {
  return "castchannel.AuthResponse";
}


// ===================================================================

class AuthError::_Internal {
 public:
  using HasBits = decltype(std::declval<AuthError>()._has_bits_);
  static void set_has_error_type(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static bool MissingRequiredFields(const HasBits& has_bits) {
    return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0;
  }
};

AuthError::AuthError(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:castchannel.AuthError)
}
AuthError::AuthError(const AuthError& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  error_type_ = from.error_type_;
  // @@protoc_insertion_point(copy_constructor:castchannel.AuthError)
}

inline void AuthError::SharedCtor() {
error_type_ = 0;
}

AuthError::~AuthError() {
  // @@protoc_insertion_point(destructor:castchannel.AuthError)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void AuthError::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}

void AuthError::ArenaDtor(void* object) {
  AuthError* _this = reinterpret_cast< AuthError* >(object);
  (void)_this;
}
void AuthError::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void AuthError::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void AuthError::Clear() {
// @@protoc_insertion_point(message_clear_start:castchannel.AuthError)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  error_type_ = 0;
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* AuthError::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // required .castchannel.AuthError.ErrorType error_type = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
          uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::castchannel::AuthError_ErrorType_IsValid(val))) {
            _internal_set_error_type(static_cast<::castchannel::AuthError_ErrorType>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields());
          }
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* AuthError::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:castchannel.AuthError)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // required .castchannel.AuthError.ErrorType error_type = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      1, this->_internal_error_type(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:castchannel.AuthError)
  return target;
}

size_t AuthError::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:castchannel.AuthError)
  size_t total_size = 0;

  // required .castchannel.AuthError.ErrorType error_type = 1;
  if (_internal_has_error_type()) {
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_error_type());
  }
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void AuthError::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const AuthError*>(
      &from));
}

void AuthError::MergeFrom(const AuthError& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:castchannel.AuthError)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  if (from._internal_has_error_type()) {
    _internal_set_error_type(from._internal_error_type());
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void AuthError::CopyFrom(const AuthError& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:castchannel.AuthError)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool AuthError::IsInitialized() const {
  if (_Internal::MissingRequiredFields(_has_bits_)) return false;
  return true;
}

void AuthError::InternalSwap(AuthError* other) {
  using std::swap;
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  swap(error_type_, other->error_type_);
}

std::string AuthError::GetTypeName() const {
  return "castchannel.AuthError";
}


// ===================================================================

class DeviceAuthMessage::_Internal {
 public:
  using HasBits = decltype(std::declval<DeviceAuthMessage>()._has_bits_);
  static const ::castchannel::AuthChallenge& challenge(const DeviceAuthMessage* msg);
  static void set_has_challenge(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static const ::castchannel::AuthResponse& response(const DeviceAuthMessage* msg);
  static void set_has_response(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static const ::castchannel::AuthError& error(const DeviceAuthMessage* msg);
  static void set_has_error(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
};

const ::castchannel::AuthChallenge&
DeviceAuthMessage::_Internal::challenge(const DeviceAuthMessage* msg) {
  return *msg->challenge_;
}
const ::castchannel::AuthResponse&
DeviceAuthMessage::_Internal::response(const DeviceAuthMessage* msg) {
  return *msg->response_;
}
const ::castchannel::AuthError&
DeviceAuthMessage::_Internal::error(const DeviceAuthMessage* msg) {
  return *msg->error_;
}
DeviceAuthMessage::DeviceAuthMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:castchannel.DeviceAuthMessage)
}
DeviceAuthMessage::DeviceAuthMessage(const DeviceAuthMessage& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  if (from._internal_has_challenge()) {
    challenge_ = new ::castchannel::AuthChallenge(*from.challenge_);
  } else {
    challenge_ = nullptr;
  }
  if (from._internal_has_response()) {
    response_ = new ::castchannel::AuthResponse(*from.response_);
  } else {
    response_ = nullptr;
  }
  if (from._internal_has_error()) {
    error_ = new ::castchannel::AuthError(*from.error_);
  } else {
    error_ = nullptr;
  }
  // @@protoc_insertion_point(copy_constructor:castchannel.DeviceAuthMessage)
}

inline void DeviceAuthMessage::SharedCtor() {
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&challenge_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&error_) -
    reinterpret_cast<char*>(&challenge_)) + sizeof(error_));
}

DeviceAuthMessage::~DeviceAuthMessage() {
  // @@protoc_insertion_point(destructor:castchannel.DeviceAuthMessage)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void DeviceAuthMessage::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  if (this != internal_default_instance()) delete challenge_;
  if (this != internal_default_instance()) delete response_;
  if (this != internal_default_instance()) delete error_;
}

void DeviceAuthMessage::ArenaDtor(void* object) {
  DeviceAuthMessage* _this = reinterpret_cast< DeviceAuthMessage* >(object);
  (void)_this;
}
void DeviceAuthMessage::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void DeviceAuthMessage::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void DeviceAuthMessage::Clear() {
// @@protoc_insertion_point(message_clear_start:castchannel.DeviceAuthMessage)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      GOOGLE_DCHECK(challenge_ != nullptr);
      challenge_->Clear();
    }
    if (cached_has_bits & 0x00000002u) {
      GOOGLE_DCHECK(response_ != nullptr);
      response_->Clear();
    }
    if (cached_has_bits & 0x00000004u) {
      GOOGLE_DCHECK(error_ != nullptr);
      error_->Clear();
    }
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* DeviceAuthMessage::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // optional .castchannel.AuthChallenge challenge = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
          ptr = ctx->ParseMessage(_internal_mutable_challenge(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional .castchannel.AuthResponse response = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
          ptr = ctx->ParseMessage(_internal_mutable_response(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional .castchannel.AuthError error = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
          ptr = ctx->ParseMessage(_internal_mutable_error(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* DeviceAuthMessage::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:castchannel.DeviceAuthMessage)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional .castchannel.AuthChallenge challenge = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(
        1, _Internal::challenge(this), target, stream);
  }

  // optional .castchannel.AuthResponse response = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(
        2, _Internal::response(this), target, stream);
  }

  // optional .castchannel.AuthError error = 3;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(
        3, _Internal::error(this), target, stream);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:castchannel.DeviceAuthMessage)
  return target;
}

size_t DeviceAuthMessage::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:castchannel.DeviceAuthMessage)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    // optional .castchannel.AuthChallenge challenge = 1;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *challenge_);
    }

    // optional .castchannel.AuthResponse response = 2;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *response_);
    }

    // optional .castchannel.AuthError error = 3;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *error_);
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void DeviceAuthMessage::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const DeviceAuthMessage*>(
      &from));
}

void DeviceAuthMessage::MergeFrom(const DeviceAuthMessage& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:castchannel.DeviceAuthMessage)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      _internal_mutable_challenge()->::castchannel::AuthChallenge::MergeFrom(from._internal_challenge());
    }
    if (cached_has_bits & 0x00000002u) {
      _internal_mutable_response()->::castchannel::AuthResponse::MergeFrom(from._internal_response());
    }
    if (cached_has_bits & 0x00000004u) {
      _internal_mutable_error()->::castchannel::AuthError::MergeFrom(from._internal_error());
    }
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void DeviceAuthMessage::CopyFrom(const DeviceAuthMessage& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:castchannel.DeviceAuthMessage)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool DeviceAuthMessage::IsInitialized() const {
  if (_internal_has_response()) {
    if (!response_->IsInitialized()) return false;
  }
  if (_internal_has_error()) {
    if (!error_->IsInitialized()) return false;
  }
  return true;
}

void DeviceAuthMessage::InternalSwap(DeviceAuthMessage* other) {
  using std::swap;
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(DeviceAuthMessage, error_)
      + sizeof(DeviceAuthMessage::error_)
      - PROTOBUF_FIELD_OFFSET(DeviceAuthMessage, challenge_)>(
          reinterpret_cast<char*>(&challenge_),
          reinterpret_cast<char*>(&other->challenge_));
}

std::string DeviceAuthMessage::GetTypeName() const {
  return "castchannel.DeviceAuthMessage";
}


// @@protoc_insertion_point(namespace_scope)
}  // namespace castchannel
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::castchannel::CastMessage* Arena::CreateMaybeMessage< ::castchannel::CastMessage >(Arena* arena) {
  return Arena::CreateMessageInternal< ::castchannel::CastMessage >(arena);
}
template<> PROTOBUF_NOINLINE ::castchannel::AuthChallenge* Arena::CreateMaybeMessage< ::castchannel::AuthChallenge >(Arena* arena) {
  return Arena::CreateMessageInternal< ::castchannel::AuthChallenge >(arena);
}
template<> PROTOBUF_NOINLINE ::castchannel::AuthResponse* Arena::CreateMaybeMessage< ::castchannel::AuthResponse >(Arena* arena) {
  return Arena::CreateMessageInternal< ::castchannel::AuthResponse >(arena);
}
template<> PROTOBUF_NOINLINE ::castchannel::AuthError* Arena::CreateMaybeMessage< ::castchannel::AuthError >(Arena* arena) {
  return Arena::CreateMessageInternal< ::castchannel::AuthError >(arena);
}
template<> PROTOBUF_NOINLINE ::castchannel::DeviceAuthMessage* Arena::CreateMaybeMessage< ::castchannel::DeviceAuthMessage >(Arena* arena) {
  return Arena::CreateMessageInternal< ::castchannel::DeviceAuthMessage >(arena);
}
PROTOBUF_NAMESPACE_CLOSE

// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
