{
char *out = NULL;
int out_len, name_filter_len = 0, msg_len = 0;
- vl_api_sw_interface_dump_t *mp;
- vl_api_sw_interface_details_t *rmp;
+ int num, i;
+ vl_api_sw_interface_dump_t *mp = NULL;
+ vl_api_sw_interface_details_t *rmp = NULL;
uint32_t sw_if_index = ~0;
+ if (interface == NULL)
+ goto error;
+
name_filter_len = strlen (interface);
msg_len = sizeof (*mp) + name_filter_len;
mp = vl_msg_api_alloc (msg_len);
mp->name_filter.length = htonl (name_filter_len);
memcpy ((char *) mp->name_filter.buf, interface, name_filter_len);
- if (vac->send (vac, (char *) mp, msg_len, &out, &out_len))
+ if (vac->send_dump (vac, (char *) mp, msg_len, &out, &out_len))
{
goto error;
}
{
goto error;
}
+ num = out_len / sizeof (*rmp);
rmp = (vl_api_sw_interface_details_t *) out;
- sw_if_index = ntohl (rmp->sw_if_index);
+ for (i = 0; i < num; i++)
+ {
+ if (strlen (rmp->interface_name) &&
+ streq (interface, rmp->interface_name))
+ {
+ sw_if_index = ntohl (rmp->sw_if_index);
+ break;
+ }
+ rmp += 1;
+ }
error:
- free (out);
- vl_msg_api_free (mp);
+ if (out)
+ free (out);
+ if (mp)
+ vl_msg_api_free (mp);
return sw_if_index;
}
+
/**
* (Un)-install a security policy database
*/