https://osmocom.org/https://osmocom.org/favicon.ico?16647414092016-05-02T22:59:01ZOpen Source Mobile Communicationsosmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=13072016-05-02T22:59:01Zlaforge
<ul><li><strong>Category</strong> set to <i>osmo-sip-connector</i></li></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=34112017-03-17T21:59:22Zlaforge
<ul><li><strong>Project</strong> changed from <i>OsmoNITB</i> to <i>osmo-sip-connector</i></li><li><strong>Category</strong> deleted (<del><i>osmo-sip-connector</i></del>)</li></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=61602017-11-07T22:01:08Zlaforge
<ul></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=85462018-03-27T13:44:00Zlaforge
<ul><li><strong>Assignee</strong> changed from <i>zecke</i> to <i>4368</i></li></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=111012018-09-01T20:40:26Zlaforge
<ul><li><strong>Assignee</strong> changed from <i>4368</i> to <i>osmith</i></li></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=114882018-09-20T13:29:02Zlaforge
<ul><li><strong>Priority</strong> changed from <i>Normal</i> to <i>High</i></li></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=115082018-09-20T15:54:59Zneelsnhofmeyr@sysmocom.de
<ul></ul><p>little VTY code intro:</p>
<p>example from osmo-bsc: osmo-bsc.git/src/osmo-bsc/bsc_vty.c</p>
<pre>
DEFUN(show_bts, show_bts_cmd, "show bts [<0-255>]",
SHOW_STR "Display information about a BTS\n"
"BTS number")
{
struct gsm_network *net = gsmnet_from_vty(vty);
int bts_nr;
if (argc != 0) {
/* use the BTS number that the user has specified */
bts_nr = atoi(argv[0]);
if (bts_nr >= net->num_bts) {
vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
return CMD_SUCCESS;
}
/* print all BTS's */
for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
return CMD_SUCCESS;
}
[...]
install_element_ve(&show_bts_cmd);
</pre>
<p>The DEFUN comes from libosmocore/include/osmocom/vty/command.h.</p>
<pre>
DEFUN(my_invented_name, my_invented_name_cmd,
"my invented name (with|options)",
"Documentation for 'my' keyword\n" // <-- for the docs, no comma! just a str separated by newlines
"Documentation for 'invented' keyword\n"
"Doc for 'name'\n"
"Doc for 'with'\n"
"Doc for 'options'\n")
{
vty_out(vty, "selected option was '%s'.%s", argv[0], VTY_NEWLINE); // <-- always use VTY_NEWLINE!
return CMD_SUCCESS;
}
</pre>
<p>then, in some init func, place the _cmd at the VTY nodes, e.g. on the VIEW and ENABLE nodes with</p>
<pre>
install_element_ve(&my_invented_name_cmd);
</pre>
<p>In the VTY, you typically don't do input validation, since the command description already ensures that the input matches. In above example, just strcmp("option", argv[0 ]), no need to do something like 'else vty_out(vty, "unknown command!%s", VTY_NEWLINE);'.</p>
<p>braces indicate (alternatives|...), <numbers>, [args-that-can-be-omitted], and all-caps means unvalidated arbitrary argument.<br /><pre>
my command (keyword|choices) <0-9> [(optional|arg)] [optional_arg2]
my command2 FREE_FORMAT_STR
</pre></p>
<p>So, the example above is a VTY command invoked as one of<br /><pre>
show bts
show bts 0
</pre></p>
<p>Often, it makes sense to not use optional [args], but instead create two separate <abbr title="">DEFUN</abbr>, one with and one without the arg.</p> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=115092018-09-20T15:59:58Zneelsnhofmeyr@sysmocom.de
<ul></ul><p>and btw, each of our manuals has an introductory chapter describing the vty interaction and nodes... e.g. chapter 8 in <a class="external" href="https://ftp.osmocom.org/docs/latest/osmobsc-usermanual.pdf">https://ftp.osmocom.org/docs/latest/osmobsc-usermanual.pdf</a></p>
<p>There are also separate auto-generated VTY reference manuals; less interesting / identical to the VTY cmdline online help.</p> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=115382018-09-21T09:47:23Zosmith
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>In Progress</i></li></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=118182018-10-01T11:51:17Zosmith
<ul></ul><p>Thanks for the detailed intro neels! I was quite surprised to see that the <code>show calls</code> command is already available. From what I can tell, it shows the call legs and their states, see the example output below.</p>
<p>No active calls gives no output:<br /><pre>
OsmoSIPcon> show calls
</pre></p>
<p>Phone ringing:<br /><pre>
OsmoSIPcon> show calls
Call(5002) from 101 to 100
Initial leg of type: SIP
SIP nua_handle(0x562e70121080)
SIP state(CONFIRMED)
SIP dir(MO)
SIP wanted_codec((null))
Remote leg of type: MNCC
MNCC state(INITIAL)
MNCC dir(MT)
MNCC callref(5002)
MNCC called TON(0) NPI(0) NUM()
MNCC calling TON(0) NPI(0) NUM()
MNCC imsi()
MNCC timer pending(0)
Call(5001) from 101 to 100
Initial leg of type: MNCC
MNCC state(PROCEEDING)
MNCC dir(MO)
MNCC callref(2147483649)
MNCC called TON(0) NPI(1) NUM(100)
MNCC calling TON(0) NPI(0) NUM(101)
MNCC imsi(9017000000xxxxx)
MNCC timer pending(0)
Remote leg of type: SIP
SIP nua_handle(0x562e7011bbd0)
SIP state(CONFIRMED)
SIP dir(MT)
SIP wanted_codec(GSM)
</pre></p>
<p>Ongoing phone call:<br /><pre>
OsmoSIPcon> show calls
Call(5004) from 100 to 101
Initial leg of type: SIP
SIP nua_handle(0x562e70121110)
SIP state(CONNECTED)
SIP dir(MO)
SIP wanted_codec(GSM)
Remote leg of type: MNCC
MNCC state(CONNECTED)
MNCC dir(MT)
MNCC callref(5004)
MNCC called TON(0) NPI(0) NUM()
MNCC calling TON(0) NPI(0) NUM()
MNCC imsi()
MNCC timer pending(0)
Call(5003) from 100 to 101
Initial leg of type: MNCC
MNCC state(CONNECTED)
MNCC dir(MO)
MNCC callref(2147483650)
MNCC called TON(0) NPI(1) NUM(101)
MNCC calling TON(0) NPI(0) NUM(100)
MNCC imsi(9017000000xxxxx)
MNCC timer pending(0)
Remote leg of type: SIP
SIP nua_handle(0x562e7011bbd0)
SIP state(CONNECTED)
SIP dir(MT)
SIP wanted_codec(GSM)
</pre></p>
<hr />
<p>Is there anything left to do here?</p> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=118612018-10-02T15:39:14Zlaforge
<ul></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=119892018-10-04T09:51:41Zosmith
<ul></ul>Laforge gave the following feedback:
<ul>
<li>show calls should provide better output, imagine a huge network with many calls at once
<ul>
<li>maybe a table with one call per line</li>
<li>maybe filters for phone number prefixes</li>
</ul>
</li>
<li>update the documentation to mention how to use the feature there</li>
</ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=120032018-10-04T13:54:49Zosmith
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>10</i></li></ul> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=120042018-10-04T14:12:36Zosmith
<ul><li><strong>% Done</strong> changed from <i>10</i> to <i>0</i></li></ul><p>After looking at the code, I found that there's also a <code>show calls summary</code> command.<br />It prints two lines for each call (one for each leg), in the following format:</p>
<blockquote>
<p>Call(%u) initial(type=%s,state=%s) remote(type=%s,state=%s)</p>
</blockquote>
<p>(I did not save example output this time, but I can do it if someone's curious.)<br />The call ID is an internal ID (e.g. 5002).</p>
<p>Regarding documentation, both <code>show calls</code> and <code>show calls summary</code> are in the <a href="http://ftp.osmocom.org/docs/latest/osmosipconnector-vty-reference.pdf" class="external">VTY reference</a>. But it doesn't talk about the format in detail, so I guess it should be fine if we change it to something more useful.</p>
<p>I'm working on only displaying one line now, and displaying the actual phone numbers of who is calling who by going through the structs. As a first success, one number was correctly picked out here:<br /><pre>
OsmoSIPcon> show calls summary
Call(5002): mncc leg is remote leg
number:
Call(5001): mncc leg is initial leg
number: 101
</pre></p>
<p>WIP branch (not ready for review): <code>osmith/add-show-calls-commands</code></p> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=120252018-10-05T10:02:53Zosmith
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>90</i></li></ul><p>Patch submitted:<br /><a class="external" href="https://gerrit.osmocom.org/#/c/osmo-sip-connector/+/11238/">https://gerrit.osmocom.org/#/c/osmo-sip-connector/+/11238/</a></p> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=120262018-10-05T13:11:48Zosmith
<ul></ul><p><a class="user active" href="https://osmocom.org/users/7">laforge</a> asked me to align the commits, and I did that (see the gerrit review). The ID is aligned to 5 characters now. But it is an unsigned int, which means it can have up to 20 characters (<code>len(str(2 ** 64))</code>) on x86_64.</p>
<a class="user active" href="https://osmocom.org/users/7">laforge</a> added:
<ul>
<li>"you could print it everywhere in hex to reduce it to 16 digits" </li>
<li>"or alternatively we'd have to recycle the numbers faster by restricting the range" </li>
<li>the maximum width of the output must be 80 characters (we are at 82 already with the short ID column)</li>
</ul>
<hr />
<p>So changing to hex won't make it small enough, leaving only the two options of making the number range smaller or ignoring the 80 character limit.</p>
<p>I would recommend to ignore the 80 character limit in this case to be honest, because changing the program logic just to work around that limit doesn't seem worth it in my opinion. We would also run into the same problem as soon as we added a new column, for example for the duration of the call.</p>
<p>For what it's worth, the output of <code>osmo-bsc --version</code> and other programs also does not fit the 80 characters.</p> osmo-sip-connector - Feature #1680: osmo-sip-connector: Add show VTY commandshttps://osmocom.org/issues/1680?journal_id=121092018-10-09T10:15:43Zosmith
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li><li><strong>% Done</strong> changed from <i>90</i> to <i>100</i></li></ul><p>Patch was merged.</p>