update output for spykhanat

This commit is contained in:
AleaJactaEst 2020-12-01 22:57:45 +01:00
parent 30f648d0b0
commit da985311be
3 changed files with 203 additions and 294 deletions

View file

@ -415,6 +415,7 @@ class SpyPcap():
return actions, impulses return actions, impulses
def decode_client_message(self, msgin, clientid, dst, sequenceid, name, Parent, Source): def decode_client_message(self, msgin, clientid, dst, sequenceid, name, Parent, Source):
importantinfo = {}
target = "%s_%s" % (Source, Parent[7:]) target = "%s_%s" % (Source, Parent[7:])
CurrentReceivedNumber = msgin.readSint32('CurrentReceivedNumber') CurrentReceivedNumber = msgin.readSint32('CurrentReceivedNumber')
SystemMode = msgin.readBool('SystemMode') SystemMode = msgin.readBool('SystemMode')
@ -489,7 +490,7 @@ class SpyPcap():
else: 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).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()) 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): def decode_khanat_message(self, msgin, src, dst, sequenceid, clientname, Parent, Source):
target = "%s_%s" % (Source, Parent[7:]) target = "%s_%s" % (Source, Parent[7:])
@ -497,6 +498,7 @@ class SpyPcap():
properties = [] properties = []
impulses = [] impulses = []
databases = [] databases = []
importantinfo = {}
CurrentSendNumber = msgin.readSint32('CurrentSendNumber') CurrentSendNumber = msgin.readSint32('CurrentSendNumber')
logging.getLogger(LOGGER).debug("[Server -> Client] {CurrentSendNumber:%d, src:%s, dst:%s}" % (CurrentSendNumber, src, dst)) logging.getLogger(LOGGER).debug("[Server -> Client] {CurrentSendNumber:%d, src:%s, dst:%s}" % (CurrentSendNumber, src, dst))
SystemMode = msgin.readBool('SystemMode') SystemMode = msgin.readBool('SystemMode')
@ -691,7 +693,7 @@ class SpyPcap():
#cActionFactory.unpack(msgin) #cActionFactory.unpack(msgin)
logging.getLogger(LOGGER).debug("[Server -> Client] msg:%s" % msgin.showAllData()) logging.getLogger(LOGGER).debug("[Server -> Client] msg:%s" % msgin.showAllData())
#logging.getLogger(LOGGER).info("impulses:%s" % str(impulses)) #logging.getLogger(LOGGER).info("impulses:%s" % str(impulses))
return actions, impulses, databases, properties return actions, impulses, databases, properties, importantinfo
def read(self): def read(self):
logging.getLogger(LOGGER).info("Conversion => Start") 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): 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' _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())) 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: else:
_provenance = 'Client -> Server' _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())) 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: if not msgin.checkOnlyZeroAtEnd(): # msgin.needRead() > 7:
moredata = "message partially decoded" moredata = "message partially decoded"
fullconverted = False fullconverted = False
@ -777,6 +779,26 @@ class SpyPcap():
moredata = 'message decoded' moredata = 'message decoded'
if self.show_message_decoded: if self.show_message_decoded:
logging.getLogger(LOGGER).debug("[%s] (%s) %s" % (_provenance, moredata, msgin.showAllData())) 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: 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" % ( 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, Reference,
@ -852,9 +874,11 @@ class SpyPcap():
id = 0 id = 0
#print("-"*30) #print("-"*30)
#print(impulses_servers) #print(impulses_servers)
#print(impulses_servers)
for impulse_data in impulses_servers: for impulse_data in impulses_servers:
#print("-"*80) #print("-"*80)
#print(Impulse) #print(Impulse)
#print(impulse_data)
params = impulse_data.get_parameter() params = impulse_data.get_parameter()
self.outyaml.write(" %s:\n" % (impulse_data.get_name())) self.outyaml.write(" %s:\n" % (impulse_data.get_name()))
for key in params: for key in params:

View file

@ -36,6 +36,18 @@ def show_dico(dico, level=1):
except: except:
logging.getLogger(LOGGER).debug("empty") logging.getLogger(LOGGER).debug("empty")
def print_dico(dico, level=1):
try:
for ele in dico:
if isinstance(dico[ele], dict):
print("%s %s %s" % ("." * level, ele , ":"))
if isinstance(dico[ele], dict):
show_dico(dico[ele], level+1)
else:
print("%s %s %s" % ("." * level, ele, ':', dico[ele]))
except:
pass
def child(ele): def child(ele):
ret = {} ret = {}
ret_branch = {} ret_branch = {}
@ -114,28 +126,16 @@ class LeafDatabase():
def __init__(self): def __init__(self):
self.name = "" self.name = ""
self.type = "" self.type = ""
self.count = None
def loadXml(self, xmldata):
self.name = xmldata.get('name')
self.type = xmldata.get('type')
if xmldata.get('count'):
self.count = int(xmldata.get('count'))
def loadXmlWithoutCount(self, xmldata, extra=""): def loadXmlWithoutCount(self, xmldata, extra=""):
self.name = xmldata.get('name') + extra self.name = xmldata.get('name') + extra
self.type = xmldata.get('type') self.type = xmldata.get('type')
def countLeaves(self): def countLeaves(self):
if self.count:
logging.getLogger(LOGGER).debug("countLeaves leaf %s (nb:%s)" % (self.name, str(self.count)))
return self.count
else:
logging.getLogger(LOGGER).debug("countLeaves leaf %s (nb:1)" % (self.name)) logging.getLogger(LOGGER).debug("countLeaves leaf %s (nb:1)" % (self.name))
return 1 return 1
def show(self, level=1): def show(self, level=1):
#logging.getLogger(LOGGER).debug("%s %s Leaf %s : %s : %s" % ("*" * level, str(level), self.name, str(self.count), str(self.type)))
logging.getLogger(LOGGER).debug("%s %s Leaf %s [%s]" % ("*" * level, str(level), self.name, str(self.type))) logging.getLogger(LOGGER).debug("%s %s Leaf %s [%s]" % ("*" * level, str(level), self.name, str(self.type)))
def execute(self, msgin, name=""): def execute(self, msgin, name=""):
@ -146,59 +146,51 @@ class LeafDatabase():
if self.type[0] == 'I': # Unsigned if self.type[0] == 'I': # Unsigned
logging.getLogger(LOGGER).debug("Read:" + str (self.type)) logging.getLogger(LOGGER).debug("Read:" + str (self.type))
value = int(self.type[1:]) value = int(self.type[1:])
_ = msgin.readSerialUint64(value, name=tmp, typeName="Uint" + str(value)) data = msgin.readSerialUint64(value, name=tmp, typeName="Uint" + str(value))
elif self.type[0] == 'S': # Signed elif self.type[0] == 'S': # Signed
logging.getLogger(LOGGER).debug("Read:" + str (self.type)) logging.getLogger(LOGGER).debug("Read:" + str (self.type))
value = int(self.type[1:]) value = int(self.type[1:])
# _ = msgin.readNbChar(value, name='DatabaseXML' + tmp) # _ = msgin.readNbChar(value, name='DatabaseXML' + tmp)
_ = msgin.readSerialUint64(value, name=tmp, typeName="Sint" + str(value)) data = msgin.readSerialUint64(value, name=tmp, typeName="Sint" + str(value))
elif self.type == 'TEXT': elif self.type == 'TEXT':
logging.getLogger(LOGGER).debug("type:" + str (self.type)) logging.getLogger(LOGGER).debug("type:" + str (self.type))
value = 32 value = 32
_ = msgin.readSerialSint64(value, name=idname, typeName="Uint32/TEXT") data = msgin.readSerialSint64(value, name=idname, typeName="Uint32/TEXT")
else: else:
logging.getLogger(LOGGER).error("Type inconnu:" + str (self.type)) logging.getLogger(LOGGER).error("Type inconnu:" + str (self.type))
raise "type not managed" raise "type not managed"
return True, {tmp: data}
def execute_atom(self, level, pos, msgin, name=""): def execute_atom(self, level, pos, msgin, name=""):
if name: if name:
extraName = name + "/" + self.name extraName = name + "/" + self.name
else: else:
extraName = self.name extraName = self.name
if self.count:
step = self.count
else:
step = 1
for step in range(0, step):
if self.count:
idname = extraName + str(step)
else:
idname = extraName idname = extraName
logging.getLogger(LOGGER).debug('step:' + str(step) + ' level:'+ str(level) + ' pos:' + str(pos) + ' idname:' + idname) logging.getLogger(LOGGER).debug('level:'+ str(level) + ' pos:' + str(pos) + ' idname:' + idname)
if level < pos: if level < pos:
level += 1 return level + 1, None
continue
if self.type[0] == 'I': if self.type[0] == 'I':
value = int(self.type[1:]) value = int(self.type[1:])
if value > 64: if value > 64:
raise "type not managed" raise "type not managed"
logging.getLogger(LOGGER).debug('value:' + str(value)) logging.getLogger(LOGGER).debug('value:' + str(value))
_ = msgin.readSerialUint64(value, name=idname, typeName="Uint" + str(value)) data = msgin.readSerialUint64(value, name=idname, typeName="Uint" + str(value))
return level+1 return level+1, {extraName: data}
elif self.type[0] == 'S': elif self.type[0] == 'S':
logging.getLogger(LOGGER).debug("type:" + str (self.type)) logging.getLogger(LOGGER).debug("type:" + str (self.type))
value = int(self.type[1:]) value = int(self.type[1:])
_ = msgin.readSerialSint64(value, name=idname, typeName="Sint" + str(value)) data = msgin.readSerialSint64(value, name=idname, typeName="Sint" + str(value))
return level+1 return level+1, {extraName: data}
elif self.type == 'TEXT': elif self.type == 'TEXT':
logging.getLogger(LOGGER).debug("type:" + str (self.type)) logging.getLogger(LOGGER).debug("type:" + str (self.type))
value = 32 value = 32
_ = msgin.readSerialUint64(value, name=idname, typeName="Uint32/TEXT") data = msgin.readSerialUint64(value, name=idname, typeName="Uint32/TEXT")
return level+1 return level+1, {extraName: data}
else: else:
logging.getLogger(LOGGER).debug("Type inconnu:", self.type) logging.getLogger(LOGGER).debug("Type inconnu:", self.type)
raise "type not managed" raise "type not managed"
return level return level, None
class BranchDatabase(): class BranchDatabase():
@ -209,59 +201,6 @@ class BranchDatabase():
self.min = None self.min = None
self.max = None self.max = None
self.atom = False self.atom = False
self.count = None
def loadXmlCount(self, xmldata, extra=""):
if xmldata.get('atom'):
self.atom = True
self.name = xmldata.get('name') + extra
for ele in xmldata:
if ele.tag == 'branch':
newbranch = BranchDatabase()
newbranch.loadXml(ele, extra)
self.branch.append(newbranch)
elif ele.tag == 'leaf':
newleaf = LeafDatabase()
newleaf.loadXml(ele)
self.leaf.append(newleaf)
def loadXml2(self, xmldata, extra="", filter=None):
if filter:
if 'bank' in xmldata:
if filter != xmldata['bank']:
return
else:
return
if xmldata.get('count'):
self.count = int(xmldata.get('count'))
self.name = xmldata.get('name')
newbranch = BranchDatabase()
for i in range(0, self.count):
newbranch.loadXmlCount(xmldata, str(i))
self.branch.append(newbranch)
else:
self.loadXmlCount(xmldata, extra)
def loadXmlWithoutCount(self, xmldata, extra=""):
if xmldata.get('atom'):
self.atom = True
self.name = xmldata.get('name') + extra
for ele in xmldata:
if ele.tag == 'branch':
newbranch = BranchDatabase()
newbranch.loadXml(ele)
self.branch.append(newbranch)
elif ele.tag == 'leaf':
if ele.get('count'):
count = int(ele.get('count'))
for i in range(0, count):
newleaf = LeafDatabase()
newleaf.loadXmlWithoutCount(ele, str(i))
self.leaf.append(newleaf)
else:
newleaf = LeafDatabase()
newleaf.loadXmlWithoutCount(ele)
self.leaf.append(newleaf)
def loadXml(self, xmldata, extra="", filter=None): def loadXml(self, xmldata, extra="", filter=None):
if filter: if filter:
@ -296,34 +235,11 @@ class BranchDatabase():
newleaf.loadXmlWithoutCount(ele, "") newleaf.loadXmlWithoutCount(ele, "")
self.leaf.append(newleaf) self.leaf.append(newleaf)
def loadXmlOld(self, xmldata, extra="", filter=None):
if filter:
if 'bank' in xmldata:
if filter != xmldata['bank']:
return
else:
return
if xmldata.get('count'):
self.count = int(xmldata.get('count'))
if xmldata.get('atom'):
self.atom = True
self.name = xmldata.get('name')
for ele in xmldata:
if ele.tag == 'branch':
newbranch = BranchDatabase()
newbranch.loadXml(ele)
self.branch.append(newbranch)
elif ele.tag == 'leaf':
newleaf = LeafDatabase()
newleaf.loadXml(ele)
self.leaf.append(newleaf)
def loadRootXml(self, xmldata, filter=None): def loadRootXml(self, xmldata, filter=None):
for ele in xmldata: for ele in xmldata:
if ele.tag == 'branch': if ele.tag == 'branch':
if filter: if filter:
if ele.get('bank') == filter: if ele.get('bank') == filter:
# print(ele.get('bank'), filter)
newbranch = BranchDatabase() newbranch = BranchDatabase()
newbranch.loadXml(ele) newbranch.loadXml(ele)
self.branch.append(newbranch) self.branch.append(newbranch)
@ -331,14 +247,8 @@ class BranchDatabase():
def getIdBits(self): def getIdBits(self):
count = 0 count = 0
for ele in self.branch: for ele in self.branch:
if ele.count:
count += ele.count
else:
count += 1 count += 1
for ele in self.leaf: for ele in self.leaf:
if ele.count:
count += ele.count
else:
count += 1 count += 1
return count return count
@ -348,40 +258,29 @@ class BranchDatabase():
count += ele.countLeaves() count += ele.countLeaves()
for ele in self.leaf: for ele in self.leaf:
count += ele.countLeaves() count += ele.countLeaves()
# if self.count and self.atom:
# logging.getLogger(LOGGER).debug("countLeaves branch <- %s (nb:%s)" % (self.name, str(self.count)))
# count *= self.count
return count return count
def execute_atom_found(self, level, pos, msgin, name=""): def execute_atom_found(self, level, pos, msgin, name=""):
if self.count:
step = self.count
else:
step=1 step=1
if name: if name:
extraName = name + self.name extraName = name + self.name
else: else:
extraName = self.name extraName = self.name
for step in range(0, step): logging.getLogger(LOGGER).debug('level:' + str(level) + ' pos:' + str(pos) + ' name:' + name)
logging.getLogger(LOGGER).debug('step:' + str(step)+ ' level:' + str(level) + ' pos:' + str(pos) + ' name:' + name)
if self.count:
idname = extraName + str(step)
else:
idname = extraName idname = extraName
for ele in self.branch: for ele in self.branch:
level = ele.execute_atom_found(level, pos, msgin, idname) level, data = ele.execute_atom_found(level, pos, msgin, idname)
logging.getLogger(LOGGER).debug('step:' + str(step)+ ' level:' + str(level) + ' pos:' + str(pos) + ' name:' + name + ' idname:' + str(idname)) logging.getLogger(LOGGER).debug('level:' + str(level) + ' pos:' + str(pos) + ' name:' + name + ' idname:' + str(idname))
if level > pos: if level > pos:
return level return level, data
for ele in self.leaf: for ele in self.leaf:
level = ele.execute_atom(level, pos, msgin, idname) level, data = ele.execute_atom(level, pos, msgin, idname)
logging.getLogger(LOGGER).debug('step:' + str(step)+ ' level:' + str(level) + ' pos:' + str(pos) + ' name:' + name + ' idname:' + str(idname)) logging.getLogger(LOGGER).debug('level:' + str(level) + ' pos:' + str(pos) + ' name:' + name + ' idname:' + str(idname))
if level > pos: if level > pos:
return level return level, data
return level return level, None
def show(self, level=0, pos=0, filterlevel=None): def show(self, level=0, pos=0, filterlevel=None):
# logging.getLogger(LOGGER).debug( "%s %s pos:%s Branch:%s : %s : %s - %s" % ("*" * level, str(level), str(pos), str(self.name), str(self.count), str(self.atom), str(self.getIdBits())))
logging.getLogger(LOGGER).debug( "%s %s pos:%s Branch:%s atom:%s getIdBits:%s" % ("*" * level, str(level), str(pos), str(self.name), str(self.atom), str(self.getIdBits()))) logging.getLogger(LOGGER).debug( "%s %s pos:%s Branch:%s atom:%s getIdBits:%s" % ("*" * level, str(level), str(pos), str(self.name), str(self.atom), str(self.getIdBits())))
if filterlevel is not None: if filterlevel is not None:
if filterlevel <= level: if filterlevel <= level:
@ -394,6 +293,7 @@ class BranchDatabase():
ele.show(level + 1) ele.show(level + 1)
def execute_atom(self, msgin, parent): def execute_atom(self, msgin, parent):
ret = {}
nbchild = self.countLeaves() nbchild = self.countLeaves()
# nbchild = len(self.leaf) + len(self.branch) # nbchild = len(self.leaf) + len(self.branch)
#nbBit = getPowerOf2.getPowerOf2_Bis(nbchild) #nbBit = getPowerOf2.getPowerOf2_Bis(nbchild)
@ -414,15 +314,18 @@ class BranchDatabase():
logging.getLogger(LOGGER).debug(str(i) + " - " + str(cBitSet.get(i))) logging.getLogger(LOGGER).debug(str(i) + " - " + str(cBitSet.get(i)))
if cBitSet.get(i): if cBitSet.get(i):
todelete_count_true += 1 todelete_count_true += 1
_ = self.execute_atom_found(0, i, msgin, parent) level, data = self.execute_atom_found(0, i, msgin, parent)
#print(data)
for key in data:
ret.setdefault( key, data[key])
#ret.setdefault( self.name+str(i), data )
if todelete_count_true > 1: if todelete_count_true > 1:
logging.getLogger(LOGGER).debug(msgin.showAllData()) logging.getLogger(LOGGER).debug(msgin.showAllData())
#raise "A controler"
logging.getLogger(LOGGER).debug(msgin.showAllDataRaw())
logging.getLogger(LOGGER).debug(msgin.showAllData()) logging.getLogger(LOGGER).debug(msgin.showAllData())
#raise "A faire" if ret:
#if self.name == "GROUP": return True, ret
# raise "A controler" else:
return False, None
def execute_normal(self, msgin, parent): def execute_normal(self, msgin, parent):
nbchild = self.getIdBits() nbchild = self.getIdBits()
@ -430,7 +333,7 @@ class BranchDatabase():
nbBit = getPowerOf2.getPowerOf2_ter(nbchild) nbBit = getPowerOf2.getPowerOf2_ter(nbchild)
if nbBit > msgin.needRead() : if nbBit > msgin.needRead() :
logging.getLogger(LOGGER).debug("nbBit:" + str(nbBit) + " nbchild:" + str(nbchild) + " needRead:" + str(msgin.needRead() )) logging.getLogger(LOGGER).debug("nbBit:" + str(nbBit) + " nbchild:" + str(nbchild) + " needRead:" + str(msgin.needRead() ))
return False return False, None
logging.getLogger(LOGGER).debug("needRead:" + str(msgin.needRead()) + " nbBit:" + str(nbBit)) logging.getLogger(LOGGER).debug("needRead:" + str(msgin.needRead()) + " nbBit:" + str(nbBit))
id = msgin.readSerial(nbBit, name=parent, typeName='Uint'+str(nbBit), emulate=True) id = msgin.readSerial(nbBit, name=parent, typeName='Uint'+str(nbBit), emulate=True)
logging.getLogger(LOGGER).debug("read : needRead:" + str(msgin.needRead()) + " nbBit:" + str(nbBit) + " id:" + str(id)) logging.getLogger(LOGGER).debug("read : needRead:" + str(msgin.needRead()) + " nbBit:" + str(nbBit) + " id:" + str(id))
@ -438,15 +341,9 @@ class BranchDatabase():
ii = 0 ii = 0
for ele in self.branch: for ele in self.branch:
#logging.getLogger(LOGGER).debug(str(i) + " id:" + str(id) + " name:" + str(ele.name)) #logging.getLogger(LOGGER).debug(str(i) + " id:" + str(id) + " name:" + str(ele.name))
if ele.count:
i += ele.count
else:
i += 1 i += 1
if i > id: if i > id:
comment = "" comment = ""
if ele.count:
pos = id - ii
comment = str(pos)
logging.getLogger(LOGGER).debug(str(i) + " id:" + str(id) + " name:" + str(ele.name)) logging.getLogger(LOGGER).debug(str(i) + " id:" + str(id) + " name:" + str(ele.name))
if self.name: if self.name:
idnameshort = parent + self.name + '/' idnameshort = parent + self.name + '/'
@ -454,70 +351,44 @@ class BranchDatabase():
idnameshort = parent idnameshort = parent
idname = idnameshort + ele.name idname = idnameshort + ele.name
_= msgin.readSerial(nbBit, name=idname, typeName='Uint'+str(nbBit), emulate=False, commentValue=ele.name+comment) _= msgin.readSerial(nbBit, name=idname, typeName='Uint'+str(nbBit), emulate=False, commentValue=ele.name+comment)
logging.getLogger(LOGGER).debug("name:" + ele.name + ", count:" + str(ele.count) + ", atom:" + str(ele.atom)) logging.getLogger(LOGGER).debug("name:" + ele.name + ", atom:" + str(ele.atom))
ele.execute(msgin, idnameshort) state, data = ele.execute(msgin, idnameshort)
return True if state:
return True, data
return False, None
ii = i ii = i
for ele in self.leaf: for ele in self.leaf:
logging.getLogger(LOGGER).debug(str(i) + " id:" + str(id) + " name:" + str(ele.name)) logging.getLogger(LOGGER).debug(str(i) + " id:" + str(id) + " name:" + str(ele.name))
if ele.count:
i += ele.count
else:
i += 1 i += 1
if i > id: if i > id:
comment = ""
if ele.count:
pos = id - ii
comment = str(pos)
if self.name: if self.name:
idnameshort = parent + self.name + '/' idnameshort = parent + self.name + '/'
else: else:
idnameshort = parent idnameshort = parent
idname = idnameshort + ele.name + comment idname = idnameshort + ele.name
logging.getLogger(LOGGER).debug(str(i) + " id:" + str(id) + " name:" + str(ele.name)) logging.getLogger(LOGGER).debug(str(i) + " id:" + str(id) + " name:" + str(ele.name))
_ = msgin.readSerial(nbBit, name= idname, typeName='Uint'+str(nbBit), emulate=False, commentValue=ele.name+comment) _ = msgin.readSerial(nbBit, name= idname, typeName='Uint'+str(nbBit), emulate=False, commentValue=ele.name)
logging.getLogger(LOGGER).debug("name:" + ele.name + ", count:" + str(ele.count)) logging.getLogger(LOGGER).debug("name:" + ele.name )
ele.execute(msgin, name=idnameshort) state, data = ele.execute(msgin, name=idname)
return True if state:
return True, data
return False, None
ii = i ii = i
id = msgin.readSerial(nbBit, name=parent, typeName='Uint'+str(nbBit)) id = msgin.readSerial(nbBit, name=parent, typeName='Uint'+str(nbBit))
logging.getLogger(LOGGER).debug("OUT : needRead:" + str(msgin.needRead()) + " nbBit:" + str(nbBit) + " id:" + str(id)+ " i:" + str(ii)) logging.getLogger(LOGGER).debug("OUT : needRead:" + str(msgin.needRead()) + " nbBit:" + str(nbBit) + " id:" + str(id)+ " i:" + str(ii))
print(msgin.showAllData()) logging.getLogger(LOGGER).debug(msgin.showAllData())
raise "Oh" return False, None
return False
def execute(self, msgin, parent='DatabaseXML/'): def execute(self, msgin, parent='DatabaseXML/'):
ret = False, None
if self.atom: if self.atom:
logging.getLogger(LOGGER).debug("execute:" + parent) logging.getLogger(LOGGER).debug("execute:" + parent)
self.execute_atom(msgin, parent) state, data = self.execute_atom(msgin, parent)
else: else:
logging.getLogger(LOGGER).debug("execute:" + parent) logging.getLogger(LOGGER).debug("execute:" + parent)
ok = self.execute_normal(msgin, parent) state, data = self.execute_normal(msgin, parent)
return state, data
def execute2(self, msgin, parent='DatabaseXML/'):
ok = True
while ok:
if self.atom:
logging.getLogger(LOGGER).debug("execute:" + parent)
self.execute_atom(msgin, parent)
else:
logging.getLogger(LOGGER).debug("execute:" + parent)
ok = self.execute_normal(msgin, parent)
# def execute_root(self, msgin):
# if self.atom:
# nbchild = self.countLeaves()
# #nbBit = getPowerOf2.getPowerOf2_Bis(nbchild)
# nbBit = getPowerOf2.getPowerOf2(nbchild)
# raise "A faire"
# else:
# nbchild = self.getIdBits()
# #nbBit = getPowerOf2.getPowerOf2_Bis(nbchild)
# nbBit = getPowerOf2.getPowerOf2(nbchild)
# while msgin.needRead() > nbBit:
# logging.getLogger(LOGGER).debug("needRead:" + str(msgin.needRead()) + ", nbBit:" + str(nbBit))
# self.execute(msgin)
class DecodeDatabase(): class DecodeDatabase():
@ -533,73 +404,6 @@ class DecodeDatabase():
def execute(self, msgin, world): def execute(self, msgin, world):
logging.getLogger(LOGGER).debug("Start execute") logging.getLogger(LOGGER).debug("Start execute")
self.databasePlr.execute(msgin) ret = self.databasePlr.execute(msgin)
logging.getLogger(LOGGER).debug("End execute") logging.getLogger(LOGGER).debug("End execute")
return ret
def loadDatabase2(self, databaseXml):
logging.getLogger(LOGGER).debug("loadDatabase")
base = BranchDatabase()
#base.loadXml(databaseXml, 'PLR')
base.loadRootXml(databaseXml, 'PLR')
base.show(filterlevel=2)
base.show()
tmp = BitStream.BitStream()
tmp.internalSerial(23, 5)
tmp.internalSerial(0,1)
tmp.internalSerial(13237038,32)
base.execute_root(tmp)
logging.getLogger(LOGGER).debug(tmp.showAllData())
tmp = BitStream.BitStream()
tmp.internalSerial(21, 5)
tmp.internalSerial(8,5)
tmp.internalSerial(2,3)
tmp.internalSerial(0,3)
tmp.internalSerial(0,5)
tmp.internalSerial(3,9)
tmp.internalSerial(69,9)
tmp.internalSerial(10,5)
tmp.internalSerial(10,5)
tmp.internalSerial(0,5)
tmp.internalSerial(0,9)
tmp.internalSerial(200,9)
tmp.internalSerial(21,5)
tmp.internalSerial(10,5)
tmp.internalSerial(8,5)
tmp.internalSerial(0,1)
tmp.internalSerial(821933,32)
tmp.internalSerial(0,5)
tmp.internalSerial(0,9)
tmp.internalSerial(100,9)
tmp.internalSerial(14,5)
tmp.internalSerial(16,5)
tmp.internalSerial(4,5)
tmp.internalSerial(0,2)
tmp.internalSerial(15,8)
tmp.internalSerial(64,8)
tmp.internalSerial(0,8)
tmp.internalSerial(1,2)
base.execute_root(tmp)
logging.getLogger(LOGGER).debug(tmp.showAllData())
raise "Stop"
self.databaseXml = databaseXml
id = 0
self.databasePlr = {'name': 'root', 'bank': 'PLR', 'child': {}, 'min':0, 'max':0 , 'atom': False}
for ele in self.databaseXml:
if ele.tag == 'branch':
if ele.get('bank') == "PLR":
if 'atom' in ele:
if int(ele.get('atom')) > 0:
#self.databasePlr
pass
self.databasePlr['child'][id] = child(ele)
self.databasePlr['child'][id]['min'] = id
self.databasePlr['child'][id]['max'] = id
id += 1
#print(dir(ele))
nb = len(self.databasePlr) - 1
self.databasePlr['min'] = 0
self.databasePlr['max'] = nb
show_dico(self.databasePlr)
logging.getLogger(LOGGER).debug("max %d" % str(self.databasePlr['max']))
#raise "Decode"

View file

@ -22,6 +22,7 @@ import logging
from tools import getPowerOf2 from tools import getPowerOf2
from tools import BitStream from tools import BitStream
from tools import Enum from tools import Enum
from tools import DecodeDatabase
# from tools import Enum # from tools import Enum
ItemPropStr = [ ItemPropStr = [
@ -56,6 +57,25 @@ class ImpulseBase:
self.id = "" self.id = ""
self.param = {} self.param = {}
#self.Reference = [] #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): def set_name(self, name):
self.name = name.replace(':', '_') self.name = name.replace(':', '_')
@ -88,46 +108,55 @@ class ImpulseBase:
def readBool(self, msgin, id): def readBool(self, msgin, id):
value = msgin.readBool(id) value = msgin.readBool(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readUint8(self, msgin, id): def readUint8(self, msgin, id):
value = msgin.readUint8(id) value = msgin.readUint8(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readSint8(self, msgin, id): def readSint8(self, msgin, id):
value = msgin.readSint8(id) value = msgin.readSint8(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readUint16(self, msgin, id): def readUint16(self, msgin, id):
value = msgin.readUint16(id) value = msgin.readUint16(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readSint16(self, msgin, id): def readSint16(self, msgin, id):
value = msgin.readSint16(id) value = msgin.readSint16(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readUint32(self, msgin, id): def readUint32(self, msgin, id):
value = msgin.readUint32(id) value = msgin.readUint32(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readSint32(self, msgin, id): def readSint32(self, msgin, id):
value = msgin.readSint32(id) value = msgin.readSint32(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readUint64(self, msgin, id): def readUint64(self, msgin, id):
value = msgin.readUint64(id) value = msgin.readUint64(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readSint64(self, msgin, id): def readSint64(self, msgin, id):
value = msgin.readSint64(id) value = msgin.readSint64(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readSerial(self, msgin, nbBits, id): def readSerial(self, msgin, nbBits, id):
@ -136,6 +165,7 @@ class ImpulseBase:
else: else:
value = msgin.readSerial(nbBits, id, typeName="%d bits" % nbBits) value = msgin.readSerial(nbBits, id, typeName="%d bits" % nbBits)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readSerialEnum(self, msgin, nbBits, id, typeEnum): 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) value = msgin.readSerial(nbBits, id, typeName="%d bits" % nbBits, commentValue=" " + typeEnum.__name__ + "." + nameValue)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.param.setdefault(id + "_name", typeEnum.__name__ + "." + nameValue) self.param.setdefault(id + "_name", typeEnum.__name__ + "." + nameValue)
self.add_notice(id, value)
return value return value
def readUString(self, msgin, id): def readUString(self, msgin, id):
value = msgin.readUString(id) value = msgin.readUString(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readUtf8String(self, msgin, id): def readUtf8String(self, msgin, id):
value = msgin.readUtf8String(id) value = msgin.readUtf8String(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readString(self, msgin, id): def readString(self, msgin, id):
value = msgin.readString(id) value = msgin.readString(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readFloat(self, msgin, id): def readFloat(self, msgin, id):
value = msgin.readFloat(id) value = msgin.readFloat(id)
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readVersion(self, msgin, id): def readVersion(self, msgin, id):
@ -177,17 +212,20 @@ class ImpulseBase:
if value == 255: #0xFF: # 0xFF if value == 255: #0xFF: # 0xFF
value = msgin.readUint32(id + '_extended') value = msgin.readUint32(id + '_extended')
self.param.setdefault(id, value) self.param.setdefault(id, value)
self.add_notice(id, value)
return value return value
def readDatabases(self, world, decodeDatabase): def readDatabases(self, world, decodeDatabase):
return None return None
class ImpulseBotchatSetFilters(ImpulseBase): class ImpulseBotchatSetFilters(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/BOTCHAT/SET_FILTERS')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_') self.name = name.replace(':', '_',)
self.readUint32(msgin, 'qualityMin') self.readUint32(msgin, 'qualityMin')
self.readUint32(msgin, 'qualityMax') self.readUint32(msgin, 'qualityMax')
self.readUint32(msgin, 'priceMin') self.readUint32(msgin, 'priceMin')
@ -201,6 +239,7 @@ class ImpulseBotchatSetFilters(ImpulseBase):
class ImpulseConnectionAskName(ImpulseBase): class ImpulseConnectionAskName(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CONNECTION/ASK_NAME')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -212,6 +251,7 @@ class ImpulseConnectionAskName(ImpulseBase):
class ImpulseConnectionCreateChar(ImpulseBase): class ImpulseConnectionCreateChar(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CCONNECTION/CREATE_CHAR')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -255,6 +295,7 @@ class ImpulseConnectionCreateChar(ImpulseBase):
class ImpulseConnectionReady(ImpulseBase): class ImpulseConnectionReady(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CONNECTION/READY')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -265,6 +306,7 @@ class ImpulseConnectionReady(ImpulseBase):
class ImpulseConnectionSelectChar(ImpulseBase): class ImpulseConnectionSelectChar(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CONNECTION/SELECT_CHAR')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -275,6 +317,7 @@ class ImpulseConnectionSelectChar(ImpulseBase):
class ImpulseConnectionUserChar(ImpulseBase): class ImpulseConnectionUserChar(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CONNECTION/USER_CHAR')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -293,6 +336,7 @@ class ImpulseConnectionUserChar(ImpulseBase):
class ImpulseConnectionShardId(ImpulseBase): class ImpulseConnectionShardId(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CONNECTION/SHARD_ID')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -304,16 +348,19 @@ class ImpulseConnectionShardId(ImpulseBase):
class ImpulseConnectionValidName(ImpulseBase): class ImpulseConnectionValidName(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CONNECTION/VALID_NAME')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_') self.name = name.replace(':', '_')
self.readUint8(msgin, 'valide') self.readUint8(msgin, 'valide')
return {}
class ImpulseDebugPing(ImpulseBase): class ImpulseDebugPing(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/DEBUG/PING')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -324,6 +371,7 @@ class ImpulseDebugPing(ImpulseBase):
class ImpulseGuildFemaleTitles(ImpulseBase): class ImpulseGuildFemaleTitles(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/GUILD/USE_FEMALE_TITLES')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -335,6 +383,7 @@ class ImpulseNpcIconSetDesc(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.data = BitStream.BitStream() self.data = BitStream.BitStream()
self.set_header_notice('MsgXML/NPC_ICON/SET_DESC')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
''' '''
@ -357,6 +406,7 @@ class ImpulseNpcIconSetDesc(ImpulseBase):
class ImpulsePhraseDownload(ImpulseBase): class ImpulsePhraseDownload(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/PHRASE/DOWNLOAD')
def readSerialPhrase(self, msgin, id): def readSerialPhrase(self, msgin, id):
self.readUtf8String(msgin, id) self.readUtf8String(msgin, id)
@ -413,6 +463,7 @@ class ImpulsePhraseDownload(ImpulseBase):
class ImpulsePosition(ImpulseBase): class ImpulsePosition(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/POSITION')
def read(self, name, msgin, world, databaseXml): 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 ) # 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): class ImpulseSringDynString(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/STRING/DYN_STRING')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -438,6 +490,7 @@ class ImpulseSringDynString(ImpulseBase):
class ImpulseSringManagerReloadCache(ImpulseBase): class ImpulseSringManagerReloadCache(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/STRING_MANAGER/RELOAD_CACHE')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -448,6 +501,7 @@ class ImpulseSringManagerReloadCache(ImpulseBase):
class ImpulseSringManagerPhraseSend(ImpulseBase): class ImpulseSringManagerPhraseSend(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/STRING_MANAGER/PHRASE_SEND')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -465,6 +519,7 @@ class ImpulseSringManagerPhraseSend(ImpulseBase):
class ImpulseSringManagerStringResp(ImpulseBase): class ImpulseSringManagerStringResp(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/STRING_MANAGER/STRING_RESP')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -476,6 +531,7 @@ class ImpulseSringManagerStringResp(ImpulseBase):
class ImpulseSringManagerStringRq(ImpulseBase): class ImpulseSringManagerStringRq(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/STRING_MANAGER/STRING_RQ')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -486,6 +542,7 @@ class ImpulseSringManagerStringRq(ImpulseBase):
class impulseGuildUpdatePlayerTitle(ImpulseBase): class impulseGuildUpdatePlayerTitle(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/GUILD/UPDATE_PLAYER_TITLE')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
@ -499,6 +556,7 @@ class impulseGuildUpdatePlayerTitle(ImpulseBase):
class impulseDeathRespawnPoint(ImpulseBase): class impulseDeathRespawnPoint(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/DEATH/RESPAWN_POINT')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
id = "CRespawnPointsMsg" id = "CRespawnPointsMsg"
@ -513,6 +571,7 @@ class impulseDeathRespawnPoint(ImpulseBase):
class impulseEncyclopediaInit(ImpulseBase): class impulseEncyclopediaInit(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/ENCYCLOPEDIA/INIT')
def read_thema(self, id, msgin): def read_thema(self, id, msgin):
size_thema = self.readSint32(msgin, '%s_thema_len' % (id)) size_thema = self.readSint32(msgin, '%s_thema_len' % (id))
@ -556,6 +615,7 @@ class impulseEncyclopediaInit(ImpulseBase):
class impulseInitInventory(ImpulseBase): class impulseInitInventory(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/DB_INIT/INV')
def read(self, name, msgin, world, databaseXml): 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) # 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): class ImpulseConnectionUserChars(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CONNECTION/USER_CHARS')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
# khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseUserChars(NLMISC::CBitMemStream &impulse) # 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): class impulseDatabaseInitPlayer(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/DB_INIT/PLR')
def read(self, name, msgin, world, databaseXml): 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/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) # khanat-opennel-code/code/ryzom/server/src/simulation_service/simulated_editor.cpp void impulseDatabaseInitPlayer(NLMISC::CBitMemStream &impulse)
data = {}
id = "DatabaseInitPlayer" id = "DatabaseInitPlayer"
logging.getLogger(LOGGER).debug("read") logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_') self.name = name.replace(':', '_')
@ -665,17 +728,24 @@ class impulseDatabaseInitPlayer(ImpulseBase):
for i in range(0, propertyCount): for i in range(0, propertyCount):
logging.getLogger(LOGGER).debug("read i:%d" % i) logging.getLogger(LOGGER).debug("read i:%d" % i)
logging.getLogger(LOGGER).debug("#" * 80) 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" #raise "TODO"
if msgin.needRead() > 5: if msgin.needRead() > 5:
logging.getLogger(LOGGER).debug(msgin.showAllData()) logging.getLogger(LOGGER).debug(msgin.showAllData())
logging.getLogger(LOGGER).debug(msgin.showAllData()) logging.getLogger(LOGGER).debug(msgin.showAllData())
#raise "TODO" #raise "TODO"
#self.append_notice(data)
class ImpulseConnectionDeleteChar(ImpulseBase): class ImpulseConnectionDeleteChar(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/CONNECTION/DELETE_CHAR')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
id = "ConnectionDeleteChar" id = "ConnectionDeleteChar"
@ -687,6 +757,7 @@ class ImpulseConnectionDeleteChar(ImpulseBase):
class impulseTeamContactInit(ImpulseBase): class impulseTeamContactInit(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/TEAM/CONTACT_INIT')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
id = "TeamContactInit" id = "TeamContactInit"
@ -706,6 +777,7 @@ class impulseTeamContactInit(ImpulseBase):
class impulseNpcIconGetDesc(ImpulseBase): class impulseNpcIconGetDesc(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/NPC_ICON/GET_DESC')
def read(self, name, msgin, world, databaseXml): 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 ) # 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): class impulseUserBars(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/USER/BARS')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
# khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp void CCharacter::barUpdate() # 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): class impulseDbGroupInitBank(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/DB_GROUP/INIT_BANK')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
# khanat/khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseDatabaseInitBank(NLMISC::CBitMemStream &impulse) # 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): class impulseDatabaseUpdatePlayer(ImpulseBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.set_header_notice('MsgXML/DB_UPD_PLR')
def read(self, name, msgin, world, databaseXml): def read(self, name, msgin, world, databaseXml):
# khanat/khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseDatabaseUpdatePlayer(NLMISC::CBitMemStream &impulse) # khanat/khanat-opennel-code/code/ryzom/client/src/net_manager.cpp void impulseDatabaseUpdatePlayer(NLMISC::CBitMemStream &impulse)
data = {}
id = "DbUpdPlr" id = "DbUpdPlr"
logging.getLogger(LOGGER).debug("read %s" % id) logging.getLogger(LOGGER).debug("read %s" % id)
self.name = name.replace(':', '_') self.name = name.replace(':', '_')
_ = self.readUint32(msgin, '%s_serverTick' % id) _ = self.readUint32(msgin, '%s_serverTick' % id)
propertyCount = self.readUint16(msgin, '%s_propertyCount' % id) propertyCount = self.readUint16(msgin, '%s_propertyCount' % id)
for i in range(0, propertyCount): 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" #raise "TODO"
if msgin.needRead() > 5: if msgin.needRead() > 5:
logging.getLogger(LOGGER).debug(msgin.showAllData()) logging.getLogger(LOGGER).debug(msgin.showAllData())
#raise "TODO" #raise "TODO"
#raise "TODO" #raise "TODO"
self.append_notice(data)
class DecodeImpulseSimple: class DecodeImpulseSimple: