MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / tmsis

Function tmsis

CLI/CLI.cpp:395–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393 " query - run sql query, which may be quoted, eg: tmsis query \"UPDATE TMSI_TABLE SET AUTH=0 WHERE IMSI=='123456789012'\" This option may be removed in future."
394 ;
395static CLIStatus tmsis(int argc, char** argv, ostream& os)
396{
397 // (pat) We used to allow just "dump" or "clear", so be backward compatible for a while.
398 map<string,string> options = cliParse(argc,argv,os,"-a -l -ll -r dump: clear delete -imsi: -tmsi: query: set:");
399 string imsiopt = options["-imsi"];
400 string tmsiopt = options["-tmsi"];
401 unsigned tmsi = strtoul(tmsiopt.c_str(),NULL,0); // No bad effect if option is empty.
402 string myquery;
403 if (argc) return BAD_NUM_ARGS;
404 int verbose = 0;
405 if (options.count("-l")) { verbose = 1; }
406 if (options.count("-ll")) { verbose = 2; }
407 bool showAll = options.count("-a");
408 if (options.count("clear")) {
409 os << "clearing TMSI table" << endl;
410 gTMSITable.tmsiTabClear();
411 return SUCCESS;
412 }
413 if (options.count("dump")) {
414 ofstream fileout;
415 string filename = options["dump"];
416 if (filename.size() == 0) { os << "bad filename"<<endl; return FAILURE; }
417 os << "dumping TMSI table to " << filename << endl;
418 fileout.open(filename.c_str(), ios::out); // erases existing!
419 gTMSITable.tmsiTabDump(verbose,options.count("-r"),fileout,showAll);
420 return SUCCESS;
421 }
422 if (options.count("delete")) {
423 if (tmsiopt.size()) {
424 if (gTMSITable.dropTmsi(tmsi)) {
425 os << format("Deleted TMSI table entry for 0x%x",tmsi) << endl;
426 } else {
427 os << format("Cound not delete TMSI table entry for 0x%x",tmsi) << endl;
428 return FAILURE;
429 }
430 } else if (imsiopt.size()) {
431 if (gTMSITable.dropImsi(imsiopt.c_str())) {
432 os << format("Deleted TMSI table entry for %s",imsiopt) << endl;
433 } else {
434 os << format("Cound not delete TMSI table entry for %s",imsiopt) << endl;
435 return FAILURE;
436 }
437 } else {
438 oops2:
439 os << "expecting: -tmsi or -imsi option" << endl;
440 return FAILURE;
441 }
442 return SUCCESS;
443 }
444 if (options.count("set")) {
445 if (tmsiopt.size()) {
446 myquery = format("UPDATE TMSI_TABLE SET %s WHERE TMSI==%u",options["set"],tmsi);
447 } else if (imsiopt.size()) {
448 myquery = format("UPDATE TMSI_TABLE SET %s WHERE IMSI==%s",options["set"],options["-imsi"]);
449 } else {
450 goto oops2;
451 }
452 goto runmyquery;

Callers

nothing calls this directly

Calls 8

cliParseFunction · 0.85
tmsiTabClearMethod · 0.80
tmsiTabDumpMethod · 0.80
dropTmsiMethod · 0.80
dropImsiMethod · 0.80
sizeMethod · 0.45
openMethod · 0.45
runQueryMethod · 0.45

Tested by

no test coverage detected