diff --git a/build/ac/Makefile.am b/build/ac/Makefile.am index 788af71..d9845e2 100755 --- a/build/ac/Makefile.am +++ b/build/ac/Makefile.am @@ -51,6 +51,27 @@ ac_SOURCES = \ $(top_srcdir)/src/ac/ac_session.c \ $(top_srcdir)/src/ac/ac_discovery.c \ $(top_srcdir)/src/ac/ac_80211_json.c \ + $(top_srcdir)/src/ac/ac_80211_json_addwlan.c \ + $(top_srcdir)/src/ac/ac_80211_json_antenna.c \ + $(top_srcdir)/src/ac/ac_80211_json_assignbssid.c \ + $(top_srcdir)/src/ac/ac_80211_json_deletewlan.c \ + $(top_srcdir)/src/ac/ac_80211_json_directsequencecontrol.c \ + $(top_srcdir)/src/ac/ac_80211_json_ie.c \ + $(top_srcdir)/src/ac/ac_80211_json_macoperation.c \ + $(top_srcdir)/src/ac/ac_80211_json_miccountermeasures.c \ + $(top_srcdir)/src/ac/ac_80211_json_multidomaincapability.c \ + $(top_srcdir)/src/ac/ac_80211_json_ofdmcontrol.c \ + $(top_srcdir)/src/ac/ac_80211_json_rateset.c \ + $(top_srcdir)/src/ac/ac_80211_json_rsnaerrorreport.c \ + $(top_srcdir)/src/ac/ac_80211_json_statistics.c \ + $(top_srcdir)/src/ac/ac_80211_json_supportedrates.c \ + $(top_srcdir)/src/ac/ac_80211_json_txpower.c \ + $(top_srcdir)/src/ac/ac_80211_json_txpowerlevel.c \ + $(top_srcdir)/src/ac/ac_80211_json_updatewlan.c \ + $(top_srcdir)/src/ac/ac_80211_json_wtpqos.c \ + $(top_srcdir)/src/ac/ac_80211_json_wtpradioconf.c \ + $(top_srcdir)/src/ac/ac_80211_json_wtpradiofailalarm.c \ + $(top_srcdir)/src/ac/ac_80211_json_wtpradioinformation.c \ $(top_srcdir)/src/ac/ac_dfa_join.c \ $(top_srcdir)/src/ac/ac_dfa_configure.c \ $(top_srcdir)/src/ac/ac_dfa_imagedata.c \ diff --git a/src/ac/ac_80211_json.c b/src/ac/ac_80211_json.c index 5268c68..44060b2 100644 --- a/src/ac/ac_80211_json.c +++ b/src/ac/ac_80211_json.c @@ -1,6 +1,61 @@ #include "ac.h" #include "ac_json.h" +/* */ +static struct ac_json_ieee80211_ops* ac_json_80211_message_elements[] = { + /* CAPWAP_ELEMENT_80211_ADD_WLAN */ &ac_json_80211_addwlan_ops, + /* CAPWAP_ELEMENT_80211_ANTENNA */ &ac_json_80211_antenna_ops, + /* CAPWAP_ELEMENT_80211_ASSIGN_BSSID */ &ac_json_80211_assignbssid_ops, + /* CAPWAP_ELEMENT_80211_DELETE_WLAN */ &ac_json_80211_deletewlan_ops, + /* CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL */ &ac_json_80211_directsequencecontrol_ops, + /* CAPWAP_ELEMENT_80211_IE */ &ac_json_80211_ie_ops, + /* CAPWAP_ELEMENT_80211_MACOPERATION */ &ac_json_80211_macoperation_ops, + /* CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES */ &ac_json_80211_miccountermeasures_ops, + /* CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY */ &ac_json_80211_multidomaincapability_ops, + /* CAPWAP_ELEMENT_80211_OFDMCONTROL */ &ac_json_80211_ofdmcontrol_ops, + /* CAPWAP_ELEMENT_80211_RATESET */ &ac_json_80211_rateset_ops, + /* CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT */ &ac_json_80211_rsnaerrorreport_ops, + /* CAPWAP_ELEMENT_80211_STATION */ NULL, + /* CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE */ NULL, + /* CAPWAP_ELEMENT_80211_STATION_SESSION_KEY_PROFILE */ NULL, + /* CAPWAP_ELEMENT_80211_STATISTICS */ &ac_json_80211_statistics_ops, + /* CAPWAP_ELEMENT_80211_SUPPORTEDRATES */ &ac_json_80211_supportedrates_ops, + /* CAPWAP_ELEMENT_80211_TXPOWER */ &ac_json_80211_txpower_ops, + /* CAPWAP_ELEMENT_80211_TXPOWERLEVEL */ &ac_json_80211_txpowerlevel_ops, + /* CAPWAP_ELEMENT_80211_UPDATE_STATION_QOS */ NULL, + /* CAPWAP_ELEMENT_80211_UPDATE_WLAN */ &ac_json_80211_updatewlan_ops, + /* CAPWAP_ELEMENT_80211_WTP_QOS */ &ac_json_80211_wtpqos_ops, + /* CAPWAP_ELEMENT_80211_WTP_RADIO_CONF */ &ac_json_80211_wtpradioconf_ops, + /* CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM */ &ac_json_80211_wtpradiofailalarm_ops, + /* CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION */ &ac_json_80211_wtpradioinformation_ops +}; + +/* */ +static struct ac_json_ieee80211_ops* ac_json_80211_getops_by_capwaptype(uint16_t type) { + int i; + + for (i = 0; i < CAPWAP_80211_MESSAGE_ELEMENTS_COUNT; i++) { + if (ac_json_80211_message_elements[i] && (ac_json_80211_message_elements[i]->type == type)) { + return ac_json_80211_message_elements[i]; + } + } + + return NULL; +} + +/* */ +static struct ac_json_ieee80211_ops* ac_json_80211_getops_by_jsontype(char* type) { + int i; + + for (i = 0; i < CAPWAP_80211_MESSAGE_ELEMENTS_COUNT; i++) { + if (ac_json_80211_message_elements[i] && !strcmp(ac_json_80211_message_elements[i]->json_type, type)) { + return ac_json_80211_message_elements[i]; + } + } + + return NULL; +} + /* */ void ac_json_ieee80211_init(struct ac_json_ieee80211_wtpradio* wtpradio) { ASSERT(wtpradio != NULL); @@ -113,394 +168,19 @@ void ac_json_ieee80211_free(struct ac_json_ieee80211_wtpradio* wtpradio) { /* */ int ac_json_ieee80211_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, uint16_t type, void* data, int overwrite) { + struct ac_json_ieee80211_ops* ops; + ASSERT(wtpradio != NULL); ASSERT(IS_80211_MESSAGE_ELEMENTS(type)); ASSERT(data != NULL); - switch (type) { - case CAPWAP_ELEMENT_80211_ADD_WLAN: { - struct capwap_80211_addwlan_element* addwlan = (struct capwap_80211_addwlan_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[addwlan->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ADD_WLAN); + /* */ + ops = ac_json_80211_getops_by_capwaptype(type); + if (!ops) { + return 0; + } - if (item->addwlan) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->addwlan); - } - - item->valid = 1; - item->addwlan = (struct capwap_80211_addwlan_element*)ops->clone_message_element(addwlan); - break; - } - - case CAPWAP_ELEMENT_80211_ANTENNA: { - struct capwap_80211_antenna_element* antenna = (struct capwap_80211_antenna_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[antenna->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ANTENNA); - - if (item->antenna) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->antenna); - } - - item->valid = 1; - item->antenna = (struct capwap_80211_antenna_element*)ops->clone_message_element(antenna); - break; - } - - case CAPWAP_ELEMENT_80211_ASSIGN_BSSID: { - struct capwap_80211_assignbssid_element* assignbssid = (struct capwap_80211_assignbssid_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[assignbssid->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ASSIGN_BSSID); - - if (item->assignbssid) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->assignbssid); - } - - item->valid = 1; - item->assignbssid = (struct capwap_80211_assignbssid_element*)ops->clone_message_element(assignbssid); - break; - } - - case CAPWAP_ELEMENT_80211_DELETE_WLAN: { - struct capwap_80211_deletewlan_element* deletewlan = (struct capwap_80211_deletewlan_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[deletewlan->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_DELETE_WLAN); - - if (item->deletewlan) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->deletewlan); - } - - item->valid = 1; - item->deletewlan = (struct capwap_80211_deletewlan_element*)ops->clone_message_element(deletewlan); - break; - } - - case CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL: { - struct capwap_80211_directsequencecontrol_element* directsequencecontrol = (struct capwap_80211_directsequencecontrol_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[directsequencecontrol->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL); - - if (item->directsequencecontrol) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->directsequencecontrol); - } - - item->valid = 1; - item->directsequencecontrol = (struct capwap_80211_directsequencecontrol_element*)ops->clone_message_element(directsequencecontrol); - break; - } - - case CAPWAP_ELEMENT_80211_IE: { - struct capwap_80211_ie_element** ieclone; - struct capwap_80211_ie_element* ie = (struct capwap_80211_ie_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[ie->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_IE); - - if (!item->iearray) { - item->iearray = capwap_array_create(sizeof(struct capwap_80211_ie_element*), 0, 0); - } - - item->valid = 1; - ieclone = (struct capwap_80211_ie_element**)capwap_array_get_item_pointer(item->iearray, item->iearray->count); - *ieclone = (struct capwap_80211_ie_element*)ops->clone_message_element(ie); - - break; - } - - case CAPWAP_ELEMENT_80211_MACOPERATION: { - struct capwap_80211_macoperation_element* macoperation = (struct capwap_80211_macoperation_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[macoperation->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MACOPERATION); - - if (item->macoperation) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->macoperation); - } - - item->valid = 1; - item->macoperation = (struct capwap_80211_macoperation_element*)ops->clone_message_element(macoperation); - break; - } - - case CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES: { - struct capwap_80211_miccountermeasures_element* miccountermeasures = (struct capwap_80211_miccountermeasures_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[miccountermeasures->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES); - - if (item->miccountermeasures) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->miccountermeasures); - } - - item->valid = 1; - item->miccountermeasures = (struct capwap_80211_miccountermeasures_element*)ops->clone_message_element(miccountermeasures); - break; - } - - case CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY: { - struct capwap_80211_multidomaincapability_element* multidomaincapability = (struct capwap_80211_multidomaincapability_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[multidomaincapability->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY); - - if (item->multidomaincapability) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->multidomaincapability); - } - - item->valid = 1; - item->multidomaincapability = (struct capwap_80211_multidomaincapability_element*)ops->clone_message_element(multidomaincapability); - break; - } - - case CAPWAP_ELEMENT_80211_OFDMCONTROL: { - struct capwap_80211_ofdmcontrol_element* ofdmcontrol = (struct capwap_80211_ofdmcontrol_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[ofdmcontrol->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_OFDMCONTROL); - - if (item->ofdmcontrol) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->ofdmcontrol); - } - - item->valid = 1; - item->ofdmcontrol = (struct capwap_80211_ofdmcontrol_element*)ops->clone_message_element(ofdmcontrol); - break; - } - - case CAPWAP_ELEMENT_80211_RATESET: { - struct capwap_80211_rateset_element* rateset = (struct capwap_80211_rateset_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[rateset->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_RATESET); - - if (item->rateset) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->rateset); - } - - item->valid = 1; - item->rateset = (struct capwap_80211_rateset_element*)ops->clone_message_element(rateset); - break; - } - - case CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT: { - struct capwap_80211_rsnaerrorreport_element* rsnaerrorreport = (struct capwap_80211_rsnaerrorreport_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[rsnaerrorreport->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT); - - if (item->rsnaerrorreport) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->rsnaerrorreport); - } - - item->valid = 1; - item->rsnaerrorreport = (struct capwap_80211_rsnaerrorreport_element*)ops->clone_message_element(rsnaerrorreport); - break; - } - - case CAPWAP_ELEMENT_80211_STATISTICS: { - struct capwap_80211_statistics_element* statistics = (struct capwap_80211_statistics_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[statistics->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_STATISTICS); - - if (item->statistics) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->statistics); - } - - item->valid = 1; - item->statistics = (struct capwap_80211_statistics_element*)ops->clone_message_element(statistics); - break; - } - - case CAPWAP_ELEMENT_80211_SUPPORTEDRATES: { - struct capwap_80211_supportedrates_element* supportedrates = (struct capwap_80211_supportedrates_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[supportedrates->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_SUPPORTEDRATES); - - if (item->supportedrates) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->supportedrates); - } - - item->valid = 1; - item->supportedrates = (struct capwap_80211_supportedrates_element*)ops->clone_message_element(supportedrates); - break; - } - - case CAPWAP_ELEMENT_80211_TXPOWER: { - struct capwap_80211_txpower_element* txpower = (struct capwap_80211_txpower_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[txpower->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_TXPOWER); - - if (item->txpower) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->txpower); - } - - item->valid = 1; - item->txpower = (struct capwap_80211_txpower_element*)ops->clone_message_element(txpower); - break; - } - - case CAPWAP_ELEMENT_80211_TXPOWERLEVEL: { - struct capwap_80211_txpowerlevel_element* txpowerlevel = (struct capwap_80211_txpowerlevel_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[txpowerlevel->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_TXPOWERLEVEL); - - if (item->txpowerlevel) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->txpowerlevel); - } - - item->valid = 1; - item->txpowerlevel = (struct capwap_80211_txpowerlevel_element*)ops->clone_message_element(txpowerlevel); - break; - } - - case CAPWAP_ELEMENT_80211_UPDATE_WLAN: { - struct capwap_80211_updatewlan_element* updatewlan = (struct capwap_80211_updatewlan_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[updatewlan->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_UPDATE_WLAN); - - if (item->updatewlan) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->updatewlan); - } - - item->valid = 1; - item->updatewlan = (struct capwap_80211_updatewlan_element*)ops->clone_message_element(updatewlan); - break; - } - - case CAPWAP_ELEMENT_80211_WTP_QOS: { - struct capwap_80211_wtpqos_element* wtpqos = (struct capwap_80211_wtpqos_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[wtpqos->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_QOS); - - if (item->wtpqos) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->wtpqos); - } - - item->valid = 1; - item->wtpqos = (struct capwap_80211_wtpqos_element*)ops->clone_message_element(wtpqos); - break; - } - - case CAPWAP_ELEMENT_80211_WTP_RADIO_CONF: { - struct capwap_80211_wtpradioconf_element* wtpradioconf = (struct capwap_80211_wtpradioconf_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[wtpradioconf->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_RADIO_CONF); - - if (item->wtpradioconf) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->wtpradioconf); - } - - item->valid = 1; - item->wtpradioconf = (struct capwap_80211_wtpradioconf_element*)ops->clone_message_element(wtpradioconf); - break; - } - - case CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM: { - struct capwap_80211_wtpradiofailalarm_element* wtpradiofailalarm = (struct capwap_80211_wtpradiofailalarm_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[wtpradiofailalarm->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM); - - if (item->wtpradiofailalarm) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->wtpradiofailalarm); - } - - item->valid = 1; - item->wtpradiofailalarm = (struct capwap_80211_wtpradiofailalarm_element*)ops->clone_message_element(wtpradiofailalarm); - break; - } - - case CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION: { - struct capwap_80211_wtpradioinformation_element* wtpradioinformation = (struct capwap_80211_wtpradioinformation_element*)data; - struct ac_json_ieee80211_item* item = &wtpradio->items[wtpradioinformation->radioid - 1]; - struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION); - - if (item->wtpradioinformation) { - if (!overwrite) { - return 0; - } - - ops->free_message_element(item->wtpradioinformation); - } - - item->valid = 1; - item->wtpradioinformation = (struct capwap_80211_wtpradioinformation_element*)ops->clone_message_element(wtpradioinformation); - break; - } - - default: { - return 0; - } - } - - return 1; + return ops->add_message_element(wtpradio, data, overwrite); } /* */ @@ -509,259 +189,22 @@ int ac_json_ieee80211_parsingmessageelement(struct ac_json_ieee80211_wtpradio* w ASSERT(wtpradio != NULL); ASSERT(messageelement != NULL); + ASSERT(IS_80211_MESSAGE_ELEMENTS(messageelement->type)); - switch (messageelement->type) { - case CAPWAP_ELEMENT_80211_ADD_WLAN: { - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE); + if (messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE) { + if (!ac_json_ieee80211_addmessageelement(wtpradio, messageelement->type, messageelement->data, 0)) { + return 0; + } + } else if (messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY) { + struct capwap_array* items = (struct capwap_array*)messageelement->data; - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_ADD_WLAN, messageelement->data, 0)) { + for (i = 0; i < items->count; i++) { + if (!ac_json_ieee80211_addmessageelement(wtpradio, messageelement->type, *(void**)capwap_array_get_item_pointer(items, i), 0)) { return 0; } - - break; - } - - case CAPWAP_ELEMENT_80211_ANTENNA: { - struct capwap_array* antennaarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < antennaarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_ANTENNA, *(struct capwap_80211_antenna_element**)capwap_array_get_item_pointer(antennaarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_ASSIGN_BSSID: { - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE); - - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_ASSIGN_BSSID, messageelement->data, 0)) { - return 0; - } - - break; - } - - case CAPWAP_ELEMENT_80211_DELETE_WLAN: { - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE); - - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_DELETE_WLAN, messageelement->data, 0)) { - return 0; - } - - break; - } - - case CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL: { - struct capwap_array* directsequencecontrolarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < directsequencecontrolarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL, *(struct capwap_80211_directsequencecontrol_element**)capwap_array_get_item_pointer(directsequencecontrolarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_IE: { - struct capwap_array* iearray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < iearray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_IE, *(struct capwap_80211_ie_element**)capwap_array_get_item_pointer(iearray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_MACOPERATION: { - struct capwap_array* macoperationarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < macoperationarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_MACOPERATION, *(struct capwap_80211_macoperation_element**)capwap_array_get_item_pointer(macoperationarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES: { - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE); - - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES, messageelement->data, 0)) { - return 0; - } - - break; - } - - case CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY: { - struct capwap_array* multidomaincapabilityarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < multidomaincapabilityarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY, *(struct capwap_80211_multidomaincapability_element**)capwap_array_get_item_pointer(multidomaincapabilityarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_OFDMCONTROL: { - struct capwap_array* ofdmcontrolarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < ofdmcontrolarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_OFDMCONTROL, *(struct capwap_80211_ofdmcontrol_element**)capwap_array_get_item_pointer(ofdmcontrolarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_RATESET: { - struct capwap_array* ratesetarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < ratesetarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_RATESET, *(struct capwap_80211_rateset_element**)capwap_array_get_item_pointer(ratesetarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT: { - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE); - - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT, messageelement->data, 0)) { - return 0; - } - - break; - } - - case CAPWAP_ELEMENT_80211_STATISTICS: { - struct capwap_array* statisticsarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < statisticsarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_STATISTICS, *(struct capwap_80211_statistics_element**)capwap_array_get_item_pointer(statisticsarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_SUPPORTEDRATES: { - struct capwap_array* supportedratesarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < supportedratesarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_SUPPORTEDRATES, *(struct capwap_80211_supportedrates_element**)capwap_array_get_item_pointer(supportedratesarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_TXPOWER: { - struct capwap_array* txpowerarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < txpowerarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_TXPOWER, *(struct capwap_80211_txpower_element**)capwap_array_get_item_pointer(txpowerarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_TXPOWERLEVEL: { - struct capwap_array* txpowerlevelarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < txpowerlevelarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_TXPOWERLEVEL, *(struct capwap_80211_txpowerlevel_element**)capwap_array_get_item_pointer(txpowerlevelarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_UPDATE_WLAN: { - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE); - - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_UPDATE_WLAN, messageelement->data, 0)) { - return 0; - } - - break; - } - - case CAPWAP_ELEMENT_80211_WTP_QOS: { - struct capwap_array* wtpqosarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < wtpqosarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_WTP_QOS, *(struct capwap_80211_wtpqos_element**)capwap_array_get_item_pointer(wtpqosarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_WTP_RADIO_CONF: { - struct capwap_array* wtpradioconfarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < wtpradioconfarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_WTP_RADIO_CONF, *(struct capwap_80211_wtpradioconf_element**)capwap_array_get_item_pointer(wtpradioconfarray, i), 0)) { - return 0; - } - } - - break; - } - - case CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM: { - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE); - - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM, messageelement->data, 0)) { - return 0; - } - - break; - } - - case CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION: { - struct capwap_array* wtpradioinformationarray = (struct capwap_array*)messageelement->data; - ASSERT(messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY); - - for (i = 0; i < wtpradioinformationarray->count; i++) { - if (!ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION, *(struct capwap_80211_wtpradioinformation_element**)capwap_array_get_item_pointer(wtpradioinformationarray, i), 0)) { - return 0; - } - } - - break; } + } else { + return 0; } return 1; @@ -769,6 +212,44 @@ int ac_json_ieee80211_parsingmessageelement(struct ac_json_ieee80211_wtpradio* w /* */ int ac_json_ieee80211_parsingjson(struct ac_json_ieee80211_wtpradio* wtpradio, struct json_object* jsonroot) { + int i; + int length; + + ASSERT(wtpradio != NULL); + ASSERT(jsonroot != NULL); + ASSERT(json_object_get_type(jsonroot) == json_type_array) + + /* */ + length = json_object_array_length(jsonroot); + for (i = 0; i < length; i++) { + struct json_object* jsonitem; + struct json_object* jsonradio = json_object_array_get_idx(jsonroot, i); + + /* Get RadioID */ + jsonitem = json_object_object_get(jsonradio, "RadioID"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + int radioid = json_object_get_int(jsonitem); + if (IS_VALID_RADIOID(radioid)) { + struct lh_entry* entry; + + /* Parsing every entry */ + for(entry = json_object_get_object(jsonradio)->head; entry != NULL; entry = entry->next) { + struct ac_json_ieee80211_ops* ops = ac_json_80211_getops_by_jsontype((char*)entry->k); /* Retrieve JSON handler */ + if (ops) { + void* data = ops->create_message_element((struct json_object*)entry->v, radioid); + if (data) { + /* Message element complete */ + ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION, data, 1); + + /* Free resource */ + capwap_get_message_element_ops(ops->type)->free_message_element(data); + } + } + } + } + } + } + return 1; } @@ -777,7 +258,6 @@ struct json_object* ac_json_ieee80211_getjson(struct ac_json_ieee80211_wtpradio* int i; struct json_object* jsonarray; struct json_object* jsonitems; - struct json_object* jsonitem; ASSERT(wtpradio != NULL); @@ -796,151 +276,87 @@ struct json_object* ac_json_ieee80211_getjson(struct ac_json_ieee80211_wtpradio* json_object_object_add(jsonitems, "RadioID", json_object_new_int(i + 1)); if (item->addwlan) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_ADD_WLAN)->create_json(jsonitems, item->addwlan); } if (item->antenna) { - struct json_object* jsonantenna; - - jsonantenna = json_object_new_array(); - for (i = 0; i < item->antenna->selections->count; i++) { - json_object_array_add(jsonantenna, json_object_new_int((int)*(uint8_t*)capwap_array_get_item_pointer(item->antenna->selections, i))); - } - - jsonitem = json_object_new_object(); - json_object_object_add(jsonitem, "Diversity", json_object_new_boolean((item->antenna->diversity == CAPWAP_ANTENNA_DIVERSITY_ENABLE) ? 1 : 0)); - json_object_object_add(jsonitem, "Combiner", json_object_new_int((int)item->antenna->combiner)); - json_object_object_add(jsonitem, "AntennaSelection", jsonantenna); - json_object_object_add(jsonitems, "IEEE80211Antenna", jsonitem); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_ANTENNA)->create_json(jsonitems, item->antenna); } if (item->assignbssid) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_ASSIGN_BSSID)->create_json(jsonitems, item->assignbssid); } if (item->deletewlan) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_DELETE_WLAN)->create_json(jsonitems, item->deletewlan); } if (item->directsequencecontrol) { - jsonitem = json_object_new_object(); - json_object_object_add(jsonitem, "CurrentChan", json_object_new_int((int)item->directsequencecontrol->currentchannel)); - json_object_object_add(jsonitem, "CurrentCCA", json_object_new_int((int)item->directsequencecontrol->currentcca)); - json_object_object_add(jsonitem, "EnergyDetectThreshold", json_object_new_int((int)item->directsequencecontrol->enerydetectthreshold)); - json_object_object_add(jsonitems, "IEEE80211DirectSequenceControl", jsonitem); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL)->create_json(jsonitems, item->directsequencecontrol); } if (item->iearray) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_IE)->create_json(jsonitems, item->iearray); } if (item->macoperation) { - jsonitem = json_object_new_object(); - json_object_object_add(jsonitem, "RTSThreshold", json_object_new_int((int)item->macoperation->rtsthreshold)); - json_object_object_add(jsonitem, "ShortRetry", json_object_new_int((int)item->macoperation->shortretry)); - json_object_object_add(jsonitem, "LongRetry", json_object_new_int((int)item->macoperation->longretry)); - json_object_object_add(jsonitem, "FragmentationThreshold", json_object_new_int((int)item->macoperation->fragthreshold)); - json_object_object_add(jsonitem, "TxMSDULifetime", json_object_new_int((int)item->macoperation->txmsdulifetime)); - json_object_object_add(jsonitem, "RxMSDULifetime", json_object_new_int((int)item->macoperation->rxmsdulifetime)); - json_object_object_add(jsonitems, "IEEE80211MACOperation", jsonitem); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_MACOPERATION)->create_json(jsonitems, item->macoperation); } if (item->miccountermeasures) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES)->create_json(jsonitems, item->miccountermeasures); } if (item->multidomaincapability) { - jsonitem = json_object_new_object(); - json_object_object_add(jsonitem, "FirstChannel", json_object_new_int((int)item->multidomaincapability->firstchannel)); - json_object_object_add(jsonitem, "NumberChannels", json_object_new_int((int)item->multidomaincapability->numberchannels)); - json_object_object_add(jsonitem, "MaxTxPowerLevel", json_object_new_int((int)item->multidomaincapability->maxtxpowerlevel)); - json_object_object_add(jsonitems, "IEEE80211MultiDomainCapability", jsonitem); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY)->create_json(jsonitems, item->multidomaincapability); } if (item->ofdmcontrol) { - jsonitem = json_object_new_object(); - json_object_object_add(jsonitem, "CurrentChan", json_object_new_int((int)item->ofdmcontrol->currentchannel)); - json_object_object_add(jsonitem, "BandSupport", json_object_new_int((int)item->ofdmcontrol->bandsupport)); - json_object_object_add(jsonitem, "TIThreshold", json_object_new_int((int)item->ofdmcontrol->tithreshold)); - json_object_object_add(jsonitems, "IEEE80211OFDMControl", jsonitem); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_OFDMCONTROL)->create_json(jsonitems, item->ofdmcontrol); } if (item->rateset) { - struct json_object* jsonrates; - - jsonrates = json_object_new_array(); - for (i = 0; i < item->rateset->ratesetcount; i++) { - json_object_array_add(jsonrates, json_object_new_int((int)item->rateset->rateset[i])); - } - - json_object_object_add(jsonitems, "IEEE80211Rateset", jsonrates); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_RATESET)->create_json(jsonitems, item->rateset); } if (item->rsnaerrorreport) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT)->create_json(jsonitems, item->rsnaerrorreport); } if (item->statistics) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_STATISTICS)->create_json(jsonitems, item->statistics); } if (item->supportedrates) { - struct json_object* jsonrates; - - jsonrates = json_object_new_array(); - for (i = 0; i < item->supportedrates->supportedratescount; i++) { - json_object_array_add(jsonrates, json_object_new_int((int)item->supportedrates->supportedrates[i])); - } - - json_object_object_add(jsonitems, "IEEE80211SupportedRates", jsonrates); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_SUPPORTEDRATES)->create_json(jsonitems, item->supportedrates); } if (item->txpower) { - jsonitem = json_object_new_object(); - json_object_object_add(jsonitem, "CurrentTxPower", json_object_new_int((int)item->txpower->currenttxpower)); - json_object_object_add(jsonitems, "IEEE80211TxPower", jsonitem); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_TXPOWER)->create_json(jsonitems, item->txpower); } if (item->txpowerlevel) { - struct json_object* jsontxpower; - - jsontxpower = json_object_new_array(); - for (i = 0; i < item->txpowerlevel->numlevels; i++) { - json_object_array_add(jsontxpower, json_object_new_int((int)item->txpowerlevel->powerlevel[i])); - } - - json_object_object_add(jsonitems, "IEEE80211TXPowerLevel", jsontxpower); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_TXPOWERLEVEL)->create_json(jsonitems, item->txpowerlevel); } if (item->updatewlan) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_UPDATE_WLAN)->create_json(jsonitems, item->updatewlan); } if (item->wtpqos) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_WTP_QOS)->create_json(jsonitems, item->wtpqos); } if (item->wtpradioconf) { - char buffer[18]; - - jsonitem = json_object_new_object(); - json_object_object_add(jsonitem, "ShortPreamble", json_object_new_int((int)item->wtpradioconf->shortpreamble)); - json_object_object_add(jsonitem, "NumBSSIDs", json_object_new_int((int)item->wtpradioconf->maxbssid)); - json_object_object_add(jsonitem, "DTIMPeriod", json_object_new_int((int)item->wtpradioconf->dtimperiod)); - json_object_object_add(jsonitem, "BSSID", json_object_new_string(capwap_printf_macaddress(buffer, (unsigned char*)item->wtpradioconf->bssid, MACADDRESS_EUI48_LENGTH))); - json_object_object_add(jsonitem, "BeaconPeriod", json_object_new_int((int)item->wtpradioconf->beaconperiod)); - json_object_object_add(jsonitem, "CountryString", json_object_new_string((char*)item->wtpradioconf->country)); - json_object_object_add(jsonitems, "IEEE80211WTPRadioConfiguration", jsonitem); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_WTP_RADIO_CONF)->create_json(jsonitems, item->wtpradioconf); } if (item->wtpradiofailalarm) { - /* TODO */ + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM)->create_json(jsonitems, item->wtpradiofailalarm); } if (item->wtpradioinformation) { - jsonitem = json_object_new_object(); - json_object_object_add(jsonitem, "Mode", json_object_new_int((int)item->wtpradioinformation->radiotype)); - json_object_object_add(jsonitems, "IEEE80211WTPRadioInformation", jsonitem); + ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION)->create_json(jsonitems, item->wtpradioinformation); } /* */ diff --git a/src/ac/ac_80211_json_addwlan.c b/src/ac/ac_80211_json_addwlan.c new file mode 100644 index 0000000..22a251f --- /dev/null +++ b/src/ac/ac_80211_json_addwlan.c @@ -0,0 +1,41 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_addwlan_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_addwlan_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_addwlan_element* addwlan = (struct capwap_80211_addwlan_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[addwlan->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ADD_WLAN); + + if (item->addwlan) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->addwlan); + } + + item->valid = 1; + item->addwlan = (struct capwap_80211_addwlan_element*)ops->clone_message_element(addwlan); + + return 1; +} + +/* */ +static void ac_json_80211_addwlan_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_addwlan_ops = { + .type = CAPWAP_ELEMENT_80211_ADD_WLAN, + .json_type = "IEEE80211AddWLAN", + .create_message_element = ac_json_80211_addwlan_createmessageelement, + .add_message_element = ac_json_80211_addwlan_addmessageelement, + .create_json = ac_json_80211_addwlan_createjson +}; diff --git a/src/ac/ac_80211_json_addwlan.h b/src/ac/ac_80211_json_addwlan.h new file mode 100644 index 0000000..89171fd --- /dev/null +++ b/src/ac/ac_80211_json_addwlan.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_ADDWLAN_HEADER__ +#define __AC_JSON_80211_ADDWLAN_HEADER__ + +#include "capwap_element_80211_addwlan.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_addwlan_ops; + +#endif /* __AC_JSON_80211_ADDWLAN_HEADER__ */ diff --git a/src/ac/ac_80211_json_antenna.c b/src/ac/ac_80211_json_antenna.c new file mode 100644 index 0000000..dcc2fe7 --- /dev/null +++ b/src/ac/ac_80211_json_antenna.c @@ -0,0 +1,109 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211Antenna: { + Diversity: [bool], + Combiner: [int], + AntennaSelection: [ + [int] + ] +} +*/ + +/* */ +static void* ac_json_80211_antenna_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + struct json_object* jsonitem; + struct capwap_80211_antenna_element* antenna; + + antenna = (struct capwap_80211_antenna_element*)capwap_alloc(sizeof(struct capwap_80211_antenna_element)); + memset(antenna, 0, sizeof(struct capwap_80211_antenna_element)); + antenna->radioid = radioid; + + /* */ + jsonitem = json_object_object_get(jsonparent, "Diversity"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_boolean)) { + antenna->diversity = (json_object_get_boolean(jsonitem) ? CAPWAP_ANTENNA_DIVERSITY_ENABLE : CAPWAP_ANTENNA_DIVERSITY_DISABLE); + } else { + capwap_free(antenna); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "Combiner"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + antenna->combiner = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(antenna); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "AntennaSelection"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_array)) { + int i; + int length; + + antenna->selections = capwap_array_create(sizeof(uint8_t), 0, 1); + + length = json_object_array_length(jsonitem); + for (i = 0; i < length; i++) { + struct json_object* jsonvalue = json_object_array_get_idx(jsonitem, i); + if (jsonvalue && (json_object_get_type(jsonvalue) == json_type_int)) { + uint8_t* value = (uint8_t*)capwap_array_get_item_pointer(antenna->selections, antenna->selections->count); + *value = (uint8_t)json_object_get_int(jsonvalue); + } + } + } else { + capwap_free(antenna); + return NULL; + } + + return antenna; +} + +/* */ +static int ac_json_80211_antenna_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_antenna_element* antenna = (struct capwap_80211_antenna_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[antenna->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ANTENNA); + + if (item->antenna) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->antenna); + } + + item->valid = 1; + item->antenna = (struct capwap_80211_antenna_element*)ops->clone_message_element(antenna); + + return 1; +} + +/* */ +static void ac_json_80211_antenna_createjson(struct json_object* jsonparent, void* data) { + int i; + struct json_object* jsonantenna; + struct json_object* jsonitem; + struct capwap_80211_antenna_element* antenna = (struct capwap_80211_antenna_element*)data; + + jsonantenna = json_object_new_array(); + for (i = 0; i < antenna->selections->count; i++) { + json_object_array_add(jsonantenna, json_object_new_int((int)*(uint8_t*)capwap_array_get_item_pointer(antenna->selections, i))); + } + + jsonitem = json_object_new_object(); + json_object_object_add(jsonitem, "Diversity", json_object_new_boolean((antenna->diversity == CAPWAP_ANTENNA_DIVERSITY_ENABLE) ? 1 : 0)); + json_object_object_add(jsonitem, "Combiner", json_object_new_int((int)antenna->combiner)); + json_object_object_add(jsonitem, "AntennaSelection", jsonantenna); + json_object_object_add(jsonparent, "IEEE80211Antenna", jsonitem); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_antenna_ops = { + .type = CAPWAP_ELEMENT_80211_ANTENNA, + .json_type = "IEEE80211Antenna", + .create_message_element = ac_json_80211_antenna_createmessageelement, + .add_message_element = ac_json_80211_antenna_addmessageelement, + .create_json = ac_json_80211_antenna_createjson +}; diff --git a/src/ac/ac_80211_json_antenna.h b/src/ac/ac_80211_json_antenna.h new file mode 100644 index 0000000..ce6c072 --- /dev/null +++ b/src/ac/ac_80211_json_antenna.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_ANTENNA_HEADER__ +#define __AC_JSON_80211_ANTENNA_HEADER__ + +#include "capwap_element_80211_antenna.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_antenna_ops; + +#endif /* __AC_JSON_80211_ANTENNA_HEADER__ */ diff --git a/src/ac/ac_80211_json_assignbssid.c b/src/ac/ac_80211_json_assignbssid.c new file mode 100644 index 0000000..c35c2a5 --- /dev/null +++ b/src/ac/ac_80211_json_assignbssid.c @@ -0,0 +1,41 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_assignbssid_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_assignbssid_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_assignbssid_element* assignbssid = (struct capwap_80211_assignbssid_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[assignbssid->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ASSIGN_BSSID); + + if (item->assignbssid) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->assignbssid); + } + + item->valid = 1; + item->assignbssid = (struct capwap_80211_assignbssid_element*)ops->clone_message_element(assignbssid); + + return 1; +} + +/* */ +static void ac_json_80211_assignbssid_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_assignbssid_ops = { + .type = CAPWAP_ELEMENT_80211_ASSIGN_BSSID, + .json_type = "IEEE80211AssignBSSID", + .create_message_element = ac_json_80211_assignbssid_createmessageelement, + .add_message_element = ac_json_80211_assignbssid_addmessageelement, + .create_json = ac_json_80211_assignbssid_createjson +}; diff --git a/src/ac/ac_80211_json_assignbssid.h b/src/ac/ac_80211_json_assignbssid.h new file mode 100644 index 0000000..0e4593f --- /dev/null +++ b/src/ac/ac_80211_json_assignbssid.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_ASSIGNBSSID_HEADER__ +#define __AC_JSON_80211_ASSIGNBSSID_HEADER__ + +#include "capwap_element_80211_assignbssid.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_assignbssid_ops; + +#endif /* __AC_JSON_80211_ASSIGNBSSID_HEADER__ */ diff --git a/src/ac/ac_80211_json_deletewlan.c b/src/ac/ac_80211_json_deletewlan.c new file mode 100644 index 0000000..cbf9513 --- /dev/null +++ b/src/ac/ac_80211_json_deletewlan.c @@ -0,0 +1,41 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_deletewlan_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_deletewlan_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_deletewlan_element* deletewlan = (struct capwap_80211_deletewlan_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[deletewlan->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_DELETE_WLAN); + + if (item->deletewlan) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->deletewlan); + } + + item->valid = 1; + item->deletewlan = (struct capwap_80211_deletewlan_element*)ops->clone_message_element(deletewlan); + + return 1; +} + +/* */ +static void ac_json_80211_deletewlan_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_deletewlan_ops = { + .type = CAPWAP_ELEMENT_80211_DELETE_WLAN, + .json_type = "IEEE80211DeleteWLAN", + .create_message_element = ac_json_80211_deletewlan_createmessageelement, + .add_message_element = ac_json_80211_deletewlan_addmessageelement, + .create_json = ac_json_80211_deletewlan_createjson +}; diff --git a/src/ac/ac_80211_json_deletewlan.h b/src/ac/ac_80211_json_deletewlan.h new file mode 100644 index 0000000..e549573 --- /dev/null +++ b/src/ac/ac_80211_json_deletewlan.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_DELETEWLAN_HEADER__ +#define __AC_JSON_80211_DELETEWLAN_HEADER__ + +#include "capwap_element_80211_deletewlan.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_deletewlan_ops; + +#endif /* __AC_JSON_80211_DELETEWLAN_HEADER__ */ diff --git a/src/ac/ac_80211_json_directsequencecontrol.c b/src/ac/ac_80211_json_directsequencecontrol.c new file mode 100644 index 0000000..9ad8c1e --- /dev/null +++ b/src/ac/ac_80211_json_directsequencecontrol.c @@ -0,0 +1,88 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211DirectSequenceControl: { + CurrentChan: [int], + CurrentCCA: [int], + EnergyDetectThreshold: [int] +} +*/ + +/* */ +static void* ac_json_80211_directsequencecontrol_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + struct json_object* jsonitem; + struct capwap_80211_directsequencecontrol_element* directsequencecontrol; + + directsequencecontrol = (struct capwap_80211_directsequencecontrol_element*)capwap_alloc(sizeof(struct capwap_80211_directsequencecontrol_element)); + memset(directsequencecontrol, 0, sizeof(struct capwap_80211_directsequencecontrol_element)); + directsequencecontrol->radioid = radioid; + + /* */ + jsonitem = json_object_object_get(jsonparent, "CurrentChan"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + directsequencecontrol->currentchannel = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(directsequencecontrol); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "CurrentCCA"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + directsequencecontrol->currentcca = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(directsequencecontrol); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "EnergyDetectThreshold"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + directsequencecontrol->enerydetectthreshold = (uint32_t)json_object_get_int(jsonitem); + } else { + capwap_free(directsequencecontrol); + return NULL; + } + + return directsequencecontrol; +} + +/* */ +static int ac_json_80211_directsequencecontrol_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_directsequencecontrol_element* directsequencecontrol = (struct capwap_80211_directsequencecontrol_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[directsequencecontrol->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL); + + if (item->directsequencecontrol) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->directsequencecontrol); + } + + item->valid = 1; + item->directsequencecontrol = (struct capwap_80211_directsequencecontrol_element*)ops->clone_message_element(directsequencecontrol); + + return 1; +} + +/* */ +static void ac_json_80211_directsequencecontrol_createjson(struct json_object* jsonparent, void* data) { + struct json_object* jsonitem; + struct capwap_80211_directsequencecontrol_element* directsequencecontrol = (struct capwap_80211_directsequencecontrol_element*)data; + + jsonitem = json_object_new_object(); + json_object_object_add(jsonitem, "CurrentChan", json_object_new_int((int)directsequencecontrol->currentchannel)); + json_object_object_add(jsonitem, "CurrentCCA", json_object_new_int((int)directsequencecontrol->currentcca)); + json_object_object_add(jsonitem, "EnergyDetectThreshold", json_object_new_int((int)directsequencecontrol->enerydetectthreshold)); + json_object_object_add(jsonparent, "IEEE80211DirectSequenceControl", jsonitem); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_directsequencecontrol_ops = { + .type = CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL, + .json_type = "IEEE80211DirectSequenceControl", + .create_message_element = ac_json_80211_directsequencecontrol_createmessageelement, + .add_message_element = ac_json_80211_directsequencecontrol_addmessageelement, + .create_json = ac_json_80211_directsequencecontrol_createjson +}; diff --git a/src/ac/ac_80211_json_directsequencecontrol.h b/src/ac/ac_80211_json_directsequencecontrol.h new file mode 100644 index 0000000..baa5544 --- /dev/null +++ b/src/ac/ac_80211_json_directsequencecontrol.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_DIRECTSEQUENCECONTROL_HEADER__ +#define __AC_JSON_80211_DIRECTSEQUENCECONTROL_HEADER__ + +#include "capwap_element_80211_directsequencecontrol.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_directsequencecontrol_ops; + +#endif /* __AC_JSON_80211_DIRECTSEQUENCECONTROL_HEADER__ */ diff --git a/src/ac/ac_80211_json_ie.c b/src/ac/ac_80211_json_ie.c new file mode 100644 index 0000000..b84e58d --- /dev/null +++ b/src/ac/ac_80211_json_ie.c @@ -0,0 +1,39 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_ie_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_ie_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_ie_element** ieclone; + struct capwap_80211_ie_element* ie = (struct capwap_80211_ie_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[ie->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_IE); + + if (!item->iearray) { + item->iearray = capwap_array_create(sizeof(struct capwap_80211_ie_element*), 0, 0); + } + + item->valid = 1; + ieclone = (struct capwap_80211_ie_element**)capwap_array_get_item_pointer(item->iearray, item->iearray->count); + *ieclone = (struct capwap_80211_ie_element*)ops->clone_message_element(ie); + + return 1; +} + +/* */ +static void ac_json_80211_ie_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_ie_ops = { + .type = CAPWAP_ELEMENT_80211_IE, + .json_type = "IEEE80211IE", + .create_message_element = ac_json_80211_ie_createmessageelement, + .add_message_element = ac_json_80211_ie_addmessageelement, + .create_json = ac_json_80211_ie_createjson +}; diff --git a/src/ac/ac_80211_json_ie.h b/src/ac/ac_80211_json_ie.h new file mode 100644 index 0000000..74acd45 --- /dev/null +++ b/src/ac/ac_80211_json_ie.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_IE_HEADER__ +#define __AC_JSON_80211_IE_HEADER__ + +#include "capwap_element_80211_ie.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_ie_ops; + +#endif /* __AC_JSON_80211_IE_HEADER__ */ diff --git a/src/ac/ac_80211_json_macoperation.c b/src/ac/ac_80211_json_macoperation.c new file mode 100644 index 0000000..0cdb7aa --- /dev/null +++ b/src/ac/ac_80211_json_macoperation.c @@ -0,0 +1,118 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211MACOperation: { + RTSThreshold: [int], + ShortRetry: [int], + LongRetry: [int], + FragmentationThreshold: [int], + TxMSDULifetime: [int], + RxMSDULifetime: [int] +} +*/ + +/* */ +static void* ac_json_80211_macoperation_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + struct json_object* jsonitem; + struct capwap_80211_macoperation_element* macoperation; + + macoperation = (struct capwap_80211_macoperation_element*)capwap_alloc(sizeof(struct capwap_80211_macoperation_element)); + memset(macoperation, 0, sizeof(struct capwap_80211_macoperation_element)); + macoperation->radioid = radioid; + + /* */ + jsonitem = json_object_object_get(jsonparent, "RTSThreshold"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + macoperation->rtsthreshold = (uint16_t)json_object_get_int(jsonitem); + } else { + capwap_free(macoperation); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "ShortRetry"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + macoperation->shortretry = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(macoperation); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "LongRetry"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + macoperation->longretry = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(macoperation); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "FragmentationThreshold"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + macoperation->fragthreshold = (uint16_t)json_object_get_int(jsonitem); + } else { + capwap_free(macoperation); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "TxMSDULifetime"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + macoperation->txmsdulifetime = (uint32_t)json_object_get_int(jsonitem); + } else { + capwap_free(macoperation); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "RxMSDULifetime"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + macoperation->rxmsdulifetime = (uint32_t)json_object_get_int(jsonitem); + } else { + capwap_free(macoperation); + return NULL; + } + + return macoperation; +} + +/* */ +static int ac_json_80211_macoperation_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_macoperation_element* macoperation = (struct capwap_80211_macoperation_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[macoperation->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MACOPERATION); + + if (item->macoperation) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->macoperation); + } + + item->valid = 1; + item->macoperation = (struct capwap_80211_macoperation_element*)ops->clone_message_element(macoperation); + + return 1; +} + +/* */ +static void ac_json_80211_macoperation_createjson(struct json_object* jsonparent, void* data) { + struct json_object* jsonitem; + struct capwap_80211_macoperation_element* macoperation = (struct capwap_80211_macoperation_element*)data; + + jsonitem = json_object_new_object(); + json_object_object_add(jsonitem, "RTSThreshold", json_object_new_int((int)macoperation->rtsthreshold)); + json_object_object_add(jsonitem, "ShortRetry", json_object_new_int((int)macoperation->shortretry)); + json_object_object_add(jsonitem, "LongRetry", json_object_new_int((int)macoperation->longretry)); + json_object_object_add(jsonitem, "FragmentationThreshold", json_object_new_int((int)macoperation->fragthreshold)); + json_object_object_add(jsonitem, "TxMSDULifetime", json_object_new_int((int)macoperation->txmsdulifetime)); + json_object_object_add(jsonitem, "RxMSDULifetime", json_object_new_int((int)macoperation->rxmsdulifetime)); + json_object_object_add(jsonparent, "IEEE80211MACOperation", jsonitem); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_macoperation_ops = { + .type = CAPWAP_ELEMENT_80211_MACOPERATION, + .json_type = "IEEE80211MACOperation", + .create_message_element = ac_json_80211_macoperation_createmessageelement, + .add_message_element = ac_json_80211_macoperation_addmessageelement, + .create_json = ac_json_80211_macoperation_createjson +}; diff --git a/src/ac/ac_80211_json_macoperation.h b/src/ac/ac_80211_json_macoperation.h new file mode 100644 index 0000000..b7410e5 --- /dev/null +++ b/src/ac/ac_80211_json_macoperation.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_MACOPERATION_HEADER__ +#define __AC_JSON_80211_MACOPERATION_HEADER__ + +#include "capwap_element_80211_macoperation.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_macoperation_ops; + +#endif /* __AC_JSON_80211_MACOPERATION_HEADER__ */ diff --git a/src/ac/ac_80211_json_miccountermeasures.c b/src/ac/ac_80211_json_miccountermeasures.c new file mode 100644 index 0000000..5c15f83 --- /dev/null +++ b/src/ac/ac_80211_json_miccountermeasures.c @@ -0,0 +1,41 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_miccountermeasures_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_miccountermeasures_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_miccountermeasures_element* miccountermeasures = (struct capwap_80211_miccountermeasures_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[miccountermeasures->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES); + + if (item->miccountermeasures) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->miccountermeasures); + } + + item->valid = 1; + item->miccountermeasures = (struct capwap_80211_miccountermeasures_element*)ops->clone_message_element(miccountermeasures); + + return 1; +} + +/* */ +static void ac_json_80211_miccountermeasures_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_miccountermeasures_ops = { + .type = CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES, + .json_type = "IEEE80211MicCounterMeasures", + .create_message_element = ac_json_80211_miccountermeasures_createmessageelement, + .add_message_element = ac_json_80211_miccountermeasures_addmessageelement, + .create_json = ac_json_80211_miccountermeasures_createjson +}; diff --git a/src/ac/ac_80211_json_miccountermeasures.h b/src/ac/ac_80211_json_miccountermeasures.h new file mode 100644 index 0000000..95d8f62 --- /dev/null +++ b/src/ac/ac_80211_json_miccountermeasures.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_MICCOUNTERMEASURES_HEADER__ +#define __AC_JSON_80211_MICCOUNTERMEASURES_HEADER__ + +#include "capwap_element_80211_miccountermeasures.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_miccountermeasures_ops; + +#endif /* __AC_JSON_80211_MICCOUNTERMEASURES_HEADER__ */ diff --git a/src/ac/ac_80211_json_multidomaincapability.c b/src/ac/ac_80211_json_multidomaincapability.c new file mode 100644 index 0000000..837b169 --- /dev/null +++ b/src/ac/ac_80211_json_multidomaincapability.c @@ -0,0 +1,88 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211MultiDomainCapability: { + FirstChannel: [int], + NumberChannels: [int], + MaxTxPowerLevel: [int] +} +*/ + +/* */ +static void* ac_json_80211_multidomaincapability_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + struct json_object* jsonitem; + struct capwap_80211_multidomaincapability_element* multidomaincapability; + + multidomaincapability = (struct capwap_80211_multidomaincapability_element*)capwap_alloc(sizeof(struct capwap_80211_multidomaincapability_element)); + memset(multidomaincapability, 0, sizeof(struct capwap_80211_multidomaincapability_element)); + multidomaincapability->radioid = radioid; + + /* */ + jsonitem = json_object_object_get(jsonparent, "FirstChannel"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + multidomaincapability->firstchannel = (uint16_t)json_object_get_int(jsonitem); + } else { + capwap_free(multidomaincapability); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "NumberChannels"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + multidomaincapability->numberchannels = (uint16_t)json_object_get_int(jsonitem); + } else { + capwap_free(multidomaincapability); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "MaxTxPowerLevel"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + multidomaincapability->maxtxpowerlevel = (uint16_t)json_object_get_int(jsonitem); + } else { + capwap_free(multidomaincapability); + return NULL; + } + + return multidomaincapability; +} + +/* */ +static int ac_json_80211_multidomaincapability_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_multidomaincapability_element* multidomaincapability = (struct capwap_80211_multidomaincapability_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[multidomaincapability->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY); + + if (item->multidomaincapability) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->multidomaincapability); + } + + item->valid = 1; + item->multidomaincapability = (struct capwap_80211_multidomaincapability_element*)ops->clone_message_element(multidomaincapability); + + return 1; +} + +/* */ +static void ac_json_80211_multidomaincapability_createjson(struct json_object* jsonparent, void* data) { + struct json_object* jsonitem; + struct capwap_80211_multidomaincapability_element* multidomaincapability = (struct capwap_80211_multidomaincapability_element*)data; + + jsonitem = json_object_new_object(); + json_object_object_add(jsonitem, "FirstChannel", json_object_new_int((int)multidomaincapability->firstchannel)); + json_object_object_add(jsonitem, "NumberChannels", json_object_new_int((int)multidomaincapability->numberchannels)); + json_object_object_add(jsonitem, "MaxTxPowerLevel", json_object_new_int((int)multidomaincapability->maxtxpowerlevel)); + json_object_object_add(jsonparent, "IEEE80211MultiDomainCapability", jsonitem); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_multidomaincapability_ops = { + .type = CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY, + .json_type = "IEEE80211MultiDomainCapability", + .create_message_element = ac_json_80211_multidomaincapability_createmessageelement, + .add_message_element = ac_json_80211_multidomaincapability_addmessageelement, + .create_json = ac_json_80211_multidomaincapability_createjson +}; diff --git a/src/ac/ac_80211_json_multidomaincapability.h b/src/ac/ac_80211_json_multidomaincapability.h new file mode 100644 index 0000000..7d90e19 --- /dev/null +++ b/src/ac/ac_80211_json_multidomaincapability.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_MULTIDOMAINCAPABILITY_HEADER__ +#define __AC_JSON_80211_MULTIDOMAINCAPABILITY_HEADER__ + +#include "capwap_element_80211_multidomaincapability.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_multidomaincapability_ops; + +#endif /* __AC_JSON_80211_MULTIDOMAINCAPABILITY_HEADER__ */ diff --git a/src/ac/ac_80211_json_ofdmcontrol.c b/src/ac/ac_80211_json_ofdmcontrol.c new file mode 100644 index 0000000..6d3a7d7 --- /dev/null +++ b/src/ac/ac_80211_json_ofdmcontrol.c @@ -0,0 +1,88 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211OFDMControl: { + CurrentChan: [int], + BandSupport: [int], + TIThreshold: [int] +} +*/ + +/* */ +static void* ac_json_80211_ofdmcontrol_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + struct json_object* jsonitem; + struct capwap_80211_ofdmcontrol_element* ofdmcontrol; + + ofdmcontrol = (struct capwap_80211_ofdmcontrol_element*)capwap_alloc(sizeof(struct capwap_80211_ofdmcontrol_element)); + memset(ofdmcontrol, 0, sizeof(struct capwap_80211_ofdmcontrol_element)); + ofdmcontrol->radioid = radioid; + + /* */ + jsonitem = json_object_object_get(jsonparent, "CurrentChan"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + ofdmcontrol->currentchannel = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(ofdmcontrol); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "BandSupport"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + ofdmcontrol->bandsupport = (uint8_t)json_object_get_int(jsonitem) & CAPWAP_OFDMCONTROL_BAND_MASK; + } else { + capwap_free(ofdmcontrol); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "TIThreshold"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + ofdmcontrol->tithreshold = (uint32_t)json_object_get_int(jsonitem); + } else { + capwap_free(ofdmcontrol); + return NULL; + } + + return ofdmcontrol; +} + +/* */ +static int ac_json_80211_ofdmcontrol_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_ofdmcontrol_element* ofdmcontrol = (struct capwap_80211_ofdmcontrol_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[ofdmcontrol->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_OFDMCONTROL); + + if (item->ofdmcontrol) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->ofdmcontrol); + } + + item->valid = 1; + item->ofdmcontrol = (struct capwap_80211_ofdmcontrol_element*)ops->clone_message_element(ofdmcontrol); + + return 1; +} + +/* */ +static void ac_json_80211_ofdmcontrol_createjson(struct json_object* jsonparent, void* data) { + struct json_object* jsonitem; + struct capwap_80211_ofdmcontrol_element* ofdmcontrol = (struct capwap_80211_ofdmcontrol_element*)data; + + jsonitem = json_object_new_object(); + json_object_object_add(jsonitem, "CurrentChan", json_object_new_int((int)ofdmcontrol->currentchannel)); + json_object_object_add(jsonitem, "BandSupport", json_object_new_int((int)ofdmcontrol->bandsupport)); + json_object_object_add(jsonitem, "TIThreshold", json_object_new_int((int)ofdmcontrol->tithreshold)); + json_object_object_add(jsonparent, "IEEE80211OFDMControl", jsonitem); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_ofdmcontrol_ops = { + .type = CAPWAP_ELEMENT_80211_OFDMCONTROL, + .json_type = "IEEE80211OFDMControl", + .create_message_element = ac_json_80211_ofdmcontrol_createmessageelement, + .add_message_element = ac_json_80211_ofdmcontrol_addmessageelement, + .create_json = ac_json_80211_ofdmcontrol_createjson +}; diff --git a/src/ac/ac_80211_json_ofdmcontrol.h b/src/ac/ac_80211_json_ofdmcontrol.h new file mode 100644 index 0000000..fb3a149 --- /dev/null +++ b/src/ac/ac_80211_json_ofdmcontrol.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_OFDMCONTROL_HEADER__ +#define __AC_JSON_80211_OFDMCONTROL_HEADER__ + +#include "capwap_element_80211_ofdmcontrol.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_ofdmcontrol_ops; + +#endif /* __AC_JSON_80211_OFDMCONTROL_HEADER__ */ diff --git a/src/ac/ac_80211_json_rateset.c b/src/ac/ac_80211_json_rateset.c new file mode 100644 index 0000000..45fcbd6 --- /dev/null +++ b/src/ac/ac_80211_json_rateset.c @@ -0,0 +1,81 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211Rateset: [ + [int] +] +*/ + +/* */ +static void* ac_json_80211_rateset_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + int i; + int length; + struct capwap_80211_rateset_element* rateset; + + if (json_object_get_type(jsonparent) != json_type_array) { + return NULL; + } + + length = json_object_array_length(jsonparent); + if ((length < CAPWAP_RATESET_MINLENGTH) || (length > CAPWAP_RATESET_MAXLENGTH)) { + return NULL; + } + + rateset = (struct capwap_80211_rateset_element*)capwap_alloc(sizeof(struct capwap_80211_rateset_element)); + memset(rateset, 0, sizeof(struct capwap_80211_rateset_element)); + rateset->radioid = radioid; + + for (i = 0; i < length; i++) { + struct json_object* jsonvalue = json_object_array_get_idx(jsonparent, i); + if (jsonvalue && (json_object_get_type(jsonvalue) == json_type_int)) { + rateset->ratesetcount++; + rateset->rateset[i] = (uint8_t)json_object_get_int(jsonvalue); + } + } + + return rateset; +} + +/* */ +static int ac_json_80211_rateset_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_rateset_element* rateset = (struct capwap_80211_rateset_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[rateset->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_RATESET); + + if (item->rateset) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->rateset); + } + + item->valid = 1; + item->rateset = (struct capwap_80211_rateset_element*)ops->clone_message_element(rateset); + + return 1; +} + +/* */ +static void ac_json_80211_rateset_createjson(struct json_object* jsonparent, void* data) { + int i; + struct json_object* jsonrates; + struct capwap_80211_rateset_element* rateset = (struct capwap_80211_rateset_element*)data; + + jsonrates = json_object_new_array(); + for (i = 0; i < rateset->ratesetcount; i++) { + json_object_array_add(jsonrates, json_object_new_int((int)rateset->rateset[i])); + } + + json_object_object_add(jsonparent, "IEEE80211Rateset", jsonrates); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_rateset_ops = { + .type = CAPWAP_ELEMENT_80211_RATESET, + .json_type = "IEEE80211Rateset", + .create_message_element = ac_json_80211_rateset_createmessageelement, + .add_message_element = ac_json_80211_rateset_addmessageelement, + .create_json = ac_json_80211_rateset_createjson +}; diff --git a/src/ac/ac_80211_json_rateset.h b/src/ac/ac_80211_json_rateset.h new file mode 100644 index 0000000..5d3b22e --- /dev/null +++ b/src/ac/ac_80211_json_rateset.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_RATESET_HEADER__ +#define __AC_JSON_80211_RATESET_HEADER__ + +#include "capwap_element_80211_rateset.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_rateset_ops; + +#endif /* __AC_JSON_80211_RATESET_HEADER__ */ diff --git a/src/ac/ac_80211_json_rsnaerrorreport.c b/src/ac/ac_80211_json_rsnaerrorreport.c new file mode 100644 index 0000000..4e98c6b --- /dev/null +++ b/src/ac/ac_80211_json_rsnaerrorreport.c @@ -0,0 +1,41 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_rsnaerrorreport_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_rsnaerrorreport_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_rsnaerrorreport_element* rsnaerrorreport = (struct capwap_80211_rsnaerrorreport_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[rsnaerrorreport->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT); + + if (item->rsnaerrorreport) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->rsnaerrorreport); + } + + item->valid = 1; + item->rsnaerrorreport = (struct capwap_80211_rsnaerrorreport_element*)ops->clone_message_element(rsnaerrorreport); + + return 1; +} + +/* */ +static void ac_json_80211_rsnaerrorreport_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_rsnaerrorreport_ops = { + .type = CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT, + .json_type = "IEEE80211RSNAErrorReport", + .create_message_element = ac_json_80211_rsnaerrorreport_createmessageelement, + .add_message_element = ac_json_80211_rsnaerrorreport_addmessageelement, + .create_json = ac_json_80211_rsnaerrorreport_createjson +}; diff --git a/src/ac/ac_80211_json_rsnaerrorreport.h b/src/ac/ac_80211_json_rsnaerrorreport.h new file mode 100644 index 0000000..15e1d52 --- /dev/null +++ b/src/ac/ac_80211_json_rsnaerrorreport.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_RSNAERRORREPORT_HEADER__ +#define __AC_JSON_80211_RSNAERRORREPORT_HEADER__ + +#include "capwap_element_80211_rsnaerrorreport.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_rsnaerrorreport_ops; + +#endif /* __AC_JSON_80211_RSNAERRORREPORT_HEADER__ */ diff --git a/src/ac/ac_80211_json_statistics.c b/src/ac/ac_80211_json_statistics.c new file mode 100644 index 0000000..d5b2baa --- /dev/null +++ b/src/ac/ac_80211_json_statistics.c @@ -0,0 +1,41 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_statistics_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_statistics_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_statistics_element* statistics = (struct capwap_80211_statistics_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[statistics->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_STATISTICS); + + if (item->statistics) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->statistics); + } + + item->valid = 1; + item->statistics = (struct capwap_80211_statistics_element*)ops->clone_message_element(statistics); + + return 1; +} + +/* */ +static void ac_json_80211_statistics_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_statistics_ops = { + .type = CAPWAP_ELEMENT_80211_STATISTICS, + .json_type = "IEEE80211Statistics", + .create_message_element = ac_json_80211_statistics_createmessageelement, + .add_message_element = ac_json_80211_statistics_addmessageelement, + .create_json = ac_json_80211_statistics_createjson +}; diff --git a/src/ac/ac_80211_json_statistics.h b/src/ac/ac_80211_json_statistics.h new file mode 100644 index 0000000..120dcdb --- /dev/null +++ b/src/ac/ac_80211_json_statistics.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_STATISTICS_HEADER__ +#define __AC_JSON_80211_STATISTICS_HEADER__ + +#include "capwap_element_80211_statistics.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_statistics_ops; + +#endif /* __AC_JSON_80211_STATISTICS_HEADER__ */ diff --git a/src/ac/ac_80211_json_supportedrates.c b/src/ac/ac_80211_json_supportedrates.c new file mode 100644 index 0000000..7e494d2 --- /dev/null +++ b/src/ac/ac_80211_json_supportedrates.c @@ -0,0 +1,81 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211SupportedRates: [ + [int] +] +*/ + +/* */ +static void* ac_json_80211_supportedrates_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + int i; + int length; + struct capwap_80211_supportedrates_element* supportedrates; + + if (json_object_get_type(jsonparent) != json_type_array) { + return NULL; + } + + length = json_object_array_length(jsonparent); + if ((length < CAPWAP_SUPPORTEDRATES_MINLENGTH) || (length > CAPWAP_SUPPORTEDRATES_MAXLENGTH)) { + return NULL; + } + + supportedrates = (struct capwap_80211_supportedrates_element*)capwap_alloc(sizeof(struct capwap_80211_supportedrates_element)); + memset(supportedrates, 0, sizeof(struct capwap_80211_supportedrates_element)); + supportedrates->radioid = radioid; + + for (i = 0; i < length; i++) { + struct json_object* jsonvalue = json_object_array_get_idx(jsonparent, i); + if (jsonvalue && (json_object_get_type(jsonvalue) == json_type_int)) { + supportedrates->supportedratescount++; + supportedrates->supportedrates[i] = (uint8_t)json_object_get_int(jsonvalue); + } + } + + return supportedrates; +} + +/* */ +static int ac_json_80211_supportedrates_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_supportedrates_element* supportedrates = (struct capwap_80211_supportedrates_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[supportedrates->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_SUPPORTEDRATES); + + if (item->supportedrates) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->supportedrates); + } + + item->valid = 1; + item->supportedrates = (struct capwap_80211_supportedrates_element*)ops->clone_message_element(supportedrates); + + return 1; +} + +/* */ +static void ac_json_80211_supportedrates_createjson(struct json_object* jsonparent, void* data) { + int i; + struct json_object* jsonrates; + struct capwap_80211_supportedrates_element* supportedrates = (struct capwap_80211_supportedrates_element*)data; + + jsonrates = json_object_new_array(); + for (i = 0; i < supportedrates->supportedratescount; i++) { + json_object_array_add(jsonrates, json_object_new_int((int)supportedrates->supportedrates[i])); + } + + json_object_object_add(jsonparent, "IEEE80211SupportedRates", jsonrates); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_supportedrates_ops = { + .type = CAPWAP_ELEMENT_80211_SUPPORTEDRATES, + .json_type = "IEEE80211SupportedRates", + .create_message_element = ac_json_80211_supportedrates_createmessageelement, + .add_message_element = ac_json_80211_supportedrates_addmessageelement, + .create_json = ac_json_80211_supportedrates_createjson +}; diff --git a/src/ac/ac_80211_json_supportedrates.h b/src/ac/ac_80211_json_supportedrates.h new file mode 100644 index 0000000..f4d0470 --- /dev/null +++ b/src/ac/ac_80211_json_supportedrates.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_SUPPORTEDRATES_HEADER__ +#define __AC_JSON_80211_SUPPORTEDRATES_HEADER__ + +#include "capwap_element_80211_supportedrates.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_supportedrates_ops; + +#endif /* __AC_JSON_80211_SUPPORTEDRATES_HEADER__ */ diff --git a/src/ac/ac_80211_json_txpower.c b/src/ac/ac_80211_json_txpower.c new file mode 100644 index 0000000..0307d9f --- /dev/null +++ b/src/ac/ac_80211_json_txpower.c @@ -0,0 +1,68 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211TxPower: { + CurrentTxPower: [int] +} +*/ + +/* */ +static void* ac_json_80211_txpower_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + struct json_object* jsonitem; + struct capwap_80211_txpower_element* txpower; + + txpower = (struct capwap_80211_txpower_element*)capwap_alloc(sizeof(struct capwap_80211_txpower_element)); + memset(txpower, 0, sizeof(struct capwap_80211_txpower_element)); + txpower->radioid = radioid; + + /* */ + jsonitem = json_object_object_get(jsonparent, "CurrentTxPower"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + txpower->currenttxpower = (uint16_t)json_object_get_int(jsonitem); + } else { + capwap_free(txpower); + return NULL; + } + + return txpower; +} + +/* */ +static int ac_json_80211_txpower_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_txpower_element* txpower = (struct capwap_80211_txpower_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[txpower->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_TXPOWER); + + if (item->txpower) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->txpower); + } + + item->valid = 1; + item->txpower = (struct capwap_80211_txpower_element*)ops->clone_message_element(txpower); + + return 1; +} + +/* */ +static void ac_json_80211_txpower_createjson(struct json_object* jsonparent, void* data) { + struct json_object* jsonitem; + struct capwap_80211_txpower_element* txpower = (struct capwap_80211_txpower_element*)data; + + jsonitem = json_object_new_object(); + json_object_object_add(jsonitem, "CurrentTxPower", json_object_new_int((int)txpower->currenttxpower)); + json_object_object_add(jsonparent, "IEEE80211TxPower", jsonitem); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_txpower_ops = { + .type = CAPWAP_ELEMENT_80211_TXPOWER, + .json_type = "IEEE80211TxPower", + .create_message_element = ac_json_80211_txpower_createmessageelement, + .add_message_element = ac_json_80211_txpower_addmessageelement, + .create_json = ac_json_80211_txpower_createjson +}; diff --git a/src/ac/ac_80211_json_txpower.h b/src/ac/ac_80211_json_txpower.h new file mode 100644 index 0000000..8a5a49a --- /dev/null +++ b/src/ac/ac_80211_json_txpower.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_TXPOWER_HEADER__ +#define __AC_JSON_80211_TXPOWER_HEADER__ + +#include "capwap_element_80211_txpower.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_txpower_ops; + +#endif /* __AC_JSON_80211_TXPOWER_HEADER__ */ diff --git a/src/ac/ac_80211_json_txpowerlevel.c b/src/ac/ac_80211_json_txpowerlevel.c new file mode 100644 index 0000000..5af0dd7 --- /dev/null +++ b/src/ac/ac_80211_json_txpowerlevel.c @@ -0,0 +1,81 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211TXPowerLevel: [ + [int] +] +*/ + +/* */ +static void* ac_json_80211_txpowerlevel_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + int i; + int length; + struct capwap_80211_txpowerlevel_element* txpowerlevel; + + if (json_object_get_type(jsonparent) != json_type_array) { + return NULL; + } + + length = json_object_array_length(jsonparent); + if (length > CAPWAP_TXPOWERLEVEL_MAXLENGTH) { + return NULL; + } + + txpowerlevel = (struct capwap_80211_txpowerlevel_element*)capwap_alloc(sizeof(struct capwap_80211_txpowerlevel_element)); + memset(txpowerlevel, 0, sizeof(struct capwap_80211_txpowerlevel_element)); + txpowerlevel->radioid = radioid; + + for (i = 0; i < length; i++) { + struct json_object* jsonvalue = json_object_array_get_idx(jsonparent, i); + if (jsonvalue && (json_object_get_type(jsonvalue) == json_type_int)) { + txpowerlevel->numlevels++; + txpowerlevel->powerlevel[i] = (uint16_t)json_object_get_int(jsonvalue); + } + } + + return txpowerlevel; +} + +/* */ +static int ac_json_80211_txpowerlevel_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_txpowerlevel_element* txpowerlevel = (struct capwap_80211_txpowerlevel_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[txpowerlevel->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_TXPOWERLEVEL); + + if (item->txpowerlevel) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->txpowerlevel); + } + + item->valid = 1; + item->txpowerlevel = (struct capwap_80211_txpowerlevel_element*)ops->clone_message_element(txpowerlevel); + + return 1; +} + +/* */ +static void ac_json_80211_txpowerlevel_createjson(struct json_object* jsonparent, void* data) { + int i; + struct json_object* jsontxpower; + struct capwap_80211_txpowerlevel_element* txpowerlevel = (struct capwap_80211_txpowerlevel_element*)data; + + jsontxpower = json_object_new_array(); + for (i = 0; i < txpowerlevel->numlevels; i++) { + json_object_array_add(jsontxpower, json_object_new_int((int)txpowerlevel->powerlevel[i])); + } + + json_object_object_add(jsonparent, "IEEE80211TXPowerLevel", jsontxpower); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_txpowerlevel_ops = { + .type = CAPWAP_ELEMENT_80211_TXPOWERLEVEL, + .json_type = "IEEE80211TXPowerLevel", + .create_message_element = ac_json_80211_txpowerlevel_createmessageelement, + .add_message_element = ac_json_80211_txpowerlevel_addmessageelement, + .create_json = ac_json_80211_txpowerlevel_createjson +}; diff --git a/src/ac/ac_80211_json_txpowerlevel.h b/src/ac/ac_80211_json_txpowerlevel.h new file mode 100644 index 0000000..d3c2f30 --- /dev/null +++ b/src/ac/ac_80211_json_txpowerlevel.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_TXPOWERLEVEL_HEADER__ +#define __AC_JSON_80211_TXPOWERLEVEL_HEADER__ + +#include "capwap_element_80211_txpowerlevel.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_txpowerlevel_ops; + +#endif /* __AC_JSON_80211_TXPOWERLEVEL_HEADER__ */ diff --git a/src/ac/ac_80211_json_updatewlan.c b/src/ac/ac_80211_json_updatewlan.c new file mode 100644 index 0000000..b66bdb8 --- /dev/null +++ b/src/ac/ac_80211_json_updatewlan.c @@ -0,0 +1,41 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_updatewlan_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_updatewlan_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_updatewlan_element* updatewlan = (struct capwap_80211_updatewlan_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[updatewlan->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_UPDATE_WLAN); + + if (item->updatewlan) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->updatewlan); + } + + item->valid = 1; + item->updatewlan = (struct capwap_80211_updatewlan_element*)ops->clone_message_element(updatewlan); + + return 1; +} + +/* */ +static void ac_json_80211_updatewlan_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_updatewlan_ops = { + .type = CAPWAP_ELEMENT_80211_UPDATE_WLAN, + .json_type = "IEEE80211UpdateWLAN", + .create_message_element = ac_json_80211_updatewlan_createmessageelement, + .add_message_element = ac_json_80211_updatewlan_addmessageelement, + .create_json = ac_json_80211_updatewlan_createjson +}; diff --git a/src/ac/ac_80211_json_updatewlan.h b/src/ac/ac_80211_json_updatewlan.h new file mode 100644 index 0000000..9ed23a0 --- /dev/null +++ b/src/ac/ac_80211_json_updatewlan.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_UPDATEWLAN_HEADER__ +#define __AC_JSON_80211_UPDATEWLAN_HEADER__ + +#include "capwap_element_80211_updatewlan.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_updatewlan_ops; + +#endif /* __AC_JSON_80211_UPDATEWLAN_HEADER__ */ diff --git a/src/ac/ac_80211_json_wtpqos.c b/src/ac/ac_80211_json_wtpqos.c new file mode 100644 index 0000000..3350f41 --- /dev/null +++ b/src/ac/ac_80211_json_wtpqos.c @@ -0,0 +1,79 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211WTPQoS: { + TaggingPolicy: [int], + Voice: { + QueueDepth: [int], + CWMin: [int], + CWMax: [int], + AIFS: [int], + Priority8021p: [int], + DSCP: [int] + } + Video: { + QueueDepth: [int], + CWMin: [int], + CWMax: [int], + AIFS: [int], + Priority8021p: [int], + DSCP: [int] + } + BestEffort: { + QueueDepth: [int], + CWMin: [int], + CWMax: [int], + AIFS: [int], + Priority8021p: [int], + DSCP: [int] + } + Background: { + QueueDepth: [int], + CWMin: [int], + CWMax: [int], + AIFS: [int], + Priority8021p: [int], + DSCP: [int] + } +} +*/ + +/* */ +static void* ac_json_80211_wtpqos_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_wtpqos_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_wtpqos_element* wtpqos = (struct capwap_80211_wtpqos_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[wtpqos->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_QOS); + + if (item->wtpqos) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->wtpqos); + } + + item->valid = 1; + item->wtpqos = (struct capwap_80211_wtpqos_element*)ops->clone_message_element(wtpqos); + + return 1; +} + +/* */ +static void ac_json_80211_wtpqos_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_wtpqos_ops = { + .type = CAPWAP_ELEMENT_80211_WTP_QOS, + .json_type = "IEEE80211WTPQoS", + .create_message_element = ac_json_80211_wtpqos_createmessageelement, + .add_message_element = ac_json_80211_wtpqos_addmessageelement, + .create_json = ac_json_80211_wtpqos_createjson +}; diff --git a/src/ac/ac_80211_json_wtpqos.h b/src/ac/ac_80211_json_wtpqos.h new file mode 100644 index 0000000..2191299 --- /dev/null +++ b/src/ac/ac_80211_json_wtpqos.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_WTPQOS_HEADER__ +#define __AC_JSON_80211_WTPQOS_HEADER__ + +#include "capwap_element_80211_wtpqos.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_wtpqos_ops; + +#endif /* __AC_JSON_80211_WTPQOS_HEADER__ */ diff --git a/src/ac/ac_80211_json_wtpradioconf.c b/src/ac/ac_80211_json_wtpradioconf.c new file mode 100644 index 0000000..0da66d7 --- /dev/null +++ b/src/ac/ac_80211_json_wtpradioconf.c @@ -0,0 +1,128 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211WTPRadioConfiguration: { + ShortPreamble: [int], + NumBSSIDs: [int], + DTIMPeriod: [int], + BSSID: [string], + BeaconPeriod: [int], + CountryString: [string] +} +*/ + +/* */ +static void* ac_json_80211_wtpradioconf_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + struct json_object* jsonitem; + struct capwap_80211_wtpradioconf_element* wtpradioconf; + + wtpradioconf = (struct capwap_80211_wtpradioconf_element*)capwap_alloc(sizeof(struct capwap_80211_wtpradioconf_element)); + memset(wtpradioconf, 0, sizeof(struct capwap_80211_wtpradioconf_element)); + wtpradioconf->radioid = radioid; + + /* */ + jsonitem = json_object_object_get(jsonparent, "ShortPreamble"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + wtpradioconf->shortpreamble = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(wtpradioconf); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "NumBSSIDs"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + wtpradioconf->maxbssid = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(wtpradioconf); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "DTIMPeriod"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + wtpradioconf->dtimperiod = (uint8_t)json_object_get_int(jsonitem); + } else { + capwap_free(wtpradioconf); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "BSSID"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_string)) { + if (!capwap_scanf_macaddress((unsigned char*)wtpradioconf->bssid, json_object_get_string(jsonitem), MACADDRESS_EUI48_LENGTH)) { + capwap_free(wtpradioconf); + return NULL; + } + } else { + capwap_free(wtpradioconf); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "BeaconPeriod"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + wtpradioconf->beaconperiod = (uint16_t)json_object_get_int(jsonitem); + } else { + capwap_free(wtpradioconf); + return NULL; + } + + jsonitem = json_object_object_get(jsonparent, "CountryString"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_string)) { + const char* country = json_object_get_string(jsonitem); + if (strlen(country) == (CAPWAP_WTP_RADIO_CONF_COUNTRY_LENGTH - 1)) { + strcpy((char*)wtpradioconf->country, country); + } else { + capwap_free(wtpradioconf); + return NULL; + } + } else { + capwap_free(wtpradioconf); + return NULL; + } + + return wtpradioconf; +} + +/* */ +static int ac_json_80211_wtpradioconf_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_wtpradioconf_element* wtpradioconf = (struct capwap_80211_wtpradioconf_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[wtpradioconf->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_RADIO_CONF); + + if (item->wtpradioconf) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->wtpradioconf); + } + + item->valid = 1; + item->wtpradioconf = (struct capwap_80211_wtpradioconf_element*)ops->clone_message_element(wtpradioconf); + + return 1; +} + +/* */ +static void ac_json_80211_wtpradioconf_createjson(struct json_object* jsonparent, void* data) { + char buffer[18]; + struct json_object* jsonitem; + struct capwap_80211_wtpradioconf_element* wtpradioconf = (struct capwap_80211_wtpradioconf_element*)data; + + jsonitem = json_object_new_object(); + json_object_object_add(jsonitem, "ShortPreamble", json_object_new_int((int)wtpradioconf->shortpreamble)); + json_object_object_add(jsonitem, "NumBSSIDs", json_object_new_int((int)wtpradioconf->maxbssid)); + json_object_object_add(jsonitem, "DTIMPeriod", json_object_new_int((int)wtpradioconf->dtimperiod)); + json_object_object_add(jsonitem, "BSSID", json_object_new_string(capwap_printf_macaddress(buffer, (unsigned char*)wtpradioconf->bssid, MACADDRESS_EUI48_LENGTH))); + json_object_object_add(jsonitem, "BeaconPeriod", json_object_new_int((int)wtpradioconf->beaconperiod)); + json_object_object_add(jsonitem, "CountryString", json_object_new_string((char*)wtpradioconf->country)); + json_object_object_add(jsonparent, "IEEE80211WTPRadioConfiguration", jsonitem); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_wtpradioconf_ops = { + .type = CAPWAP_ELEMENT_80211_WTP_RADIO_CONF, + .json_type = "IEEE80211WTPRadioConfiguration", + .create_message_element = ac_json_80211_wtpradioconf_createmessageelement, + .add_message_element = ac_json_80211_wtpradioconf_addmessageelement, + .create_json = ac_json_80211_wtpradioconf_createjson +}; diff --git a/src/ac/ac_80211_json_wtpradioconf.h b/src/ac/ac_80211_json_wtpradioconf.h new file mode 100644 index 0000000..cd96f68 --- /dev/null +++ b/src/ac/ac_80211_json_wtpradioconf.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_WTPRADIOCONF_HEADER__ +#define __AC_JSON_80211_WTPRADIOCONF_HEADER__ + +#include "capwap_element_80211_wtpradioconf.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_wtpradioconf_ops; + +#endif /* __AC_JSON_80211_WTPRADIOCONF_HEADER__ */ diff --git a/src/ac/ac_80211_json_wtpradiofailalarm.c b/src/ac/ac_80211_json_wtpradiofailalarm.c new file mode 100644 index 0000000..1c41980 --- /dev/null +++ b/src/ac/ac_80211_json_wtpradiofailalarm.c @@ -0,0 +1,41 @@ +#include "ac.h" +#include "ac_json.h" + +/* */ +static void* ac_json_80211_wtpradiofailalarm_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + return NULL; /* TODO */ +} + +/* */ +static int ac_json_80211_wtpradiofailalarm_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_wtpradiofailalarm_element* wtpradiofailalarm = (struct capwap_80211_wtpradiofailalarm_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[wtpradiofailalarm->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM); + + if (item->wtpradiofailalarm) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->wtpradiofailalarm); + } + + item->valid = 1; + item->wtpradiofailalarm = (struct capwap_80211_wtpradiofailalarm_element*)ops->clone_message_element(wtpradiofailalarm); + + return 1; +} + +/* */ +static void ac_json_80211_wtpradiofailalarm_createjson(struct json_object* jsonparent, void* data) { + /* TODO */ +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_wtpradiofailalarm_ops = { + .type = CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM, + .json_type = "IEEE80211WTPRadioFailAlarm", + .create_message_element = ac_json_80211_wtpradiofailalarm_createmessageelement, + .add_message_element = ac_json_80211_wtpradiofailalarm_addmessageelement, + .create_json = ac_json_80211_wtpradiofailalarm_createjson +}; diff --git a/src/ac/ac_80211_json_wtpradiofailalarm.h b/src/ac/ac_80211_json_wtpradiofailalarm.h new file mode 100644 index 0000000..e25342f --- /dev/null +++ b/src/ac/ac_80211_json_wtpradiofailalarm.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_WTPRADIOFAILALARM_HEADER__ +#define __AC_JSON_80211_WTPRADIOFAILALARM_HEADER__ + +#include "capwap_element_80211_wtpradiofailalarm.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_wtpradiofailalarm_ops; + +#endif /* __AC_JSON_80211_WTPRADIOFAILALARM_HEADER__ */ diff --git a/src/ac/ac_80211_json_wtpradioinformation.c b/src/ac/ac_80211_json_wtpradioinformation.c new file mode 100644 index 0000000..787f685 --- /dev/null +++ b/src/ac/ac_80211_json_wtpradioinformation.c @@ -0,0 +1,68 @@ +#include "ac.h" +#include "ac_json.h" + +/* +IEEE80211WTPRadioInformation: { + Mode: [int] +} +*/ + +/* */ +static void* ac_json_80211_wtpradioinformation_createmessageelement(struct json_object* jsonparent, uint16_t radioid) { + struct json_object* jsonitem; + struct capwap_80211_wtpradioinformation_element* wtpradioinformation; + + wtpradioinformation = (struct capwap_80211_wtpradioinformation_element*)capwap_alloc(sizeof(struct capwap_80211_wtpradioinformation_element)); + memset(wtpradioinformation, 0, sizeof(struct capwap_80211_wtpradioinformation_element)); + wtpradioinformation->radioid = radioid; + + /* */ + jsonitem = json_object_object_get(jsonparent, "Mode"); + if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) { + wtpradioinformation->radiotype = (uint32_t)json_object_get_int(jsonitem) & CAPWAP_RADIO_TYPE_MASK; + } else { + capwap_free(wtpradioinformation); + return NULL; + } + + return wtpradioinformation; +} + +/* */ +static int ac_json_80211_wtpradioinformation_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite) { + struct capwap_80211_wtpradioinformation_element* wtpradioinformation = (struct capwap_80211_wtpradioinformation_element*)data; + struct ac_json_ieee80211_item* item = &wtpradio->items[wtpradioinformation->radioid - 1]; + struct capwap_message_elements_ops* ops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION); + + if (item->wtpradioinformation) { + if (!overwrite) { + return 0; + } + + ops->free_message_element(item->wtpradioinformation); + } + + item->valid = 1; + item->wtpradioinformation = (struct capwap_80211_wtpradioinformation_element*)ops->clone_message_element(wtpradioinformation); + + return 1; +} + +/* */ +static void ac_json_80211_wtpradioinformation_createjson(struct json_object* jsonparent, void* data) { + struct json_object* jsonitem; + struct capwap_80211_wtpradioinformation_element* wtpradioinformation = (struct capwap_80211_wtpradioinformation_element*)data; + + jsonitem = json_object_new_object(); + json_object_object_add(jsonitem, "Mode", json_object_new_int((int)wtpradioinformation->radiotype)); + json_object_object_add(jsonparent, "IEEE80211WTPRadioInformation", jsonitem); +} + +/* */ +struct ac_json_ieee80211_ops ac_json_80211_wtpradioinformation_ops = { + .type = CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION, + .json_type = "IEEE80211WTPRadioInformation", + .create_message_element = ac_json_80211_wtpradioinformation_createmessageelement, + .add_message_element = ac_json_80211_wtpradioinformation_addmessageelement, + .create_json = ac_json_80211_wtpradioinformation_createjson +}; diff --git a/src/ac/ac_80211_json_wtpradioinformation.h b/src/ac/ac_80211_json_wtpradioinformation.h new file mode 100644 index 0000000..af4cd4f --- /dev/null +++ b/src/ac/ac_80211_json_wtpradioinformation.h @@ -0,0 +1,8 @@ +#ifndef __AC_JSON_80211_WTPRADIOINFORMATION_HEADER__ +#define __AC_JSON_80211_WTPRADIOINFORMATION_HEADER__ + +#include "capwap_element_80211_wtpradioinformation.h" + +extern struct ac_json_ieee80211_ops ac_json_80211_wtpradioinformation_ops; + +#endif /* __AC_JSON_80211_WTPRADIOINFORMATION_HEADER__ */ diff --git a/src/ac/ac_json.h b/src/ac/ac_json.h index b87867f..f700e51 100644 --- a/src/ac/ac_json.h +++ b/src/ac/ac_json.h @@ -33,6 +33,45 @@ struct ac_json_ieee80211_wtpradio { struct ac_json_ieee80211_item items[RADIOID_MAX_COUNT]; }; +/* JSON IEEE 802.11 message elements */ +#include "ac_80211_json_addwlan.h" +#include "ac_80211_json_antenna.h" +#include "ac_80211_json_assignbssid.h" +#include "ac_80211_json_deletewlan.h" +#include "ac_80211_json_directsequencecontrol.h" +#include "ac_80211_json_ie.h" +#include "ac_80211_json_macoperation.h" +#include "ac_80211_json_miccountermeasures.h" +#include "ac_80211_json_multidomaincapability.h" +#include "ac_80211_json_ofdmcontrol.h" +#include "ac_80211_json_rateset.h" +#include "ac_80211_json_rsnaerrorreport.h" +#include "ac_80211_json_statistics.h" +#include "ac_80211_json_supportedrates.h" +#include "ac_80211_json_txpower.h" +#include "ac_80211_json_txpowerlevel.h" +#include "ac_80211_json_updatewlan.h" +#include "ac_80211_json_wtpqos.h" +#include "ac_80211_json_wtpradioconf.h" +#include "ac_80211_json_wtpradiofailalarm.h" +#include "ac_80211_json_wtpradioinformation.h" + +/* */ +struct ac_json_ieee80211_ops { + /* Message Element Type */ + uint16_t type; + + /* Message Element JSON Type */ + char* json_type; + + /* Build message element */ + void* (*create_message_element)(struct json_object* jsonparent, uint16_t radioid); + int (*add_message_element)(struct ac_json_ieee80211_wtpradio* wtpradio, void* data, int overwrite); + + /* Build JSON */ + void (*create_json)(struct json_object* jsonparent, void* data); +}; + /* */ void ac_json_ieee80211_init(struct ac_json_ieee80211_wtpradio* wtpradio); void ac_json_ieee80211_free(struct ac_json_ieee80211_wtpradio* wtpradio);