From 269dfe232b82ce25e2e73902df0007ab40be0c35 Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic Date: Thu, 8 Jan 2015 12:48:29 +0100 Subject: [PATCH] Introduce common hw features Introduce wpa_supplicant/hostapd hw features. Signed-off-by: Janusz Dziedzic --- hostapd/Android.mk | 1 + hostapd/Makefile | 1 + src/common/hw_features_common.c | 82 +++++++++++++++++++++++++++++++++ src/common/hw_features_common.h | 23 +++++++++ wpa_supplicant/Android.mk | 1 + wpa_supplicant/Makefile | 1 + 6 files changed, 109 insertions(+) create mode 100644 src/common/hw_features_common.c create mode 100644 src/common/hw_features_common.h diff --git a/hostapd/Android.mk b/hostapd/Android.mk index d6d04c5f5..d5aac6d4b 100644 --- a/hostapd/Android.mk +++ b/hostapd/Android.mk @@ -134,6 +134,7 @@ OBJS += src/utils/ip_addr.c OBJS += src/common/ieee802_11_common.c OBJS += src/common/wpa_common.c +OBJS += src/common/hw_features_common.c OBJS += src/eapol_auth/eapol_auth_sm.c diff --git a/hostapd/Makefile b/hostapd/Makefile index ef1aa6f9c..bf1043596 100644 --- a/hostapd/Makefile +++ b/hostapd/Makefile @@ -115,6 +115,7 @@ OBJS += ../src/utils/ip_addr.o OBJS += ../src/common/ieee802_11_common.o OBJS += ../src/common/wpa_common.o +OBJS += ../src/common/hw_features_common.o OBJS += ../src/eapol_auth/eapol_auth_sm.o diff --git a/src/common/hw_features_common.c b/src/common/hw_features_common.c new file mode 100644 index 000000000..be2b83736 --- /dev/null +++ b/src/common/hw_features_common.c @@ -0,0 +1,82 @@ +/* + * Common hostapd/wpa_supplicant HW features + * Copyright (c) 2002-2013, Jouni Malinen + * Copyright (c) 2015, Qualcomm Atheros, Inc. + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#include "includes.h" + +#include "common.h" +#include "defs.h" +#include "hw_features_common.h" + + +struct hostapd_channel_data * hw_get_channel_chan(struct hostapd_hw_modes *mode, + int chan, int *freq) +{ + int i; + + if (freq) + *freq = 0; + + if (!mode) + return NULL; + + for (i = 0; i < mode->num_channels; i++) { + struct hostapd_channel_data *ch = &mode->channels[i]; + if (ch->chan == chan) { + if (freq) + *freq = ch->freq; + return ch; + } + } + + return NULL; +} + + +struct hostapd_channel_data * hw_get_channel_freq(struct hostapd_hw_modes *mode, + int freq, int *chan) +{ + int i; + + if (chan) + *chan = 0; + + if (!mode) + return NULL; + + for (i = 0; i < mode->num_channels; i++) { + struct hostapd_channel_data *ch = &mode->channels[i]; + if (ch->freq == freq) { + if (chan) + *chan = ch->chan; + return ch; + } + } + + return NULL; +} + + +int hw_get_freq(struct hostapd_hw_modes *mode, int chan) +{ + int freq; + + hw_get_channel_chan(mode, chan, &freq); + + return freq; +} + + +int hw_get_chan(struct hostapd_hw_modes *mode, int freq) +{ + int chan; + + hw_get_channel_freq(mode, freq, &chan); + + return chan; +} diff --git a/src/common/hw_features_common.h b/src/common/hw_features_common.h new file mode 100644 index 000000000..90d5f59f1 --- /dev/null +++ b/src/common/hw_features_common.h @@ -0,0 +1,23 @@ +/* + * Common hostapd/wpa_supplicant HW features + * Copyright (c) 2002-2013, Jouni Malinen + * Copyright (c) 2015, Qualcomm Atheros, Inc. + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef HW_FEATURES_COMMON_H +#define HW_FEATURES_COMMON_H + +#include "drivers/driver.h" + +struct hostapd_channel_data * hw_get_channel_chan(struct hostapd_hw_modes *mode, + int chan, int *freq); +struct hostapd_channel_data * hw_get_channel_freq(struct hostapd_hw_modes *mode, + int freq, int *chan); + +int hw_get_freq(struct hostapd_hw_modes *mode, int chan); +int hw_get_chan(struct hostapd_hw_modes *mode, int freq); + +#endif /* HW_FEATURES_COMMON_H */ diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk index 7d7f1b6c9..7a1131196 100644 --- a/wpa_supplicant/Android.mk +++ b/wpa_supplicant/Android.mk @@ -1401,6 +1401,7 @@ L_CFLAGS += -DCONFIG_SME endif OBJS += src/common/ieee802_11_common.c +OBJS += src/common/hw_features_common.c ifdef NEED_EAP_COMMON OBJS += src/eap_common/eap_common.c diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index 438d61ece..6b506d3f7 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -1421,6 +1421,7 @@ CFLAGS += -DCONFIG_SME endif OBJS += ../src/common/ieee802_11_common.o +OBJS += ../src/common/hw_features_common.o ifdef NEED_EAP_COMMON OBJS += ../src/eap_common/eap_common.o