1
1
#!/usr/bin/env python3
2
2
3
- # Copyright 2013 Mike Ryan
3
+ # Copyright 2013, 2023 Mike Ryan
4
4
#
5
5
# This file is part of Project Ubertooth.
6
6
#
21
21
22
22
import getopt
23
23
import re
24
+ import signal
24
25
import sys
25
26
from subprocess import Popen , PIPE
26
27
28
+ child = None
29
+
30
+ def sig_handler (sig , frame ):
31
+ if child is not None :
32
+ child .terminate ()
27
33
28
34
def main ():
35
+ signal .signal (signal .SIGTERM , sig_handler )
36
+
29
37
try :
30
38
opts , args = getopt .getopt (
31
39
sys .argv [1 :], "h" ,
32
40
[
33
41
"help" ,
34
- "list -interfaces" ,
35
- "list -dlts" ,
36
- "config" ,
42
+ "extcap -interfaces" ,
43
+ "extcap -dlts" ,
44
+ "extcap- config" ,
37
45
"capture" ,
38
- "interface=" ,
46
+ "extcap- interface=" ,
39
47
"fifo=" ,
40
48
"channel=" ,
41
49
])
@@ -56,16 +64,16 @@ def main():
56
64
if o in ("-h" , "--help" ):
57
65
usage ()
58
66
sys .exit ()
59
- elif o == "--list -interfaces" :
67
+ elif o == "--extcap -interfaces" :
60
68
list_interfaces ()
61
69
exit (0 )
62
- elif o == "--list -dlts" :
70
+ elif o == "--extcap -dlts" :
63
71
do_list_dlts = True
64
- elif o == "--config" :
72
+ elif o == "--extcap- config" :
65
73
do_config = True
66
74
elif o == "--capture" :
67
75
do_capture = True
68
- elif o == "--interface" :
76
+ elif o == "--extcap- interface" :
69
77
interface = a
70
78
elif o == "--fifo" :
71
79
fifo = a
@@ -117,8 +125,7 @@ def list_interfaces():
117
125
118
126
119
127
def list_dlts ():
120
- # -c emits DLT_PPI + DLT_BLUETOOTH_LE_LL
121
- print ("dlt {number=192}{name=PPI}{display=Bluetooth Low Energy}" )
128
+ print ("dlt {number=256}{name=DLT_BLUETOOTH_LE_LL_WITH_PHDR}{display=Bluetooth LE}\n " );
122
129
123
130
124
131
def config ():
@@ -138,12 +145,14 @@ def config():
138
145
139
146
140
147
def capture (interface , fifo , channel ):
148
+ global child
141
149
p = Popen ([
142
150
"ubertooth-btle" , "-f" ,
143
151
"-U%s" % interface ,
144
- "-c " , fifo ,
152
+ "-q " , fifo ,
145
153
"-A" , channel ,
146
154
])
155
+ child = p
147
156
p .wait ()
148
157
149
158
if __name__ == "__main__" :
0 commit comments