+static void pim_show_interface_traffic (struct vty *vty, u_char uj)
+{
+ struct interface *ifp = NULL;
+ struct pim_interface *pim_ifp = NULL;
+ struct listnode *node = NULL;
+ json_object *json = NULL;
+ json_object *json_row = NULL;
+
+ if (uj)
+ json = json_object_new_object ();
+ else
+ {
+ vty_out (vty, "%s", VTY_NEWLINE);
+ vty_out (vty, "%-12s%-17s%-17s%-17s%-17s%-17s%-17s%s", "Interface",
+ " HELLO", " JOIN", " PRUNE", " REGISTER",
+ " REGISTER-STOP", " ASSERT", VTY_NEWLINE);
+ vty_out (vty,
+ "%-10s%-18s%-17s%-17s%-17s%-17s%-17s%s",
+ "", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
+ " Rx/Tx", " Rx/Tx", VTY_NEWLINE);
+ vty_out (vty,
+ "---------------------------------------------------------------------------------------------------------------%s",
+ VTY_NEWLINE);
+ }
+
+ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
+ {
+ pim_ifp = ifp->info;
+
+ if (!pim_ifp)
+ continue;
+
+ if (pim_ifp->pim_sock_fd < 0)
+ continue;
+ if (uj)
+ {
+ json_row = json_object_new_object ();
+ json_object_pim_ifp_add (json_row, ifp);
+ json_object_int_add (json_row, "helloRx", pim_ifp->pim_ifstat_hello_recv);
+ json_object_int_add (json_row, "helloTx", pim_ifp->pim_ifstat_hello_sent);
+ json_object_int_add (json_row, "joinRx", pim_ifp->pim_ifstat_join_recv);
+ json_object_int_add (json_row, "joinTx", pim_ifp->pim_ifstat_join_send);
+ json_object_int_add (json_row, "registerRx", pim_ifp->pim_ifstat_reg_recv);
+ json_object_int_add (json_row, "registerTx", pim_ifp->pim_ifstat_reg_recv);
+ json_object_int_add (json_row, "registerStopRx", pim_ifp->pim_ifstat_reg_stop_recv);
+ json_object_int_add (json_row, "registerStopTx", pim_ifp->pim_ifstat_reg_stop_send);
+ json_object_int_add (json_row, "assertRx", pim_ifp->pim_ifstat_assert_recv);
+ json_object_int_add (json_row, "assertTx", pim_ifp->pim_ifstat_assert_send);
+
+ json_object_object_add (json, ifp->name, json_row);
+ }
+ else
+ {
+ vty_out (vty,
+ "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %s",
+ ifp->name, pim_ifp->pim_ifstat_hello_recv,
+ pim_ifp->pim_ifstat_hello_sent, pim_ifp->pim_ifstat_join_recv,
+ pim_ifp->pim_ifstat_join_send, pim_ifp->pim_ifstat_prune_recv,
+ pim_ifp->pim_ifstat_prune_send, pim_ifp->pim_ifstat_reg_recv,
+ pim_ifp->pim_ifstat_reg_send,
+ pim_ifp->pim_ifstat_reg_stop_recv,
+ pim_ifp->pim_ifstat_reg_stop_send,
+ pim_ifp->pim_ifstat_assert_recv,
+ pim_ifp->pim_ifstat_assert_send, VTY_NEWLINE);
+ }
+ }
+ if (uj)
+ {
+ vty_out (vty, "%s%s", json_object_to_json_string_ext (json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
+ json_object_free (json);
+ }
+}
+
+static void pim_show_interface_traffic_single (struct vty *vty, const char *ifname, u_char uj)
+{
+ struct interface *ifp = NULL;
+ struct pim_interface *pim_ifp = NULL;
+ struct listnode *node = NULL;
+ json_object *json = NULL;
+ json_object *json_row = NULL;
+ uint8_t found_ifname = 0;
+
+ if (uj)
+ json = json_object_new_object ();
+ else
+ {
+ vty_out (vty, "%s", VTY_NEWLINE);
+ vty_out (vty, "%-12s%-17s%-17s%-17s%-17s%-17s%-17s%s", "Interface",
+ " HELLO", " JOIN", " PRUNE", " REGISTER",
+ " REGISTER-STOP", " ASSERT", VTY_NEWLINE);
+ vty_out (vty,
+ "%-10s%-18s%-17s%-17s%-17s%-17s%-17s%s",
+ "", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
+ " Rx/Tx", " Rx/Tx", VTY_NEWLINE);
+ vty_out (vty,
+ "---------------------------------------------------------------------------------------------------------------%s",
+ VTY_NEWLINE);
+ }
+
+ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
+ {
+ if (strcmp (ifname, ifp->name))
+ continue;
+
+ pim_ifp = ifp->info;
+
+ if (!pim_ifp)
+ continue;
+
+ if (pim_ifp->pim_sock_fd < 0)
+ continue;
+
+ found_ifname = 1;
+ if (uj)
+ {
+ json_row = json_object_new_object ();
+ json_object_pim_ifp_add (json_row, ifp);
+ json_object_int_add (json_row, "helloRx", pim_ifp->pim_ifstat_hello_recv);
+ json_object_int_add (json_row, "helloTx", pim_ifp->pim_ifstat_hello_sent);
+ json_object_int_add (json_row, "joinRx", pim_ifp->pim_ifstat_join_recv);
+ json_object_int_add (json_row, "joinTx", pim_ifp->pim_ifstat_join_send);
+ json_object_int_add (json_row, "registerRx", pim_ifp->pim_ifstat_reg_recv);
+ json_object_int_add (json_row, "registerTx", pim_ifp->pim_ifstat_reg_recv);
+ json_object_int_add (json_row, "registerStopRx", pim_ifp->pim_ifstat_reg_stop_recv);
+ json_object_int_add (json_row, "registerStopTx", pim_ifp->pim_ifstat_reg_stop_send);
+ json_object_int_add (json_row, "assertRx", pim_ifp->pim_ifstat_assert_recv);
+ json_object_int_add (json_row, "assertTx", pim_ifp->pim_ifstat_assert_send);
+
+ json_object_object_add (json, ifp->name, json_row);
+ }
+ else
+ {
+ vty_out (vty,
+ "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %s",
+ ifp->name, pim_ifp->pim_ifstat_hello_recv,
+ pim_ifp->pim_ifstat_hello_sent, pim_ifp->pim_ifstat_join_recv,
+ pim_ifp->pim_ifstat_join_send, pim_ifp->pim_ifstat_prune_recv,
+ pim_ifp->pim_ifstat_prune_send, pim_ifp->pim_ifstat_reg_recv,
+ pim_ifp->pim_ifstat_reg_send,
+ pim_ifp->pim_ifstat_reg_stop_recv,
+ pim_ifp->pim_ifstat_reg_stop_send,
+ pim_ifp->pim_ifstat_assert_recv,
+ pim_ifp->pim_ifstat_assert_send, VTY_NEWLINE);
+ }
+ }
+ if (uj)
+ {
+ vty_out (vty, "%s%s", json_object_to_json_string_ext (json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
+ json_object_free (json);
+ }
+ else
+ {
+ if (!found_ifname)
+ vty_out (vty, "%% No such interface%s", VTY_NEWLINE);
+ }
+}
+