diff --git a/src/cwmp.c b/src/cwmp.c index 0fbb35d..f75dc78 100644 --- a/src/cwmp.c +++ b/src/cwmp.c @@ -425,6 +425,12 @@ int run_session_end_func (struct session *session) if (session->end_session & END_SESSION_RELOAD) cwmp_apply_acs_changes(); + if (session->end_session & END_SESSION_FACTORY_RESET) + { + external_simple("factory_reset", NULL); + exit(EXIT_SUCCESS); + } + session->end_session = 0; return CWMP_OK; diff --git a/src/inc/cwmp.h b/src/inc/cwmp.h index dca6abc..c165220 100644 --- a/src/inc/cwmp.h +++ b/src/inc/cwmp.h @@ -53,7 +53,8 @@ enum end_session { END_SESSION_REBOOT = 1, END_SESSION_EXTERNAL_ACTION = 1<<1, - END_SESSION_RELOAD = 1<<2 + END_SESSION_RELOAD = 1<<2, + END_SESSION_FACTORY_RESET = 1<<3 }; enum cwmp_start { diff --git a/src/scripts/freecwmp.sh b/src/scripts/freecwmp.sh index 69ac23f..9a468ea 100644 --- a/src/scripts/freecwmp.sh +++ b/src/scripts/freecwmp.sh @@ -492,7 +492,7 @@ if [ "$action" = "factory_reset" ]; then else jffs2_mark_erase "rootfs_data" sync - ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 command '{ "command": "reboot_end_session" }' 2>&1 > /dev/null + reboot fi fi @@ -554,7 +554,7 @@ if [ "$action" = "notify" ]; then fi freecwmp_execute_functions "$get_notification_functions" "$__param" fault_code="$?" - if [ "$fault_code" != "$FAULT_CPE_NO_FAULT" ]; then + if [ "$fault_code" = "$FAULT_CPE_NO_FAULT" ]; then freecwmp_notify "$__arg1" "$__arg2" "$__arg3" else echo "Invalid parameter name" 1>&2 diff --git a/src/xml.c b/src/xml.c index 8abed5c..6e799dd 100644 --- a/src/xml.c +++ b/src/xml.c @@ -1524,8 +1524,7 @@ int cwmp_handle_rpc_cpe_factory_reset(struct session *session, struct rpc *rpc) b = mxmlNewElement(b, "cwmp:FactoryResetResponse"); if (!b) goto fault; - if (external_simple("factory_reset", NULL)) - goto fault; + cwmp_set_end_session(END_SESSION_FACTORY_RESET); return 0;