Horizon Official Technical Documentation
PacketLengthTable.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 * Copyright (c) 2023 Horizon Dev Team.
11 *
12 * Base Author - Sephus. (sagunxp@gmail.com)
13 *
14 * This library is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this library. If not, see <http://www.gnu.org/licenses/>.
26 **************************************************/
27
28#ifndef HORIZON_AUTH_AD_PACKET_LENGTH_TABLE
29#define HORIZON_AUTH_AD_PACKET_LENGTH_TABLE
30
34
35namespace Horizon
36{
37namespace Auth
38{
39 typedef std::shared_ptr<Base::NetworkPacket<AuthSession>> HPacketStructPtrType;
40 typedef std::shared_ptr<Base::NetworkPacket<AuthSession>> TPacketStructPtrType;
41 typedef std::pair<int16_t, HPacketStructPtrType> HPacketTablePairType;
42 typedef std::pair<int16_t, TPacketStructPtrType> TPacketTablePairType;
47{
48public:
49 PacketLengthTable(std::shared_ptr<AuthSession> s)
50 : _session(s)
51 {
52#define ADD_HPKT(i, j, k) _hpacket_length_table.insert(i, std::make_pair(j, std::make_shared<k>(s)))
53#define ADD_TPKT(i, j, k) _tpacket_length_table.insert(i, std::make_pair(j, std::make_shared<k>(s)))
54 ADD_TPKT(0x0069, -1, AC_ACCEPT_LOGIN);
55 ADD_TPKT(0x01dc, -1, AC_ACK_HASH);
56 ADD_TPKT(0x01be, 2, AC_ASK_PNGAMEROOM);
57 ADD_TPKT(0x01f1, -1, AC_NOTIFY_ERROR);
58 ADD_TPKT(0x006a, 23, AC_REFUSE_LOGIN);
60 ADD_HPKT(0x0204, 18, CA_EXE_HASHCHECK);
61 ADD_HPKT(0x0064, 55, CA_LOGIN);
62 ADD_HPKT(0x01dd, 47, CA_LOGIN2);
63 ADD_HPKT(0x01fa, 48, CA_LOGIN3);
64 ADD_HPKT(0x01bf, 3, CA_REPLY_PNGAMEROOM);
65 ADD_HPKT(0x01db, 2, CA_REQ_HASH);
66#undef ADD_HPKT
67#undef ADD_TPKT
68 }
69
71
72 std::shared_ptr<AuthSession> get_session() { return _session.lock(); }
73
74 HPacketTablePairType get_hpacket_info(uint16_t packet_id) { return _hpacket_length_table.at(packet_id); }
75 TPacketTablePairType get_tpacket_info(uint16_t packet_id) { return _tpacket_length_table.at(packet_id); }
76
77protected:
80 std::weak_ptr<AuthSession> _session;
81
82};
83}
84}
85#endif /* HORIZON_AUTH_AD_PACKET_LENGTH_TABLE */
#define ADD_HPKT(i, j, k)
#define ADD_TPKT(i, j, k)
Main object for the aegis packet: AC_ACCEPT_LOGIN.
Definition: TransmittedPackets.hpp:104
Main object for the aegis packet: AC_ACK_HASH.
Definition: TransmittedPackets.hpp:518
Main object for the aegis packet: AC_ASK_PNGAMEROOM.
Definition: TransmittedPackets.hpp:594
Main object for the aegis packet: AC_NOTIFY_ERROR.
Definition: TransmittedPackets.hpp:720
Main object for the aegis packet: AC_REFUSE_LOGIN.
Definition: TransmittedPackets.hpp:881
Main object for the aegis packet: CA_CONNECT_INFO_CHANGED.
Definition: HandledPackets.hpp:318
Main object for the aegis packet: CA_EXE_HASHCHECK.
Definition: HandledPackets.hpp:356
Main object for the aegis packet: CA_LOGIN2.
Definition: HandledPackets.hpp:437
Main object for the aegis packet: CA_LOGIN3.
Definition: HandledPackets.hpp:475
Main object for the aegis packet: CA_LOGIN.
Definition: HandledPackets.hpp:394
Main object for the aegis packet: CA_REPLY_PNGAMEROOM.
Definition: HandledPackets.hpp:796
Main object for the aegis packet: CA_REQ_HASH.
Definition: HandledPackets.hpp:872
Auto-generated with a python generator tool authored by Sephus (sagunxp@gmail.com).
Definition: PacketLengthTable.hpp:47
HPacketTablePairType get_hpacket_info(uint16_t packet_id)
Definition: PacketLengthTable.hpp:74
~PacketLengthTable()
Definition: PacketLengthTable.hpp:70
TPacketTablePairType get_tpacket_info(uint16_t packet_id)
Definition: PacketLengthTable.hpp:75
std::weak_ptr< AuthSession > _session
Definition: PacketLengthTable.hpp:80
PacketLengthTable(std::shared_ptr< AuthSession > s)
Definition: PacketLengthTable.hpp:49
LockedLookupTable< uint16_t, HPacketTablePairType > _hpacket_length_table
Definition: PacketLengthTable.hpp:78
std::shared_ptr< AuthSession > get_session()
Definition: PacketLengthTable.hpp:72
LockedLookupTable< uint16_t, TPacketTablePairType > _tpacket_length_table
Definition: PacketLengthTable.hpp:79
Value at(Key const &key, Value const &default_value=Value()) const
Definition: LockedLookupTable.hpp:63
std::pair< int16_t, HPacketStructPtrType > HPacketTablePairType
Definition: PacketLengthTable.hpp:41
std::shared_ptr< Base::NetworkPacket< AuthSession > > TPacketStructPtrType
Definition: PacketLengthTable.hpp:40
std::shared_ptr< Base::NetworkPacket< AuthSession > > HPacketStructPtrType
Definition: PacketLengthTable.hpp:39
std::pair< int16_t, TPacketStructPtrType > TPacketTablePairType
Definition: PacketLengthTable.hpp:42
Definition: Element.hpp:7