📄 xsupconfig_parse_eap_ttls_mschap.c
字号:
/**
* Licensed under a dual GPL/BSD license. (See LICENSE file for more info.)
*
* \file xsupconfig_parse_eap_ttls_mschap.c
*
* \author chris@open1x.org
*
* $Id: xsupconfig_parse_eap_ttls_mschap.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_structs.h"
#include "xsupconfig_parse.h"
#include "xsupconfig_parse_eap_ttls_mschap.h"
#include "xsupconfig_common.h"
void *xsupconfig_parse_eap_ttls_mschap(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 MSCHAP 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_mschap_password(void **attr, xmlNodePtr node)
{
struct config_pwd_only *mschap;
char *value;
mschap = (*attr);
value = xmlNodeGetContent(node);
#ifdef PARSE_DEBUG
printf("MSCHAP Password : %s\n", value);
#endif
if ((value == NULL) || (strlen(value) == 0))
{
free(value);
mschap->password = NULL;
}
else
{
mschap->password = value;
}
return mschap;
}
void *xsupconfig_parse_eap_ttls_enc_mschap_password(void **attr, xmlNodePtr node)
{
struct config_pwd_only *mschap = NULL;
char *value = NULL;
int size = 0;
mschap = (*attr);
value = xmlNodeGetContent(node);
#ifdef PARSE_DEBUG
printf("MSCHAP Password : %s\n", value);
#endif
if ((value == NULL) || (strlen(value) == 0))
{
free(value);
return mschap;
}
if (pwcrypt_decrypt(value, strlen(value), &mschap->password, &size) != 0)
{
free(value);
mschap->password = NULL;
return mschap;
}
if ((mschap->password != NULL) && (strlen(mschap->password) == 0))
{
FREE(mschap->password);
}
free(value);
return mschap;
}
parser eap_ttls_mschap[] = {
{"Password", NULL, FALSE,
&xsupconfig_parse_eap_ttls_mschap_password},
{"Encrypted_Password", NULL, FALSE, &xsupconfig_parse_eap_ttls_enc_mschap_password}};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -