本文整理汇总了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()