Use a string to identify xauth backends, no need for integer types

This commit is contained in:
Martin Willi
2012-03-20 17:31:15 +01:00
parent 4e73f85b81
commit 1fe6cdfac2
11 changed files with 52 additions and 187 deletions
+1 -2
View File
@@ -70,8 +70,7 @@ utils/linked_list.c utils/linked_list.h \
utils/hashtable.c utils/hashtable.h \
utils/enumerator.c utils/enumerator.h \
utils/optionsfrom.c utils/optionsfrom.h \
utils/backtrace.c utils/backtrace.h \
xauth/xauth.h xauth/xauth.c
utils/backtrace.c utils/backtrace.h
library.lo : $(top_builddir)/config.status
+3 -4
View File
@@ -25,7 +25,6 @@ typedef struct plugin_feature_t plugin_feature_t;
#include <library.h>
#include <eap/eap.h>
#include <xauth/xauth.h>
#include <plugins/plugin.h>
/**
@@ -188,7 +187,7 @@ struct plugin_feature_t {
/** FEATURE_CUSTOM */
char *custom;
/** FEATURE_XAUTH_SERVER/CLIENT */
xauth_type_t xauth;
char *xauth;
/** FEATURE_REGISTER */
struct {
@@ -273,8 +272,8 @@ struct plugin_feature_t {
#define _PLUGIN_FEATURE_DATABASE(kind, type) __PLUGIN_FEATURE(kind, DATABASE, .database = type)
#define _PLUGIN_FEATURE_FETCHER(kind, type) __PLUGIN_FEATURE(kind, FETCHER, .fetcher = type)
#define _PLUGIN_FEATURE_CUSTOM(kind, name) __PLUGIN_FEATURE(kind, CUSTOM, .custom = name)
#define _PLUGIN_FEATURE_XAUTH_SERVER(kind, type) __PLUGIN_FEATURE(kind, XAUTH_SERVER, .xauth = type)
#define _PLUGIN_FEATURE_XAUTH_PEER(kind, type) __PLUGIN_FEATURE(kind, XAUTH_PEER, .xauth = type)
#define _PLUGIN_FEATURE_XAUTH_SERVER(kind, name) __PLUGIN_FEATURE(kind, XAUTH_SERVER, .xauth = name)
#define _PLUGIN_FEATURE_XAUTH_PEER(kind, name) __PLUGIN_FEATURE(kind, XAUTH_PEER, .xauth = name)
#define __PLUGIN_FEATURE_REGISTER(type, _f) (plugin_feature_t){ FEATURE_REGISTER, FEATURE_##type, .arg.reg.f = _f }
#define __PLUGIN_FEATURE_REGISTER_BUILDER(type, _f, _final) (plugin_feature_t){ FEATURE_REGISTER, FEATURE_##type, .arg.reg = {.f = _f, .final = _final, }}
-50
View File
@@ -1,50 +0,0 @@
/*
* Copyright (C) 2006 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "xauth.h"
ENUM_BEGIN(xauth_method_type_names, XAUTH_RADIUS, XAUTH_NULL,
"XAUTH_RADIUS",
"XAUTH_NULL");
ENUM_END(xauth_method_type_names, XAUTH_NULL);
ENUM_BEGIN(xauth_method_type_short_names, XAUTH_RADIUS, XAUTH_NULL,
"RAD",
"NULL");
ENUM_END(xauth_method_type_short_names, XAUTH_NULL);
/*
* See header
*/
xauth_type_t xauth_type_from_string(char *name)
{
int i;
static struct {
char *name;
xauth_type_t type;
} types[] = {
{"radius", XAUTH_RADIUS},
{"null", XAUTH_NULL},
};
for (i = 0; i < countof(types); i++)
{
if (strcaseeq(name, types[i].name))
{
return types[i].type;
}
}
return 0;
}
-54
View File
@@ -1,54 +0,0 @@
/*
* Copyright (C) 2010 Martin Willi
* Copyright (C) 2010 revosec AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/**
* @defgroup xauth xauth
* @{ @ingroup libstrongswan
*/
#ifndef XAUTH_H__
#define XAUTH_H__
typedef enum xauth_type_t xauth_type_t;
#include <library.h>
/**
* XAuth types, defines the XAuth method implementation
*/
enum xauth_type_t {
XAUTH_RADIUS = 253,
XAUTH_NULL = 254,
};
/**
* enum names for xauth_type_t.
*/
extern enum_name_t *xauth_method_type_names;
/**
* short string enum names for xauth_type_t.
*/
extern enum_name_t *xauth_method_type_short_names;
/**
* Lookup the XAuth method type from a string.
*
* @param name XAuth method name (such as "md5", "aka")
* @return method type, 0 if unknown
*/
xauth_type_t xauth_type_from_string(char *name);
#endif /** XAUTH_H_ @}*/