3 #include "../common/logsys.h"
4 #include "../common/PyPacket.h"
5 #include "../common/PyRep.h"
6 #include "../packets/AccountPkts.h"
7 #include "../packets/General.h"
8 #include "../packets/LSCPkts.h"
9 #include "../common/PyDumpVisitor.h"
10 #include "../common/PyXMLGenerator.h"
11 #include "../common/CachedObjectMgr.h"
12 #include "../common/RowsetReader.h"
19 #define CALL_REQ_HANDLER(c) m_callReqDisp[#c] = &EVECollectDispatcher::Req_##c;
20 #define CALL_RSP_HANDLER(c) m_callRspDisp[#c] = &EVECollectDispatcher::Rsp_##c;
21 #define BOUND_CALL_RSP_HANDLER(c) m_callRspDisp[#c] = &EVECollectDispatcher::Bound_Rsp_##c;
22 #define NOTIFY_HANDLER(c) m_notifyDisp[#c] = &EVECollectDispatcher::Notify_##c;
25 #define DESTINY_HANDLER(c) m_destinyDisp[#c] = &EVECollectDispatcher::Destiny_##c;
34 _log(COLLECT__MESSAGE,
"Saw AuthenticationReq for %s", (*call)->login.c_str());
38 _log(COLLECT__MESSAGE,
"Saw AuthenticationRsp");
49 packet->
source.
Dump(COLLECT__PACKET_SRC,
" Src: ");
50 packet->
dest.
Dump(COLLECT__PACKET_DEST,
" Dest: ");
53 call->
Dump(COLLECT__CALL_DUMP, &dumper);
57 if(call->
method !=
"MachoBindObject") {
59 printf(
"<element name=\"Call%s\">\n", call->
method.c_str());
62 printf(
"</element>\n");
67 std::map<std::string, _CallReqDispatch>::const_iterator res;
71 (this->*dsp)(packet, &call);
78 PyRepTuple *result = *in_result;
81 std::map<uint32, std::string>::iterator res;
85 if(result->items.size() == 1 && result->items[0]->CheckType(PyRep::SubStream)) {
86 PyRepSubStream *ss = (PyRepSubStream *) result->items[0];
88 if(ss->decoded != NULL) {
94 ss->decoded->visit(&ssd);
100 packet->
source.
Dump(COLLECT__PACKET_SRC,
" Src: ");
101 packet->
dest.
Dump(COLLECT__PACKET_DEST,
" Dest: ");
104 if(res->second !=
"GetCachableObject") {
108 result->visit(&dumper);
114 && res->second !=
"MachoBindObject"
118 result->visit(&sql_dumper);
123 && res->second !=
"MachoBindObject"
125 printf(
"<element name=\"Rsp%s\">\n", res->second.c_str());
128 printf(
"</element>\n");
132 std::map<std::string, _CallRspDispatch>::const_iterator res2;
136 (this->*dsp)(packet, &result);
152 _log(COLLECT__NOTIFY_SUMMARY,
"Notification of type %s", packet->
dest.
service.c_str());
153 packet->
source.
Dump(COLLECT__PACKET_SRC,
" Src: ");
154 packet->
dest.
Dump(COLLECT__PACKET_DEST,
" Dest: ");
156 PyLookupDump dumper(&
lookResolver, COLLECT__NOTIFY_DUMP);
157 notify->
Dump(COLLECT__NOTIFY_DUMP, &dumper);
161 printf(
"<element name=\"Notify%s\">\n", packet->
dest.
service.c_str());
164 printf(
"</element>\n");
168 std::map<std::string, _NotifyDispatch>::const_iterator res;
172 (this->*dsp)(packet, ¬ify);
179 _log(COLLECT__ERROR,
"Unprocessed SessionChange");
183 _log(COLLECT__ERROR,
"Unprocessed ErrorResponse");
198 _log(COLLECT__OTHER_DUMP,
"Misc Packet:");
200 packet->
source.
Dump(COLLECT__PACKET_SRC,
" Src: ");
201 packet->
dest.
Dump(COLLECT__PACKET_DEST,
" Dest: ");
204 packet->
Dump(COLLECT__CALL_DUMP, &dumper);
207 printf(
"<element name=\"??\">\n");
210 printf(
"</element>\n");
217 void EVECollectDispatcher::Rsp_MachoBindObject(
const PyPacket *packet, PyRepTuple **res) {
218 if( (*res)->items.size() != 1
219 || !(*res)->items[0]->CheckType(PyRep::SubStream)) {
220 _log(COLLECT__ERROR,
"Invalid MachoBindObject RSP");
223 PyRepSubStream *ss = (PyRepSubStream *) (*res)->items[0];
225 if(ss->decoded == NULL) {
226 _log(COLLECT__ERROR,
"Unable to decode MachoBindObject RSP");
230 std::string method_name =
"UNKNOWN";
231 std::map<uint32, std::string>::iterator resp;
234 method_name = resp->second;
238 RspMachoBindObject c;
240 _log(COLLECT__CALL_SUMMARY,
"Call Response for Bind Call ID %" PRIu64 ": %s", packet->
dest.
callID, method_name.c_str());
245 c.call_return->visit(&sql_dumper);
249 printf(
"<element name=\"Call%s\">\n", method_name.c_str());
251 c.call_return->visit(&gen);
252 printf(
"</element>\n");
259 _log(COLLECT__ERROR,
"UN-dispatched MachoBindObject call");
260 CallMachoBindObject obj;
261 if(obj.Decode(&(*call)->arg_tuple)) {
263 CallMachoBindObject_call c;
264 if(c.Decode(&obj.call)) {
265 _log(COLLECT__CALL_SUMMARY,
"Nested Call ID %" PRIu64 ": %s", packet->
source.
callID, c.method_name.c_str());
271 printf(
"<element name=\"Call%s\">\n", c.method_name.c_str());
273 c.arguments->visit(&gen);
274 printf(
"</element>\n");
281 void EVECollectDispatcher::Rsp_GetCachableObject(
const PyPacket *packet, PyRepTuple **in_result) {
282 PyRepTuple *result = *in_result;
285 if(result->items.size() == 1 &&
286 result->items[0]->CheckType(PyRep::SubStream)) {
287 PyRepSubStream *s = (PyRepSubStream *) result->items[0];
288 result->items[0] = NULL;
291 if(!cobj.Decode(&s)) {
292 _log(CLIENT__ERROR,
"Failed to decode GetCachableObject response");
297 cobj.cache->visit(&v);
299 _log(COLLECT__CALL_DUMP,
"GetCachableObject reply decoded:");
301 cobj.Dump(stdout,
" ",
true);
306 cobj.cache->visit(&sql_dumper);
319 if(!lsc.Decode(¬ify->
args)) {
321 codelog(COLLECT__ERROR,
"Unable to decode OnLSC update main.");
325 _log(COLLECT__NOTIFY_SUMMARY,
" LSC Method on channel %u: %s", lsc.channelID, lsc.method.c_str());
void Dump(LogType type, PyVisitor &dumper)
void(EVECollectDispatcher::* _CallReqDispatch)(const PyPacket *packet, PyCallStream **call)
#define _log(type, fmt,...)
virtual void Handle_Notify(const PyPacket *packet, EVENotificationStream **notify)
std::map< uint32, std::string > pendingBinds
Python object SQL dumper.
virtual void Handle_Other(PyPacket **packet)
virtual void Handle_CallRsp(const PyPacket *packet, PyRepTuple **res)
void(EVECollectDispatcher::* _NotifyDispatch)(const PyPacket *packet, EVENotificationStream **notify)
void Dump(FILE *into, const char *pfx) const
#define is_log_enabled(type)
void Dump(LogType type, PyVisitor &dumper)
void(EVECollectDispatcher::* _CallRspDispatch)(const PyPacket *packet, PyRepTuple **res)
virtual ~EVECollectDispatcher()
std::map< std::string, _CallReqDispatch > m_callReqDisp
#define codelog(type, fmt,...)
virtual void Handle_ErrorResponse(const PyPacket *packet, ErrorResponseBody **body)
virtual void Handle_CallReq(const PyPacket *packet, PyCallStream **call)
std::map< uint32, std::string > pendingCalls
std::map< std::string, _NotifyDispatch > m_notifyDisp
void Dump(LogType type, PyVisitor &dumper)
virtual void Handle_AuthenticationReq(const PyPacket *packet, AuthenticationReq **call)
virtual void Handle_AuthenticationRsp(const PyPacket *packet, AuthenticationRsp **call)
virtual void Handle_SessionChange(const PyPacket *packet, SessionChangeNotification **notify)
PyLookupResolver lookResolver
bool visit(PyVisitor &v) const
Visits object.
std::map< std::string, _CallRspDispatch > m_callRspDisp