⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipctest.c

📁 linux 下通过802.1认证的安装包
💻 C
📖 第 1 页 / 共 4 页
字号:
		return;
	}

	switch (retval)
	{
	case AUTH_NONE:
	case AUTH_EAP:
		printf("\n\n Authentication Type : EAP\n");
		printf("Username = %s    Password = %s\n", username, password);
		break;

	case AUTH_PSK:
		printf("\n\n Authentication Type : PSK\n");
		printf("Password = %s\n", password);
		break;

	default:
		printf("Unknown type %d.\n", retval);
		break;
	}

	xsupgui_request_free_str(&username);
	xsupgui_request_free_str(&password);
	printf("\n");
}

void getcapabilities(char *device)
{
	int retval = 0;

	printf("Capabilities : ");
	if (xsupgui_request_get_interface_capabilities(device, &retval) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
		return;
	}
	printf("%04x\n", retval);
}

/**
 *  \brief  Request, and display, the method of association that the supplicant is
 *          attempting to use on this connection.
 *
 *  @param[in] device   The OS specific device name that the request is for.
 **/
void getassoctype(char *device)
{
	int retval = 0;

	printf("Association Type : ");
	if (xsupgui_request_get_association_type(device, &retval) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
		return;
	}

	switch (retval)
	{
	case ASSOC_TYPE_UNKNOWN:
		printf("Unknown\n");
		break;

	case ASSOC_TYPE_OPEN:
		printf("Open\n");
		break;

	case ASSOC_TYPE_SHARED:
		printf("Shared\n");
		break;

	case ASSOC_TYPE_LEAP:
		printf("LEAP\n");
		break;

	case ASSOC_TYPE_WPA1:
		printf("WPA\n");
		break;

	case ASSOC_TYPE_WPA2:
		printf("WPA2\n");
		break;

	default:
		printf("Unknown type %d.\n", retval);
		die();
		break;
	}

	printf("\n");
}

/**
 *  \brief  Request that the username and password for the specified connection be changed
 *          to a new value.
 *
 *  @param[in] conn_name   The name of the connection to set the username/password for.
 *  @param[in] username   The new username for this connection.
 *  @param[in] password   The new password for this connection.
 **/
void setupwd(char *conn_name, char *username, char *password)
{
	int retval = 0;

	printf("Setting username/password...");
	retval = xsupgui_request_set_connection_upw(conn_name, username, password);
	switch (retval)
	{
	case REQUEST_TIMEOUT:
		printf("timed out.\n");
		die();
		break;

	case REQUEST_FAILURE:
		printf("Error!\n");
		die();
		break;

	case REQUEST_SUCCESS:
		printf("OK\n");
		break;

	default:
		printf("Got error %d.\n", retval);
		die();
		break;
	}

	printf("\n");
}

/**
 *  \brief  Request, that the supplicant change to a new connection.
 *
 *  @param[in] device   The OS specific device name that the request is for.
 **/
void dochangeconn(char *device, char *conn)
{
	int retval = 0;

	printf("Requesting connection change to '%s'...", conn);
	retval = xsupgui_request_set_connection(device, conn);
	switch (retval)
	{
	case REQUEST_TIMEOUT:
		printf("timed out.\n");
		die();
		break;

	case REQUEST_SUCCESS:
		printf("OK!\n");
		break;

	case REQUEST_FAILURE:
		printf("Error!\n");
		die();
		break;

	default:
		printf("Error %d.\n", retval);
		break;
	}

	printf("\n");
}

/**
 *  \brief  Request that the supplicant disassociate from the currently associated
 *          network.
 *
 *  @param[in] device   The OS specific device name that the request is for.
 **/
void setdisassoc(char *device)
{
	int retval = 0;

	printf("Disassociating....");
	retval = xsupgui_request_set_disassociate(device, 0);
	switch (retval)
	{
	case REQUEST_TIMEOUT:
		printf("timed out.\n");
		die();
		break;

	case REQUEST_SUCCESS:
		printf("OK!\n");
		break;

	case REQUEST_FAILURE:
		printf("Error!\n");
		die();
		break;

	default:
		printf("Error %d.\n", retval);
		break;
	}

	printf("\n");
}

/**
 *  \brief  Request that an interface no longer process events, or frames on a given
 *          interface.  This will cause authentication attempts to be ignored.
 *
 *  @param[in] device   The OS specific device name that the request is for.
 **/
void setpause(char *device)
{
	int retval = 0;

	printf("Pausing....");
	retval = xsupgui_request_stop(device);
	switch (retval)
	{
	case REQUEST_TIMEOUT:
		printf("timed out.\n");
		die();
		break;

	case REQUEST_SUCCESS:
		printf("OK!\n");
		break;

	case REQUEST_FAILURE:
		printf("Error!\n");
		die();
		break;

	default:
		printf("Error %d.\n", retval);
		break;
	}

	printf("\n");
}

/**
 *  \brief  Request, and display, the IP address information for the currently active
 *          connection.
 *
 *  @param[in] device   The OS specific device name that the request is for.
 *
 *  \note It is possible for this request to return success but for any, or all, results
 *        to be NULL.
 **/
void getipaddr(char *device)
{
	int retval = 0;
	ipinfo_type *ipi = NULL;

	printf("Requesting IP information.\n\n");
	retval = xsupgui_request_get_ip_info(device, &ipi);
	switch (retval)
	{
	case REQUEST_TIMEOUT:
		printf("timed out.\n");
		die();
		break;

	case REQUEST_SUCCESS:
		printf("\tIP Address : %s\n", ipi->ipaddr);
		printf("\tNetmask    : %s\n", ipi->netmask);
		printf("\tGateway    : %s\n", ipi->gateway);
		printf("\tDNS 1      : %s\n", ipi->dns1);
		printf("\tDNS 2      : %s\n", ipi->dns2);
		printf("\tDNS 3      : %s\n", ipi->dns3);
		break;

	case REQUEST_FAILURE:
		printf("Error!\n");
		die();
		break;

	default:
		printf("Error %d.\n", retval);
		die();
		break;
	}

	printf("\n");

	xsupgui_request_free_ip_info(&ipi);
}

/**
 * \brief Ask the supplicant to write it's configuration file to 'test.out'.
 **/
void dowrite_conf(char *filename)
{
	printf("Writing configuration file....");

	if (xsupgui_request_write_config(filename) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
	}
	else
	{
		printf("Success.\n");
	}
}

/**
 * \brief Ask the supplicant for the current global settings.
 **/
void doget_globals()
{
	struct config_globals *myglobs;

	printf("Getting global settings...");

	if (xsupgui_request_get_globals_config(&myglobs) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
		return;
	}
	
	printf("Success...\n\n");

	printf("Setting for logging is : %s\n", myglobs->logpath);
	printf("Max Starts : %d\n", myglobs->max_starts);
	printf("Auth Period : %d\n", myglobs->auth_period);
	printf("Held Period : %d\n", myglobs->held_period);
}

/**
 * \brief Ask the supplicant for the configuration for a named profile.
 **/
void doget_profile()
{
	struct config_profiles *myprof;

	printf("Getting profile settings...");

	if (xsupgui_request_get_profile_config("House_TTLS", &myprof) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
		return;
	}

	printf("Success...\n\n");

	printf("Identity = %s\n", myprof->identity);
}

/**
 * \brief Ask the supplicant for the configuration for a named connection.
 **/
void doget_connection()
{
	struct config_connection *mycon;

	printf("Getting connection settings...");

	if (xsupgui_request_get_connection_config("Home WPA 2 PSK Network", &mycon) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
		return;
	}

	printf("Success...\n\n");

	printf("Device = %s\n", mycon->device);
	xsupgui_request_free_connection_config(&mycon);
}

/**
 * \brief Ask the supplicant for the trusted server configuration for the named server.
 **/
void doget_ts()
{
	struct config_trusted_server *ts;

	printf("Getting trusted server settings...");

	if (xsupgui_request_get_trusted_server_config("Test Server", &ts) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		//die();
		return;
	}

	printf("Success...\n\n");

	printf("Location = %s\n", ts->location);
}

/**
 * \brief Ask the supplicant for configuration information about a specific interface.
 **/
void doget_int()
{
	config_interfaces *ints;

	printf("Getting interface settings...");

	if (xsupgui_request_get_interface_config("Intel IPW3945", &ints) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
		return;
	}

	printf("Success...\n\n");
	
	printf("Description = %s\n", ints->description);
}

/**
 * \brief Enumerate managed networks and list them to the console.
 **/
void doget_enum_managed_nets()
{
	managed_nets_enum *nenum;
	int i = 0;

	printf("Getting Managed Networks list : ");

	if (xsupgui_request_enum_managed_networks(&nenum) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
		return;
	}

	printf("Success!\n\n");

	while (nenum[i].ou != NULL)
	{
		printf("Managed Network OU : %s\n", nenum[i].ou);
		i++;
	}

	xsupgui_request_free_managed_networks_enum(&nenum);
}

/**
 * \brief Ask the supplicant to give us information about a managed network.
 **/
void get_managed_net()
{
	config_managed_networks *head = NULL;

	if (xsupgui_request_get_managed_network_config("testme.com", &head) != REQUEST_SUCCESS)
	{
		printf("Failed!\n");
		die();
		return;
	}

	printf("Update URL : %s\n", head->update_url);
}

/**
 * \brief Ask the supplicant to delete a managed network from memory.
 **/
void del_managed_net()
{
  if (xsupgui_request_delete_managed_network_config("testme.com") != REQUEST_SUCCESS)
    {
      printf("Couldn't delete 'testme.com' from the managed networks list!\n");
	  die();
      return;
    }
  else
    {
      printf("Delete 'testme.com' from the managed networks list.\n");
    }
}

/**
 * \brief Ask the supplicant to delete a profile from memory.
 **/
void del_profile()
{
  if (xsupgui_request_delete_profile_config("Beat me!", TRUE) != REQUEST_SUCCESS)
    {
      printf("Couldn't delete 'Beat me!' from the profiles list!\n");
	  die();
      return;
    }
  else
    {
      printf("Delete 'Beat me!' from the profiles list.\n");
    }
}

/**
 * \brief Ask the supplicant to delete a connection from memory.
 **/
void del_connection()
{
  if (xsupgui_request_delete_connection_config("RSA Test") != REQUEST_SUCCESS)
    {
      printf("Couldn't delete 'RSA Test' from the connections list!\n");
	  die();
      return;
    }
  else
    {
      printf("Delete 'RSA Test' from the connections list.\n");
    }
}

/**
 * \brief Ask the supplicant to delete an interface from memory.
 **/
void del_interface()
{
  if (xsupgui_request_delete_interface_config("Intel IPW3945") != REQUEST_SUCCESS)
    {
      printf("Couldn't delete 'Intel IPW3945' from the interfaces list!\n");
	  die();
      return;
    }
  else
    {
      printf("Delete 'Intel IPW3945' from the interfaces list.\n");
    }
}

/**
 * \brief Ask the supplicant to delete a trusted server from memory.
 **/
void del_trusted_server()
{
  if (xsupgui_request_delete_trusted_server_config("Test Server 1", TRUE) != REQUEST_SUCCESS)
    {
      printf("Couldn't delete 'Test Server 1' from the trusted servers list!\n");
	  die();
      return;
    }
  else
    {
      printf("Delete 'Test Server 1' from the trusted servers list.\n");
    }
}

/**
 * \brief Change a value in the globals settings.
 **/
void change_globals()
{
	struct config_globals *globs = NULL;
	char *val = NULL;

	if (xsupgui_request_get_globals_config(&globs) != REQUEST_SUCCESS)
	{
		printf("Couldn't get global settings.\n");
		die();
		return;
	}

	val = globs->logpath;
	globs->logpath = "c:\\newpath\\";

	if (xsupgui_request_set_globals_config(globs) != REQUEST_SUCCESS)
	{
		printf("Couldn't set global settings.\n");
		die();
		return;
	}

	if (xsupgui_request_get_globals_config(&globs)  != REQUEST_SUCCESS)
	{
		printf("Couldn't get global settings the second time!\n");
		die();
		return;
	}

	printf("Logpath is now set to '%s'.\n", globs->logpath);
}

/**
 * \brief Change a value in the connection settings.
 **/
void change_conn()
{
	struct config_connection *conn = NULL;
	char *val = NULL;

	if (xsupgui_request_get_connection_config("Ignition Test", &conn) != REQUEST_SUCCESS)
	{
		printf("Couldn't get connection settings.\n");
		die();
		return;
	}

	val = conn->device;
	free(conn->device);
	conn->device = _strdup("some device");

	if (xsupgui_request_set_connection_config(conn) != REQUEST_SUCCESS)
	{
		printf("Couldn't set connection settings.\n");
		die();
		return;
	}

	if (xsupgui_request_get_connection_config("Ignition Test", &conn)  != REQUEST_SUCCESS)
	{
		printf("Couldn't get connection settings the second time!\n");
		die();
		return;
	}

	printf("Device is now set to '%s'.\n", conn->device);
}

/**
 * \brief Change a value in the profile settings.
 **/
void change_prof()
{
	struct config_profiles *prof = NULL;
	char *val = NULL;

	if (xsupgui_request_get_profile_config("House_TTLS", &prof) != REQUEST_SUCCESS)
	{
		printf("Couldn't get profile settings.\n");
		die();
		return;
	}

	val = prof->identity;
	free(prof->identity);
	prof->identity = _strdup("some id");

	if (xsupgui_request_set_profile_config(prof) != REQUEST_SUCCESS)
	{
		printf("Couldn't set profile settings.\n");
		die();
		return;
	}

	if (xsupgui_request_get_profile_config("House_TTLS", &prof)  != REQUEST_SUCCESS)
	{
		printf("Couldn't get profile settings the second time!\n");
		die();
		return;
	}

	printf("Identity is now set to '%s'.\n", prof->identity);
}

/**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -