Update AW.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2022-03-15 19:45:49 +00:00
parent 29bc469bc1
commit bda732cce4

View file

@ -363,23 +363,22 @@ namespace sa2
if (ImGui::BeginCombo("pcap", current_interface.c_str())) if (ImGui::BeginCombo("pcap", current_interface.c_str()))
{ {
std::vector<char *> ifaces; std::vector<std::string> ifaces;
if (PCapBackend::tfe_enumadapter_open()) if (PCapBackend::tfe_enumadapter_open())
{ {
char *pname; std::string name;
char *pdescription; std::string description;
while (PCapBackend::tfe_enumadapter(&pname, &pdescription)) while (PCapBackend::tfe_enumadapter(name, description))
{ {
ifaces.push_back(pname); ifaces.push_back(name);
lib_free(pdescription);
} }
PCapBackend::tfe_enumadapter_close(); PCapBackend::tfe_enumadapter_close();
for (const auto & iface : ifaces) for (const auto & iface : ifaces)
{ {
const bool isSelected = strcmp(iface, current_interface.c_str()) == 0; const bool isSelected = iface == current_interface;
if (ImGui::Selectable(iface, isSelected)) if (ImGui::Selectable(iface.c_str(), isSelected))
{ {
// the following line interacts with tfe_enumadapter, so we must run it outside the above loop // the following line interacts with tfe_enumadapter, so we must run it outside the above loop
PCapBackend::tfe_interface = iface; PCapBackend::tfe_interface = iface;
@ -389,7 +388,6 @@ namespace sa2
{ {
ImGui::SetItemDefaultFocus(); ImGui::SetItemDefaultFocus();
} }
lib_free(iface);
} }
} }
ImGui::EndCombo(); ImGui::EndCombo();