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

📄 xsupconfig_parse_eap_ttls_chap.c

📁 linux 下通过802.1认证的安装包
💻 C
字号:
/**
 * Licensed under a dual GPL/BSD license.  (See LICENSE file for more info.)
 *
 * \file xsupconfig_parse_eap_ttls_chap.c
 *
 * \author chris@open1x.org
 *
 * $Id: xsupconfig_parse_eap_ttls_chap.c,v 1.1.2.18 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_parse.h"
#include "xsupconfig_parse_eap_ttls_chap.h"
#include "xsupconfig_common.h"

void *xsupconfig_parse_eap_ttls_chap(void **attr, xmlNodePtr node)
{
  struct config_eap_ttls *ttls;

  ttls = (*attr);

  if (ttls == NULL)
    {
      xsupconfig_common_log("Invalid TTLS phase 1!  You cannot have TTLS phase 2 data without"
	     " having a phase 1!  (This is likely a bug in the parser code!)"
	     "  (Line %ld)\n", xsupconfig_parse_get_line_num());
      exit(2);
    }

  ttls->phase2_data = malloc(sizeof(struct config_pwd_only));
  if (ttls->phase2_data == NULL)
    {
      printf("Couldn't allocate memory to store CHAP configuration for "
	     "EAP-TTLS!  (Line %ld)\n", xsupconfig_parse_get_line_num());
      exit(2);
    }

  memset(ttls->phase2_data, 0x00, sizeof(struct config_pwd_only));

  return ttls->phase2_data;
}

void *xsupconfig_parse_eap_ttls_chap_password(void **attr, xmlNodePtr node)
{
  struct config_pwd_only *chap;
  char *value;

  chap = (*attr);

  value = xmlNodeGetContent(node);

#ifdef PARSE_DEBUG
  printf("CHAP Password : %s\n", value);
#endif

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

  return chap;
}

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

  chap = (*attr);

  value = xmlNodeGetContent(node);

#ifdef PARSE_DEBUG
  printf("CHAP Password : %s\n", value);
#endif

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

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

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

  free(value);

  return chap;
}

parser eap_ttls_chap[] = {
  {"Password", NULL, FALSE, 
   &xsupconfig_parse_eap_ttls_chap_password},
  {"Encrypted_Password", NULL, FALSE, &xsupconfig_parse_eap_ttls_enc_chap_password}};

⌨️ 快捷键说明

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