本文整理匯總了Python中error.Scapy_Exception方法的典型用法代碼示例。如果您正苦於以下問題:Python error.Scapy_Exception方法的具體用法?Python error.Scapy_Exception怎麽用?Python error.Scapy_Exception使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類error
的用法示例。
在下文中一共展示了error.Scapy_Exception方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: make_route
# 需要導入模塊: import error [as 別名]
# 或者: from error import Scapy_Exception [as 別名]
def make_route(self, host=None, net=None, gw=None, dev=None):
if host is not None:
thenet,msk = host,32
elif net is not None:
thenet,msk = net.split("/")
msk = int(msk)
else:
raise Scapy_Exception("make_route: Incorrect parameters. You should specify a host or a net")
if gw is None:
gw="0.0.0.0"
if dev is None:
if gw:
nhop = gw
else:
nhop = thenet
dev,ifaddr,x = self.route(nhop)
else:
ifaddr = get_if_addr(dev)
return (atol(thenet), itom(msk), gw, dev, ifaddr)
示例2: __init__
# 需要導入模塊: import error [as 別名]
# 或者: from error import Scapy_Exception [as 別名]
def __init__(self, filename):
self.filename = filename
try:
self.f = gzip.open(filename,"rb")
magic = self.f.read(4)
except IOError:
self.f = open(filename,"rb")
magic = self.f.read(4)
if magic == "\xa1\xb2\xc3\xd4": #big endian
self.endian = ">"
elif magic == "\xd4\xc3\xb2\xa1": #little endian
self.endian = "<"
else:
raise Scapy_Exception("Not a pcap capture file (bad magic)")
hdr = self.f.read(20)
if len(hdr)<20:
raise Scapy_Exception("Invalid pcap file (too short)")
vermaj,vermin,tz,sig,snaplen,linktype = struct.unpack(self.endian+"HHIIII",hdr)
self.linktype = linktype
示例3: add_payload
# 需要導入模塊: import error [as 別名]
# 或者: from error import Scapy_Exception [as 別名]
def add_payload(self, payload):
raise Scapy_Exception("Can't add payload to NoPayload instance")
示例4: fragment
# 需要導入模塊: import error [as 別名]
# 或者: from error import Scapy_Exception [as 別名]
def fragment(self, *args, **kargs):
raise Scapy_Exception("cannot fragment this packet")
示例5: sprintf
# 需要導入模塊: import error [as 別名]
# 或者: from error import Scapy_Exception [as 別名]
def sprintf(self, fmt, relax):
if relax:
return "??"
else:
raise Scapy_Exception("Format not found [%s]"%fmt)