예제 #1
0
 def save(self, root, namespace):
     """Save in the XML tree the actor definition"""
     xmlActor = etree.SubElement(root, "{" + namespace + "}actor")
     xmlActor.set('id', str(self.getID()))
     xmlActor.set('name', str(self.getName()))
     xmlActor.set('initiator', TypeConvertor.bool2str(self.isInitiator()))
     self.abstractionLayer.save(xmlActor, namespace)
예제 #2
0
 def addPropertiesToElement(xmlMessage, message, namespace):
     # direction
     subDirection = etree.SubElement(xmlMessage,
                                     "{" + namespace + "}direction")
     subDirection.text = message.getDirection()
     # major
     subMajor = etree.SubElement(xmlMessage, "{" + namespace + "}major")
     subMajor.text = message.getMajor()
     # minor
     subMinor = etree.SubElement(xmlMessage, "{" + namespace + "}minor")
     subMinor.text = str(message.getMinor())
     # requestMode
     subRequestMode = etree.SubElement(xmlMessage,
                                       "{" + namespace + "}requestMode")
     subRequestMode.text = message.getRequestMode()
     # pid
     subPid = etree.SubElement(xmlMessage, "{" + namespace + "}pid")
     subPid.text = str(message.getPID())
     # status
     subStatus = etree.SubElement(xmlMessage, "{" + namespace + "}status")
     subStatus.text = str(message.getStatus())
     # information
     subInformation = etree.SubElement(xmlMessage,
                                       "{" + namespace + "}information")
     subInformation.text = str(message.getInformation())
     # cancel
     subCancel = etree.SubElement(xmlMessage, "{" + namespace + "}cancel")
     subCancel.text = TypeConvertor.bool2str(message.getCancel())
     # sizeIn
     subSizeIn = etree.SubElement(xmlMessage, "{" + namespace + "}sizeIn")
     subSizeIn.text = str(message.getSizeIn())
     # sizeOut
     subSizeOut = etree.SubElement(xmlMessage, "{" + namespace + "}sizeOut")
     subSizeOut.text = str(message.getSizeOut())
예제 #3
0
 def addPropertiesToElement(xmlMessage, message, namespace):
     # direction
     subDirection = etree.SubElement(xmlMessage, "{" + namespace + "}direction")
     subDirection.text = message.getDirection()
     # major
     subMajor = etree.SubElement(xmlMessage, "{" + namespace + "}major")
     subMajor.text = message.getMajor()
     # minor
     subMinor = etree.SubElement(xmlMessage, "{" + namespace + "}minor")
     subMinor.text = str(message.getMinor())
     # requestMode
     subRequestMode = etree.SubElement(xmlMessage, "{" + namespace + "}requestMode")
     subRequestMode.text = message.getRequestMode()
     # pid
     subPid = etree.SubElement(xmlMessage, "{" + namespace + "}pid")
     subPid.text = str(message.getPID())
     # status
     subStatus = etree.SubElement(xmlMessage, "{" + namespace + "}status")
     subStatus.text = str(message.getStatus())
     # information
     subInformation = etree.SubElement(xmlMessage, "{" + namespace + "}information")
     subInformation.text = str(message.getInformation())
     # cancel
     subCancel = etree.SubElement(xmlMessage, "{" + namespace + "}cancel")
     subCancel.text = TypeConvertor.bool2str(message.getCancel())
     # sizeIn
     subSizeIn = etree.SubElement(xmlMessage, "{" + namespace + "}sizeIn")
     subSizeIn.text = str(message.getSizeIn())
     # sizeOut
     subSizeOut = etree.SubElement(xmlMessage, "{" + namespace + "}sizeOut")
     subSizeOut.text = str(message.getSizeOut())
예제 #4
0
 def save(self, root, namespace):
     """Save in the XML tree the actor definition"""
     xmlActor = etree.SubElement(root, "{" + namespace + "}actor")
     xmlActor.set('id', str(self.getID()))
     xmlActor.set('name', str(self.getName()))
     xmlActor.set('initiator', TypeConvertor.bool2str(self.isInitiator()))
     self.abstractionLayer.save(xmlActor, namespace)
    def save(message, xmlMessages, namespace_project, namespace):
        root = etree.SubElement(xmlMessages, "{" + namespace + "}message")
        root.set("id", str(message.getID()))
        root.set("timestamp", str(message.getTimestamp()))
        root.set("{http://www.w3.org/2001/XMLSchema-instance}type", "netzob-common:IRPDeviceIoControlMessage")
        # data
        subData = etree.SubElement(root, "{" + namespace + "}data")
        subData.text = str(message.getData())
        # direction
        subDirection = etree.SubElement(root, "{" + namespace + "}direction")
        subDirection.text = message.getDirection()
        # major
        subMajor = etree.SubElement(root, "{" + namespace + "}major")
        subMajor.text = message.getMajor()
        # minor
        subMinor = etree.SubElement(root, "{" + namespace + "}minor")
        subMinor.text = str(message.getMinor())
        # requestMode
        subRequestMode = etree.SubElement(root, "{" + namespace + "}requestMode")
        subRequestMode.text = message.getRequestMode()
        # pid
        subPid = etree.SubElement(root, "{" + namespace + "}pid")
        subPid.text = str(message.getPID())
        # status
        subStatus = etree.SubElement(root, "{" + namespace + "}status")
        subStatus.text = str(message.getStatus())
        # information
        subInformation = etree.SubElement(root, "{" + namespace + "}information")
        subInformation.text = str(message.getInformation())
        # cancel
        subCancel = etree.SubElement(root, "{" + namespace + "}cancel")
        subCancel.text = TypeConvertor.bool2str(message.getCancel())
        # sizeIn
        subSizeIn = etree.SubElement(root, "{" + namespace + "}sizeIn")
        subSizeIn.text = str(message.getSizeIn())
        # sizeOut
        subSizeOut = etree.SubElement(root, "{" + namespace + "}sizeOut")
        subSizeOut.text = str(message.getSizeOut())
        # ioctl
        subIoctl = etree.SubElement(root, "{" + namespace + "}ioctl")
        subIoctl.text = str(message.getIOCTL())

        #pattern
        subPattern = etree.SubElement(root, "{" + namespace + "}pattern")
        subsubDirection = etree.SubElement(subPattern, "{" + namespace + "}direction")
        subsubDirection.text = str(message.getPattern()[0])
        for t in message.getPattern()[1]:
            subsubToken = etree.SubElement(subPattern, "{" + namespace + "}token")
            subsubToken.set("format", t.getFormat())
            subsubToken.set("length", str(t.getLength()))
            subsubToken.set("type", t.getType())
            subsubToken.set("value", t.getValue().encode("base-64"))

        return etree.tostring(root)