When there is a Leafref node in a RPC input, the server will pass to the SIL code a value of Leafref type,
where it's fields in val->v are not set.
Thus, all VAL_XXX macros that accessing val->v fields will not return the actual value of the node.
In order to retrieve the actual value for the Leafref node you need to convert Leafref node first to a real value node.
/******************************************************************** * FUNCTION rpc_invoke * * RPC invocation phase * All constraints have passed at this point. * Call device instrumentation code in this function. * * INPUTS: * see agt/agt_rpc.h for details * * RETURNS: * error status ********************************************************************/ rpc_invoke/validate(ses_cb_t *scb, rpc_msg_t *msg, xml_node_t *methnode) val_value_t *inputval = msg->rpc_input; if (!dlq_empty(&msg->rpc_inputQ)) { inputval = (val_value_t *)dlq_firstEntry(&msg->rpc_inputQ); } val_value_t *child_newval = val_find_child(inputval, (const xmlChar*)"module_name", (const xmlChar*)"leafref_node_name"); if (child_newval && child_newval->res == NO_ERR) { val_value_t *realval = NULL; val_value_t *useval = NULL; /* Convert a value of type NCX_BT_LEAFREF to the value * that the final leafref is pointing at. */ if (VAL_BTYPE(child_newval) == NCX_BT_LEAFREF) { /* malloced val_value_t that must be freed with val_free_value * the val->btyp and val->typdef and val->v fields will be set * based on the real type; the val->obj will still point at * the original object */ realval = val_convert_leafref(child_newval); useval = realval; } else { useval = child_newval; } log_debug("\nleafref_node_name='%u'", VAL_UINT32(useval)); val_free_value(realval); }