-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcollect_mi.py
executable file
·58 lines (49 loc) · 1.1 KB
/
collect_mi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python2.7
from l1ctl import *
import socket
from scapy.all import *
import SocketServer
osmosock = None
def osmo_read():
print "read()"
global osmosock
buff = osmosock.recv(100)
def init_osmosock():
global osmosock
osmosock = socket.socket(socket.AF_UNIX,socket.SOCK_STREAM)
osmosock.connect('/tmp/osmocom_l2')
def osmo_send(msg):
msg = str(msg)
global osmosock
osmosock.send(msg)
def collect_mi():
init_osmosock()
osmo_init(1005)
global osmosock
while True:
buff = osmosock.recv(100)
p = l1ctl_hdr(buff)
try:
mi = p.payload.payload.payload.getfieldval("mi")
miLen = len(mi)
if miLen is 8 or miLen is 5:
hexdump(mi)
try:
mi2 = p.payload.payload.payload.getfieldval("mi2")
mi2Len = len(mi2)
if mi2Len is 8 or mi2Len is 5:
hexdump(mi2)
except:
pass
except:
pass
def osmo_init(arfcn):
l1_hdr = l1ctl_hdr(msg_type=L1CTL_RESET_REQ)
l1_res = l1ctl_reset()
osmo_send(l1_hdr / l1_res)
osmo_read()
l1_hdr = l1ctl_hdr(msg_type=L1CTL_FBSB_REQ)
l1_fbsb = l1ctl_fbsb_req(band_arfcn=arfcn)
osmo_send(l1_hdr / l1_fbsb)
osmo_read()
collect_mi()