tibia-client/src/framework/net/protocol.h

69 lines
2.8 KiB
C
Raw Normal View History

2011-04-20 08:40:31 +02:00
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef PROTOCOL_H
#define PROTOCOL_H
#include <net/connection.h>
2011-05-30 05:11:12 +02:00
#include <net/inputmessage.h>
#include <net/outputmessage.h>
#include <script/luaobject.h>
2011-05-30 05:11:12 +02:00
#define CIPSOFT_PUBLIC_RSA "1321277432058722840622950990822933849527763264961655079678763618" \
"4334395343554449668205332383339435179772895415509701210392836078" \
"6959821132214473291575712138800495033169914814069637740318278150" \
"2907336840325241747827401343576296990629870233111328210165697754" \
"88792221429527047321331896351555606801473202394175817"
//#define RSA "109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110603907230888610072655818825358503429057592827629436413108566029093628212635953836686562675849720620786279431090218017681061521755056710823876476444260558147179707119674283982419152118103759076030616683978566631413"
2011-04-20 08:40:31 +02:00
class Protocol : public LuaObject
2011-04-20 08:40:31 +02:00
{
public:
Protocol();
void connect(const std::string& host, uint16 port, const std::function<void()>& callback);
2011-05-30 05:11:12 +02:00
void send(OutputMessage *outputMessage);
2011-04-20 08:40:31 +02:00
2011-05-30 05:11:12 +02:00
virtual void onRecv(InputMessage *inputMessage);
2011-07-13 23:12:36 +02:00
virtual void onError(const boost::system::error_code& err);
2011-04-20 08:40:31 +02:00
virtual const char* getLuaTypeName() const { return "Protocol"; }
2011-05-31 03:55:34 +02:00
2011-05-30 05:11:12 +02:00
protected:
uint32 m_xteaKey[4];
bool m_xteaEncryptionEnabled;
2011-04-20 08:40:31 +02:00
private:
2011-05-30 05:11:12 +02:00
bool xteaDecrypt(InputMessage *inputMessage);
void xteaEncrypt(OutputMessage *outputMessage);
uint32 getAdlerChecksum(uint8 *buffer, uint16 size);
2011-04-20 08:40:31 +02:00
ConnectionPtr m_connection;
};
typedef std::shared_ptr<Protocol> ProtocolPtr;
2011-05-31 03:55:34 +02:00
2011-04-20 08:40:31 +02:00
#endif