本文整理汇总了Python中pcapy.pcap方法的典型用法代码示例。如果您正苦于以下问题:Python pcapy.pcap方法的具体用法?Python pcapy.pcap怎么用?Python pcapy.pcap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pcapy
的用法示例。
在下文中一共展示了pcapy.pcap方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setfilter
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import pcap [as 别名]
def setfilter(self, filter):
self.pcap.setfilter(filter, 0, 0)
示例2: next
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import pcap [as 别名]
def next(self):
c = self.pcap.next()
if c is None:
return
l,pkt,ts = c
return ts,pkt
示例3: __init__
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import pcap [as 别名]
def __init__(self, *args, **kargs):
self.pcap = pcap.open_live(*args, **kargs)
示例4: __getattr__
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import pcap [as 别名]
def __getattr__(self, attr):
return getattr(self.pcap, attr)
示例5: __init__
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import pcap [as 别名]
def __init__(self, device, snaplen, promisc, to_ms):
try:
self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1, timeout_ms=to_ms)
except TypeError:
# Older pypcap versions do not support the timeout_ms argument
self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1)
示例6: next
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import pcap [as 别名]
def next(self):
c = self.pcap.next()
if c is None:
return
ts, pkt = c
return ts, str(pkt)
示例7: __del__
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import pcap [as 别名]
def __del__(self):
fd = self.pcap.fileno()
os.close(fd)
示例8: __init__
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import pcap [as 别名]
def __init__(self, device, snaplen, promisc, to_ms):
# Normal pypcap module has no timeout parameter,
# only the specially patched "scapy" variant has.
if "scapy" in pcap.__version__.lower():
self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1, timeout_ms=to_ms)
else:
self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1)