This commit is contained in:
vemax78 2014-01-23 21:24:45 +01:00
parent 0790fb511a
commit 64a8bdfa1e
5 changed files with 105 additions and 51 deletions

View File

@ -66,6 +66,7 @@ endif
if BUILD_WTP_WIFI_DRIVERS_NL80211
wtp_SOURCES += $(top_srcdir)/src/binding/ieee80211/wifi_nl80211.c
AM_CFLAGS += ${LIBNL_CFLAGS}
wtp_LDADD += $(LIBNL_LIBS)
endif

View File

@ -130,6 +130,61 @@ AC_HEADER_STDC
AC_CHECK_HEADER([libconfig.h], [], [AC_MSG_ERROR(You need the libconfig headers)])
AC_CHECK_LIB([config], [config_init], [CONFIG_LIBS="-lconfig"], [AC_MSG_ERROR(You need the libconfig library)])
# Check LIBCONFIG config_lookup_int() param type
LIBCONFIG_LOOKUP_INT_ARG=int
AC_MSG_CHECKING([what type of argument config_lookup_int() is expecting])
saved_CFLAGS="${CFLAGS}"
saved_LIBS="${LIBS}"
saved_LDFLAGS="${LDFLAGS}"
CFLAGS="$CFLAGS $LIBCONFIG_CFLAGS -Werror"
LIBS="$LIBS $CONFIG_LIBS"
LDFLAGS="$LDFLAGS $LIBCONFIG_LDFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[
#include <libconfig.h>
],
[
int check;
config_t config;
(void)config_lookup_int(&config, "check", &check);
]
)],
[
AC_MSG_RESULT([int])
LIBCONFIG_LOOKUP_INT_ARG=int
],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[
#include <libconfig.h>
],
[
long check;
config_t config;
(void)config_lookup_int(&config, "check", &check);
]
)],
[
AC_MSG_RESULT([long])
LIBCONFIG_LOOKUP_INT_ARG=long
],
[
AC_MSG_RESULT([unknown])
AC_MSG_ERROR([failed to determine config_lookup_int() argument type])
]
)]
)
CFLAGS="$saved_CFLAGS"
LIBS="$saved_LIBS"
LDFLAGS="$saved_LDFLAGS"
AC_DEFINE_UNQUOTED([LIBCONFIG_LOOKUP_INT_ARG], [$LIBCONFIG_LOOKUP_INT_ARG], [config_lookup_int() argument type])
# Check PTHREAD library
AC_CHECK_HEADER([pthread.h], [], [AC_MSG_ERROR(You need the pthread headers)])
AC_CHECK_LIB([pthread], [pthread_create], [PTHREAD_LIBS="-lpthread"], [AC_MSG_ERROR(You need the pthread library)])

View File

@ -131,16 +131,16 @@ static void ac_print_usage(void) {
/* Parsing configuration */
static int ac_parsing_configuration_1_0(config_t* config) {
int i;
int configInt;
int configBool;
int configIPv4;
int configIPv6;
long int configLongInt;
LIBCONFIG_LOOKUP_INT_ARG configInt;
const char* configString;
config_setting_t* configSetting;
/* Logging configuration */
if (config_lookup_bool(config, "logging.enable", &configInt) == CONFIG_TRUE) {
if (!configInt) {
if (config_lookup_bool(config, "logging.enable", &configBool) == CONFIG_TRUE) {
if (!configBool) {
capwap_logging_verboselevel(CAPWAP_LOGGING_NONE);
capwap_logging_disable_allinterface();
} else {
@ -188,8 +188,8 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
/* Set running mode */
if (config_lookup_bool(config, "application.standalone", &configInt) == CONFIG_TRUE) {
g_ac.standalone = ((configInt != 0) ? 1 : 0);
if (config_lookup_bool(config, "application.standalone", &configBool) == CONFIG_TRUE) {
g_ac.standalone = ((configBool != 0) ? 1 : 0);
}
/* Set name of AC */
@ -226,9 +226,9 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
/* Set max stations of AC */
if (config_lookup_int(config, "application.descriptor.maxstations", &configLongInt) == CONFIG_TRUE) {
if ((configLongInt > 0) && (configLongInt < 65536)) {
g_ac.descriptor.stationlimit = (unsigned short)configLongInt;
if (config_lookup_int(config, "application.descriptor.maxstations", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65536)) {
g_ac.descriptor.stationlimit = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, unknown application.descriptor.maxstations value");
return 0;
@ -236,9 +236,9 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
/* Set max wtp of AC */
if (config_lookup_int(config, "application.descriptor.maxwtp", &configLongInt) == CONFIG_TRUE) {
if ((configLongInt > 0) && (configLongInt < 65536)) {
g_ac.descriptor.maxwtp = (unsigned short)configLongInt;
if (config_lookup_int(config, "application.descriptor.maxwtp", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65536)) {
g_ac.descriptor.maxwtp = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, unknown application.descriptor.maxwtp value");
return 0;
@ -248,35 +248,35 @@ static int ac_parsing_configuration_1_0(config_t* config) {
/* Set security of AC */
if (config_lookup(config, "application.descriptor.security") != NULL) {
g_ac.descriptor.security = 0;
if (config_lookup_bool(config, "application.descriptor.security.presharedkey", &configInt) == CONFIG_TRUE) {
if (configInt != 0) {
if (config_lookup_bool(config, "application.descriptor.security.presharedkey", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
g_ac.descriptor.security |= CAPWAP_ACDESC_SECURITY_PRESHARED_KEY;
}
}
if (config_lookup_bool(config, "application.descriptor.security.x509", &configInt) == CONFIG_TRUE) {
if (configInt != 0) {
if (config_lookup_bool(config, "application.descriptor.security.x509", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
g_ac.descriptor.security |= CAPWAP_ACDESC_SECURITY_X509_CERT;
}
}
}
/* Set rmacfiled of AC */
if (config_lookup_bool(config, "application.descriptor.rmacfiled.supported", &configInt) == CONFIG_TRUE) {
g_ac.descriptor.rmacfield = ((configInt != 0) ? CAPWAP_ACDESC_RMACFIELD_SUPPORTED : CAPWAP_ACDESC_RMACFIELD_NOTSUPPORTED);
if (config_lookup_bool(config, "application.descriptor.rmacfiled.supported", &configBool) == CONFIG_TRUE) {
g_ac.descriptor.rmacfield = ((configBool != 0) ? CAPWAP_ACDESC_RMACFIELD_SUPPORTED : CAPWAP_ACDESC_RMACFIELD_NOTSUPPORTED);
}
/* Set DTLS policy of AC */
if (config_lookup(config, "application.descriptor.dtlspolicy") != NULL) {
g_ac.descriptor.dtlspolicy = 0;
if (config_lookup_bool(config, "application.descriptor.dtlspolicy.cleardatachannel", &configInt) == CONFIG_TRUE) {
if (configInt != 0) {
if (config_lookup_bool(config, "application.descriptor.dtlspolicy.cleardatachannel", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
g_ac.descriptor.dtlspolicy |= CAPWAP_ACDESC_CLEAR_DATA_CHANNEL_ENABLED;
}
}
if (config_lookup_bool(config, "application.descriptor.dtlspolicy.dtlsdatachannel", &configInt) == CONFIG_TRUE) {
if (configInt != 0) {
if (config_lookup_bool(config, "application.descriptor.dtlspolicy.dtlsdatachannel", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
g_ac.descriptor.dtlspolicy |= CAPWAP_ACDESC_DTLS_DATA_CHANNEL_ENABLED;
}
}
@ -290,7 +290,7 @@ static int ac_parsing_configuration_1_0(config_t* config) {
for (i = 0; i < count; i++) {
config_setting_t* configElement = config_setting_get_elem(configSetting, i);
if (configElement != NULL) {
long int configVendor;
LIBCONFIG_LOOKUP_INT_ARG configVendor;
if (config_setting_lookup_int(configElement, "idvendor", &configVendor) == CONFIG_TRUE) {
const char* configType;
if (config_setting_lookup_string(configElement, "type", &configType) == CONFIG_TRUE) {
@ -351,36 +351,36 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
/* Set Timer of AC */
if (config_lookup_int(config, "application.timer.discovery", &configLongInt) == CONFIG_TRUE) {
if ((configLongInt >= AC_DEFAULT_DISCOVERY_INTERVAL) && (configLongInt <= AC_MAX_DISCOVERY_INTERVAL)) {
g_ac.dfa.timers.discovery = (unsigned char)configLongInt;
if (config_lookup_int(config, "application.timer.discovery", &configInt) == CONFIG_TRUE) {
if ((configInt >= AC_DEFAULT_DISCOVERY_INTERVAL) && (configInt <= AC_MAX_DISCOVERY_INTERVAL)) {
g_ac.dfa.timers.discovery = (unsigned char)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.timer.discovery value");
return 0;
}
}
if (config_lookup_int(config, "application.timer.echorequest", &configLongInt) == CONFIG_TRUE) {
if ((configLongInt > 0) && (configLongInt < AC_MAX_ECHO_INTERVAL)) {
g_ac.dfa.timers.echorequest = (unsigned char)configLongInt;
if (config_lookup_int(config, "application.timer.echorequest", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < AC_MAX_ECHO_INTERVAL)) {
g_ac.dfa.timers.echorequest = (unsigned char)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.timer.echorequest value");
return 0;
}
}
if (config_lookup_int(config, "application.timer.decrypterrorreport", &configLongInt) == CONFIG_TRUE) {
if ((configLongInt > 0) && (configLongInt < 65536)) {
g_ac.dfa.decrypterrorreport_interval = (unsigned short)configLongInt;
if (config_lookup_int(config, "application.timer.decrypterrorreport", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65536)) {
g_ac.dfa.decrypterrorreport_interval = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.timer.decrypterrorreport value");
return 0;
}
}
if (config_lookup_int(config, "application.timer.idletimeout", &configLongInt) == CONFIG_TRUE) {
if (configLongInt > 0) {
g_ac.dfa.idletimeout.timeout = (unsigned long)configLongInt;
if (config_lookup_int(config, "application.timer.idletimeout", &configInt) == CONFIG_TRUE) {
if (configInt > 0) {
g_ac.dfa.idletimeout.timeout = (unsigned long)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.timer.idletimeout value");
return 0;
@ -388,13 +388,13 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
/* Set wtpfallback of AC */
if (config_lookup_bool(config, "application.wtpfallback", &configInt) == CONFIG_TRUE) {
g_ac.dfa.wtpfallback.mode = ((configInt != 0) ? CAPWAP_WTP_FALLBACK_ENABLED : CAPWAP_WTP_FALLBACK_DISABLED);
if (config_lookup_bool(config, "application.wtpfallback", &configBool) == CONFIG_TRUE) {
g_ac.dfa.wtpfallback.mode = ((configBool != 0) ? CAPWAP_WTP_FALLBACK_ENABLED : CAPWAP_WTP_FALLBACK_DISABLED);
}
/* Set DTLS of WTP */
if (config_lookup_bool(config, "application.dtls.enable", &configInt) == CONFIG_TRUE) {
if (configInt != 0) {
if (config_lookup_bool(config, "application.dtls.enable", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
struct capwap_dtls_param dtlsparam;
/* Init dtls param */
@ -519,9 +519,9 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
/* Set mtu of AC */
if (config_lookup_int(config, "application.network.mtu", &configLongInt) == CONFIG_TRUE) {
if ((configLongInt > 0) && (configLongInt < 65536)) {
g_ac.mtu = (unsigned short)configLongInt;
if (config_lookup_int(config, "application.network.mtu", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65536)) {
g_ac.mtu = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.network.mtu value");
return 0;
@ -529,9 +529,9 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
/* Set network port of WTP */
if (config_lookup_int(config, "application.network.port", &configLongInt) == CONFIG_TRUE) {
if ((configLongInt > 0) && (configLongInt < 65535)) {
g_ac.net.bind_sock_ctrl_port = (unsigned short)configLongInt;
if (config_lookup_int(config, "application.network.port", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65535)) {
g_ac.net.bind_sock_ctrl_port = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.network.port value");
return 0;
@ -569,8 +569,8 @@ static int ac_parsing_configuration_1_0(config_t* config) {
}
/* Set ip dual stack of WTP */
if (config_lookup_bool(config, "application.network.ipdualstack", &configInt) == CONFIG_TRUE) {
if (!configInt) {
if (config_lookup_bool(config, "application.network.ipdualstack", &configBool) == CONFIG_TRUE) {
if (!configBool) {
g_ac.net.bind_ctrl_flags |= CAPWAP_IPV6ONLY_FLAG;
g_ac.net.bind_data_flags |= CAPWAP_IPV6ONLY_FLAG;
} else {

View File

@ -291,7 +291,6 @@ int ieee80211_create_probe_response(char* buffer, int length, struct ieee80211_p
/* */
int ieee80211_create_authentication_response(char* buffer, int length, struct ieee80211_authentication_params* params) {
char* pos;
int responselength;
struct ieee80211_header_mgmt* header;
@ -314,7 +313,6 @@ int ieee80211_create_authentication_response(char* buffer, int length, struct ie
/* Header frame size */
responselength = (int)((uint8_t*)&header->authetication.ie[0] - (uint8_t*)header);
pos = buffer + responselength;
/* TODO: add custon IE */

View File

@ -1720,7 +1720,7 @@ static int nl80211_device_setfrequency(wifi_device_handle handle, struct wifi_fr
if (!result) {
memcpy(&devicehandle->currentfrequency, freq, sizeof(struct wifi_frequency));
} else {
capwap_logging_error("Unable retrieve physical device capability, error code: %d", result);
capwap_logging_error("Unable set frequency %d, error code: %d", (int)freq->frequency, result);
}
/* */
@ -2133,7 +2133,7 @@ static wifi_global_handle nl80211_global_init(void) {
/* Get nl80211 netlink family */
globalhandle->nl80211_id = genl_ctrl_resolve(globalhandle->nl, "nl80211");
if (globalhandle->nl80211_id < 0) {
capwap_logging_warning("Unable to found mac80211 kernel module: %s", nl_geterror());
capwap_logging_warning("Unable to found mac80211 kernel module");
nl80211_global_deinit((wifi_global_handle)globalhandle);
return NULL;
}