本文整理汇总了Python中dnet.eth方法的典型用法代码示例。如果您正苦于以下问题:Python dnet.eth方法的具体用法?Python dnet.eth怎么用?Python dnet.eth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dnet
的用法示例。
在下文中一共展示了dnet.eth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send
# 需要导入模块: import dnet [as 别名]
# 或者: from dnet import eth [as 别名]
def send(self, x):
iff,a,gw = x.route()
if iff is None:
iff = conf.iface
ifs,cls = self.iflist.get(iff,(None,None))
if ifs is None:
iftype = self.intf.get(iff)["type"]
if iftype == dnet.INTF_TYPE_ETH:
try:
cls = conf.l2types[1]
except KeyError:
warning("Unable to find Ethernet class. Using nothing")
ifs = dnet.eth(iff)
else:
ifs = dnet.ip()
self.iflist[iff] = ifs,cls
if cls is None:
sx = str(x)
else:
sx = str(cls()/x)
x.sent_time = time.time()
ifs.send(sx)
示例2: __init__
# 需要导入模块: import dnet [as 别名]
# 或者: from dnet import eth [as 别名]
def __init__(self, iface = None, type = ETH_P_ALL, filter=None, nofilter=0):
if iface is None:
iface = conf.iface
self.iface = iface
self.ins = open_pcap(iface, 1600, 0, 100)
try:
ioctl(self.ins.fileno(),BIOCIMMEDIATE,struct.pack("I",1))
except:
pass
if nofilter:
if type != ETH_P_ALL: # PF_PACKET stuff. Need to emulate this for pcap
filter = "ether proto %i" % type
else:
filter = None
else:
if conf.except_filter:
if filter:
filter = "(%s) and not (%s)" % (filter, conf.except_filter)
else:
filter = "not (%s)" % conf.except_filter
if type != ETH_P_ALL: # PF_PACKET stuff. Need to emulate this for pcap
if filter:
filter = "(ether proto %i) and (%s)" % (type,filter)
else:
filter = "ether proto %i" % type
if filter:
self.ins.setfilter(filter)
self.outs = dnet.eth(iface)