Work in progress in JSON director
This commit is contained in:
parent
d8d284038f
commit
e0800c672f
@ -217,7 +217,10 @@ int ac_json_ieee80211_parsingjson(struct ac_json_ieee80211_wtpradio* wtpradio, s
|
|||||||
|
|
||||||
ASSERT(wtpradio != NULL);
|
ASSERT(wtpradio != NULL);
|
||||||
ASSERT(jsonroot != NULL);
|
ASSERT(jsonroot != NULL);
|
||||||
ASSERT(json_object_get_type(jsonroot) == json_type_array)
|
|
||||||
|
if (json_object_get_type(jsonroot) != json_type_array) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
length = json_object_array_length(jsonroot);
|
length = json_object_array_length(jsonroot);
|
||||||
@ -239,7 +242,7 @@ int ac_json_ieee80211_parsingjson(struct ac_json_ieee80211_wtpradio* wtpradio, s
|
|||||||
void* data = ops->create_message_element((struct json_object*)entry->v, radioid);
|
void* data = ops->create_message_element((struct json_object*)entry->v, radioid);
|
||||||
if (data) {
|
if (data) {
|
||||||
/* Message element complete */
|
/* Message element complete */
|
||||||
ac_json_ieee80211_addmessageelement(wtpradio, CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION, data, 1);
|
ac_json_ieee80211_addmessageelement(wtpradio, ops->type, data, 1);
|
||||||
|
|
||||||
/* Free resource */
|
/* Free resource */
|
||||||
capwap_get_message_element_ops(ops->type)->free_message_element(data);
|
capwap_get_message_element_ops(ops->type)->free_message_element(data);
|
||||||
|
@ -1,9 +1,41 @@
|
|||||||
#include "ac.h"
|
#include "ac.h"
|
||||||
#include "ac_json.h"
|
#include "ac_json.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
IEEE80211WTPRadioFailAlarm: {
|
||||||
|
Type: [int],
|
||||||
|
Status: [int]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
static void* ac_json_80211_wtpradiofailalarm_createmessageelement(struct json_object* jsonparent, uint16_t radioid) {
|
static void* ac_json_80211_wtpradiofailalarm_createmessageelement(struct json_object* jsonparent, uint16_t radioid) {
|
||||||
return NULL; /* TODO */
|
struct json_object* jsonitem;
|
||||||
|
struct capwap_80211_wtpradiofailalarm_element* wtpradiofailalarm;
|
||||||
|
|
||||||
|
wtpradiofailalarm = (struct capwap_80211_wtpradiofailalarm_element*)capwap_alloc(sizeof(struct capwap_80211_wtpradiofailalarm_element));
|
||||||
|
memset(wtpradiofailalarm, 0, sizeof(struct capwap_80211_wtpradiofailalarm_element));
|
||||||
|
wtpradiofailalarm->radioid = radioid;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
jsonitem = json_object_object_get(jsonparent, "Type");
|
||||||
|
if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) {
|
||||||
|
wtpradiofailalarm->type = (uint8_t)json_object_get_int(jsonitem);
|
||||||
|
} else {
|
||||||
|
capwap_free(wtpradiofailalarm);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* */
|
||||||
|
jsonitem = json_object_object_get(jsonparent, "Status");
|
||||||
|
if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) {
|
||||||
|
wtpradiofailalarm->status = (uint8_t)json_object_get_int(jsonitem);
|
||||||
|
} else {
|
||||||
|
capwap_free(wtpradiofailalarm);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wtpradiofailalarm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
@ -28,7 +60,13 @@ static int ac_json_80211_wtpradiofailalarm_addmessageelement(struct ac_json_ieee
|
|||||||
|
|
||||||
/* */
|
/* */
|
||||||
static void ac_json_80211_wtpradiofailalarm_createjson(struct json_object* jsonparent, void* data) {
|
static void ac_json_80211_wtpradiofailalarm_createjson(struct json_object* jsonparent, void* data) {
|
||||||
/* TODO */
|
struct json_object* jsonitem;
|
||||||
|
struct capwap_80211_wtpradiofailalarm_element* wtpradiofailalarm = (struct capwap_80211_wtpradiofailalarm_element*)data;
|
||||||
|
|
||||||
|
jsonitem = json_object_new_object();
|
||||||
|
json_object_object_add(jsonitem, "Type", json_object_new_int((int)wtpradiofailalarm->type));
|
||||||
|
json_object_object_add(jsonitem, "Status", json_object_new_int((int)wtpradiofailalarm->status));
|
||||||
|
json_object_object_add(jsonparent, "IEEE80211WTPRadioFailAlarm", jsonitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
|
@ -210,7 +210,7 @@ static struct ac_soap_response* ac_dfa_state_configure_parsing_request(struct ac
|
|||||||
|
|
||||||
/* Generate JSON tree */
|
/* Generate JSON tree */
|
||||||
jsonarray = ac_json_ieee80211_getjson(&wtpradio);
|
jsonarray = ac_json_ieee80211_getjson(&wtpradio);
|
||||||
json_object_object_add(jsonparam, "WTPRadio", jsonarray);
|
json_object_object_add(jsonparam, IEEE80211_BINDING_JSON_ROOT, jsonarray);
|
||||||
|
|
||||||
/* Free resource */
|
/* Free resource */
|
||||||
ac_json_ieee80211_free(&wtpradio);
|
ac_json_ieee80211_free(&wtpradio);
|
||||||
@ -685,7 +685,7 @@ static uint32_t ac_dfa_state_configure_create_response(struct ac_session_t* sess
|
|||||||
ac_json_ieee80211_init(&wtpradio);
|
ac_json_ieee80211_init(&wtpradio);
|
||||||
|
|
||||||
/* Parsing SOAP response */
|
/* Parsing SOAP response */
|
||||||
jsonelement = json_object_object_get(jsonroot, "WTPRadio");
|
jsonelement = json_object_object_get(jsonroot, IEEE80211_BINDING_JSON_ROOT);
|
||||||
if (jsonelement) {
|
if (jsonelement) {
|
||||||
if (ac_json_ieee80211_parsingjson(&wtpradio, jsonelement)) {
|
if (ac_json_ieee80211_parsingjson(&wtpradio, jsonelement)) {
|
||||||
/* Add IEEE802.11 message elements to packet */
|
/* Add IEEE802.11 message elements to packet */
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "capwap_dfa.h"
|
#include "capwap_dfa.h"
|
||||||
#include "capwap_array.h"
|
#include "capwap_array.h"
|
||||||
#include "ac_session.h"
|
#include "ac_session.h"
|
||||||
|
#include "ac_json.h"
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
@ -15,6 +16,7 @@ static struct ac_soap_response* ac_dfa_state_datacheck_parsing_request(struct ac
|
|||||||
struct json_object* jsonhash;
|
struct json_object* jsonhash;
|
||||||
struct ac_soap_response* response;
|
struct ac_soap_response* response;
|
||||||
struct capwap_resultcode_element* resultcode;
|
struct capwap_resultcode_element* resultcode;
|
||||||
|
unsigned short binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||||
|
|
||||||
/* Create SOAP request with JSON param
|
/* Create SOAP request with JSON param
|
||||||
{
|
{
|
||||||
@ -31,7 +33,17 @@ static struct ac_soap_response* ac_dfa_state_datacheck_parsing_request(struct ac
|
|||||||
ReturnedMessageElement: [
|
ReturnedMessageElement: [
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
<IEEE 802.11 BINDING>
|
||||||
|
WTPRadio: [
|
||||||
|
{
|
||||||
|
RadioID: [int],
|
||||||
|
IEEE80211WTPRadioFailAlarm: {
|
||||||
|
Type: [int],
|
||||||
|
Status: [int]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -67,6 +79,37 @@ static struct ac_soap_response* ac_dfa_state_datacheck_parsing_request(struct ac
|
|||||||
/* TODO */
|
/* TODO */
|
||||||
json_object_object_add(jsonparam, "ReturnedMessageElement", jsonarray);
|
json_object_object_add(jsonparam, "ReturnedMessageElement", jsonarray);
|
||||||
|
|
||||||
|
/* Binding message */
|
||||||
|
if (binding == CAPWAP_WIRELESS_BINDING_IEEE80211) {
|
||||||
|
struct ac_json_ieee80211_wtpradio wtpradio;
|
||||||
|
struct capwap_list_item* search = packet->messages->first;
|
||||||
|
|
||||||
|
/* Reording message by radioid and management */
|
||||||
|
ac_json_ieee80211_init(&wtpradio);
|
||||||
|
|
||||||
|
while (search) {
|
||||||
|
struct capwap_message_element_itemlist* messageelement = (struct capwap_message_element_itemlist*)search->item;
|
||||||
|
|
||||||
|
/* Parsing only IEEE 802.11 message element */
|
||||||
|
if (IS_80211_MESSAGE_ELEMENTS(messageelement->type)) {
|
||||||
|
if (!ac_json_ieee80211_parsingmessageelement(&wtpradio, messageelement)) {
|
||||||
|
json_object_put(jsonparam);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Next */
|
||||||
|
search = search->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generate JSON tree */
|
||||||
|
jsonarray = ac_json_ieee80211_getjson(&wtpradio);
|
||||||
|
json_object_object_add(jsonparam, IEEE80211_BINDING_JSON_ROOT, jsonarray);
|
||||||
|
|
||||||
|
/* Free resource */
|
||||||
|
ac_json_ieee80211_free(&wtpradio);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get JSON param and convert base64 */
|
/* Get JSON param and convert base64 */
|
||||||
jsonmessage = json_object_to_json_string(jsonparam);
|
jsonmessage = json_object_to_json_string(jsonparam);
|
||||||
base64confstatus = capwap_alloc(AC_BASE64_ENCODE_LENGTH(strlen(jsonmessage)));
|
base64confstatus = capwap_alloc(AC_BASE64_ENCODE_LENGTH(strlen(jsonmessage)));
|
||||||
|
@ -253,7 +253,7 @@ static struct ac_soap_response* ac_dfa_state_join_parsing_request(struct ac_sess
|
|||||||
|
|
||||||
/* Generate JSON tree */
|
/* Generate JSON tree */
|
||||||
jsonarray = ac_json_ieee80211_getjson(&wtpradio);
|
jsonarray = ac_json_ieee80211_getjson(&wtpradio);
|
||||||
json_object_object_add(jsonparam, "WTPRadio", jsonarray);
|
json_object_object_add(jsonparam, IEEE80211_BINDING_JSON_ROOT, jsonarray);
|
||||||
|
|
||||||
/* Free resource */
|
/* Free resource */
|
||||||
ac_json_ieee80211_free(&wtpradio);
|
ac_json_ieee80211_free(&wtpradio);
|
||||||
@ -403,7 +403,7 @@ static uint32_t ac_dfa_state_join_create_response(struct ac_session_t* session,
|
|||||||
ac_json_ieee80211_init(&wtpradio);
|
ac_json_ieee80211_init(&wtpradio);
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
jsonelement = json_object_object_get(jsonroot, "WTPRadio");
|
jsonelement = json_object_object_get(jsonroot, IEEE80211_BINDING_JSON_ROOT);
|
||||||
if (jsonelement) {
|
if (jsonelement) {
|
||||||
ac_json_ieee80211_parsingjson(&wtpradio, jsonelement);
|
ac_json_ieee80211_parsingjson(&wtpradio, jsonelement);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "capwap_array.h"
|
#include "capwap_array.h"
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
|
|
||||||
|
#define IEEE80211_BINDING_JSON_ROOT "WTPRadio"
|
||||||
|
|
||||||
struct ac_json_ieee80211_item {
|
struct ac_json_ieee80211_item {
|
||||||
int valid;
|
int valid;
|
||||||
struct capwap_80211_addwlan_element* addwlan;
|
struct capwap_80211_addwlan_element* addwlan;
|
||||||
|
Loading…
Reference in New Issue
Block a user