Notify event request atomic block of memory
This commit is contained in:
parent
0747168361
commit
68f14a8aca
@ -87,18 +87,26 @@ static void ac_backend_parsing_resetwtp_event(const char* eventid, struct json_o
|
|||||||
jsondata = json_object_object_get(jsonimage, "Data");
|
jsondata = json_object_object_get(jsonimage, "Data");
|
||||||
|
|
||||||
if (jsonvendor && jsondata && (json_object_get_type(jsonvendor) == json_type_int) && (json_object_get_type(jsondata) == json_type_string)) {
|
if (jsonvendor && jsondata && (json_object_get_type(jsonvendor) == json_type_int) && (json_object_get_type(jsondata) == json_type_string)) {
|
||||||
struct ac_notify_reset_t reset;
|
const char* name = json_object_get_string(jsondata);
|
||||||
|
if (name && *name) {
|
||||||
|
int length;
|
||||||
|
struct ac_notify_reset_t* reset;
|
||||||
|
|
||||||
/* */
|
/* Notification data */
|
||||||
memset(&reset, 0, sizeof(struct ac_notify_reset_t));
|
length = sizeof(struct ac_notify_reset_t) + strlen(name) + 1;
|
||||||
reset.startupimage.vendor = (uint32_t)json_object_get_int(jsonvendor);
|
reset = (struct ac_notify_reset_t*)capwap_alloc(length);
|
||||||
reset.startupimage.name = (uint8_t*)capwap_duplicate_string(json_object_get_string(jsondata));
|
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
capwap_logging_debug("Receive reset request for WTP %s", session->wtpid);
|
reset->vendor = (uint32_t)json_object_get_int(jsonvendor);
|
||||||
|
strcpy((char*)reset->name, name);
|
||||||
|
|
||||||
/* Notify Action */
|
/* Notify Action */
|
||||||
ac_session_send_action(session, AC_SESSION_ACTION_RESET_WTP, 0, (void*)&reset, sizeof(struct ac_notify_reset_t));
|
capwap_logging_debug("Receive reset request for WTP %s", session->wtpid);
|
||||||
|
ac_session_send_action(session, AC_SESSION_ACTION_RESET_WTP, 0, (void*)reset, length);
|
||||||
|
|
||||||
|
/* */
|
||||||
|
capwap_free(reset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
/* Reset notification */
|
/* Reset notification */
|
||||||
struct ac_notify_reset_t {
|
struct ac_notify_reset_t {
|
||||||
struct capwap_imageidentifier_element startupimage;
|
uint32_t vendor;
|
||||||
|
uint8_t name[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
|
@ -14,15 +14,13 @@ static int ac_session_action_execute(struct ac_session_t* session, struct ac_ses
|
|||||||
|
|
||||||
switch (action->action) {
|
switch (action->action) {
|
||||||
case AC_SESSION_ACTION_RESET_WTP: {
|
case AC_SESSION_ACTION_RESET_WTP: {
|
||||||
|
struct capwap_imageidentifier_element imageidentifier;
|
||||||
struct ac_notify_reset_t* reset = (struct ac_notify_reset_t*)action->data;
|
struct ac_notify_reset_t* reset = (struct ac_notify_reset_t*)action->data;
|
||||||
|
|
||||||
/* Send reset command */
|
/* Send reset command */
|
||||||
ac_session_reset(session, &reset->startupimage);
|
imageidentifier.vendor = reset->vendor;
|
||||||
|
imageidentifier.name = reset->name;
|
||||||
/* Free resource */
|
ac_session_reset(session, &imageidentifier);
|
||||||
if (reset->startupimage.name) {
|
|
||||||
capwap_free(reset->startupimage.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user