Commit da985311 authored by aleajactaest's avatar aleajactaest
Browse files

update output for spykhanat

parent 30f648d0
......@@ -415,6 +415,7 @@ class SpyPcap():
return actions, impulses
def decode_client_message(self, msgin, clientid, dst, sequenceid, name, Parent, Source):
importantinfo = {}
target = "%s_%s" % (Source, Parent[7:])
CurrentReceivedNumber = msgin.readSint32('CurrentReceivedNumber')
SystemMode = msgin.readBool('SystemMode')
......@@ -489,7 +490,7 @@ class SpyPcap():
else:
logging.getLogger(LOGGER).info("[Client -> Server] System Mode:%s (%d) {CurrentReceivedNumber:%d, src:%s, dst:%s}" % (typeMessage, message, CurrentReceivedNumber, clientid, dst))
logging.getLogger(LOGGER).debug("[Client -> Server] msg:%s" % msgin.showAllData())
return actions, impulses, databases
return actions, impulses, databases, importantinfo
def decode_khanat_message(self, msgin, src, dst, sequenceid, clientname, Parent, Source):
target = "%s_%s" % (Source, Parent[7:])
......@@ -497,6 +498,7 @@ class SpyPcap():
properties = []
impulses = []
databases = []
importantinfo = {}
CurrentSendNumber = msgin.readSint32('CurrentSendNumber')
logging.getLogger(LOGGER).debug("[Server -> Client] {CurrentSendNumber:%d, src:%s, dst:%s}" % (CurrentSendNumber, src, dst))
SystemMode = msgin.readBool('SystemMode')
......@@ -691,7 +693,7 @@ class SpyPcap():
#cActionFactory.unpack(msgin)
logging.getLogger(LOGGER).debug("[Server -> Client] msg:%s" % msgin.showAllData())
#logging.getLogger(LOGGER).info("impulses:%s" % str(impulses))
return actions, impulses, databases, properties
return actions, impulses, databases, properties, importantinfo
def read(self):
logging.getLogger(LOGGER).info("Conversion => Start")
......@@ -765,11 +767,11 @@ class SpyPcap():
if (self.khanat_host_service and self.khanat_host_service.match(src)) or ( not self.khanat_host_service and khanat_host == src):
_provenance = 'Server -> Client'
logging.getLogger(LOGGER).debug("[%s] (message received) [%s] %s" % (_provenance, datetime.fromtimestamp(pkt.timestamp).strftime("%Y/%m/%d %H:%M:%S"), msgin.showAllData()))
actions_servers, impulses_servers, databases_servers, properties_servers = self.decode_khanat_message(msgin, src, dst, sequenceid, list_host[dst], Reference, list_host[src])
actions_servers, impulses_servers, databases_servers, properties_servers, importantinfo = self.decode_khanat_message(msgin, src, dst, sequenceid, list_host[dst], Reference, list_host[src])
else:
_provenance = 'Client -> Server'
logging.getLogger(LOGGER).debug("[%s] (message received) [%s] %s" % (_provenance, datetime.fromtimestamp(pkt.timestamp).strftime("%Y/%m/%d %H:%M:%S"), msgin.showAllData()))
actions_clients, impulses_clients, databases_clients = self.decode_client_message(msgin, src, dst, sequenceid, list_host[dst], Reference, list_host[src])
actions_clients, impulses_clients, databases_clients, importantinfo = self.decode_client_message(msgin, src, dst, sequenceid, list_host[dst], Reference, list_host[src])
if not msgin.checkOnlyZeroAtEnd(): # msgin.needRead() > 7:
moredata = "message partially decoded"
fullconverted = False
......@@ -777,6 +779,26 @@ class SpyPcap():
moredata = 'message decoded'
if self.show_message_decoded:
logging.getLogger(LOGGER).debug("[%s] (%s) %s" % (_provenance, moredata, msgin.showAllData()))
if importantinfo:
havedata = True
else:
havedata = False
if not havedata:
for impulse_data in impulses_servers:
if impulse_data.get_notice():
havedata = True
break
if havedata:
print(datetime.fromtimestamp(pkt.timestamp).strftime("%Y/%m/%d %H:%M:%S"), _provenance, "(", list_host[src], "=>", list_host[dst], ") [", Reference, "] ")
if importantinfo:
for key in importantinfo:
print(" " * 3, key, ":", importantinfo[key])
if impulses_servers:
for impulse_data in impulses_servers:
data = impulse_data.get_notice()
for key in data:
print(" " * 3, key, ":", data[key])
if self.outyaml:
self.outyaml.write("\n%s:\n sequence: %d\n time: %s\n source: %s\n destination: %s\n function: %s\n adress_source: %s\n adress_destination: %s\n state: %s\n message:\n" % (
Reference,
......@@ -852,9 +874,11 @@ class SpyPcap():
id = 0
#print("-"*30)
#print(impulses_servers)
#print(impulses_servers)
for impulse_data in impulses_servers:
#print("-"*80)
#print(Impulse)
#print(impulse_data)
params = impulse_data.get_parameter()
self.outyaml.write(" %s:\n" % (impulse_data.get_name()))
for key in params:
......
This diff is collapsed.
......@@ -22,6 +22,7 @@ import logging
from tools import getPowerOf2
from tools import BitStream
from tools import Enum
from tools import DecodeDatabase
# from tools import Enum
ItemPropStr = [
......@@ -56,6 +57,25 @@ class ImpulseBase:
self.id = ""
self.param = {}
#self.Reference = []
self.notice = {}
self.headernotice = None
def set_header_notice(self, header):
self.headernotice = header
def append_notice(self, data):
for key in data:
#print("Add", key)
self.notice.setdefault(key, data [key])
def add_notice(self, id, value):
if not self.headernotice:
return
ref = { self.headernotice + '/' +id: value}
self.append_notice(ref)
def get_notice(self):
return self.notice
def set_name(self, name):
self.name = name.replace(':', '_')
......@@ -88,46 +108,55 @@ class ImpulseBase:
def readBool(self, msgin, id):
value = msgin.readBool(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readUint8(self, msgin, id):
value = msgin.readUint8(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readSint8(self, msgin, id):
value = msgin.readSint8(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readUint16(self, msgin, id):
value = msgin.readUint16(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readSint16(self, msgin, id):
value = msgin.readSint16(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readUint32(self, msgin, id):
value = msgin.readUint32(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readSint32(self, msgin, id):
value = msgin.readSint32(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readUint64(self, msgin, id):
value = msgin.readUint64(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readSint64(self, msgin, id):
value = msgin.readSint64(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readSerial(self, msgin, nbBits, id):
......@@ -136,6 +165,7 @@ class ImpulseBase:
else:
value = msgin.readSerial(nbBits, id, typeName="%d bits" % nbBits)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readSerialEnum(self, msgin, nbBits, id, typeEnum):
......@@ -150,26 +180,31 @@ class ImpulseBase:
value = msgin.readSerial(nbBits, id, typeName="%d bits" % nbBits, commentValue=" " + typeEnum.__name__ + "." + nameValue)
self.param.setdefault(id, value)
self.param.setdefault(id + "_name", typeEnum.__name__ + "." + nameValue)
self.add_notice(id, value)
return value
def readUString(self, msgin, id):
value = msgin.readUString(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readUtf8String(self, msgin, id):
value = msgin.readUtf8String(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readString(self, msgin, id):
value = msgin.readString(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readFloat(self, msgin, id):
value = msgin.readFloat(id)
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readVersion(self, msgin, id):
......@@ -177,17 +212,20 @@ class ImpulseBase:
if value == 255: #0xFF: # 0xFF
value = msgin.readUint32(id + '_extended')
self.param.setdefault(id, value)
self.add_notice(id, value)
return value
def readDatabases(self, world, decodeDatabase):
return None
class ImpulseBotchatSetFilters(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/BOTCHAT/SET_FILTERS')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_')
self.name = name.replace(':', '_',)
self.readUint32(msgin, 'qualityMin')
self.readUint32(msgin, 'qualityMax')
self.readUint32(msgin, 'priceMin')
......@@ -201,6 +239,7 @@ class ImpulseBotchatSetFilters(ImpulseBase):
class ImpulseConnectionAskName(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CONNECTION/ASK_NAME')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -212,6 +251,7 @@ class ImpulseConnectionAskName(ImpulseBase):
class ImpulseConnectionCreateChar(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CCONNECTION/CREATE_CHAR')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -255,6 +295,7 @@ class ImpulseConnectionCreateChar(ImpulseBase):
class ImpulseConnectionReady(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CONNECTION/READY')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -265,6 +306,7 @@ class ImpulseConnectionReady(ImpulseBase):
class ImpulseConnectionSelectChar(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CONNECTION/SELECT_CHAR')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -275,6 +317,7 @@ class ImpulseConnectionSelectChar(ImpulseBase):
class ImpulseConnectionUserChar(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CONNECTION/USER_CHAR')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -293,6 +336,7 @@ class ImpulseConnectionUserChar(ImpulseBase):
class ImpulseConnectionShardId(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CONNECTION/SHARD_ID')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -304,16 +348,19 @@ class ImpulseConnectionShardId(ImpulseBase):
class ImpulseConnectionValidName(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CONNECTION/VALID_NAME')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_')
self.readUint8(msgin, 'valide')
return {}
class ImpulseDebugPing(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/DEBUG/PING')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -324,6 +371,7 @@ class ImpulseDebugPing(ImpulseBase):
class ImpulseGuildFemaleTitles(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/GUILD/USE_FEMALE_TITLES')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -335,6 +383,7 @@ class ImpulseNpcIconSetDesc(ImpulseBase):
def __init__(self):
super().__init__()
self.data = BitStream.BitStream()
self.set_header_notice('MsgXML/NPC_ICON/SET_DESC')
def read(self, name, msgin, world, databaseXml):
'''
......@@ -357,6 +406,7 @@ class ImpulseNpcIconSetDesc(ImpulseBase):
class ImpulsePhraseDownload(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/PHRASE/DOWNLOAD')
def readSerialPhrase(self, msgin, id):
self.readUtf8String(msgin, id)
......@@ -413,6 +463,7 @@ class ImpulsePhraseDownload(ImpulseBase):
class ImpulsePosition(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/POSITION')
def read(self, name, msgin, world, databaseXml):
# khanat-opennel-code/code/ryzom/server/src/gpm_service/client_messages.cpp void cbClientPosition( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
......@@ -428,6 +479,7 @@ class ImpulsePosition(ImpulseBase):
class ImpulseSringDynString(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/STRING/DYN_STRING')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -438,6 +490,7 @@ class ImpulseSringDynString(ImpulseBase):
class ImpulseSringManagerReloadCache(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/STRING_MANAGER/RELOAD_CACHE')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -448,6 +501,7 @@ class ImpulseSringManagerReloadCache(ImpulseBase):
class ImpulseSringManagerPhraseSend(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/STRING_MANAGER/PHRASE_SEND')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -465,6 +519,7 @@ class ImpulseSringManagerPhraseSend(ImpulseBase):
class ImpulseSringManagerStringResp(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/STRING_MANAGER/STRING_RESP')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -476,6 +531,7 @@ class ImpulseSringManagerStringResp(ImpulseBase):
class ImpulseSringManagerStringRq(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/STRING_MANAGER/STRING_RQ')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -486,6 +542,7 @@ class ImpulseSringManagerStringRq(ImpulseBase):
class impulseGuildUpdatePlayerTitle(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/GUILD/UPDATE_PLAYER_TITLE')
def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read")
......@@ -499,6 +556,7 @@ class impulseGuildUpdatePlayerTitle(ImpulseBase):
class impulseDeathRespawnPoint(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/DEATH/RESPAWN_POINT')
def read(self, name, msgin, world, databaseXml):
id = "CRespawnPointsMsg"
......@@ -513,6 +571,7 @@ class impulseDeathRespawnPoint(ImpulseBase):
class impulseEncyclopediaInit(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/ENCYCLOPEDIA/INIT')
def read_thema(self, id, msgin):
size_thema = self.readSint32(msgin, '%s_thema_len' % (id))
......@@ -556,6 +615,7 @@ class impulseEncyclopediaInit(ImpulseBase):
class impulseInitInventory(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/DB_INIT/INV')
def read(self, name, msgin, world, databaseXml):
# khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void updateInventoryFromStream (NLMISC::CBitMemStream &impulse, const CInventoryCategoryTemplate *templ, bool notifyItemSheetChanges)
......@@ -609,6 +669,7 @@ class impulseInitInventory(ImpulseBase):
class ImpulseConnectionUserChars(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CONNECTION/USER_CHARS')
def read(self, name, msgin, world, databaseXml):
# khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseUserChars(NLMISC::CBitMemStream &impulse)
......@@ -651,10 +712,12 @@ class ImpulseConnectionUserChars(ImpulseBase):
class impulseDatabaseInitPlayer(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/DB_INIT/PLR')
def read(self, name, msgin, world, databaseXml):
# khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseDatabaseInitPlayer(NLMISC::CBitMemStream &impulse)
# khanat-opennel-code/code/ryzom/server/src/simulation_service/simulated_editor.cpp void impulseDatabaseInitPlayer(NLMISC::CBitMemStream &impulse)
data = {}
id = "DatabaseInitPlayer"
logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_')
......@@ -665,17 +728,24 @@ class impulseDatabaseInitPlayer(ImpulseBase):
for i in range(0, propertyCount):
logging.getLogger(LOGGER).debug("read i:%d" % i)
logging.getLogger(LOGGER).debug("#" * 80)
databaseXml.execute(msgin, world)
state, data = databaseXml.execute(msgin, world)
if state:
# DecodeDatabase.print_dico(data)
self.append_notice(data)
# for key, value in data:
# ret.setdefault(key, value)
#raise "TODO"
if msgin.needRead() > 5:
logging.getLogger(LOGGER).debug(msgin.showAllData())
logging.getLogger(LOGGER).debug(msgin.showAllData())
#raise "TODO"
#self.append_notice(data)
class ImpulseConnectionDeleteChar(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/CONNECTION/DELETE_CHAR')
def read(self, name, msgin, world, databaseXml):
id = "ConnectionDeleteChar"
......@@ -687,6 +757,7 @@ class ImpulseConnectionDeleteChar(ImpulseBase):
class impulseTeamContactInit(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/TEAM/CONTACT_INIT')
def read(self, name, msgin, world, databaseXml):
id = "TeamContactInit"
......@@ -706,6 +777,7 @@ class impulseTeamContactInit(ImpulseBase):
class impulseNpcIconGetDesc(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/NPC_ICON/GET_DESC')
def read(self, name, msgin, world, databaseXml):
# khanat-opennel-code/code/ryzom/server/src/frontend_service/id_impulsions.cpp void cbImpulsionGetNpcIconDesc( CEntityId& sender, CBitMemStream &bms, TGameCycle gamecycle, uint16 serviceId )
......@@ -720,6 +792,7 @@ class impulseNpcIconGetDesc(ImpulseBase):
class impulseUserBars(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/USER/BARS')
def read(self, name, msgin, world, databaseXml):
# khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp void CCharacter::barUpdate()
......@@ -736,6 +809,7 @@ class impulseUserBars(ImpulseBase):
class impulseDbGroupInitBank(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/DB_GROUP/INIT_BANK')
def read(self, name, msgin, world, databaseXml):
# khanat/khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseDatabaseInitBank(NLMISC::CBitMemStream &impulse)
......@@ -752,21 +826,28 @@ class impulseDbGroupInitBank(ImpulseBase):
class impulseDatabaseUpdatePlayer(ImpulseBase):
def __init__(self):
super().__init__()
self.set_header_notice('MsgXML/DB_UPD_PLR')
def read(self, name, msgin, world, databaseXml):
# khanat/khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseDatabaseUpdatePlayer(NLMISC::CBitMemStream &impulse)
data = {}
id = "DbUpdPlr"
logging.getLogger(LOGGER).debug("read %s" % id)
self.name = name.replace(':', '_')
_ = self.readUint32(msgin, '%s_serverTick' % id)
propertyCount = self.readUint16(msgin, '%s_propertyCount' % id)
for i in range(0, propertyCount):
databaseXml.execute(msgin, world)
state, data = databaseXml.execute(msgin, world)
if state:
DecodeDatabase.print_dico(data)
# for key, value in data:
# ret.setdefault(key, value)
#raise "TODO"
if msgin.needRead() > 5:
logging.getLogger(LOGGER).debug(msgin.showAllData())
#raise "TODO"
#raise "TODO"
self.append_notice(data)
class DecodeImpulseSimple:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment