Updated config defaults

This commit is contained in:
vdutta 2022-10-31 14:21:30 +05:30
parent e88c577693
commit 61131746e2
5 changed files with 110 additions and 110 deletions

View file

@ -49,7 +49,7 @@
<td class="td_row_odd"><div class="td_row_odd">periodic_inform_enable</div></td>
<td class="td_row_odd"><div class="td_row_odd">boolean</div></td>
<td class="td_row_odd"><div class="td_row_odd">no</div></td>
<td class="td_row_odd"><div class="td_row_odd"></div></td>
<td class="td_row_odd"><div class="td_row_odd">1</div></td>
<td class="td_row_odd">
<div class="td_row_odd">If set to <b>1</b>, the CPE must periodically open session with ACS by sending Inform message to the ACS.</div>
</td>
@ -58,7 +58,7 @@
<td class="td_row_even"><div class="td_row_even">periodic_inform_interval</div></td>
<td class="td_row_even"><div class="td_row_even">uinteger</div></td>
<td class="td_row_even"><div class="td_row_even">no</div></td>
<td class="td_row_even"><div class="td_row_even"></div></td>
<td class="td_row_even"><div class="td_row_even">86400</div></td>
<td class="td_row_even"><div class="td_row_even">The duration in seconds of the interval for which the CPE must attempt to connect with the ACS and call the Inform method.</div></td>
</tr>
<tr>
@ -90,14 +90,14 @@
<td class="td_row_even"><div class="td_row_even">retry_min_wait_interval</div></td>
<td class="td_row_even"><div class="td_row_even">uinteger</div></td>
<td class="td_row_even"><div class="td_row_even">no</div></td>
<td class="td_row_even"><div class="td_row_even"></div></td>
<td class="td_row_even"><div class="td_row_even">5</div></td>
<td class="td_row_even"><div class="td_row_even">The minimum wait interval for session retry (in seconds)</div></td>
</tr>
<tr>
<td class="td_row_odd"><div class="td_row_odd">retry_interval_multiplier</div></td>
<td class="td_row_odd"><div class="td_row_odd">uinteger</div></td>
<td class="td_row_odd"><div class="td_row_odd">no</div></td>
<td class="td_row_odd"><div class="td_row_odd"></div></td>
<td class="td_row_odd"><div class="td_row_odd">2000</div></td>
<td class="td_row_odd"><div class="td_row_odd">The retry interval multiplier for session retry session as described in the standard.</div></td>
</tr>
<tr>
@ -319,9 +319,16 @@
<td class="td_row_odd"><div class="td_row_odd">port</div></td>
<td class="td_row_odd"><div class="td_row_odd">uinteger</div></td>
<td class="td_row_odd"><div class="td_row_odd">no</div></td>
<td class="td_row_odd"><div class="td_row_odd"></div></td>
<td class="td_row_odd"><div class="td_row_odd">7547</div></td>
<td class="td_row_odd"><div class="td_row_odd">The port used for connection request.</div></td>
</tr>
<tr>
<td class="td_row_odd"><div class="td_row_odd">path</div></td>
<td class="td_row_odd"><div class="td_row_odd">string</div></td>
<td class="td_row_odd"><div class="td_row_odd">no</div></td>
<td class="td_row_odd"><div class="td_row_odd">/</div></td>
<td class="td_row_odd"><div class="td_row_odd">CPE Connection request URI path</div></td>
</tr>
<tr>
<td class="td_row_even"><div class="td_row_even">ubus_socket</div></td>
<td class="td_row_even"><div class="td_row_even">string</div></td>
@ -396,7 +403,7 @@
<td class="td_row_even"><div class="td_row_even">periodic_notify_enable</div></td>
<td class="td_row_even"><div class="td_row_even">boolean</div></td>
<td class="td_row_even"><div class="td_row_even">no</div></td>
<td class="td_row_even"><div class="td_row_even"></div></td>
<td class="td_row_even"><div class="td_row_even">1</div></td>
<td class="td_row_even">
<div class="td_row_even">If set to <b>1</b>, icwmp will be able to detect parameter value change at any time.</div>
</td>
@ -444,7 +451,7 @@
<td class="td_row_even"><div class="td_row_even">enable</div></td>
<td class="td_row_even"><div class="td_row_even">boolean</div></td>
<td class="td_row_even"><div class="td_row_even">no</div></td>
<td class="td_row_even"><div class="td_row_even"></div></td>
<td class="td_row_even"><div class="td_row_even">0</div></td>
<td class="td_row_even">
<div class="td_row_even">if set to <b>1</b>, the Lightweight Notifications will be enabled.</div>
</td>
@ -453,14 +460,14 @@
<td class="td_row_odd"><div class="td_row_odd">hostname</div></td>
<td class="td_row_odd"><div class="td_row_odd">host</div></td>
<td class="td_row_odd"><div class="td_row_odd">no</div></td>
<td class="td_row_odd"><div class="td_row_odd"></div></td>
<td class="td_row_odd"><div class="td_row_odd">ACS url</div></td>
<td class="td_row_odd"><div class="td_row_odd">The hostname or address to be used when sending the UDP Lightweight Notifications.</div></td>
</tr>
<tr>
<td class="td_row_even"><div class="td_row_even">port</div></td>
<td class="td_row_even"><div class="td_row_even">port</div></td>
<td class="td_row_even"><div class="td_row_even">no</div></td>
<td class="td_row_even"><div class="td_row_even"></div></td>
<td class="td_row_even"><div class="td_row_even">7547</div></td>
<td class="td_row_even"><div class="td_row_even">The port number to be used when sending UDP Lightweight Notifications.</div></td>
</tr>
</tbody>

View file

@ -30,14 +30,14 @@
"name": "periodic_inform_enable",
"type": "boolean",
"required": "no",
"default": "",
"default": "1",
"description": "If set to **1**, the CPE must periodically open session with ACS by sending Inform message to the ACS."
},
{
"name": "periodic_inform_interval",
"type": "uinteger",
"required": "no",
"default": "",
"default": "86400",
"description": "The duration in seconds of the interval for which the CPE must attempt to connect with the ACS and call the Inform method."
},
{
@ -65,14 +65,14 @@
"name": "retry_min_wait_interval",
"type": "uinteger",
"required": "no",
"default": "",
"default": "5",
"description": "The minimum wait interval for session retry (in seconds)"
},
{
"name": "retry_interval_multiplier",
"type": "uinteger",
"required": "no",
"default": "",
"default": "2000",
"description": "The retry interval multiplier for session retry session as described in the standard."
},
{
@ -254,9 +254,16 @@
"name": "port",
"type": "uinteger",
"required": "no",
"default": "",
"default": "7547",
"description": "The port used for connection request."
},
{
"name": "path",
"type": "string",
"required": "no",
"default": "/",
"description": "CPE Connection request URI path"
},
{
"name": "ubus_socket",
"type": "string",
@ -317,7 +324,7 @@
"name": "periodic_notify_enable",
"type": "boolean",
"required": "no",
"default": "",
"default": "1",
"description": "If set to **1**, icwmp will be able to detect parameter value change at any time."
},
{
@ -352,21 +359,21 @@
"name": "enable",
"type": "boolean",
"required": "no",
"default": "",
"default": "0",
"description": "if set to **1**, the Lightweight Notifications will be enabled. "
},
{
"name": "hostname",
"type": "host",
"required": "no",
"default": "",
"default": "ACS url",
"description": "The hostname or address to be used when sending the UDP Lightweight Notifications."
},
{
"name": "port",
"type": "port",
"required": "no",
"default": "",
"default": "7547",
"description": "The port number to be used when sending UDP Lightweight Notifications."
}
]

View file

@ -338,7 +338,6 @@ int get_global_config()
bool discovery_enable = false;
error = uci_get_value(UCI_DHCP_DISCOVERY_PATH, &value);
// now read the vendor info from ifstatus before reading the DHCP_ACS_URL from uci
if (error == CWMP_OK && value != NULL) {
discovery_enable = uci_str_to_bool(value);
@ -368,6 +367,7 @@ int get_global_config()
FREE(value);
}
} else {
CWMP_LOG(INFO, "Failed to get userid");
return error;
}
@ -378,10 +378,11 @@ int get_global_config()
FREE(value);
}
} else {
CWMP_LOG(INFO, "Failed to get acs password");
return error;
}
if ((error = uci_get_value(UCI_ACS_COMPRESSION, &value)) == CWMP_OK) {
if (uci_get_value(UCI_ACS_COMPRESSION, &value) == CWMP_OK) {
cwmp_main->conf.compression = COMP_NONE;
if (cwmp_main->conf.amd_version >= AMD_5 && value != NULL) {
if (0 == strcasecmp(value, "gzip")) {
@ -393,8 +394,9 @@ int get_global_config()
}
}
FREE(value);
} else
} else {
cwmp_main->conf.compression = COMP_NONE;
}
cwmp_main->conf.retry_min_wait_interval = DEFAULT_RETRY_MINIMUM_WAIT_INTERVAL;
uci_get_value(UCI_ACS_RETRY_MIN_WAIT_INTERVAL, &value2);
@ -430,37 +432,30 @@ int get_global_config()
FREE(value2);
FREE(value3);
if ((error = uci_get_value(UCI_ACS_GETRPC, &value)) == CWMP_OK) {
if (uci_get_value(UCI_ACS_GETRPC, &value) == CWMP_OK) {
cwmp_main->conf.acs_getrpc = uci_str_to_bool(value);
FREE(value);
} else {
cwmp_main->conf.acs_getrpc = true;
}
if ((error = uci_get_value(UCI_CPE_USERID_PATH, &value)) == CWMP_OK) {
FREE(cwmp_main->conf.cpe_userid);
if (value != NULL) {
if (uci_get_value(UCI_CPE_USERID_PATH, &value) == CWMP_OK) {
cwmp_main->conf.cpe_userid = strdup(value);
FREE(value);
} else
cwmp_main->conf.cpe_userid = strdup("");
} else {
return error;
cwmp_main->conf.cpe_userid = strdup("");
}
if ((error = uci_get_value(UCI_CPE_PASSWD_PATH, &value)) == CWMP_OK) {
FREE(cwmp_main->conf.cpe_passwd);
if (value != NULL) {
if (uci_get_value(UCI_CPE_PASSWD_PATH, &value) == CWMP_OK) {
cwmp_main->conf.cpe_passwd = strdup(value);
FREE(value);
} else {
cwmp_main->conf.cpe_passwd = strdup("");
}
} else {
return error;
}
if ((error = uci_get_value(UCI_CPE_PORT_PATH, &value)) == CWMP_OK) {
if (uci_get_value(UCI_CPE_PORT_PATH, &value) == CWMP_OK) {
int a = 0;
if (value != NULL) {
@ -469,20 +464,18 @@ int get_global_config()
}
if (a == 0) {
CWMP_LOG(INFO, "Set the connection request port to the default value: %d", DEFAULT_CONNECTION_REQUEST_PORT);
CWMP_LOG(DEBUG, "Set the connection request port to the default value: %d", DEFAULT_CONNECTION_REQUEST_PORT);
cwmp_main->conf.connection_request_port = DEFAULT_CONNECTION_REQUEST_PORT;
} else {
cwmp_main->conf.connection_request_port = a;
}
} else {
return error;
CWMP_LOG(DEBUG, "Failed to read cpe port, defaults to: %d", DEFAULT_CONNECTION_REQUEST_PORT);
cwmp_main->conf.connection_request_port = DEFAULT_CONNECTION_REQUEST_PORT;
}
if ((error = uci_get_value(UCI_CPE_CRPATH_PATH, &value)) == CWMP_OK) {
FREE(cwmp_main->conf.connection_request_path);
if (value == NULL)
cwmp_main->conf.connection_request_path = strdup("/");
else {
if (uci_get_value(UCI_CPE_CRPATH_PATH, &value) == CWMP_OK) {
if (value[0] == '/')
cwmp_main->conf.connection_request_path = strdup(value);
else {
@ -491,23 +484,18 @@ int get_global_config()
cwmp_main->conf.connection_request_path = strdup(cr_path);
}
FREE(value);
}
} else {
return error;
cwmp_main->conf.connection_request_path = strdup("/");
}
if ((error = uci_get_value(UCI_CPE_NOTIFY_PERIODIC_ENABLE, &value)) == CWMP_OK) {
bool a = true;
if (value != NULL) {
a = uci_str_to_bool(value);
if (uci_get_value(UCI_CPE_NOTIFY_PERIODIC_ENABLE, &value) == CWMP_OK) {
cwmp_main->conf.periodic_notify_enable = uci_str_to_bool(value);
FREE(value);
}
cwmp_main->conf.periodic_notify_enable = a;
} else {
return error;
cwmp_main->conf.periodic_notify_enable = true;
}
if ((error = uci_get_value(UCI_CPE_NOTIFY_PERIOD, &value)) == CWMP_OK) {
if (uci_get_value(UCI_CPE_NOTIFY_PERIOD, &value) == CWMP_OK) {
int a = 0;
if (value != NULL) {
@ -516,23 +504,22 @@ int get_global_config()
}
if (a == 0) {
CWMP_LOG(INFO, "Set notify period to the default value: %d", DEFAULT_NOTIFY_PERIOD);
CWMP_LOG(DEBUG, "Set notify period to the default value: %d", DEFAULT_NOTIFY_PERIOD);
cwmp_main->conf.periodic_notify_interval = DEFAULT_NOTIFY_PERIOD;
} else {
cwmp_main->conf.periodic_notify_interval = a;
}
} else {
return error;
CWMP_LOG(DEBUG, "Failed to read notify period, default value: %d", DEFAULT_NOTIFY_PERIOD);
cwmp_main->conf.periodic_notify_interval = DEFAULT_NOTIFY_PERIOD;
}
if ((error = uci_get_value(UCI_PERIODIC_INFORM_TIME_PATH, &value)) == CWMP_OK) {
if (value != NULL) {
if (uci_get_value(UCI_PERIODIC_INFORM_TIME_PATH, &value) == CWMP_OK) {
cwmp_main->conf.time = convert_datetime_to_timestamp(value);
FREE(value);
} else
} else {
cwmp_main->conf.time = 0;
} else
return error;
}
char *entropy = generate_random_string(sizeof(unsigned int));
if (entropy != NULL) {
@ -540,7 +527,7 @@ int get_global_config()
free(entropy);
}
if ((error = uci_get_value(UCI_PERIODIC_INFORM_INTERVAL_PATH, &value)) == CWMP_OK) {
if (uci_get_value(UCI_PERIODIC_INFORM_INTERVAL_PATH, &value) == CWMP_OK) {
int a = 0;
if (value != NULL) {
@ -551,22 +538,22 @@ int get_global_config()
if (a >= PERIOD_INFORM_MIN) {
cwmp_main->conf.period = a;
} else {
CWMP_LOG(ERROR, "Period interval of periodic inform should be > %ds. Set to default: %ds", PERIOD_INFORM_MIN, PERIOD_INFORM_DEFAULT);
CWMP_LOG(DEBUG, "Period interval of periodic inform should be > %ds. Set to default: %ds", PERIOD_INFORM_MIN, PERIOD_INFORM_DEFAULT);
cwmp_main->conf.period = PERIOD_INFORM_DEFAULT;
}
} else {
return error;
CWMP_LOG(DEBUG, "Failed to read period interval, default: %ds", PERIOD_INFORM_DEFAULT);
cwmp_main->conf.period = PERIOD_INFORM_DEFAULT;
}
if ((error = uci_get_value(UCI_PERIODIC_INFORM_ENABLE_PATH, &value)) == CWMP_OK) {
if (uci_get_value(UCI_PERIODIC_INFORM_ENABLE_PATH, &value) == CWMP_OK) {
cwmp_main->conf.periodic_enable = uci_str_to_bool(value);
FREE(value);
} else {
return error;
cwmp_main->conf.periodic_enable = true;
}
if ((error = uci_get_value(UCI_CPE_INSTANCE_MODE, &value)) == CWMP_OK) {
if (value != NULL) {
if (uci_get_value(UCI_CPE_INSTANCE_MODE, &value) == CWMP_OK) {
if (0 == strcmp(value, "InstanceNumber")) {
cwmp_main->conf.instance_mode = INSTANCE_MODE_NUMBER;
} else {
@ -576,11 +563,8 @@ int get_global_config()
} else {
cwmp_main->conf.instance_mode = DEFAULT_INSTANCE_MODE;
}
} else {
return error;
}
if ((error = uci_get_value(UCI_CPE_SESSION_TIMEOUT, &value)) == CWMP_OK) {
if (uci_get_value(UCI_CPE_SESSION_TIMEOUT, &value) == CWMP_OK) {
cwmp_main->conf.session_timeout = DEFAULT_SESSION_TIMEOUT;
if (value != NULL) {
int a = atoi(value);
@ -590,17 +574,17 @@ int get_global_config()
FREE(value);
}
} else {
return error;
cwmp_main->conf.session_timeout = DEFAULT_SESSION_TIMEOUT;
}
if ((error = uci_get_value(LW_NOTIFICATION_ENABLE, &value)) == CWMP_OK) {
if (uci_get_value(LW_NOTIFICATION_ENABLE, &value) == CWMP_OK) {
cwmp_main->conf.lw_notification_enable = uci_str_to_bool(value);
FREE(value);
} else {
return error;
cwmp_main->conf.lw_notification_enable = false;
}
if ((error = uci_get_value(LW_NOTIFICATION_HOSTNAME, &value)) == CWMP_OK) {
if (uci_get_value(LW_NOTIFICATION_HOSTNAME, &value) == CWMP_OK) {
FREE(cwmp_main->conf.lw_notification_hostname);
if (value != NULL) {
cwmp_main->conf.lw_notification_hostname = strdup(value);
@ -609,10 +593,10 @@ int get_global_config()
cwmp_main->conf.lw_notification_hostname = strdup(cwmp_main->conf.acsurl ? cwmp_main->conf.acsurl : "");
}
} else {
return error;
cwmp_main->conf.lw_notification_hostname = strdup(cwmp_main->conf.acsurl ? cwmp_main->conf.acsurl : "");
}
if ((error = uci_get_value(LW_NOTIFICATION_PORT, &value)) == CWMP_OK) {
if (uci_get_value(LW_NOTIFICATION_PORT, &value) == CWMP_OK) {
if (value != NULL) {
int a = atoi(value);
cwmp_main->conf.lw_notification_port = a;
@ -621,7 +605,7 @@ int get_global_config()
cwmp_main->conf.lw_notification_port = DEFAULT_LWN_PORT;
}
} else {
return error;
cwmp_main->conf.lw_notification_port = DEFAULT_LWN_PORT;
}
if (uci_get_value(UCI_CPE_SCHEDULE_REBOOT, &value) == CWMP_OK) {
@ -632,7 +616,7 @@ int get_global_config()
cwmp_main->conf.schedule_reboot = 0;
}
} else {
return error;
cwmp_main->conf.schedule_reboot = 0;
}
if (uci_get_value(UCI_CPE_DELAY_REBOOT, &value) == CWMP_OK) {
@ -645,26 +629,26 @@ int get_global_config()
cwmp_main->conf.delay_reboot = delay;
} else {
return error;
cwmp_main->conf.delay_reboot = -1;
}
cwmp_main->conf.custom_notify_json = NULL;
if (uci_get_value(UCI_CPE_JSON_CUSTOM_NOTIFY_FILE, &value) == CWMP_OK) {
FREE(cwmp_main->conf.custom_notify_json);
if (value != NULL) {
cwmp_main->conf.custom_notify_json = strdup(value);
FREE(value);
} else {
cwmp_main->conf.custom_notify_json = NULL;
}
}
if ((error = uci_get_value(UCI_ACS_HEARTBEAT_ENABLE, &value)) == CWMP_OK) {
if (uci_get_value(UCI_ACS_HEARTBEAT_ENABLE, &value) == CWMP_OK) {
cwmp_main->conf.heart_beat_enable = uci_str_to_bool(value);
FREE(value);
} else {
return error;
cwmp_main->conf.heart_beat_enable = false;
}
if ((error = uci_get_value(UCI_ACS_HEARTBEAT_INTERVAL, &value)) == CWMP_OK) {
if (uci_get_value(UCI_ACS_HEARTBEAT_INTERVAL, &value) == CWMP_OK) {
int a = 30;
if (value != NULL) {
@ -673,10 +657,10 @@ int get_global_config()
}
cwmp_main->conf.heartbeat_interval = a;
} else {
return error;
cwmp_main->conf.heartbeat_interval = 30;
}
if ((error = uci_get_value(UCI_ACS_HEARTBEAT_TIME, &value)) == CWMP_OK) {
if (uci_get_value(UCI_ACS_HEARTBEAT_TIME, &value) == CWMP_OK) {
if (value != NULL) {
cwmp_main->conf.heart_time = convert_datetime_to_timestamp(value);
FREE(value);
@ -684,8 +668,9 @@ int get_global_config()
cwmp_main->conf.heart_time = 0;
}
} else {
return error;
cwmp_main->conf.heart_time = 0;
}
return CWMP_OK;
}

View file

@ -201,9 +201,10 @@ int cwmp_uci_get_value_by_path(char *path, uci_config_paths uci_type, char **val
return UCI_OK;
}
*value = strdup(ptr.o->v.string);
}
return UCI_OK;
}
return UCI_ERR_NOTFOUND;
}
int uci_get_state_value(char *path, char **value)
{

View file

@ -48,7 +48,7 @@ static void cwmp_uci_get_tests(void **state)
assert_string_equal(value, "iopsys");
error = uci_get_value(UCI_WRONG_PATH, &value);
assert_int_equal(error, UCI_OK);
assert_int_equal(error, UCI_ERR_NOTFOUND);
assert_null(value);
error = uci_get_state_value(UCI_DHCP_ACS_URL, &value);
@ -56,7 +56,7 @@ static void cwmp_uci_get_tests(void **state)
assert_string_equal(value, "http://192.168.103.160:8080/openacs/acs");
error = uci_get_state_value(UCI_WRONG_PATH, &value);
assert_int_equal(error, UCI_OK);
assert_int_equal(error, UCI_ERR_NOTFOUND);
assert_null(value);
error = cwmp_uci_get_option_value_string("cwmp", "acs", "dhcp_url", UCI_VARSTATE_CONFIG, &value);