📄 xsupconfig_parse_eap_tnc.c
字号:
/**
* Licensed under a dual GPL/BSD license. (See LICENSE file for more info.)
*
* \file xsupconfig_parse_eap_tnc.c
*
* \author chris@open1x.org
*
* $Id: xsupconfig_parse_eap_tnc.c,v 1.1.2.10 2007/03/30 15:03:29 chessing Exp $
* $Date: 2007/03/30 15:03:29 $
**/
#include <stdio.h>
#ifndef WINDOWS
#include <stdint.h>
#include <strings.h>
#endif
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string.h>
#include "../../src/xsup_common.h"
#include "xsupconfig.h"
#include "xsupconfig_structs.h"
#include "xsupconfig_common.h"
#include "xsupconfig_parse.h"
#include "xsupconfig_parse_eap_tnc.h"
void *xsupconfig_parse_eap_tnc(void **attr, xmlNodePtr node)
{
struct config_eap_ttls *ttls;
struct config_eap_method *eap, *cur;
ttls = (*attr);
if (ttls == NULL)
{
printf("Invalid TTLS phase 1! You cannot have 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);
}
if (ttls->phase2_data == NULL)
{
ttls->phase2_data = malloc(sizeof(struct config_eap_method));
if (ttls->phase2_data == NULL)
{
printf("Couldn't allocate memory to store TTLS-EAP-TNC data! "
"(Line %ld)\n", xsupconfig_parse_get_line_num());
exit(2);
}
memset(ttls->phase2_data, 0x00, sizeof(struct config_eap_method));
eap = ttls->phase2_data;
}
else
{
cur = ttls->phase2_data;
while (cur->next != NULL) cur = cur->next;
cur->next = malloc(sizeof(struct config_eap_method));
if (cur->next == NULL)
{
printf("Couldn't allocate memory to store TTLS-EAP-TNC data! "
"(Line %ld)\n", xsupconfig_parse_get_line_num());
exit(2);
}
memset(cur->next, 0x00, sizeof(struct config_eap_method));
eap = cur->next;
}
eap->method_num = EAP_TYPE_TNC;
eap->method_data = malloc(sizeof(struct config_eap_tnc));
if (eap->method_data == NULL)
{
printf("Couldn't allocate memory to store TTLS-EAP-TNC data! (Line %ld)"
"\n", xsupconfig_parse_get_line_num());
exit(2);
}
memset(eap->method_data, 0x00, sizeof(struct config_eap_tnc));
return eap->method_data;
}
void *xsupconfig_parse_eap_tnc_chunk_size(void **attr, xmlNodePtr node)
{
struct config_eap_tnc *tnc;
char *value;
value = xmlNodeGetContent(node);
tnc = (*attr);
#ifdef PARSE_DEBUG
printf("Chunk Size for TNC is '%s'!\n", value);
#endif
if (xsupconfig_common_is_number(value) == 0)
{
printf("Value assigned to 'Chunk_Size' is not a number! Using "
"default! (Line %ld)\n", xsupconfig_parse_get_line_num());
}
else
{
tnc->frag_size = atoi(value);
}
FREE(value);
return tnc;
}
parser eap_tnc[] = {
{"Chunk_Size", NULL, FALSE, &xsupconfig_parse_eap_tnc_chunk_size},
{"Type", NULL, FALSE, xsupcommon_do_nothing},
{NULL, NULL, FALSE, NULL}};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -