📄 ipctest.c
字号:
* @param[in] device The OS specific name for the device to query.
**/
void dogetbackendstate(char *device)
{
int retval = 0;
printf("802.1X backend state for test interface : ");
if (xsupgui_request_get_backend_state(device, &retval) != REQUEST_SUCCESS)
{
printf("Failed\n");
die();
}
switch (retval)
{
case 255:
printf("Hasn't run!\n");
break;
case BACKEND_UNKNOWN:
printf("UNKNOWN\n");
break;
case BACKEND_REQUEST:
printf("REQUEST\n");
break;
case BACKEND_RESPONSE:
printf("RESPONSE\n");
break;
case BACKEND_SUCCESS:
printf("SUCCESS\n");
break;
case BACKEND_FAIL:
printf("FAIL\n");
break;
case BACKEND_TIMEOUT:
printf("TIMEOUT\n");
break;
case BACKEND_IDLE:
printf("IDLE\n");
break;
case BACKEND_INITIALIZE:
printf("INITIALIZE\n");
break;
case BACKEND_RECEIVE:
printf("RECEIVE\n");
break;
default:
printf("Got error %d.\n", retval);
break;
}
printf("\n");
}
/**
* \brief Request that the supplicant tell us the state that the physical state
* machine is currently in.
*
* @param[in] device The OS specific name for the device we want to know about.
*
* \note The physical device state machine doesn't map to any IEEE or IETF standard.
* It is internal to the supplicant.
**/
void dogetphysicalstate(char *device)
{
int retval = 0;
printf("Physical state for test interface : ");
if (xsupgui_request_get_physical_state(device, &retval) != REQUEST_SUCCESS)
{
printf("Failed!\n");
die();
return;
}
switch (retval)
{
case WIRELESS_UNKNOWN_STATE:
printf("UNKNOWN_STATE\n");
break;
case WIRELESS_UNASSOCIATED:
printf("UNASSOCIATED\n");
break;
case WIRELESS_ASSOCIATED:
printf("ASSOCIATED\n");
break;
case WIRELESS_ACTIVE_SCAN:
printf("ACTIVE_SCAN\n");
break;
case WIRELESS_ASSOCIATING:
printf("ASSOCIATING\n");
break;
case WIRELESS_ASSOCIATION_TIMEOUT_S:
printf("WIRELESS_ASSOCIATION_TIMEOUT_S\n");
break;
case WIRELESS_PORT_DOWN:
printf("PORT_DOWN\n");
break;
case WIRELESS_NO_ENC_ASSOCIATION:
printf("NO_ENC_ASSOCIATION\n");
break;
case WIRELESS_INT_RESTART:
printf("INT_RESTART\n");
break;
case WIRELESS_INT_STOPPED:
printf("INT_STOPPED\n");
break;
case WIRELESS_INT_HELD:
printf("INT_HELD\n");
break;
case 255:
printf("Hasn't run!\n");
break;
default:
printf("Unknown state %d.\n", retval);
break;
}
printf("\n");
}
/**
* \brief Determine the pairwise (unicast) encryption method being used on a
* specific interface.
*
* @param[in] device The OS specific device name to get the pairwise encryption
* method for.
**/
void dogetpairwisetype(char *device)
{
int retval = 0;
printf("Pairwise Key Type for test interface : ");
if (xsupgui_request_get_pairwise_key_type(device, &retval) != REQUEST_SUCCESS)
{
printf("Failed\n");
die();
return;
}
switch (retval)
{
case CIPHER_NONE:
printf("NONE\n");
break;
case CIPHER_WEP40:
printf("WEP40\n");
break;
case CIPHER_TKIP:
printf("TKIP\n");
break;
case CIPHER_WRAP:
// Shouldn't ever get this!
printf("WRAP\n");
break;
case CIPHER_CCMP:
printf("CCMP\n");
break;
case CIPHER_WEP104:
printf("WEP104\n");
break;
default:
printf("Unknown cipher : %d\n", retval);
die();
break;
}
printf("\n");
}
/**
* \brief Ask the supplicant what group (multicast/broadcast) encryption method is
* currently in use.
*
* @param[in] device The OS specific device name for the device that we want to know
* the encryption type for.
**/
void dogetgrouptype(char *device)
{
int retval = 0;
printf("Group Key Type for test interface : ");
if (xsupgui_request_get_group_key_type(device, &retval) != REQUEST_SUCCESS)
{
printf("Failed\n");
die();
return;
}
switch (retval)
{
case CIPHER_NONE:
printf("NONE\n");
break;
case CIPHER_WEP40:
printf("WEP40\n");
break;
case CIPHER_TKIP:
printf("TKIP\n");
break;
case CIPHER_WRAP:
// Shouldn't ever get this!
printf("WRAP\n");
break;
case CIPHER_CCMP:
printf("CCMP\n");
break;
case CIPHER_WEP104:
printf("WEP104\n");
break;
default:
printf("Unknown value : %d\n", retval);
die();
break;
}
printf("\n");
}
/**
* \brief Request, and display, the SSID that the supplicant is attempting to connect
* to on a specific interface.
*
* @param[in] device The OS specific device name that the request is for.
*
* \note Even if the interface isn't associated to the SSID, it may still return a value.
* This call should not be used to determine if an interface is associated or not.
**/
void dogetssid(char *device)
{
int retval = 0;
char *ssid = NULL;
printf("SSID : ");
retval = xsupgui_request_get_ssid(device, &ssid);
switch (retval)
{
case REQUEST_TIMEOUT:
printf("Request timed out!\n");
die();
break;
case REQUEST_FAILURE:
printf("Request failed!\n");
die();
break;
case REQUEST_SUCCESS:
printf("%s\n", ssid);
break;
default:
printf("Error : %d\n", retval);
die();
break;
}
printf("\n");
xsupgui_request_free_str(&ssid);
}
/**
* \brief Request, and display, the BSSID that the supplicant is attempting to connect
* to on a specific interface.
*
* @param[in] device The OS specific device name that the request is for.
**/
void dogetbssid(char *device)
{
int retval = 0;
char *bssid = NULL;
printf("BSSID : ");
retval = xsupgui_request_get_bssid(device, &bssid);
switch (retval)
{
case REQUEST_TIMEOUT:
printf("Request timed out!\n");
die();
break;
case REQUEST_FAILURE:
printf("Request failed!\n");
die();
break;
case REQUEST_SUCCESS:
printf("%s\n", bssid);
break;
default:
printf("Error : %d\n", retval);
if (retval != IPC_ERROR_INVALID_BSSID) die(); // Invalid BSSID probably means we aren't associated.
break;
}
printf("\n");
xsupgui_request_free_str(&bssid);
}
/**
* \brief Request, and display, the number of seconds that the supplicant has been
* in authenticated state.
*
* @param[in] device The OS specific device name that the request is for.
**/
void dogettimeauthed(char *device)
{
int retval = 0;
long int timeauthed = 0;
printf("Time authenticated : ");
retval = xsupgui_request_get_seconds_authenticated(device, &timeauthed);
switch (retval)
{
case REQUEST_TIMEOUT:
printf("Request timed out!\n");
die();
break;
case REQUEST_FAILURE:
printf("Request failed!\n");
die();
break;
case REQUEST_SUCCESS:
printf("%ld second(s)\n", timeauthed);
break;
default:
printf("Error : %d\n", retval);
die();
break;
}
printf("\n");
}
/**
* \brief Request, and display, the current signal strength for the requested device.
*
* @param[in] device The OS specific device name that the request is for.
**/
void dogetsignal(char *device)
{
int retval = 0;
printf("Signal Strength : ");
if (xsupgui_request_get_signal_strength_percent(device, &retval) != REQUEST_SUCCESS)
{
printf("Failed!\n");
die();
return;
}
if (retval > 100)
{
printf("Error : %d\n", retval);
die();
}
else
{
printf("%d percent\n", retval);
}
printf("\n");
}
/**
* \brief Request, and display, the EAP type that was used for the authentication
* on a given device.
*
* @param[in] device The OS specific device name that the request is for.
**/
void dogeteaptype(char *device)
{
int retval = 0;
printf("EAP Type for test interface : ");
if (xsupgui_request_get_eap_type_in_use(device, &retval) != REQUEST_SUCCESS)
{
printf("Failed!\n");
die();
return;
}
switch (retval)
{
case 0:
printf("EAP hasn't started yet!\n");
break;
default:
printf("Type %d.\n", retval);
break;
}
printf("\n");
}
/**
* \brief Display information about possible connections to use.
**/
void show_poss_conns(poss_conn_enum *conn)
{
int i = 0, retval = 0;
char *devname = NULL;
printf("\n");
while (conn[i].name != NULL)
{
printf("Connection : %s\n", conn[i].name);
printf("\tPriority : %d\n", conn[i].priority);
printf("\tSSID: %s\n", conn[i].ssid);
printf("\tFlags : %04X\n", conn[i].flags);
printf("\tDevice: %s\n", conn[i].dev_desc);
printf("\tAuth : %d\n", conn[i].auth_type);
printf("\tEncryption Enabled : ");
switch(conn[i].encryption)
{
case CONNECTION_ENC_NONE:
printf("NONE\n");
break;
case CONNECTION_ENC_ENABLED:
printf("Enabled\n");
break;
case CONNECTION_ENC_UNKNOWN:
// Allow this to fall through to the default case.
default:
printf("Unknown\n");
break;
}
printf("\tDevice Name : ");
retval = xsupgui_request_get_devname(conn[i].dev_desc, &devname);
switch(retval)
{
case REQUEST_TIMEOUT:
printf("timed out.\n");
if (devname != NULL) free(devname);
die();
break;
case REQUEST_FAILURE:
printf("Error!\n");
if (devname != NULL) free(devname);
die();
break;
case REQUEST_SUCCESS:
printf("%s\n", devname);
free(devname);
break;
default:
printf("Error %d.\n", retval);
// die();
break;
}
i++;
}
}
/**
* \brief Display information about all of the connections in use.
**/
void show_conns(conn_enum *conn)
{
int i = 0, retval = 0;
char *devname = NULL;
printf("\n");
while (conn[i].name != NULL)
{
printf("Connection : %s\n", conn[i].name);
printf("\tPriority : %d\n", conn[i].priority);
printf("\tSSID: %s\n", conn[i].ssid);
printf("\tDevice: %s\n", conn[i].dev_desc);
printf("\tEncryption Enabled : ");
switch(conn[i].encryption)
{
case CONNECTION_ENC_NONE:
printf("NONE\n");
break;
case CONNECTION_ENC_ENABLED:
printf("Enabled\n");
break;
case CONNECTION_ENC_UNKNOWN:
// Allow this to fall through to the default case.
default:
printf("Unknown\n");
break;
}
printf("\tDevice Name : ");
retval = xsupgui_request_get_devname(conn[i].dev_desc, &devname);
switch(retval)
{
case REQUEST_TIMEOUT:
printf("timed out.\n");
if (devname != NULL) free(devname);
die();
break;
case REQUEST_FAILURE:
printf("Error!\n");
if (devname != NULL) free(devname);
die();
break;
case REQUEST_SUCCESS:
printf("%s\n", devname);
free(devname);
break;
default:
printf("Error %d.\n", retval);
die();
break;
}
i++;
}
}
/**
* \brief Request, and display, the connections that the supplicant might be able to connect to.
**/
void doget_possible_connections()
{
int retval = 0;
poss_conn_enum *connections = NULL;
printf("Possible connections : ");
retval = xsupgui_request_enum_possible_connections(&connections);
switch (retval)
{
case REQUEST_TIMEOUT:
printf("timed out.\n");
die();
break;
case REQUEST_FAILURE:
printf("Error!\n");
die();
break;
case REQUEST_SUCCESS:
show_poss_conns(connections);
break;
default:
printf("Got error %d.\n", retval);
die();
break;
}
xsupgui_request_free_poss_conn_enum(&connections);
printf("\n");
}
/**
* \brief Request, and display, the connections that are currently in the supplicant's
* memory.
**/
void dogetconnections()
{
int retval = 0;
conn_enum *connections = NULL;
printf("Known connections : ");
retval = xsupgui_request_enum_connections(&connections);
switch (retval)
{
case REQUEST_TIMEOUT:
printf("timed out.\n");
die();
break;
case REQUEST_FAILURE:
printf("Error!\n");
die();
break;
case REQUEST_SUCCESS:
show_conns(connections);
break;
default:
printf("Got error %d.\n", retval);
die();
break;
}
xsupgui_request_free_conn_enum(&connections);
printf("\n");
}
/**
* \brief Request, and display, the username/password for the given connection name.
*
* @param[in] conn_name The connection name that we want to get the username/password
* from.
**/
void getupwd(char *conn_name)
{
int retval = 0;
char *username = NULL, *password = NULL;
int err = 0;
printf("Requested credentials for connection '%s'...", conn_name);
err = xsupgui_request_get_connection_upw(conn_name, &username, &password, &retval);
if (err != REQUEST_SUCCESS)
{
printf("Failed (Error : %d)\n", err);
die();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -