vam->result_ready = 1;
}
+static void vl_api_get_next_index_reply_t_handler
+(vl_api_get_next_index_reply_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ i32 retval = ntohl(mp->retval);
+ if (vam->async_mode) {
+ vam->async_errors += (retval < 0);
+ } else {
+ vam->retval = retval;
+ if (retval == 0)
+ errmsg ("next node index %d\n", ntohl(mp->next_index));
+ vam->result_ready = 1;
+ }
+}
+
+static void vl_api_get_next_index_reply_t_handler_json
+(vl_api_get_next_index_reply_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ vat_json_node_t node;
+
+ vat_json_init_object(&node);
+ vat_json_object_add_int(&node, "retval", ntohl(mp->retval));
+ vat_json_object_add_uint(&node, "next_index", ntohl(mp->next_index));
+
+ vat_json_print(vam->ofp, &node);
+ vat_json_free(&node);
+
+ vam->retval = ntohl(mp->retval);
+ vam->result_ready = 1;
+}
+
static void vl_api_add_node_next_reply_t_handler
(vl_api_add_node_next_reply_t * mp)
{
_(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
_(CLASSIFY_SESSION_DETAILS, classify_session_details) \
_(IPFIX_ENABLE_REPLY, ipfix_enable_reply) \
-_(IPFIX_DETAILS, ipfix_details)
+_(IPFIX_DETAILS, ipfix_details) \
+_(GET_NEXT_INDEX_REPLY, get_next_index_reply)
/* M: construct, but don't yet send a message */
return 0;
}
+static int api_get_next_index (vat_main_t * vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_get_next_index_t * mp;
+ f64 timeout;
+ u8 * node_name = 0, * next_node_name = 0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "node-name %s", &node_name))
+ ;
+ else if (unformat (i, "next-node-name %s", &next_node_name))
+ break;
+ }
+
+ if (node_name == 0) {
+ errmsg ("node name required\n");
+ return -99;
+ }
+ if (vec_len (node_name) >= ARRAY_LEN(mp->node_name)) {
+ errmsg ("node name too long, max %d\n", ARRAY_LEN(mp->node_name));
+ return -99;
+ }
+
+ if (next_node_name == 0) {
+ errmsg ("next node name required\n");
+ return -99;
+ }
+ if (vec_len (next_node_name) >= ARRAY_LEN(mp->next_name)) {
+ errmsg ("next node name too long, max %d\n", ARRAY_LEN(mp->next_name));
+ return -99;
+ }
+
+ M(GET_NEXT_INDEX, get_next_index);
+ clib_memcpy (mp->node_name, node_name, vec_len(node_name));
+ clib_memcpy (mp->next_name, next_node_name, vec_len(next_node_name));
+ vec_free(node_name);
+ vec_free(next_node_name);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
static int api_add_node_next (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
_(ipfix_enable, "collector_address <ip4> [collector_port <nn>] " \
"src_address <ip4> [fib_id <nn>] [path_mtu <nn>] " \
"[template_interval <nn>]") \
-_(ipfix_dump, "")
+_(ipfix_dump, "") \
+_(get_next_index, "node-name <node-name> next-node-name <node-name>")
/* List of command functions, CLI names map directly to functions */
#define foreach_cli_function \
_(CLASSIFY_SESSION_DUMP,classify_session_dump) \
_(CLASSIFY_SESSION_DETAILS,classify_session_details) \
_(IPFIX_ENABLE,ipfix_enable) \
-_(IPFIX_DUMP,ipfix_dump)
+_(IPFIX_DUMP,ipfix_dump) \
+_(GET_NEXT_INDEX, get_next_index)
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
}))
}
+static void vl_api_get_next_index_t_handler
+(vl_api_get_next_index_t * mp)
+{
+ vlib_main_t * vm = vlib_get_main();
+ vl_api_get_next_index_reply_t * rmp;
+ vlib_node_t * node, * next_node;
+ int rv = 0;
+ u32 next_node_index = ~0, next_index = ~0;
+ uword * p;
+
+ node = vlib_get_node_by_name (vm, mp->node_name);
+
+ if (node == 0) {
+ rv = VNET_API_ERROR_NO_SUCH_NODE;
+ goto out;
+ }
+
+ next_node = vlib_get_node_by_name (vm, mp->next_name);
+
+ if (next_node == 0) {
+ rv = VNET_API_ERROR_NO_SUCH_NODE2;
+ goto out;
+ }
+ else
+ next_node_index = next_node->index;
+
+ p = hash_get (node->next_slot_by_node, next_node_index);
+
+ if (p == 0) {
+ rv = VNET_API_ERROR_NO_SUCH_ENTRY;
+ goto out;
+ }
+ else
+ next_index = p[0];
+
+ out:
+ REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
+ ({
+ rmp->next_index = ntohl(next_index);
+ }));
+}
+
static void vl_api_add_node_next_t_handler
(vl_api_add_node_next_t * mp)
{
FINISH;
}
+static void *vl_api_get_next_index_t_print
+(vl_api_get_next_index_t * mp, void *handle)
+{
+ u8 * s;
+
+ s = format (0, "SCRIPT: get_next_index ");
+ s = format (s, "node-name %s ", mp->node_name);
+ s = format (s, "next-node-name %s ", mp->next_name);
+
+ FINISH;
+}
+
#define foreach_custom_print_function \
_(CREATE_LOOPBACK, create_loopback) \
_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
_(CLASSIFY_TABLE_INFO,classify_table_info) \
_(CLASSIFY_SESSION_DUMP,classify_session_dump) \
_(IPFIX_ENABLE,ipfix_enable) \
-_(IPFIX_DUMP,ipfix_dump)
+_(IPFIX_DUMP,ipfix_dump) \
+_(GET_NEXT_INDEX, get_next_index)
-void vl_msg_api_custom_dump_configure (api_main_t *am)
+void vl_msg_api_custom_dump_configure (api_main_t *am)
{
#define _(n,f) am->msg_print_handlers[VL_API_##n] \
= (void *) vl_api_##f##_t_print;