本文整理匯總了Python中scapy.layers.rtp.RTP屬性的典型用法代碼示例。如果您正苦於以下問題:Python rtp.RTP屬性的具體用法?Python rtp.RTP怎麽用?Python rtp.RTP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類scapy.layers.rtp
的用法示例。
在下文中一共展示了rtp.RTP屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: voip_play3
# 需要導入模塊: from scapy.layers import rtp [as 別名]
# 或者: from scapy.layers.rtp import RTP [as 別名]
def voip_play3(lst=None,**kargs):
dsp,rd = os.popen2("sox -t .ul - -t ossdsp /dev/dsp")
try:
def play(pkt, dsp=dsp):
if pkt and pkt.haslayer(UDP) and pkt.haslayer(Raw):
dsp.write(pkt.getlayer(RTP).load)
if lst is None:
sniff(store=0, prn=play, **kargs)
else:
for p in lst:
play(p)
finally:
try:
dsp.close()
rd.close()
except:
pass
示例2: voip_play3
# 需要導入模塊: from scapy.layers import rtp [as 別名]
# 或者: from scapy.layers.rtp import RTP [as 別名]
def voip_play3(lst=None,**kargs):
dsp,rd = os.popen2("sox -t .ul - -t ossdsp /dev/dsp")
try:
def play(pkt, dsp=dsp):
if pkt and pkt.haslayer(UDP) and pkt.haslayer(conf.raw_layer):
dsp.write(pkt.getlayer(RTP).load)
if lst is None:
sniff(store=0, prn=play, **kargs)
else:
for p in lst:
play(p)
finally:
try:
dsp.close()
rd.close()
except:
pass
示例3: voip_play3
# 需要導入模塊: from scapy.layers import rtp [as 別名]
# 或者: from scapy.layers.rtp import RTP [as 別名]
def voip_play3(lst=None, **kargs):
"""Same than voip_play, but made to
read and play VoIP RTP packets, without
checking IP.
.. seealso:: voip_play
for basic VoIP packets
"""
proc = subprocess.Popen(sox_base[0] + sox_base[1], stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
dsp, rd = proc.stdin, proc.stdout
def play(pkt, dsp=dsp):
if pkt and pkt.haslayer(UDP) and pkt.haslayer(RTP):
dsp.write(pkt.getlayer(RTP).load)
try:
if lst is None:
sniff(store=0, prn=play, **kargs)
else:
for p in lst:
play(p)
finally:
try:
dsp.close()
rd.close()
except Exception:
pass
示例4: voip_play
# 需要導入模塊: from scapy.layers import rtp [as 別名]
# 或者: from scapy.layers.rtp import RTP [as 別名]
def voip_play(s1, lst=None, **kargs):
"""Play VoIP packets with RAW data that
are either sniffed either from an IP, or
specified as a list.
It will play only the incoming packets !
:param s1: The IP of the src of all VoIP packets.
:param lst: (optional) A list of packets to load
:type s1: string
:type lst: list
:Example:
>>> voip_play("64.2.142.189")
while calling '411@ideasip.com'
>>> voip_play("64.2.142.189", lst)
with list a list of packets with VoIP data
in their RAW layer
.. seealso:: voip_play2
to play both the outcoming and incoming packets
at the same time.
.. seealso:: voip_play3
to read RTP VoIP packets
"""
proc = subprocess.Popen(sox_base[0] + sox_base[1], stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
dsp, rd = proc.stdin, proc.stdout
def play(pkt):
if not pkt:
return
if not pkt.haslayer(UDP) or not pkt.haslayer(IP):
return
ip = pkt.getlayer(IP)
if s1 == ip.src:
dsp.write(pkt.getlayer(conf.raw_layer).load[12:])
try:
if lst is None:
sniff(store=0, prn=play, **kargs)
else:
for p in lst:
play(p)
finally:
dsp.close()
rd.close()