Fix wifi messages
This commit is contained in:
@ -423,12 +423,18 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
|
||||
if (g_wtp.binding == CAPWAP_WIRELESS_BINDING_IEEE80211) {
|
||||
for (i = 0; i < count; i++) {
|
||||
int radioid;
|
||||
int radiostatus;
|
||||
struct wtp_radio* radio;
|
||||
char radioname[IFNAMSIZ];
|
||||
char drivername[WIFI_DRIVER_NAME_SIZE];
|
||||
unsigned char radiotype = 0;
|
||||
int radiostatus = WTP_RADIO_ENABLED;
|
||||
|
||||
|
||||
if (!IS_VALID_RADIOID(g_wtp.radios->count + 1)) {
|
||||
capwap_logging_error("Exceeded max number of radio device");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* */
|
||||
config_setting_t* configElement = config_setting_get_elem(configSetting, i);
|
||||
if (configElement != NULL) {
|
||||
if (config_setting_lookup_string(configElement, "device", &configString) == CONFIG_TRUE) {
|
||||
@ -437,80 +443,25 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
if (config_setting_lookup_string(configElement, "driver", &configString) == CONFIG_TRUE) {
|
||||
if (*configString && (strlen(configString) < WIFI_DRIVER_NAME_SIZE)) {
|
||||
strcpy(drivername, configString);
|
||||
if (config_setting_lookup_string(configElement, "type", &configString) == CONFIG_TRUE) {
|
||||
int length = strlen(configString);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
switch (configString[i]) {
|
||||
case 'a': {
|
||||
radiotype |= CAPWAP_RADIO_TYPE_80211A;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'b': {
|
||||
radiotype |= CAPWAP_RADIO_TYPE_80211B;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'g': {
|
||||
radiotype |= CAPWAP_RADIO_TYPE_80211G;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'n': {
|
||||
radiotype |= CAPWAP_RADIO_TYPE_80211N;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.descriptor.radio.type value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (radiotype != 0) {
|
||||
int radioid;
|
||||
|
||||
if (config_setting_lookup_string(configElement, "status", &configString) == CONFIG_TRUE) {
|
||||
if (!strcmp(configString, "enabled")) {
|
||||
radiostatus = WTP_RADIO_ENABLED;
|
||||
} else if (!strcmp(configString, "disabled")) {
|
||||
radiostatus = WTP_RADIO_DISABLED;
|
||||
} else if (!strcmp(configString, "hwfailure")) {
|
||||
radiostatus = WTP_RADIO_HWFAILURE;
|
||||
} else if (!strcmp(configString, "swfailure")) {
|
||||
radiostatus = WTP_RADIO_SWFAILURE;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.descriptor.radio.type value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize radio device */
|
||||
radioid = g_wtp.radios->count + 1;
|
||||
if (radiostatus == WTP_RADIO_ENABLED) {
|
||||
result = wifi_create_device(radioid, radioname, drivername);
|
||||
if (result) {
|
||||
radiostatus = WTP_RADIO_HWFAILURE;
|
||||
capwap_logging_warning("Unable to register radio device: %s - %s", radioname, drivername);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create new radio device */
|
||||
radio = (struct wtp_radio*)capwap_array_get_item_pointer(g_wtp.radios, g_wtp.radios->count);
|
||||
strcpy(radio->device, radioname);
|
||||
radio->radioinformation.radioid = radioid;
|
||||
radio->radioinformation.radiotype = radiotype;
|
||||
radio->status = radiostatus;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.descriptor.radio.type value");
|
||||
return 0;
|
||||
}
|
||||
/* Initialize radio device */
|
||||
radioid = g_wtp.radios->count + 1;
|
||||
result = wifi_create_device(radioid, radioname, drivername);
|
||||
if (!result) {
|
||||
radiostatus = WTP_RADIO_ENABLED;
|
||||
capwap_logging_warning("Register radioid %d with radio device: %s - %s", radioid, radioname, drivername);
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, element application.descriptor.radio.type not found");
|
||||
return 0;
|
||||
radiostatus = WTP_RADIO_HWFAILURE;
|
||||
capwap_logging_warning("Unable to register radio device: %s - %s", radioname, drivername);
|
||||
}
|
||||
|
||||
/* Create new radio device */
|
||||
radio = (struct wtp_radio*)capwap_array_get_item_pointer(g_wtp.radios, g_wtp.radios->count);
|
||||
|
||||
/* Radio device information */
|
||||
radio->radioid = radioid;
|
||||
strcpy(radio->device, radioname);
|
||||
radio->status = radiostatus;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, application.descriptor.radio.driver string length exceeded");
|
||||
return 0;
|
||||
|
||||
@ -140,9 +140,11 @@ struct wtp_t {
|
||||
#define WTP_RADIO_SWFAILURE 3
|
||||
|
||||
struct wtp_radio {
|
||||
int radioid;
|
||||
char device[IFNAMSIZ];
|
||||
int status;
|
||||
|
||||
/*
|
||||
struct capwap_80211_antenna_element antenna;
|
||||
struct capwap_80211_directsequencecontrol_element directsequencecontrol;
|
||||
struct capwap_80211_macoperation_element macoperation;
|
||||
@ -150,6 +152,7 @@ struct wtp_radio {
|
||||
struct capwap_80211_ofdmcontrol_element ofdmcontrol;
|
||||
struct capwap_80211_supportedrates_element supportedrates;
|
||||
struct capwap_80211_wtpradioinformation_element radioinformation;
|
||||
*/
|
||||
};
|
||||
|
||||
extern struct wtp_t g_wtp;
|
||||
|
||||
@ -45,9 +45,25 @@ void wtp_create_radioadmstate_element(struct capwap_packet_txmng* txmngpacket) {
|
||||
/* */
|
||||
void wtp_create_80211_wtpradioinformation_element(struct capwap_packet_txmng* txmngpacket) {
|
||||
int i;
|
||||
struct wtp_radio* radio;
|
||||
struct capwap_80211_wtpradioinformation_element element;
|
||||
|
||||
for (i = 0; i < g_wtp.radios->count; i++) {
|
||||
struct wtp_radio* radio = (struct wtp_radio*)capwap_array_get_item_pointer(g_wtp.radios, i);
|
||||
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION, &radio->radioinformation);
|
||||
radio = (struct wtp_radio*)capwap_array_get_item_pointer(g_wtp.radios, i);
|
||||
|
||||
/* Set message element */
|
||||
memset(&element, 0, sizeof(struct capwap_80211_wtpradioinformation_element));
|
||||
element.radioid = (uint8_t)radio->radioid;
|
||||
if (radio->status == WTP_RADIO_ENABLED) {
|
||||
struct wifi_capability* capability = NULL;
|
||||
|
||||
/* Retrieve device capability */
|
||||
capability = wifi_get_capability_device(radio->radioid);
|
||||
if (capability) {
|
||||
element.radiotype = capability->radiotype & CAPWAP_RADIO_TYPE_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION, &element);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user