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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/26086 ) Change subject: sim-rest-client: Add support for 'info' command to get IMSI+ICCID ...................................................................... sim-rest-client: Add support for 'info' command to get IMSI+ICCID Change-Id: Ia2a13033b1d3e009a841579184f4ad39101f94d0 --- M contrib/sim-rest-client.py 1 file changed, 49 insertions(+), 22 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/86/26086/1 diff --git a/contrib/sim-rest-client.py b/contrib/sim-rest-client.py index 512765b..7da2363 100755 --- a/contrib/sim-rest-client.py +++ b/contrib/sim-rest-client.py @@ -73,10 +73,9 @@ return False -def build_url(suffix:str) -> str: +def build_url(suffix:str, base_path="/sim-auth-api/v1") -> str: """Build an URL from global server_host, server_port, BASE_PATH and suffix.""" - BASE_PATH= "/sim-auth-api/v1" - return "http://%s:%u%s%s" % (server_host, server_port, BASE_PATH, suffix) + return "http://%s:%u%s%s" % (server_host, server_port, base_path, suffix) def rest_post(suffix:str, js:Optional[dict] = None): @@ -91,29 +90,29 @@ print("POST failed") return resp +def rest_get(suffix:str, base_path=None): + """Perform a RESTful GET.""" + url = build_url(suffix, base_path) + if verbose: + print("GET %s" % url) + resp = requests.get(url) + if verbose: + print("-> %s" % (resp)) + if not resp.ok: + print("GET failed") + return resp -def main(argv): - global server_port, server_host, verbose +def main_info(args): + resp = rest_get('/slot/%u' % args.slot_nr, base_path="/sim-info-api/v1") + if not resp.ok: + print("<- ERROR %u: %s" % (resp.status_code, resp.text)) + sys.exit(1) + resp_json = resp.json() + print("<- %s" % resp_json) - parser = argparse.ArgumentParser() - parser.add_argument("-H", "--host", help="Host to connect to", default="localhost") - parser.add_argument("-p", "--port", help="TCP port to connect to", default=8000) - parser.add_argument("-v", "--verbose", help="increase output verbosity", action='count', default=0) - parser.add_argument("-n", "--slot-nr", help="SIM slot number", type=int, default=0) - parser.add_argument("-c", "--count", help="Auth count", type=int, default=10) - parser.add_argument("-k", "--key", help="Secret key K (hex)", type=str, required=True) - parser.add_argument("-o", "--opc", help="Secret OPc (hex)", type=str, required=True) - parser.add_argument("-a", "--amf", help="AMF Field (hex)", type=str, default="0000") - parser.add_argument("-s", "--sqn", help="SQN Field (hex)", type=str, default="000000000000") - - args = parser.parse_args() - - server_host = args.host - server_port = args.port - verbose = args.verbose - +def main_auth(args): #opc = bytes.fromhex('767A662ACF4587EB0C450C6A95540A04') #k = bytes.fromhex('876B2D8D403EE96755BEF3E0A1857EBE') opc = bytes.fromhex(args.opc) @@ -154,5 +153,33 @@ raise RuntimeError("Auth failure") +def main(argv): + global server_port, server_host, verbose + + parser = argparse.ArgumentParser() + parser.add_argument("-H", "--host", help="Host to connect to", default="localhost") + parser.add_argument("-p", "--port", help="TCP port to connect to", default=8000) + parser.add_argument("-v", "--verbose", help="increase output verbosity", action='count', default=0) + parser.add_argument("-n", "--slot-nr", help="SIM slot number", type=int, default=0) + subp = parser.add_subparsers() + + auth_p = subp.add_parser('auth', help='UMTS AKA Authentication') + auth_p.add_argument("-c", "--count", help="Auth count", type=int, default=10) + auth_p.add_argument("-k", "--key", help="Secret key K (hex)", type=str, required=True) + auth_p.add_argument("-o", "--opc", help="Secret OPc (hex)", type=str, required=True) + auth_p.add_argument("-a", "--amf", help="AMF Field (hex)", type=str, default="0000") + auth_p.add_argument("-s", "--sqn", help="SQN Field (hex)", type=str, default="000000000000") + auth_p.set_defaults(func=main_auth) + + info_p = subp.add_parser('info', help='Information about the Card') + info_p.set_defaults(func=main_info) + + args = parser.parse_args() + server_host = args.host + server_port = args.port + verbose = args.verbose + args.func(args) + + if __name__ == "__main__": main(sys.argv) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/26086 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ia2a13033b1d3e009a841579184f4ad39101f94d0 Gerrit-Change-Number: 26086 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211103/c3e79dda/attachment.htm>