From 534eab19127c3269c960c48ab167b57eda853d55 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 31 Jan 2019 05:23:40 +0300 Subject: [PATCH] Add PacketInfo.h. GitOrigin-RevId: 76db525e427aaa8afc0f64473743dffaffdd89be --- CMakeLists.txt | 1 + td/mtproto/HandshakeConnection.h | 1 + td/mtproto/PacketInfo.h | 33 +++++++++++++++++++++++++++++ td/mtproto/PingConnection.h | 1 + td/mtproto/RawConnection.h | 2 +- td/mtproto/SessionConnection.h | 2 +- td/mtproto/Transport.h | 18 +--------------- td/telegram/NotificationManager.cpp | 1 + td/telegram/SecretChatActor.cpp | 1 + 9 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 td/mtproto/PacketInfo.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ae72f9102..2abd374ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -447,6 +447,7 @@ set(TDLIB_SOURCE td/mtproto/HttpTransport.h td/mtproto/IStreamTransport.h td/mtproto/NoCryptoStorer.h + td/mtproto/PacketInfo.h td/mtproto/PacketStorer.h td/mtproto/PingConnection.h td/mtproto/RawConnection.h diff --git a/td/mtproto/HandshakeConnection.h b/td/mtproto/HandshakeConnection.h index ada294d57..53aae3ee3 100644 --- a/td/mtproto/HandshakeConnection.h +++ b/td/mtproto/HandshakeConnection.h @@ -9,6 +9,7 @@ #include "td/mtproto/AuthKey.h" #include "td/mtproto/Handshake.h" #include "td/mtproto/NoCryptoStorer.h" +#include "td/mtproto/PacketInfo.h" #include "td/mtproto/PacketStorer.h" #include "td/mtproto/RawConnection.h" #include "td/mtproto/Transport.h" diff --git a/td/mtproto/PacketInfo.h b/td/mtproto/PacketInfo.h new file mode 100644 index 000000000..1d78cb4f9 --- /dev/null +++ b/td/mtproto/PacketInfo.h @@ -0,0 +1,33 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#pragma once + +#include "td/utils/common.h" +#include "td/utils/UInt.h" + +namespace td { +namespace mtproto { + +struct PacketInfo { + enum { Common, EndToEnd } type = Common; + uint64 auth_key_id; + uint32 message_ack; + UInt128 message_key; + + uint64 salt; + uint64 session_id; + + uint64 message_id; + int32 seq_no; + int32 version{1}; + bool no_crypto_flag; + bool is_creator{false}; + bool check_mod4{true}; +}; + +} // namespace mtproto +} // namespace td diff --git a/td/mtproto/PingConnection.h b/td/mtproto/PingConnection.h index 045ae2843..5f2bab7c7 100644 --- a/td/mtproto/PingConnection.h +++ b/td/mtproto/PingConnection.h @@ -8,6 +8,7 @@ #include "td/mtproto/AuthKey.h" #include "td/mtproto/NoCryptoStorer.h" +#include "td/mtproto/PacketInfo.h" #include "td/mtproto/PacketStorer.h" #include "td/mtproto/RawConnection.h" #include "td/mtproto/utils.h" diff --git a/td/mtproto/RawConnection.h b/td/mtproto/RawConnection.h index 7773ae152..2c6987e04 100644 --- a/td/mtproto/RawConnection.h +++ b/td/mtproto/RawConnection.h @@ -7,6 +7,7 @@ #pragma once #include "td/mtproto/IStreamTransport.h" +#include "td/mtproto/PacketInfo.h" #include "td/mtproto/TransportType.h" #include "td/utils/buffer.h" @@ -24,7 +25,6 @@ namespace td { class Storer; namespace mtproto { class AuthKey; -struct PacketInfo; } // namespace mtproto } // namespace td diff --git a/td/mtproto/SessionConnection.h b/td/mtproto/SessionConnection.h index d6b3246c0..f7c75c81d 100644 --- a/td/mtproto/SessionConnection.h +++ b/td/mtproto/SessionConnection.h @@ -7,6 +7,7 @@ #pragma once #include "td/mtproto/RawConnection.h" +#include "td/mtproto/PacketInfo.h" #include "td/mtproto/utils.h" #include "td/utils/buffer.h" @@ -45,7 +46,6 @@ class destroy_auth_key_none; namespace mtproto { class AuthData; -struct PacketInfo; struct MsgInfo { uint64 session_id; diff --git a/td/mtproto/Transport.h b/td/mtproto/Transport.h index bfeae13b5..556a3572a 100644 --- a/td/mtproto/Transport.h +++ b/td/mtproto/Transport.h @@ -6,6 +6,7 @@ // #pragma once +#include "td/mtproto/PacketInfo.h" #include "td/mtproto/utils.h" #include "td/utils/common.h" @@ -122,23 +123,6 @@ struct NoCryptoHeader { #endif #pragma pack(pop) -struct PacketInfo { - enum { Common, EndToEnd } type = Common; - uint64 auth_key_id; - uint32 message_ack; - UInt128 message_key; - - uint64 salt; - uint64 session_id; - - uint64 message_id; - int32 seq_no; - int32 version{1}; - bool no_crypto_flag; - bool is_creator{false}; - bool check_mod4{true}; -}; - class Transport { public: class ReadResult { diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index f690132f7..85bdc33a7 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -17,6 +17,7 @@ #include "td/telegram/TdDb.h" #include "td/mtproto/AuthKey.h" +#include "td/mtproto/PacketInfo.h" #include "td/mtproto/Transport.h" #include "td/utils/as.h" diff --git a/td/telegram/SecretChatActor.cpp b/td/telegram/SecretChatActor.cpp index b542769c8..e924b6e00 100644 --- a/td/telegram/SecretChatActor.cpp +++ b/td/telegram/SecretChatActor.cpp @@ -13,6 +13,7 @@ #include "td/telegram/secret_api.hpp" #include "td/telegram/telegram_api.hpp" +#include "td/mtproto/PacketInfo.h" #include "td/mtproto/PacketStorer.h" #include "td/mtproto/Transport.h" #include "td/mtproto/utils.h"