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

📄 xsupconfig.c

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

  dump_config_eap_method(method->next, dumplevel);
}

  /**********************/
 /* CONFIG_CONNECTION  */
/**********************/

/**
 * \brief Delete a single connection structure stored in memory.
 *
 * @param[in] tmp_conn   A double dereferenced pointer to the location
 *                       in memory where the connection data is stored.
 **/
void delete_config_single_connection(struct config_connection **tmp_conn)
{
  if (*tmp_conn == NULL)
    return;

  FREE_STRING((*tmp_conn)->name);
  FREE_STRING((*tmp_conn)->ssid);
  FREE_STRING((*tmp_conn)->profile);
  FREE_STRING((*tmp_conn)->device);

  delete_config_ip_data((*tmp_conn));
  delete_config_association((*tmp_conn));

  free ((*tmp_conn));
  (*tmp_conn) = NULL;
}

/**
 * \brief  Delete all of the connections in memory.
 *
 * @param[in] tmp_conn   A double dereferenced pointer to the head of
 *                       a linked list of connections to be cleared from
 *                       memory.
 **/
void delete_config_connections(struct config_connection **tmp_conn)
{
  struct config_connection *next, *cur;

  if (*tmp_conn == NULL)
    return;

  cur = (*tmp_conn);
  next = (*tmp_conn)->next;

  while (cur)
    {
      delete_config_single_connection(&cur);
      cur = next;
      if (next)
	{
	  next = next->next;
	}
    }

  *tmp_conn = NULL;
}

/**
 * \brief Allocate memory to store a new connection.
 *
 * @param[in] tmp_conn   A pointer to the pointer that will hold the new
 *                       connection node in a linked list.
 **/
void initialize_config_connections(struct config_connection **tmp_conn)
{
  if (*tmp_conn != NULL) {
    delete_config_connections(tmp_conn);
  }
  *tmp_conn = 
    (struct config_connection *)malloc(sizeof(struct config_connection));  
  if (*tmp_conn)
    {
      memset(*tmp_conn, 0, sizeof(struct config_connection));
      (*tmp_conn)->priority = DEFAULT_PRIORITY;
      SET_FLAG((*tmp_conn)->flags, CONFIG_NET_USE_OSC_TNC);
    }
}

/**
 * \brief Delete a single managed network stored in memory.
 *
 * @param[in] tmp_mn  A double dereferenced pointer to a location
 *                    in memory where the managed network data is
 *                    stored.
 **/
void delete_config_managed_network(struct config_managed_networks **tmp_mn)
{
  if ((*tmp_mn) == NULL)
    return;

  FREE_STRING((*tmp_mn)->ou);
  FREE_STRING((*tmp_mn)->key);
  FREE_STRING((*tmp_mn)->update_url);
  FREE_STRING((*tmp_mn)->last_update);

  FREE((*tmp_mn));
  (*tmp_mn) = NULL;
}

/**
 * \brief Delete all of the managed networks that are currently stored
 *        in memory.
 *
 * @param[in] head   The pointer to the head of the linked list that 
 *                   contains the managed networks information.
 **/
void delete_config_managed_networks(struct config_managed_networks **head)
{
  struct config_managed_networks *next, *cur;

  if (*head == NULL)
    return;

  cur = (*head);
  next = (*head)->next;

  while (cur)
    {
      delete_config_managed_network(&cur);
      cur = next;
      if (next != NULL)
	{
	  next = next->next;
	}
    }
}

/**
 * \brief Delete all information for a single interface in the linked list.
 *
 * @param[in] intdata   A double dereferenced pointer to the structure that we
 *                      need to free.
 **/
void delete_config_interface(struct xsup_interfaces **intdata)
{
	FREE((*intdata)->description);
	FREE((*intdata)->driver_type);

	FREE((*intdata));
}

/**
 * \brief Delete all of the devices that are currently stored
 *        in memory.
 *
 * @param[in] head   The pointer to the head of the linked list that 
 *                   contains the devices information.
 **/
void delete_config_devices(struct xsup_devices **head)
{
  struct xsup_interfaces *next, *cur;

  if (*head == NULL)
    return;

  cur = (*head)->interf;
  next = (*head)->interf->next;

  while (cur)
    {
      delete_config_interface(&cur);
      cur = next;
      if (next != NULL)
	{
	  next = next->next;
	}
    }

  free((*head));
}
  /***************************/
 /* CONFIG_TRUSTED_SERVERS  */
/***************************/

/**
 * \brief Delete a single trusted server structure stored in memory.
 *
 * @param[in] tmp_server   A double dereferenced pointer to the location
 *                         in memory where the trusted server data is stored.
 **/
void delete_config_trusted_server(struct config_trusted_server **tmp_server)
{
  if (((*tmp_server) == NULL) || (tmp_server == NULL))
    return;

  FREE_STRING((*tmp_server)->name);
  FREE_STRING((*tmp_server)->store_type);
  FREE_STRING((*tmp_server)->location);
  FREE_STRING((*tmp_server)->common_name);

  free ((*tmp_server));
  (*tmp_server) = NULL;
}

/**
 * \brief  Delete all of the trusted servers in memory.
 *
 * @param[in] tmp_servers   A double dereferenced pointer to the head of
 *                          a linked list of trusted servers to be cleared from
 *                          memory.
 **/
void delete_config_trusted_servers(struct config_trusted_servers **tmp_servers)
{
  struct config_trusted_server *next = NULL, *cur = NULL;

  if (((*tmp_servers) == NULL) || (tmp_servers == NULL))
    return;

  cur = (*tmp_servers)->servers;

  if ((*tmp_servers)->servers != NULL) 
  {
	  next = (*tmp_servers)->servers->next;
  }

  while (cur)
    {
      delete_config_trusted_server(&cur);
      cur = next;
      if (next != NULL)
		{
			next = next->next;
		}
    }

  FREE((*tmp_servers));
  *tmp_servers = NULL;
}

/**
 * \brief Dump to the screen, the encryption type that WPA/WPA2 will use.
 *
 * @param[in] crypt  A byte that identifies the encryption method that should be
 *                   used for encryption with WPA/WPA2.
 **/
void dump_config_network_wpa(uint8_t crypt)
{
  switch (crypt)
    {
    case CRYPT_WEP40:
      printf("WEP40\n");
      return;

    case CRYPT_TKIP:
      printf("TKIP\n");
      return;

    case CRYPT_WRAP:
      printf("WRAP\n");
      return;

    case CRYPT_CCMP:
      printf("CCMP\n");
      return;

    case CRYPT_WEP104:
      printf("WEP104\n");
      return;
    
    default:
      printf("NONE\n");
      return;
    }
}

/**
 * \brief Dump to the screen, the association block of a connection
 *        structure in memory.
 *
 * @param[in] conn   A pointer to memory that contains a connection that
 *                   we want to dump the association block of.
 **/
void dump_config_association(struct config_connection *conn)
{
	if (!conn) return;

	printf("\t------- Association Information -------\n");
	printf("\tAssociation Type    : %d\n", conn->association.association_type);
	printf("\tPairwise Key Type   : %02x\n", conn->association.pairwise_keys);
	printf("\tGroup Key Type      : %d\n", conn->association.group_keys);
	printf("\tAuthentication Type : %d\n", conn->association.auth_type);
	printf("\tStatic WEP TX Index : %d\n", conn->association.txkey);
	printf("\tWPA PSK             : %s\n", conn->association.psk);
	printf("\tWPA PSK (Hex)       : %s\n", conn->association.psk_hex);
	printf("\t---------------------------------------\n");
}

/**
 * \brief Free memory used by the association configuration.
 *
 * @param[in] conn   A connection configuration structure that contains the 
 *                   association data we want to free.
 **/
void delete_config_association(struct config_connection *conn)
{
	if (conn == NULL) return;  // Nothing to do.

	FREE(conn->association.psk);
	FREE(conn->association.psk_hex);
	FREE(conn->association.keys[1]);
	FREE(conn->association.keys[2]);
	FREE(conn->association.keys[3]);
	FREE(conn->association.keys[4]);
}

/**
 * \brief Free memory used by the IP configuration structures.
 *
 * @param[in] conn   A connection configuration sturcture that contains the
 *                   IP address data we want to free.
 **/
void delete_config_ip_data(struct config_connection *conn)
{
	if (conn == NULL) return; // Nothing to do.

	FREE(conn->ip.dns1);
	FREE(conn->ip.dns2);
	FREE(conn->ip.dns3);
	FREE(conn->ip.gateway);
	FREE(conn->ip.ipaddr);
	FREE(conn->ip.netmask);
	FREE(conn->ip.search_domain);
}

/**
 * \brief Dump all of the IP data from the configuration file.
 *
 * @param[in] conn  A pointer to a structure that contains the "<IP_Address>" block
 *                  data from the config file.
 **/
void dump_config_ip(struct config_connection *conn)
{
	printf("\t------------- IP Data -------------\n");
	printf("\tType         : %d\n", conn->ip.type);
	printf("\tRenew on Re. : %d\n", conn->ip.renew_on_reauth);
	printf("\tIP Address   : %s\n", conn->ip.ipaddr);
	printf("\tNetmask      : %s\n", conn->ip.netmask);
	printf("\tGateway      : %s\n", conn->ip.gateway);
	printf("\tDNS1         : %s\n", conn->ip.dns1);
	printf("\tDNS2         : %s\n", conn->ip.dns2);
	printf("\tDNS3         : %s\n", conn->ip.dns3);
	printf("\tSearch Domain: %s\n", conn->ip.search_domain);
	printf("\t-----------------------------------\n");
}

/**
 * \brief Dump all of the known information about a single connection.
 *
 * @param[in] conn   A pointer to a structure that contains the connection
 *                   we wish to display data for.
 **/
void dump_config_connections(struct config_connection *conn)
{
  if (!conn)
    return;
  printf("+-+-+-+-+  Network Name: \"%s\" +-+-+-+-+\n", conn->name);

  printf("  SSID: \"%s\"\n", conn->ssid);
  printf("  OU  : \"%s\"\n", conn->ou);

  if (TEST_FLAG(conn->flags, CONFIG_NET_IS_HIDDEN))
  {
	  printf("  Hidden SSID : yes\n");
  }
  else
  {
	  printf("  Hidden SSID : no\n");
  }

  if (TEST_FLAG(conn->flags, CONFIG_NET_USE_OSC_TNC))
    {
      printf("  Use OSC TNC support : Yes\n");
    } 
  else
    {
      printf("  Use OSC TNC support : No\n");
    }

  if (TEST_FLAG(conn->flags, CONFIG_NET_DEST_MAC))
    printf("  DEST MAC: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
	   conn->dest_mac[0], conn->dest_mac[1], conn->dest_mac[2],
	   conn->dest_mac[3], conn->dest_mac[4], conn->dest_mac[5]);

  printf("  Priority  : %d\n", conn->priority);
  printf("  Device    : %s\n", conn->device);
  printf("  Profile   : %s\n", conn->profile);
  printf("  EAPoL Ver : %d\n", conn->force_eapol_ver);

  dump_config_association(conn);
  dump_config_ip(conn);

  if (conn->next)
    dump_config_connections(conn->next);
      
}


  /*******************/
 /* CONFIG_GLOBALS  */
/*******************/

/**
 * \brief Free all of the memory that is used by the configuration 
 *        information from the <Globals> section of the configuration.
 *
 * @param[in] tmp_globals   A double dereferenced pointer to the structure
 *                          in memory that contains the configuration information
 *                          from the <Globals> section of the configuration.
 **/
void delete_config_globals(struct config_globals **tmp_globals)
{
  if (*tmp_globals == NULL)
    return;

  FREE_STRING((*tmp_globals)->logpath);
  FREE_STRING((*tmp_globals)->ipc_group_name);
  FREE_STRING((*tmp_globals)->log_facility);
  
  free (*tmp_globals);
  *tmp_globals = NULL;
}

/**
 * \brief Point the config globals to a new structure.
 *
 * @param[in] new_globals   A pointer to the new structure that contains all
 *                          of our globals.
 *
 * \warning DO NOT free the memory used by the structure passed in.  This call
 *          doesn't copy the data, it simple changes an internal pointer to 
 *          point to the new data!
 *
 * \retval XENONE on success
 * \retval XEMALLOC on memory errors
 **/
int config_set_new_globals(struct config_globals *new_globals)
{
  if (new_globals == NULL) return XEMALLOC;

  conf_globals = new_globals;

  return XENONE;
}

/**
 * \brief Allocate the memory to be used to store the information from
 *        the <Globals> section of the configuration file.
 *
 * @param[in] tmp_globals   A pointer to the pointer that will contain
 *                          the configuration information from the <Globals>
 *                          portion of the configuration.
 **/
void initialize_config_globals(struct config_globals **tmp_globals)
{
  if (*tmp_globals != NULL) {
    delete_config_globals(tmp_globals);
  }
  *tmp_globals = 
    (struct config_globals *)malloc(sizeof(struct config_globals));  

⌨️ 快捷键说明

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