Skip to content

Commit

Permalink
sta_disconnect: DisconnectInterface
Browse files Browse the repository at this point in the history
Support the DisconnectInterface argument for P2P.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
  • Loading branch information
Shivani Baranwal authored and Jouni Malinen committed Dec 20, 2024
1 parent 14bdf10 commit fc7b9db
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions p2p.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,33 @@ static struct wfa_cs_p2p_group * p2p_group_get(struct sigma_dut *dut,
}


const char * get_p2p_group_ifname(struct sigma_dut *dut, const char *ifname)
{
char *iface, *pos;
static char buf[1000];

/* Try to find a suitable group interface */
if (wpa_command_resp(get_main_ifname(dut), "INTERFACES",
buf, sizeof(buf)) < 0)
return ifname;

iface = buf;
while (iface && *iface) {
pos = strchr(iface, '\n');
if (pos)
*pos++ = '\0';
if (memcmp(iface, "p2p-", 4) == 0) {
sigma_dut_print(dut, DUT_MSG_DEBUG,
"Considering interface '%s' for IP address",
iface);
return iface;
}
iface = pos;
}
return ifname;
}


static const char * get_group_ifname(struct sigma_dut *dut, const char *ifname)
{
static char buf[1000];
Expand Down
1 change: 1 addition & 0 deletions sigma_dut.h
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,7 @@ void start_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
void stop_dhcp(struct sigma_dut *dut, const char *group_ifname, int go);
int p2p_discover_peer(struct sigma_dut *dut, const char *ifname,
const char *peer, int full);
const char * get_p2p_group_ifname(struct sigma_dut *dut, const char *ifname);
enum sigma_cmd_result cmd_sta_p2p_reset(struct sigma_dut *dut,
struct sigma_conn *conn,
struct sigma_cmd *cmd);
Expand Down
4 changes: 4 additions & 0 deletions sta.c
Original file line number Diff line number Diff line change
Expand Up @@ -9005,6 +9005,10 @@ static enum sigma_cmd_result cmd_sta_disconnect(struct sigma_dut *dut,
{
const char *intf = get_param(cmd, "Interface");
const char *val = get_param(cmd, "maintain_profile");
const char *disconnect_iface = get_param(cmd, "DisconnectInterface");

if (disconnect_iface && strcmp(disconnect_iface, "P2P") == 0)
intf = get_p2p_group_ifname(dut, intf);

if (dut->program == PROGRAM_OCE ||
dut->program == PROGRAM_HE ||
Expand Down

0 comments on commit fc7b9db

Please sign in to comment.