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

📄 xsupgui_request5.c

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

	err = xsupgui_request_send(doc, &retdoc);
	if (err != REQUEST_SUCCESS)
	{
		done = err;
		goto finish_write_config;
	}

	// Check if we got errors.
	err = xsupgui_request_check_exceptions(retdoc);
	if (err != 0) 
	{
		done = err;
		goto finish_write_config;
	}

	done = xsupgui_request_is_ack(retdoc);

finish_write_config:
	xmlFreeDoc(doc);
	xmlFreeDoc(retdoc);

	return done;
}

/**
 * \brief Ask the supplicant to delete a profile from it's configuration in 
 *        memory.
 *
 * \note If you want this change to be perminant, you need to call the request
 *       to write the configuration to disk!
 *
 * @param[in] prof_name   The name of the profile that we want to delete from
 *                        the configuration in memory.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_delete_profile_config(char *prof_name, int force)
{
	return xsupgui_request_delete_some_conf("Delete_Profile_Config", "Name", prof_name, force);
}

/**
 * \brief Ask the supplicant to delete a connection from it's configuration in
 *        memory.
 *
 * \note If you want this change to be perminant, you need to call the request
 *       to write the configuration to disk!
 *
 * @param[in] conn_name   The name of the connection that we want to delete from
 *                        the configuration in memory.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_delete_connection_config(char *conn_name)
{
	return xsupgui_request_delete_some_conf("Delete_Connection_Config", "Name", conn_name, -1);
}

/**
 * \brief Ask the supplicant to delete an interface from it's configuration in
 *        memory.
 *
 * \note If you want this change to be perminant, you need to call the request
 *       to write the configuration to disk!
 *
 * @param[in] intname   The description of the interface that we want to delete
 *                      from the configuration in memory.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_delete_interface_config(char *intname)
{
	return xsupgui_request_delete_some_conf("Delete_Interface_Config", "Description", intname, -1);
}

/**
 * \brief Set information about a trusted server in to the supplicant's 
 *        configuration memory.
 *
 * \note This will not store the change to disk!  You need to request a write
 *       for that to happen.
 *
 * @param[in] tserver   The config_trusted_server structure that should be
 *                      stored in the configuration memory of the supplicant.
 *                      If the named trusted server already exists, it will be
 *                      overwritten.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_set_trusted_server_config(config_trusted_server *tserver)
{
  xmlDocPtr doc = NULL;
  xmlDocPtr retdoc = NULL;
  xmlNodePtr n = NULL, t = NULL;
  int done = REQUEST_SUCCESS;
  int err = 0;

  if (tserver == NULL) return IPC_ERROR_INVALID_PARAMETERS;

  doc = xsupgui_xml_common_build_msg();
  if (doc == NULL) return IPC_ERROR_CANT_CREATE_REQ_HDR;

  n = xmlDocGetRootElement(doc);
  if (n == NULL)
    {
      done = IPC_ERROR_CANT_FIND_REQ_ROOT_NODE;
      goto finish_set_trusted_server_config;
    }

  n = xmlNewChild(n, NULL, "Set_Trusted_Server_Config", NULL);
  if (n == NULL)
    {
      done = IPC_ERROR_CANT_CREATE_REQUEST;
      goto finish_set_trusted_server_config;
    }

  t = xsupconfwrite_trusted_server_create_tree(tserver, TRUE);
  if (t == NULL)
  {
	  done = IPC_ERROR_UNSPEC_REQ_FAILURE;
	  goto finish_set_trusted_server_config;
  }

  if (xmlAddChild(n, t) == NULL)
  {
	  done = IPC_ERROR_CANT_ADD_NODE;
	  goto finish_set_trusted_server_config;
  }

	err = xsupgui_request_send(doc, &retdoc);
	if (err != REQUEST_SUCCESS)
	{
		done = err;
		goto finish_set_trusted_server_config;
	}

	// Check if we got errors.
	err = xsupgui_request_check_exceptions(retdoc);
	if (err != 0) 
	{
		done = err;
		goto finish_set_trusted_server_config;
	}

	done = xsupgui_request_is_ack(retdoc); 

finish_set_trusted_server_config:
	if (doc) xmlFreeDoc(doc);
	if (retdoc) xmlFreeDoc(retdoc);

	return done;
}

/**
 * \brief Free the memory that was allocated for config globals.
 *
 * @param[in] globals   The structure that contains the globals that we want
 *                      to free the memory for.  After the function returns, 
 *                      this value should be set to NULL.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_free_config_globals(config_globals **globals)
{
	delete_config_globals(globals);

  return REQUEST_SUCCESS;
}

/**
 * \brief Free the memory that was allocated for the profile configuration.
 *
 * @param[in] profile   The structure that contains the profile that we want
 *                      to free the memory for.  After the function returns,
 *                      this value should be set to NULL.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_free_profile_config(config_profiles **profile)
{
	delete_config_profiles(profile);

  return REQUEST_SUCCESS;
}

/**
 * \brief Free the memory that was allocated for the connection configuration.
 *
 * @param[in] conn   The structure that contains the connection that we want
 *                   to free the memory for.  After the function returns, 
 *                   this value should be set to NULL.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_free_connection_config(config_connection **conn)
{
	delete_config_connections(conn);

  return REQUEST_SUCCESS;
}

/**
 * \brief Free the memory that was allocated for the interface configuration.
 *
 * @param[in] intf   The structure that contains the interface that we want
 *                   to free the memory for.  After this function returns,
 *                   this value should be set to NULL.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_free_interface_config(config_interfaces **intf)
{
	delete_config_interface(intf);

  return REQUEST_SUCCESS;
}

/**
 * \brief Free the memory that was allocated for the trusted server 
 *        configuration.
 *
 * @param[in] tserver   The structure that contains the trusted server
 *                      configuration that we want to free memory for.  After
 *                      this function returns, this value should be set to 
 *                      NULL.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_free_trusted_server_config(config_trusted_server **tserver)
{
	delete_config_trusted_server(tserver);

  return REQUEST_SUCCESS;
}

/**
 * \brief Request that the supplicant delete a trusted server from it's configuration
 *        memory.
 *
 * @param[in] tserver   The structure that contains the trusted server
 *                      configuration that we want to free memory for.  After
 *                      this function returns, this value should be set to 
 *                      NULL.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_delete_trusted_server_config(char *servname, int force)
{
	return xsupgui_request_delete_some_conf("Delete_Trusted_Server_Config", "Name", servname, force);
}

/**
 * \brief Free the memory that was used in the managed network config block.
 *
 * @param[in] mnets   The structure that contains the managed network that we
 *                    want to free the memory for.
 *
 * \retval REQUEST_FAILURE on failure
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_free_managed_network_config(config_managed_networks **mnets)
{
	delete_config_managed_network(mnets);

	return REQUEST_SUCCESS;
}

/**
 * \brief Free the memory that was allocated to store the managed networks 
 *        enumeration.
 *
 * @param[in] mnets   The memory that was allocated to store the managed network
 *                    enumeration.
 *
 * \retval REQUEST_FAILURE on failure
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_free_managed_networks_enum(managed_nets_enum **mnets)
{
	int i = 0;
	managed_nets_enum *nets;

	nets = (*mnets);

	if (nets == NULL) return REQUEST_SUCCESS;

	while (nets[i].ou != NULL)
	{
		free(nets[i].ou);
		nets[i].ou = NULL;
		i++;
	}

	free((*mnets));
	(*mnets) = NULL;

	return REQUEST_SUCCESS;
}

/**
 * \brief Request an enumeration of the managed networks that we know about.
 *
 * @param[in] mnets   A pointer to memory that will be allocated, and filled with
 *                    an array that contains information about the managed networks.
 *                    The array is terminated by the final element being NULLs.
 *
 * \retval >299 on failure
 * \retval REQUEST_TIMEOUT on timeout
 * \retval REQUEST_SUCCESS on success
 **/
int xsupgui_request_enum_managed_networks(managed_nets_enum **mnets)
{
	xmlDocPtr doc = NULL;
	xmlDocPtr retdoc = NULL;
	xmlNodePtr n = NULL, t = NULL;
	xmlChar *content = NULL;
	int done = REQUEST_SUCCESS;
	int numnets = 0, i = 0, err = 0;
	managed_nets_enum *nets = NULL;

	if (mnets == NULL) return IPC_ERROR_INVALID_PARAMETERS;

	(*mnets) = NULL;

	doc = xsupgui_xml_common_build_msg();
	if (doc == NULL) return IPC_ERROR_CANT_CREATE_REQ_HDR;

	n = xmlDocGetRootElement(doc);
	if (n == NULL)
	{
		done = IPC_ERROR_CANT_FIND_REQ_ROOT_NODE;
		goto finish_enum_managed_nets;
	}

	if (xmlNewChild(n, NULL, "Enum_Managed_Networks", NULL) == NULL)
	{
		done = IPC_ERROR_CANT_CREATE_REQUEST;
		goto finish_enum_managed_nets;
	}

	err = xsupgui_request_send(doc, &retdoc);
	if (err != REQUEST_SUCCESS)
	{
		done = err;
		goto finish_enum_managed_nets;
	}

	// Otherwise, parse it and see if we got what we wanted.

	// Check if we got errors.
	err = xsupgui_request_check_exceptions(retdoc);
	if (err != 0) 
	{
		done = err;
		goto finish_enum_managed_nets;
	}

	n = xmlDocGetRootElement(retdoc);
	if (n == NULL)
	{
		done = IPC_ERROR_CANT_FIND_RESP_ROOT_NODE;
		goto finish_enum_managed_nets;
	}

	// If we get here, then we know that the document passed the
	// validation tests imposed.  So, we need to see if we got the result 
	// we wanted.
	n = xsupgui_request_find_node(n->children, "Managed_Networks_List");
	if (n == NULL)
	{
		done = IPC_ERROR_BAD_RESPONSE;
		goto finish_enum_managed_nets;
	}

	t = xsupgui_request_find_node(n->children, "Number_Of_Networks");
	if (t == NULL) 
	{
		done = IPC_ERROR_BAD_RESPONSE_DATA;
		goto finish_enum_managed_nets;
	}

	content = xmlNodeGetContent(t);
	if ((content == NULL) || (strlen(content) == 0))
	{
		done = IPC_ERROR_BAD_RESPONSE_DATA;
		goto finish_enum_managed_nets;
	}

#ifdef REQUEST_DEBUG
	printf("%s managed net(s) found!\n", content);
#endif
	if (content != NULL)
	{
		numnets = atoi(content);

		if (content != NULL) free(content);
	}
	else
	{
		done = IPC_ERROR_BAD_RESPONSE_DATA;
		goto finish_enum_managed_nets;
	}

	// Allocate memory for our return structure.
	nets = malloc(sizeof(managed_nets_enum)*(numnets+1));
	if (nets == NULL) 
	{
#ifdef REQUEST_DEBUG
		printf("Couldn't allocate memory to return managed networks data!\n");
#endif
		done = IPC_ERROR_CANT_ALLOCATE_MEMORY;
		goto finish_enum_managed_nets;
	}

	// Clear the memory.
	memset(nets, 0x00, (sizeof(managed_nets_enum)*(numnets+1)));

	n = n->children;
	for (i=0; i <numnets; i++)
	{
		n = xsupgui_request_find_node(n, "OU");
		if (n == NULL) 
		{
			if (nets != NULL) free(nets);
			done = IPC_ERROR_BAD_RESPONSE_DATA;
			goto finish_enum_managed_nets;
		}

		nets[i].ou = xmlNodeGetContent(n);

		n = n->next;
	}

	(*mnets) = nets;
	done = REQUEST_SUCCESS;

finish_enum_managed_nets:
	if (doc) xmlFreeDoc(doc);
	if (retdoc) xmlFreeDoc(retdoc);

	return done;
}

⌨️ 快捷键说明

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