-vapi_error_e
-interface_simple_stats_cb (vapi_ctx_t ctx, void *callback_ctx,
- vapi_error_e rv, bool is_last,
- vapi_payload_want_interface_simple_stats_reply *
- payload)
-{
- return VAPI_OK;
-}
-
-vapi_error_e
-simple_counters_cb (vapi_ctx_t ctx, void *callback_ctx,
- vapi_payload_vnet_interface_simple_counters * payload)
-{
- int *called = callback_ctx;
- ++*called;
- printf ("simple counters: first_sw_if_index=%u\n",
- payload->first_sw_if_index);
- return VAPI_OK;
-}
-
-START_TEST (test_stats_1)
-{
- printf ("--- Receive stats using generic blocking API ---\n");
- vapi_msg_want_interface_simple_stats *ws =
- vapi_alloc_want_interface_simple_stats (ctx);
- ws->payload.enable_disable = 1;
- ws->payload.pid = getpid ();
- vapi_error_e rv;
- rv = vapi_want_interface_simple_stats (ctx, ws, interface_simple_stats_cb,
- NULL);
- ck_assert_int_eq (VAPI_OK, rv);
- int called = 0;
- vapi_set_event_cb (ctx, vapi_msg_id_vnet_interface_simple_counters,
- (vapi_event_cb) simple_counters_cb, &called);
- rv = vapi_dispatch_one (ctx);
- ck_assert_int_eq (VAPI_OK, rv);
- ck_assert_int_eq (1, called);
-}
-
-END_TEST;
-
-START_TEST (test_stats_2)
-{
- printf ("--- Receive stats using stat-specific blocking API ---\n");
- vapi_msg_want_interface_simple_stats *ws =
- vapi_alloc_want_interface_simple_stats (ctx);
- ws->payload.enable_disable = 1;
- ws->payload.pid = getpid ();
- vapi_error_e rv;
- rv = vapi_want_interface_simple_stats (ctx, ws, interface_simple_stats_cb,
- NULL);
- ck_assert_int_eq (VAPI_OK, rv);
- int called = 0;
- vapi_set_vapi_msg_vnet_interface_simple_counters_event_cb (ctx,
- simple_counters_cb,
- &called);
- rv = vapi_dispatch_one (ctx);
- ck_assert_int_eq (VAPI_OK, rv);
- ck_assert_int_eq (1, called);
-}
-
-END_TEST;
-