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

📄 xsupconfig_parse_eap_gtc.c

📁 linux 下通过802.1认证的安装包
💻 C
字号:
/**
 * Licensed under a dual GPL/BSD license.  (See LICENSE file for more info.)
 *
 * \file xsupconfig_parse_eap_gtc.c
 *
 * \author chris@open1x.org
 *
 * $Id: xsupconfig_parse_eap_gtc.c,v 1.1.2.15 2007/07/11 01:12:34 chessing Exp $
 * $Date: 2007/07/11 01:12:34 $
 **/

#include <stdio.h>

#ifndef WINDOWS
#include <stdint.h>
#include <strings.h>
#endif

#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string.h>

#include "xsupconfig_structs.h"
#include "../../src/xsup_common.h"
#include "xsupconfig.h"
#include "xsupconfig_common.h"
#include "xsupconfig_parse.h"
#include "xsupconfig_parse_eap_gtc.h"

void *xsupconfig_parse_phase2_gtc(void **dest, void **attr, xmlNodePtr node)
{
  struct config_eap_method *meth;

#ifdef PARSE_DEBUG
  printf("Parse phase 2 GTC!\n");
#endif

  (*dest) = malloc(sizeof(struct config_eap_method));
  if ((*dest) == NULL)
    {
      printf("Couldn't allocate memory to store phase 2 EAP-GTC!  (Line %ld)"
	     "\n", xsupconfig_parse_get_line_num());
      exit(2);
    }

  meth = (*dest);
  memset(meth, 0x00, sizeof(struct config_eap_method));

  meth->method_num = EAP_TYPE_GTC;
  meth->method_data = malloc(sizeof(struct config_pwd_only));
  if (meth->method_data == NULL)
    {
      printf("Couldn't allocate memory to store phase 2 EAP-GTC data! "
	     "(Line %ld)\n", xsupconfig_parse_get_line_num());
      exit(2);
    }

  memset(meth->method_data, 0x00, sizeof(struct config_pwd_only));

  return meth->method_data;
}

void *xsupconfig_parse_eap_gtc(void **attr, xmlNodePtr node)
{
  struct config_eap_method *meth;

  meth = (*attr);

  if (meth == NULL)
  {
	meth = xsupconfig_alloc_method(meth, "EAP-GTC");
	(*attr) = meth;
  }
  else
  {
	  meth = xsupconfig_alloc_method(meth, "EAP-GTC");
  }

  if (meth == NULL) return NULL;

#ifdef PARSE_DEBUG
  printf("Parsing method 'EAP-GTC'.\n");
#endif

  meth->method_num = EAP_TYPE_GTC;
  meth->method_data = malloc(sizeof(struct config_pwd_only));
  if (meth->method_data == NULL)
    {
      printf("Couldn't allocate memory to store EAP-GTC data in network!"
	     " (Line %ld)\n", xsupconfig_parse_get_line_num());
      exit(2);
    }

  memset(meth->method_data, 0x00, sizeof(struct config_pwd_only));
  
  return meth->method_data;
}

void *xsupconfig_parse_eap_gtc_password(void **attr, xmlNodePtr node)
{
  struct config_pwd_only *gtc;
  char *value;

  gtc = (*attr);

  value = xmlNodeGetContent(node);

#ifdef PARSE_DEBUG
  printf("Password for EAP-GTC is '%s'!\n", value);
#endif

	if ((value == NULL) || (strlen(value) == 0))
	{
		free(value);
		gtc->password = NULL;
	}
	else
	{
		gtc->password = value;
	}

  return gtc;
}

void *xsupconfig_parse_eap_gtc_enc_password(void **attr, xmlNodePtr node)
{
  struct config_pwd_only *gtc;
  char *value;
  int size;

  gtc = (*attr);

  value = xmlNodeGetContent(node);

#ifdef PARSE_DEBUG
  printf("Password for EAP-GTC is '%s'!\n", value);
#endif

  if (pwcrypt_decrypt(value, strlen(value), &gtc->password, &size) != 0)
  {
	  free(value);
	  gtc->password = NULL;
	  return gtc;
  }

  if ((gtc->password != NULL) && (strlen(gtc->password) == 0))
  {
	  FREE(gtc->password);
  }

  free(value);

  return gtc;
}

parser eap_gtc[] = {
  {"Password", NULL, FALSE, &xsupconfig_parse_eap_gtc_password},
  {"Encrypted_Password", NULL, FALSE, &xsupconfig_parse_eap_gtc_enc_password},
  {"Type", NULL, FALSE, xsupcommon_do_nothing},

  {NULL, NULL, FALSE, NULL}};

⌨️ 快捷键说明

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