Continuing the discussion from How to implement command which will appear in config and show?:
I don’t understand how to implement maapi callback function. What are rules to build callback function name from cmdpoint name and yang list ? Where I can find example ?
If I have yang model:
grouping my_feature_session_brief
{
list brief
{
tailf:info "Show my_feature session brief format";
tailf:cli-show-template-enter "";
tailf:cli-show-template-footer "\n";
tailf:cli-table-legend "Flags: Legend information\n" ;
tailf:cli-full-show-path { tailf:cli-max-keys 1; }
tailf:cli-enforce-table;
tailf:sort-order unsorted;
leaf type { type session_type; }
leaf owner { type string; }
}
}
grouping my_feature_session_detail
{
list detail
{
tailf:info "Show my_feature session detail format";
tailf:cli-full-show-path { tailf:cli-max-keys 1; }
tailf:cli-suppress-table;
tailf:cli-show-template-enter "";
tailf:cli-show-template-footer "\n";
tailf:cli-show-template-legend "Flags: Legend information\n";
tailf:cli-show-template "\n"
+ "Interface $(interface)\n"
+ "Source address: $(src_address)\n"
+ "Destination address: $(dst_address)\n"
+ "State: $(state)\n"
+ "...........AND SO ON..........................";
tailf:sort-order unsorted;
leaf state { type session_type; }
/*.............AND SO ON................*/
}
}
grouping my_feature_show_session {
container session {
tailf:info "Show my_feature session information";
config false;
list check {
key "interface destination source";
leaf interface { type string; }
leaf destination { type inet:ipv4-address; }
leaf source { type inet:ipv4-address; }
}
uses my_feature_session_brief;
uses my_feature_session_detail;
}
}
And Cli model:
<?xml version="1.0" encoding="UTF-8"?><clispec xmlns="http://tail-f.com/ns/clispec/1.0" style="c">
<operationalMode>
<cmd name="my_feature" mount="show">
<info>Show my_feature command</info>
<help>Show my_feature command</help>
<cmd name="session">
<info>Show my_feature session</info>
<help>Show my_feature session</help>
<cmd name="brief">
<info>Show my_feature session brief</info>
<help>Show my_feature session brief</help>
<callback>
<capi>
<cmdpoint>show_my_feature_session</cmdpoint>
</capi>
</callback>
</cmd>
<cmd name="detail">
<info>Show my_feature session detail</info>
<help>Show my_feature session detail</help>
<callback>
<capi>
<cmdpoint>show_my_feature_session_detail</cmdpoint>
</capi>
</callback>
</cmd>
</cmd>
</cmd>
</operationalMode>
</clispec>
I don’t know how to implement maapi_cli_cmd() callback function on C .