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.orgHello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/658 to look at the new patch set (#2). Add python functions to get/set ctrl variables Add get_var and set_var functions which handle requested variable while checking for proper response and id. Split header handling into separate function. Change-Id: I08705963c277bd93a011193dd7451a626d606c21 Related: OS#1646 --- M openbsc/contrib/bsc_control.py 1 file changed, 27 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/58/658/2 diff --git a/openbsc/contrib/bsc_control.py b/openbsc/contrib/bsc_control.py index 4fc8b4d..de0c2a9 100755 --- a/openbsc/contrib/bsc_control.py +++ b/openbsc/contrib/bsc_control.py @@ -10,15 +10,18 @@ def prefix_ipa_ctrl_header(data): return struct.pack(">HBB", len(data)+1, 0xee, 0) + data +def ipa_ctrl_header(header): + (plen, ipa_proto, osmo_proto) = struct.unpack(">HBB", header) + return None if (ipa_proto != 0xee or osmo_proto != 0) else plen + def remove_ipa_ctrl_header(data): if (len(data) < 4): raise BaseException("Answer too short!") - (plen, ipa_proto, osmo_proto) = struct.unpack(">HBB", data[:4]) + plen = ipa_ctrl_header(data[:4]) + if (None == plen): + raise BaseException("Wrong protocol in answer!") if (plen + 3 > len(data)): print "Warning: Wrong payload length (expected %i, got %i)" % (plen, len(data) - 3) - if (ipa_proto != 0xee or osmo_proto != 0): - raise BaseException("Wrong protocol in answer!") - return data[4:plen+3], data[plen+3:] def connect(host, port): @@ -44,6 +47,26 @@ getmsg = "GET %s %s" %(op_id, var) send(sck, getmsg) +def do_set_get(sck, var, value = None): + r = random.randint(1, sys.maxint) + if (value != None): + s = 'SET_REPLY' + do_set(var, value, r, sck) + else: + s = 'GET_REPLY' + do_get(var, r, sck) + (answer, data) = remove_ipa_ctrl_header(sck.recv(4096)) + x = answer.split() + if (s == x[0] and str(r) == x[1] and var == x[2]): + return None if ('SET_REPLY' == s and value != x[3]) else x[3] + return None + +def set_var(sck, var, val): + return do_set_get(sck, var, val) + +def get_var(sck, var): + return do_set_get(sck, var) + if __name__ == '__main__': random.seed() -- To view, visit https://gerrit.osmocom.org/658 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I08705963c277bd93a011193dd7451a626d606c21 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder