本文整理汇总了Python中config.conf.raw_layer方法的典型用法代码示例。如果您正苦于以下问题:Python conf.raw_layer方法的具体用法?Python conf.raw_layer怎么用?Python conf.raw_layer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.conf
的用法示例。
在下文中一共展示了conf.raw_layer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_packet
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def read_packet(self, size=MTU):
rp = RawPcapReader.read_packet(self,size)
if rp is None:
return None
s,(sec,usec,wirelen) = rp
try:
p = self.LLcls(s)
except KeyboardInterrupt:
raise
except:
if conf.debug_dissector:
raise
p = conf.raw_layer(s)
p.time = sec+0.000001*usec
return p
示例2: add_payload
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def add_payload(self, payload):
if payload is None:
return
elif not isinstance(self.payload, NoPayload):
self.payload.add_payload(payload)
else:
if isinstance(payload, Packet):
self.__dict__["payload"] = payload
payload.add_underlayer(self)
for t in self.aliastypes:
if payload.overload_fields.has_key(t):
self.overloaded_fields = payload.overload_fields[t]
break
elif type(payload) is str:
self.__dict__["payload"] = conf.raw_layer(load=payload)
else:
raise TypeError("payload must be either 'Packet' or 'str', not [%s]" % repr(payload))
示例3: do_dissect_payload
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def do_dissect_payload(self, s):
if s:
cls = self.guess_payload_class(s)
try:
p = cls(s, _internal=1, _underlayer=self)
except KeyboardInterrupt:
raise
except:
if conf.debug_dissector:
if isinstance(cls,type) and issubclass(cls,Packet):
log_runtime.error("%s dissector failed" % cls.name)
else:
log_runtime.error("%s.guess_payload_class() returned [%s]" % (self.__class__.__name__,repr(cls)))
if cls is not None:
raise
p = conf.raw_layer(s, _internal=1, _underlayer=self)
self.add_payload(p)
示例4: hexraw
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def hexraw(self, lfilter=None):
"""Same as nsummary(), except that if a packet has a Raw layer, it will be hexdumped
lfilter: a truth function that decides whether a packet must be displayed"""
for i in range(len(self.res)):
p = self._elt2pkt(self.res[i])
if lfilter is not None and not lfilter(p):
continue
print "%s %s %s" % (conf.color_theme.id(i,fmt="%04i"),
p.sprintf("%.time%"),
self._elt2sum(self.res[i]))
if p.haslayer(conf.raw_layer):
hexdump(p.getlayer(conf.raw_layer).load)
示例5: getfield
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def getfield(self, pkt, s):
l = self.length_from(pkt)
try:
i = self.m2i(pkt, s[:l])
except Exception:
if conf.debug_dissector:
raise
i = conf.raw_layer(load=s[:l])
return s[l:],i
示例6: recv
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def recv(self, x=MTU):
return conf.raw_layer(self.ins.recv(x))
示例7: __init__
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def __init__(self, sock, basecls=None):
if basecls is None:
basecls = conf.raw_layer
SimpleSocket.__init__(self, sock)
self.basecls = basecls
示例8: __div__
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def __div__(self, other):
if isinstance(other, Packet):
cloneA = self.copy()
cloneB = other.copy()
cloneA.add_payload(cloneB)
return cloneA
elif type(other) is str:
return self/conf.raw_layer(load=other)
else:
return other.__rdiv__(self)
示例9: __rdiv__
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def __rdiv__(self, other):
if type(other) is str:
return conf.raw_layer(load=other)/self
else:
raise TypeError
示例10: __gen_send
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import raw_layer [as 别名]
def __gen_send(s, x, inter=0, loop=0, count=None, verbose=None, realtime=None, *args, **kargs):
if type(x) is str:
x = conf.raw_layer(load=x)
if not isinstance(x, Gen):
x = SetGen(x)
if verbose is None:
verbose = conf.verb
n = 0
if count is not None:
loop = -count
elif not loop:
loop=-1
try:
while loop:
dt0 = None
for p in x:
if realtime:
ct = time.time()
if dt0:
st = dt0+p.time-ct
if st > 0:
time.sleep(st)
else:
dt0 = ct-p.time
s.send(p)
n += 1
if verbose:
os.write(1,".")
time.sleep(inter)
if loop < 0:
loop += 1
except KeyboardInterrupt:
pass
s.close()
if verbose:
print "\nSent %i packets." % n