path: root/openbsc/contrib
diff options
authorMax <msuraev@sysmocom.de>2016-08-01 14:26:19 +0200
committerHarald Welte <laforge@gnumonks.org>2016-08-11 06:05:39 +0000
commit2a63d01c1e60aef2a82d2c65dcf640386ba7c0d4 (patch)
tree866347dd4d7a9af01422eebb5c18c18262b5b65d /openbsc/contrib
parentb6f565c97da5aeef8f5a490ea259379265c76b18 (diff)
Use random operation id
According to documentation for Control Interface Protocol <id> is "A numeric identifier, uniquely identifying this particular operation", hence it's best to be illustrated with random integer - use it as default. Fix override of id with previously used python-specific objects' id. Change-Id: I32236c067360526f4e7ee4bbdba64c5137de696d Related: OS#1646
Diffstat (limited to 'openbsc/contrib')
1 files changed, 10 insertions, 8 deletions
diff --git a/openbsc/contrib/bsc_control.py b/openbsc/contrib/bsc_control.py
index 26a421d0b..4fc8b4de4 100755
--- a/openbsc/contrib/bsc_control.py
+++ b/openbsc/contrib/bsc_control.py
@@ -1,6 +1,6 @@
-import sys,os
+import sys,os, random
from optparse import OptionParser
import socket
import struct
@@ -36,15 +36,17 @@ def send(sck, data):
data = prefix_ipa_ctrl_header(data)
-def do_set(var, value, id, sck):
- setmsg = "SET %s %s %s" %(options.id, var, value)
+def do_set(var, value, op_id, sck):
+ setmsg = "SET %s %s %s" %(op_id, var, value)
send(sck, setmsg)
-def do_get(var, id, sck):
- getmsg = "GET %s %s" %(options.id, var)
+def do_get(var, op_id, sck):
+ getmsg = "GET %s %s" %(op_id, var)
send(sck, getmsg)
if __name__ == '__main__':
+ random.seed()
parser = OptionParser("Usage: %prog [options] var [value]")
parser.add_option("-d", "--host", dest="host",
help="connect to HOST", metavar="HOST")
@@ -54,7 +56,7 @@ if __name__ == '__main__':
dest="cmd_get", help="perform GET operation")
parser.add_option("-s", "--set", action="store_true",
dest="cmd_set", help="perform SET operation")
- parser.add_option("-i", "--id", dest="id", default="1",
+ parser.add_option("-i", "--id", dest="op_id", default=random.randint(1, sys.maxint),
help="set id manually", metavar="ID")
parser.add_option("-v", "--verbose", action="store_true",
dest="verbose", help="be verbose", default=False)
@@ -79,12 +81,12 @@ if __name__ == '__main__':
if options.cmd_set:
if len(args) < 2:
parser.error("Set requires var and value arguments")
- do_set(args[0], ' '.join(args[1:]), options.id, sock)
+ do_set(args[0], ' '.join(args[1:]), options.op_id, sock)
if options.cmd_get:
if len(args) != 1:
parser.error("Get requires the var argument")
- do_get(args[0], options.id, sock)
+ do_get(args[0], options.op_id, sock)
data = sock.recv(1024)
while (len(data)>0):