-int
-api_pg_create_interface (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_pg_create_interface_t *mp;
-
- u32 if_id = ~0, gso_size = 0;
- u8 gso_enabled = 0;
- int ret;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "if_id %d", &if_id))
- ;
- else if (unformat (input, "gso-enabled"))
- {
- gso_enabled = 1;
- if (unformat (input, "gso-size %u", &gso_size))
- ;
- else
- {
- errmsg ("missing gso-size");
- return -99;
- }
- }
- else
- break;
- }
- if (if_id == ~0)
- {
- errmsg ("missing pg interface index");
- return -99;
- }
-
- /* Construct the API message */
- M (PG_CREATE_INTERFACE, mp);
- mp->context = 0;
- mp->interface_id = ntohl (if_id);
- mp->gso_enabled = gso_enabled;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-int
-api_pg_capture (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_pg_capture_t *mp;
-
- u32 if_id = ~0;
- u8 enable = 1;
- u32 count = 1;
- u8 pcap_file_set = 0;
- u8 *pcap_file = 0;
- int ret;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "if_id %d", &if_id))
- ;
- else if (unformat (input, "pcap %s", &pcap_file))
- pcap_file_set = 1;
- else if (unformat (input, "count %d", &count))
- ;
- else if (unformat (input, "disable"))
- enable = 0;
- else
- break;
- }
- if (if_id == ~0)
- {
- errmsg ("missing pg interface index");
- return -99;
- }
- if (pcap_file_set > 0)
- {
- if (vec_len (pcap_file) > 255)
- {
- errmsg ("pcap file name is too long");
- return -99;
- }
- }
-
- /* Construct the API message */
- M (PG_CAPTURE, mp);
- mp->context = 0;
- mp->interface_id = ntohl (if_id);
- mp->is_enabled = enable;
- mp->count = ntohl (count);
- if (pcap_file_set != 0)
- {
- vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
- }
- vec_free (pcap_file);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-int
-api_pg_enable_disable (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_pg_enable_disable_t *mp;
-
- u8 enable = 1;
- u8 stream_name_set = 0;
- u8 *stream_name = 0;
- int ret;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "stream %s", &stream_name))
- stream_name_set = 1;
- else if (unformat (input, "disable"))
- enable = 0;
- else
- break;
- }
-
- if (stream_name_set > 0)
- {
- if (vec_len (stream_name) > 255)
- {
- errmsg ("stream name too long");
- return -99;
- }
- }
-
- /* Construct the API message */
- M (PG_ENABLE_DISABLE, mp);
- mp->context = 0;
- mp->is_enabled = enable;
- if (stream_name_set != 0)
- {
- vl_api_vec_to_api_string (stream_name, &mp->stream_name);
- }
- vec_free (stream_name);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-int
-api_pg_interface_enable_disable_coalesce (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_pg_interface_enable_disable_coalesce_t *mp;
-
- u32 sw_if_index = ~0;
- u8 enable = 1;
- int ret;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (input, "sw_if_index %d", &sw_if_index))
- ;
- else if (unformat (input, "disable"))
- enable = 0;
- else
- break;
- }
-
- if (sw_if_index == ~0)
- {
- errmsg ("Interface required but not specified");
- return -99;
- }
-
- /* Construct the API message */
- M (PG_INTERFACE_ENABLE_DISABLE_COALESCE, mp);
- mp->context = 0;
- mp->coalesce_enabled = enable;
- mp->sw_if_index = htonl (sw_if_index);
-
- S (mp);
- W (ret);
- return ret;
-}
-