+static void vl_api_get_node_graph_reply_t_handler
+(vl_api_get_node_graph_reply_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ api_main_t * am = &api_main;
+ i32 retval = ntohl(mp->retval);
+ u8 * pvt_copy, * reply;
+ void * oldheap;
+ vlib_node_t * node;
+ int i;
+
+ if (vam->async_mode) {
+ vam->async_errors += (retval < 0);
+ } else {
+ vam->retval = retval;
+ vam->result_ready = 1;
+ }
+
+ /* "Should never happen..." */
+ if (retval != 0)
+ return;
+
+ reply = (u8 *)(mp->reply_in_shmem);
+ pvt_copy = vec_dup (reply);
+
+ /* Toss the shared-memory original... */
+ pthread_mutex_lock (&am->vlib_rp->mutex);
+ oldheap = svm_push_data_heap (am->vlib_rp);
+
+ vec_free (reply);
+
+ svm_pop_heap (oldheap);
+ pthread_mutex_unlock (&am->vlib_rp->mutex);
+
+ if (vam->graph_nodes) {
+ hash_free (vam->graph_node_index_by_name);
+
+ for (i = 0; i < vec_len (vam->graph_nodes); i++) {
+ node = vam->graph_nodes[i];
+ vec_free (node->name);
+ vec_free (node->next_nodes);
+ vec_free (node);
+ }
+ vec_free(vam->graph_nodes);
+ }
+
+ vam->graph_node_index_by_name = hash_create_string (0, sizeof(uword));
+ vam->graph_nodes = vlib_node_unserialize (pvt_copy);
+ vec_free (pvt_copy);
+
+ for (i = 0; i < vec_len (vam->graph_nodes); i++) {
+ node = vam->graph_nodes[i];
+ hash_set_mem (vam->graph_node_index_by_name, node->name, i);
+ }
+}
+
+static void vl_api_get_node_graph_reply_t_handler_json
+(vl_api_get_node_graph_reply_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ api_main_t * am = &api_main;
+ void * oldheap;
+ vat_json_node_t node;
+ u8 * reply;
+
+ /* $$$$ make this real? */
+ vat_json_init_object(&node);
+ vat_json_object_add_int(&node, "retval", ntohl(mp->retval));
+ vat_json_object_add_uint(&node, "reply_in_shmem", mp->reply_in_shmem);
+
+ reply = (u8 *)(mp->reply_in_shmem);
+
+ /* Toss the shared-memory original... */
+ pthread_mutex_lock (&am->vlib_rp->mutex);
+ oldheap = svm_push_data_heap (am->vlib_rp);
+
+ vec_free (reply);
+
+ svm_pop_heap (oldheap);
+ pthread_mutex_unlock (&am->vlib_rp->mutex);
+
+ vat_json_print(vam->ofp, &node);
+ vat_json_free(&node);
+
+ vam->retval = ntohl(mp->retval);
+ vam->result_ready = 1;
+}
+