MCPcopy Index your code
hub / github.com/secdev/scapy / voip_play

Function voip_play

scapy/modules/voip.py:47–96  ·  view source on GitHub ↗

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: lis

(s1, lst=None, **kargs)

Source from the content-addressed store, hash-verified

45
46
47def voip_play(s1, lst=None, **kargs):
48 """Play VoIP packets with RAW data that
49 are either sniffed either from an IP, or
50 specified as a list.
51
52 It will play only the incoming packets !
53
54 :param s1: The IP of the src of all VoIP packets.
55 :param lst: (optional) A list of packets to load
56 :type s1: string
57 :type lst: list
58
59 :Example:
60
61 >>> voip_play("64.2.142.189")
62 while calling '411@ideasip.com'
63
64 >>> voip_play("64.2.142.189", lst)
65 with list a list of packets with VoIP data
66 in their RAW layer
67
68 .. seealso:: voip_play2
69 to play both the outcoming and incoming packets
70 at the same time.
71
72 .. seealso:: voip_play3
73 to read RTP VoIP packets
74 """
75
76 proc = subprocess.Popen(sox_base[0] + sox_base[1], stdin=subprocess.PIPE,
77 stdout=subprocess.PIPE)
78 dsp, rd = proc.stdin, proc.stdout
79
80 def play(pkt):
81 if not pkt:
82 return
83 if not pkt.haslayer(UDP) or not pkt.haslayer(IP):
84 return
85 ip = pkt.getlayer(IP)
86 if s1 == ip.src:
87 dsp.write(pkt.getlayer(conf.raw_layer).load[12:])
88 try:
89 if lst is None:
90 sniff(store=0, prn=play, **kargs)
91 else:
92 for p in lst:
93 play(p)
94 finally:
95 dsp.close()
96 rd.close()
97
98
99def voip_play1(s1, lst=None, **kargs):

Callers 1

voip_play1Function · 0.85

Calls 3

sniffFunction · 0.90
playFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected