[PATCH] openbsc[master]: Use random operation id

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Mon Aug 1 12:49:35 UTC 2016


Review at  https://gerrit.osmocom.org/640

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 instead of
previously used python-specific objects' id which only creates
unnecessary confusion between 2 completely unrelated things.

Change-Id: I87d9ee0e9a87f58702c60bb141c973d41fa06997
Related: OS#1646
---
M openbsc/contrib/bsc_control.py
1 file changed, 8 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/40/640/1

diff --git a/openbsc/contrib/bsc_control.py b/openbsc/contrib/bsc_control.py
index 26a421d..dd5d7e9 100755
--- a/openbsc/contrib/bsc_control.py
+++ b/openbsc/contrib/bsc_control.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys,os
+import sys,os, random
 from optparse import OptionParser
 import socket
 import struct
@@ -36,12 +36,12 @@
 	data = prefix_ipa_ctrl_header(data)
 	sck.send(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__':
@@ -64,6 +64,7 @@
         (options, args) = parser.parse_args()
 
         verbose = options.verbose
+        random.seed()
 
         if options.cmd_set and options.cmd_get:
 	        parser.error("Get and set options are mutually exclusive!")
@@ -79,12 +80,12 @@
         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:]), random.randint(1, sys.maxint), 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], random.randint(1, sys.maxint), sock)
 
         data = sock.recv(1024)
         while (len(data)>0):

-- 
To view, visit https://gerrit.osmocom.org/640
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I87d9ee0e9a87f58702c60bb141c973d41fa06997
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list