Skip to content

Commit

Permalink
Add pointer to struct sigma_dut to get-ifname helper functions
Browse files Browse the repository at this point in the history
This is needed to allow more dynamic generation of the interface name
for dual-radio cases.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
  • Loading branch information
Jouni Malinen committed Nov 4, 2019
1 parent 829b7de commit 016ae6c
Show file tree
Hide file tree
Showing 16 changed files with 255 additions and 253 deletions.
102 changes: 51 additions & 51 deletions ap.c

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static enum sigma_cmd_result cmd_ca_get_version(struct sigma_dut *dut,
if (info) {
char buf[200];
snprintf(buf, sizeof(buf), "NOTE CAPI:TestInfo:%s", info);
wpa_command(get_main_ifname(), buf);
wpa_command(get_main_ifname(dut), buf);
}

send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0");
Expand Down Expand Up @@ -97,14 +97,14 @@ static enum sigma_cmd_result cmd_device_get_info(struct sigma_dut *dut,
char host_fw_ver[128];

snprintf(path, sizeof(path), "/sys/class/net/%s/phy80211",
get_main_ifname());
get_main_ifname(dut));
if (stat(path, &s) == 0) {
ssize_t res;
char *pos;

res = snprintf(fname, sizeof(fname),
"/sys/class/net/%s/device/driver",
get_main_ifname());
get_main_ifname(dut));
if (res < 0 || res >= sizeof(fname)) {
model = "Linux/";
} else if ((res = readlink(fname, path,
Expand Down Expand Up @@ -154,11 +154,11 @@ static enum sigma_cmd_result cmd_device_get_info(struct sigma_dut *dut,
sizeof(wpa_supplicant_ver));

host_fw_ver[0] = '\0';
if (get_driver_type() == DRIVER_WCN ||
get_driver_type() == DRIVER_LINUX_WCN) {
if (get_driver_type(dut) == DRIVER_WCN ||
get_driver_type(dut) == DRIVER_LINUX_WCN) {
get_ver("iwpriv wlan0 version", host_fw_ver,
sizeof(host_fw_ver));
} else if (get_driver_type() == DRIVER_WIL6210) {
} else if (get_driver_type(dut) == DRIVER_WIL6210) {
struct ethtool_drvinfo drvinfo;
struct ifreq ifr; /* ifreq suitable for ethtool ioctl */
int fd; /* socket suitable for ethtool ioctl */
Expand All @@ -167,7 +167,7 @@ static enum sigma_cmd_result cmd_device_get_info(struct sigma_dut *dut,
drvinfo.cmd = ETHTOOL_GDRVINFO;

memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, get_main_ifname(),
strlcpy(ifr.ifr_name, get_main_ifname(dut),
sizeof(ifr.ifr_name));

fd = socket(AF_INET, SOCK_DGRAM, 0);
Expand Down Expand Up @@ -236,8 +236,8 @@ static enum sigma_cmd_result cmd_device_list_interfaces(struct sigma_dut *dut,
if (strcmp(type, "802.11") != 0)
return ERROR_SEND_STATUS;

snprintf(resp, sizeof(resp), "interfaceType,802.11,"
"interfaceID,%s", get_main_ifname());
snprintf(resp, sizeof(resp), "interfaceType,802.11,interfaceID,%s",
get_main_ifname(dut));
send_resp(dut, conn, SIGMA_COMPLETE, resp);
return STATUS_SENT;
}
Expand Down
14 changes: 7 additions & 7 deletions dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,38 +125,38 @@ static enum sigma_cmd_result sta_server_cert_trust(struct sigma_dut *dut,

snprintf(buf, sizeof(buf), "hash://server/sha256/%s",
dut->server_cert_hash);
if (set_network_quoted(get_station_ifname(), dut->infra_network_id,
if (set_network_quoted(get_station_ifname(dut), dut->infra_network_id,
"ca_cert", buf) < 0) {
strlcpy(resp,
"ServerCertTrustResult,OverrideNotAllowed,Reason,Could not configure server certificate hash for the network profile",
sizeof(resp));
goto done;
}

if (set_network(get_station_ifname(), dut->infra_network_id,
if (set_network(get_station_ifname(dut), dut->infra_network_id,
"domain_match", "NULL") < 0 ||
set_network(get_station_ifname(), dut->infra_network_id,
set_network(get_station_ifname(dut), dut->infra_network_id,
"domain_suffix_match", "NULL") < 0) {
strlcpy(resp,
"ServerCertTrustResult,OverrideNotAllowed,Reason,Could not clear domain matching rules",
sizeof(resp));
goto done;
}

wpa_command(get_station_ifname(), "DISCONNECT");
wpa_command(get_station_ifname(dut), "DISCONNECT");
snprintf(buf, sizeof(buf), "SELECT_NETWORK %d", dut->infra_network_id);
if (wpa_command(get_station_ifname(), buf) < 0) {
if (wpa_command(get_station_ifname(dut), buf) < 0) {
sigma_dut_print(dut, DUT_MSG_INFO, "Failed to select "
"network id %d on %s",
dut->infra_network_id,
get_station_ifname());
get_station_ifname(dut));
strlcpy(resp,
"ServerCertTrustResult,Accepted,Result,Could not request reconnection",
sizeof(resp));
goto done;
}

ctrl = open_wpa_mon(get_station_ifname());
ctrl = open_wpa_mon(get_station_ifname(dut));
if (!ctrl)
goto done;

Expand Down
2 changes: 1 addition & 1 deletion dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void * process_dhcp_ack(void *ptr)
protocol = UDP_PROTOCOL;
port_no = DHCP_SERVER_PORT;

strlcpy(ifname, get_main_ifname(), sizeof(ifname));
strlcpy(ifname, get_main_ifname(dut), sizeof(ifname));

/* gives the network mask for ifname essential for applying filter */
pcap_lookupnet(ifname, &pcap_netp, &pcap_maskp, pcap_err);
Expand Down
10 changes: 5 additions & 5 deletions dpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int dpp_get_local_bootstrap(struct sigma_dut *dut,
const char *bs = get_param(cmd, "DPPBS");
const char *chan_list = get_param(cmd, "DPPChannelList");
char *pos, mac[50], buf[200], resp[1000], hex[2000];
const char *ifname = get_station_ifname();
const char *ifname = get_station_ifname(dut);
int res;

if (success)
Expand Down Expand Up @@ -735,7 +735,7 @@ static int dpp_scan_peer_qrcode(struct sigma_dut *dut)
static int dpp_display_own_qrcode(struct sigma_dut *dut)
{
char buf[200], resp[2000];
const char *ifname = get_station_ifname();
const char *ifname = get_station_ifname(dut);
#ifdef ANDROID
FILE *fp;
#else /* ANDROID */
Expand Down Expand Up @@ -886,7 +886,7 @@ static int dpp_automatic_dpp(struct sigma_dut *dut,
int res;
unsigned int old_timeout;
int own_pkex_id = -1;
const char *ifname = get_station_ifname();
const char *ifname = get_station_ifname(dut);
const char *auth_events[] = {
"DPP-AUTH-SUCCESS",
"DPP-NOT-COMPATIBLE",
Expand Down Expand Up @@ -998,7 +998,7 @@ static int dpp_automatic_dpp(struct sigma_dut *dut,
"Update hostapd operating channel to match listen needs");
dut->ap_channel = 6;

if (get_driver_type() == DRIVER_OPENWRT) {
if (get_driver_type(dut) == DRIVER_OPENWRT) {
snprintf(buf, sizeof(buf),
"iwconfig %s channel %d",
dut->hostapd_ifname, dut->ap_channel);
Expand Down Expand Up @@ -1458,7 +1458,7 @@ static int dpp_automatic_dpp(struct sigma_dut *dut,
}

if (!(tcp && strcasecmp(tcp, "yes") == 0) &&
get_driver_type() == DRIVER_OPENWRT) {
get_driver_type(dut) == DRIVER_OPENWRT) {
snprintf(buf, sizeof(buf), "iwconfig %s channel %d",
dut->hostapd_ifname, freq_to_channel(freq));
run_system(dut, buf);
Expand Down
14 changes: 7 additions & 7 deletions ftm.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ int loc_cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
if (cmnd == LOWI_TST_ANQP_REQ) {
sigma_dut_print(dut, DUT_MSG_DEBUG, "%s - Executing command %s",
__func__, address3Cmnd);
if (wpa_command(get_station_ifname(), address3Cmnd) < 0) {
if (wpa_command(get_station_ifname(dut), address3Cmnd) < 0) {
send_resp(dut, conn, SIGMA_ERROR, NULL);
return -1;
}
Expand Down Expand Up @@ -645,17 +645,17 @@ int loc_cmd_sta_preset_testparameters(struct sigma_dut *dut,
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Disabling RM - FTMRR",
__func__);
if (wpa_command(get_station_ifname(), WPA_RM_DISABLE) <
0) {
if (wpa_command(get_station_ifname(dut),
WPA_RM_DISABLE) < 0) {
send_resp(dut, conn, SIGMA_ERROR, NULL);
return -1;
}
} else if (rmFTMRFlag == 1) { /* Enable RM - FTMRR capability */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Enabling RM - FTMRR",
__func__);
if (wpa_command(get_station_ifname(), WPA_RM_ENABLE) <
0) {
if (wpa_command(get_station_ifname(dut),
WPA_RM_ENABLE) < 0) {
send_resp(dut, conn, SIGMA_ERROR, NULL);
return 0;
}
Expand All @@ -674,10 +674,10 @@ int loc_cmd_sta_preset_testparameters(struct sigma_dut *dut,
sigma_dut_print(dut, DUT_MSG_INFO, "%s - interworking: %u",
__func__, interworking);
if (interworking)
wpa_command(get_station_ifname(),
wpa_command(get_station_ifname(dut),
WPA_INTERWORKING_ENABLE);
else
wpa_command(get_station_ifname(),
wpa_command(get_station_ifname(dut),
WPA_INTERWORKING_DISABLE);
}

Expand Down
8 changes: 4 additions & 4 deletions miracast.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static int miracast_start_dhcp_client(struct sigma_dut *dut, const char *ifname)
}


static void miracast_stop_dhcp_client(struct sigma_dut *dut, char *ifname)
static void miracast_stop_dhcp_client(struct sigma_dut *dut, const char *ifname)
{
#ifdef MIRACAST_DHCP_M
stop_dhcp(dut, ifname, 0);
Expand Down Expand Up @@ -859,10 +859,10 @@ int miracast_preset_testparameters(struct sigma_dut *dut,
}


static int get_p2p_peers(char *respbuf, size_t bufsize)
static int get_p2p_peers(struct sigma_dut *dut, char *respbuf, size_t bufsize)
{
char addr[1024], cmd[64];
char *intf = get_main_ifname();
const char *intf = get_main_ifname(dut);
int ret;
char *pos, *end;

Expand Down Expand Up @@ -911,7 +911,7 @@ int miracast_cmd_sta_get_parameter(struct sigma_dut *dut,
int len = strlen("DeviceList,");

snprintf(resp_buf, sizeof(resp_buf), "DeviceList,");
get_p2p_peers(resp_buf + len, 1024 - len);
get_p2p_peers(dut, resp_buf + len, 1024 - len);
} else {
send_resp(dut, conn, SIGMA_ERROR, "Invalid Parameter");
return 0;
Expand Down
42 changes: 21 additions & 21 deletions p2p.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ static struct wfa_cs_p2p_group * p2p_group_get(struct sigma_dut *dut,
printf("Trying to find suitable interface for group: go_dev_addr='%s' "
"grpid='%s'\n", go_dev_addr, grpid);

if (wpa_command_resp(get_main_ifname(), "INTERFACES", buf, sizeof(buf))
< 0)
if (wpa_command_resp(get_main_ifname(dut), "INTERFACES",
buf, sizeof(buf)) < 0)
return NULL;
ifname = buf;
while (ifname && *ifname) {
Expand Down Expand Up @@ -489,7 +489,7 @@ static const char * get_group_ifname(struct sigma_dut *dut, const char *ifname)
}

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

Expand Down Expand Up @@ -604,16 +604,16 @@ static void add_dummy_services(const char *intf)

void disconnect_station(struct sigma_dut *dut)
{
wpa_command(get_station_ifname(), "DISCONNECT");
remove_wpa_networks(get_station_ifname());
wpa_command(get_station_ifname(dut), "DISCONNECT");
remove_wpa_networks(get_station_ifname(dut));
dut->infra_ssid[0] = '\0';
#ifdef __linux__
{
char path[128];
char buf[200];
struct stat s;
snprintf(path, sizeof(path), "/var/run/dhclient-%s.pid",
get_station_ifname());
get_station_ifname(dut));
if (stat(path, &s) == 0) {
snprintf(buf, sizeof(buf),
"kill `cat %s`", path);
Expand All @@ -623,7 +623,7 @@ void disconnect_station(struct sigma_dut *dut)
unlink(path);
}
snprintf(buf, sizeof(buf),
"ifconfig %s 0.0.0.0", get_station_ifname());
"ifconfig %s 0.0.0.0", get_station_ifname(dut));
sigma_dut_print(dut, DUT_MSG_DEBUG,
"Clear infrastructure station IP address: %s",
buf);
Expand Down Expand Up @@ -656,7 +656,7 @@ static enum sigma_cmd_result cmd_sta_set_p2p(struct sigma_dut *dut,
struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
const char *intf = get_p2p_ifname(get_param(cmd, "Interface"));
const char *intf = get_p2p_ifname(dut, get_param(cmd, "Interface"));
char buf[256];
const char *val;
const char *noa_dur, *noa_int, *noa_count;
Expand Down Expand Up @@ -856,7 +856,7 @@ static enum sigma_cmd_result
cmd_sta_start_autonomous_go(struct sigma_dut *dut, struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
const char *intf = get_p2p_ifname(get_param(cmd, "Interface"));
const char *intf = get_p2p_ifname(dut, get_param(cmd, "Interface"));
const char *oper_chn = get_param(cmd, "OPER_CHN");
const char *ssid_param = get_param(cmd, "SSID");
#ifdef MIRACAST
Expand Down Expand Up @@ -1000,7 +1000,7 @@ static enum sigma_cmd_result cmd_sta_p2p_connect(struct sigma_dut *dut,
struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
const char *intf = get_p2p_ifname(get_param(cmd, "Interface"));
const char *intf = get_p2p_ifname(dut, get_param(cmd, "Interface"));
const char *devid = get_param(cmd, "P2PDevID");
/* const char *grpid_param = get_param(cmd, "GroupID"); */
int res;
Expand Down Expand Up @@ -1125,7 +1125,7 @@ cmd_sta_p2p_start_group_formation(struct sigma_dut *dut,
struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
const char *intf = get_p2p_ifname(get_param(cmd, "Interface"));
const char *intf = get_p2p_ifname(dut, get_param(cmd, "Interface"));
const char *devid = get_param(cmd, "P2PDevID");
const char *intent_val = get_param(cmd, "INTENT_VAL");
const char *init_go_neg = get_param(cmd, "INIT_GO_NEG");
Expand Down Expand Up @@ -1848,9 +1848,9 @@ enum sigma_cmd_result cmd_sta_p2p_reset(struct sigma_dut *dut,
wpa_command(intf, "SET p2p_go_intent 7");
wpa_command(intf, "P2P_SET client_apsd disable");
wpa_command(intf, "P2P_SET go_apsd disable");
wpa_command(get_station_ifname(), "P2P_SET ps 98");
wpa_command(get_station_ifname(), "P2P_SET ps 96");
wpa_command(get_station_ifname(), "P2P_SET ps 0");
wpa_command(get_station_ifname(dut), "P2P_SET ps 98");
wpa_command(get_station_ifname(dut), "P2P_SET ps 96");
wpa_command(get_station_ifname(dut), "P2P_SET ps 0");
wpa_command(intf, "P2P_SET ps 0");
wpa_command(intf, "SET persistent_reconnect 1");
wpa_command(intf, "SET ampdu 1");
Expand All @@ -1862,7 +1862,7 @@ enum sigma_cmd_result cmd_sta_p2p_reset(struct sigma_dut *dut,
dut->arp_ipaddr[0] = '\0';
}
snprintf(buf, sizeof(buf), "ip nei flush dev %s",
get_station_ifname());
get_station_ifname(dut));
run_system(dut, buf);
dut->p2p_mode = P2P_IDLE;
dut->client_uapsd = 0;
Expand Down Expand Up @@ -1990,7 +1990,7 @@ static enum sigma_cmd_result cmd_sta_set_sleep(struct sigma_dut *dut,
{
/* const char *intf = get_param(cmd, "Interface"); */
struct wfa_cs_p2p_group *grp;
char *ifname;
const char *ifname;
const char *grpid = get_param(cmd, "GroupID");

if (dut->program == PROGRAM_60GHZ) {
Expand All @@ -2000,7 +2000,7 @@ static enum sigma_cmd_result cmd_sta_set_sleep(struct sigma_dut *dut,
}

if (grpid == NULL)
ifname = get_station_ifname();
ifname = get_station_ifname(dut);
else {
grp = p2p_group_get(dut, grpid);
if (grp == NULL) {
Expand Down Expand Up @@ -2106,7 +2106,7 @@ cmd_sta_add_arp_table_entry(struct sigma_dut *dut, struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
char buf[256];
char *ifname;
const char *ifname;
const char *grpid, *ipaddr, *macaddr;

grpid = get_param(cmd, "GroupID");
Expand All @@ -2116,7 +2116,7 @@ cmd_sta_add_arp_table_entry(struct sigma_dut *dut, struct sigma_conn *conn,
return -1;

if (grpid == NULL)
ifname = get_station_ifname();
ifname = get_station_ifname(dut);
else {
struct wfa_cs_p2p_group *grp;
grp = p2p_group_get(dut, grpid);
Expand Down Expand Up @@ -2147,7 +2147,7 @@ cmd_sta_block_icmp_response(struct sigma_dut *dut, struct sigma_conn *conn,
{
char buf[256];
struct wfa_cs_p2p_group *grp;
char *ifname;
const char *ifname;
const char *grpid, *ipaddr;

grpid = get_param(cmd, "GroupID");
Expand All @@ -2156,7 +2156,7 @@ cmd_sta_block_icmp_response(struct sigma_dut *dut, struct sigma_conn *conn,
return -1;

if (grpid == NULL)
ifname = get_station_ifname();
ifname = get_station_ifname(dut);
else {
grp = p2p_group_get(dut, grpid);
if (grp == NULL) {
Expand Down
Loading

0 comments on commit 016ae6c

Please sign in to comment.