本文整理汇总了Python中netzob.Common.Type.TypeConvertor.TypeConvertor.ipToNetzobRaw方法的典型用法代码示例。如果您正苦于以下问题:Python TypeConvertor.ipToNetzobRaw方法的具体用法?Python TypeConvertor.ipToNetzobRaw怎么用?Python TypeConvertor.ipToNetzobRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netzob.Common.Type.TypeConvertor.TypeConvertor
的用法示例。
在下文中一共展示了TypeConvertor.ipToNetzobRaw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: computeCurrentValue
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import ipToNetzobRaw [as 别名]
def computeCurrentValue(self, strValue):
if strValue != None:
if self.format == Format.ASCII:
strCurrentValue = str(strValue)
binCurrentValue = TypeConvertor.string2bin(strValue, 'big')
elif self.format == Format.HEX:
hexVal = TypeConvertor.ipToNetzobRaw(strValue)
if hexVal != None:
strCurrentValue = str(strValue)
binCurrentValue = TypeConvertor.netzobRawToBitArray(hexVal)
else:
strCurrentValue = str("None:Error")
binCurrentValue = None
self.currentValue = (binCurrentValue, strCurrentValue)
else:
self.currentValue = None
示例2: computeCurrentValue
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import ipToNetzobRaw [as 别名]
def computeCurrentValue(self, strValue):
"""computeCurrentValue:
Compute a couple of binary and string values for the current variable.
@type strValue: string
@param strValue: a string value proposed as default value for this variable, must be a "real" ip address declared in ASCII like : "192.168.0.10".
"""
if strValue is not None:
if self.format == Format.ASCII:
strCurrentValue = str(strValue)
binCurrentValue = TypeConvertor.string2bin(strValue, "big")
elif self.format == Format.HEX:
hexVal = TypeConvertor.ipToNetzobRaw(strValue)
if hexVal is not None:
strCurrentValue = str(strValue)
binCurrentValue = TypeConvertor.netzobRawToBitArray(hexVal)
else:
strCurrentValue = str("None:Error")
binCurrentValue = None
self.currentValue = (binCurrentValue, strCurrentValue)
else:
self.currentValue = None