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

📄 xsupconfig_parse_leap.c

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

#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_leap.h"

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

  meth = (*attr);

  if (meth == NULL)
  {
	meth = xsupconfig_alloc_method(meth, "LEAP");
	(*attr) = meth;
  }
  else
  {
	  meth = xsupconfig_alloc_method(meth, "LEAP");
  }

  if (meth == NULL) return NULL;

#ifdef PARSE_DEBUG
  printf("Parsing method 'LEAP'.\n");
#endif

  meth->method_num = EAP_TYPE_LEAP;
  meth->method_data = malloc(sizeof(struct config_pwd_only));
  if (meth->method_data == NULL)
    {
      printf("Couldn't allocate memory to store LEAP 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_leap_password(void **attr, xmlNodePtr node)
{
  struct config_pwd_only *leap;
  char *value;

  value = xmlNodeGetContent(node);

  leap = (*attr);

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

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

  return leap;
}

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

  value = xmlNodeGetContent(node);

  leap = (*attr);

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

	if ((value == NULL) || (strlen(value) == 0))
	{
		free(value);
		return leap;
	}

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

  free(value);

  return leap;
}

parser leap[] = {
  {"Password", NULL, FALSE, &xsupconfig_parse_leap_password},
  {"Encrypted_Password", NULL, FALSE, &xsupconfig_parse_leap_enc_password},
  {"Type", NULL, FALSE, xsupcommon_do_nothing},

  {NULL, NULL, FALSE, NULL}};

⌨️ 快捷键说明

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