Hi all,
My cli command is “show network device router info 2 5” (2,5 are user input).
i want output as “ciscorouter running”
i am sharing my yang and code(ref from arp) please help me.
module dwm {
namespace “http://tail-f.com/ns/example/dwm”;
prefix dwm;
import ietf-inet-types {
prefix inet;
}
import tailf-common {
prefix tailf;
}
container network {
container device {
container router {
list info {
tailf:callpoint pvt;
config false;
key “first_val second_val”;
max-elements 10;
leaf first_val {
type uint16 {
range "0 .. 3";
}
}
leaf second_val {
type uint16 {
range "0 .. 3";
}
}
}
}
}
}
struct aentry {
int first_val;
int second_val;
struct aentry *next;
};
struct arpdata {
struct aentry *arp_entries;
struct timeval lastparse;
};
static int get_next(struct confd_trans_ctx *tctx,
confd_hkeypath_t *keypath,
long next)
{
struct arpdata *dp = tctx->t_opaque;
struct aentry *curr;
confd_value_t v[2];
if (next == -1) { // first call
if (run_arp(dp) == CONFD_ERR)
return CONFD_ERR;
curr = dp->arp_entries;
next = 0;
} else {
curr = (struct aentry *)next;
}
if (curr == NULL) {
confd_data_reply_next_key(tctx, NULL, -1, -1);
return CONFD_OK;
}
// 2 keys
CONFD_SET_UINT16(&v[0], curr->first_val);
CONFD_SET_UINT16(&v[1], curr->second_val );
confd_data_reply_next_key(tctx, &v[0], 2, (long)curr->next);
return CONFD_OK;
}
static int get_elem(struct confd_trans_ctx *tctx,
confd_hkeypath_t *keypath)
{
confd_value_t v;
int id,id1;
switch (CONFD_GET_XMLTAG(&(keypath->v[0][0]))) {
case dwm_first_val:
id = CONFD_GET_UINT16(&(keypath->v[1][0]));
id1 = CONFD_GET_UINT16(&(keypath->v[1][1]));
printf("\n\t $$$$ params = %d %d \n",id,id1); // 2 5
return_result = get_module(id, id1, 1);
printf("buf_string = %s \n", buf_string); //ciscorouter running
CONFD_SET_STR(&v, buf_string);
default:
return CONFD_ERR;
}
confd_data_reply_value(tctx,&v);
return CONFD_OK;
}
show network device router info 2 5
FIRST SECOND
VAL VAL
2 5