mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-14 21:20:28 +01:00
Fix ticket#7333 fix cppcheck warnings
This commit is contained in:
parent
4eff4ace6e
commit
889c15feeb
45 changed files with 1060 additions and 705 deletions
|
|
@ -6,7 +6,7 @@ variables:
|
|||
DEBUG: 'TRUE'
|
||||
SOURCE_FOLDER: "."
|
||||
COMMON_IMAGE: iopsys/code-analysis:0.26
|
||||
RUN_CPPCHECK: "cppcheck --enable=style --error-exitcode=1 -DBBF_VENDOR_IOPSYS -DBBF_VENDOR_OPENWRT --suppress=unreadVariable --suppress=knownConditionTrueFalse --suppress=nullPointerRedundantCheck --suppress=unknownMacro --suppress=internalAstError"
|
||||
RUN_CPPCHECK: "cppcheck --enable=style --error-exitcode=1 --inline-suppr --include=/usr/local/include/json-c/json_object.h --include=/usr/include/libubox/list.h -I . -I ./include/ -I ./libbbf_api/ -i test/ -DBBF_VENDOR_IOPSYS -DBBF_VENDOR_OPENWRT"
|
||||
|
||||
stages:
|
||||
- static_code_analysis
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@ static void free_json_data(struct list_head *json_list)
|
|||
struct dm_json_obj *dm_json_obj = NULL;
|
||||
|
||||
while (json_list->next != json_list) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
dm_json_obj = list_entry(json_list->next, struct dm_json_obj, list);
|
||||
list_del(&dm_json_obj->list);
|
||||
dmfree(dm_json_obj->name);
|
||||
|
|
@ -100,6 +104,10 @@ static void free_loaded_json_files(struct list_head *json_list)
|
|||
{
|
||||
struct loaded_json_file *json_file;
|
||||
while (json_list->next != json_list) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
json_file = list_entry(json_list->next, struct loaded_json_file, list);
|
||||
list_del(&json_file->list);
|
||||
if (json_file->data)
|
||||
|
|
@ -727,6 +735,10 @@ static char *uci_v1_get_value(json_object *mapping_obj, char *refparam, struct d
|
|||
json_object_object_get_ex(mapping_obj, "data", &data_s);
|
||||
json_object_object_get_ex(mapping_obj, "key", &key);
|
||||
|
||||
/* json_object_object_get_ex is an external macro which changes the
|
||||
* value of data_s that cppcheck can't track and throws warning as
|
||||
* data_s value check always true. So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (data == NULL || data_s == NULL || (data_s && strcmp(json_object_get_string(data_s), "@Parent") != 0))
|
||||
goto end;
|
||||
|
||||
|
|
@ -752,6 +764,10 @@ static char *ubus_v1_get_value(json_object *mapping_obj, char *refparam, struct
|
|||
json_object_object_get_ex(mapping_obj, "data", &data_json);
|
||||
json_object_object_get_ex(mapping_obj, "key", &key);
|
||||
|
||||
/* json_object_object_get_ex is an external macro which changes the
|
||||
* value of data_json that cppcheck can't track and throws warning as
|
||||
* data_json value check always true. So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (data == NULL || data_json == NULL || (data_json && strcmp(json_object_get_string(data_json), "@Parent") != 0))
|
||||
goto end;
|
||||
|
||||
|
|
@ -1022,6 +1038,10 @@ static int fill_string_arguments(struct json_object *json_obj, int *min_length,
|
|||
|
||||
json_object_object_get_ex(json_obj, "pattern", &pattern_obj);
|
||||
if ((pattern_obj != NULL) && json_object_get_type(pattern_obj) == json_type_array) {
|
||||
/* json_object_object_get_ex is an external macro which changes the
|
||||
* value of pattern_obj that cppcheck can't track and throws warning as
|
||||
* pattern_obj value check always true. So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
int pattern_len = (pattern_obj) ? json_object_array_length(pattern_obj) + 1 : 1;
|
||||
|
||||
for (int i = 0; i < pattern_len - 1; i++) {
|
||||
|
|
@ -1236,6 +1256,10 @@ static void uci_v1_set_value(json_object *mapping_obj, int json_version, char *r
|
|||
json_object_object_get_ex(mapping_obj, "data", &data_s);
|
||||
json_object_object_get_ex(mapping_obj, "key", &key);
|
||||
|
||||
/* json_object_object_get_ex is an external macro which changes the
|
||||
* value of data_s that cppcheck can't track and throws warning as
|
||||
* data_s value check always true. So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (data == NULL || data_s == NULL || (data_s && strcmp(json_object_get_string(data_s), "@Parent") != 0))
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ static void free_all_list_open_library(struct list_head *library_list)
|
|||
{
|
||||
struct loaded_library *lib;
|
||||
while (library_list->next != library_list) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
lib = list_entry(library_list->next, struct loaded_library, list);
|
||||
list_del(&lib->list);
|
||||
if (lib->library) {
|
||||
|
|
@ -62,6 +66,10 @@ static void free_list_dynamic_operates(struct list_head *operate_list)
|
|||
{
|
||||
struct dynamic_operate *dyn_operate;
|
||||
while (operate_list->next != operate_list) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
dyn_operate = list_entry(operate_list->next, struct dynamic_operate, list);
|
||||
list_del(&dyn_operate->list);
|
||||
if (dyn_operate->operate_path) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ int init_supported_codecs(void)
|
|||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("voice.asterisk", "codecs", UBUS_ARGS{0}, 0, &res);
|
||||
/* value of res is being changed inside dmubus_call through pointer referencing
|
||||
* which cppcheck can't track hence throws warning for 'res' value check always
|
||||
* true. So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res)
|
||||
return -1;
|
||||
|
||||
|
|
@ -100,11 +104,11 @@ static void convert_src_dst(char *src_or_dst, size_t buf_size)
|
|||
int inst;
|
||||
|
||||
// Examples, "TELCHAN/5/2", "SIP/sip0-00000000",
|
||||
if ((token = DM_STRSTR(src_or_dst, TEL_LINE_PREFIX))) {
|
||||
inst = DM_STRTOL(token + DM_STRLEN(TEL_LINE_PREFIX)) + 1;
|
||||
if ((token = DM_LSTRSTR(src_or_dst, TEL_LINE_PREFIX))) {
|
||||
inst = DM_STRTOL(token + strlen(TEL_LINE_PREFIX)) + 1;
|
||||
snprintf(src_or_dst, buf_size, "Device.Services.VoiceService.1.CallControl.Line.%d", inst);
|
||||
} else if ((token = DM_STRSTR(src_or_dst, SIP_ACCOUNT_PREFIX))) {
|
||||
inst = DM_STRTOL(token + DM_STRLEN(SIP_ACCOUNT_PREFIX)) + 1;
|
||||
} else if ((token = DM_LSTRSTR(src_or_dst, SIP_ACCOUNT_PREFIX))) {
|
||||
inst = DM_STRTOL(token + strlen(SIP_ACCOUNT_PREFIX)) + 1;
|
||||
snprintf(src_or_dst, buf_size, "Device.Services.VoiceService.1.SIP.Client.%d", inst);
|
||||
}
|
||||
}
|
||||
|
|
@ -187,289 +191,289 @@ int init_call_log(void)
|
|||
* "1598364701.4",""
|
||||
*/
|
||||
// calling number
|
||||
token = DM_STRSTR(line, SEPARATOR);
|
||||
token = DM_LSTRSTR(line, SEPARATOR);
|
||||
CHECK_RESULT(token);
|
||||
token += SEPARATOR_SIZE;
|
||||
end = DM_STRSTR(token, SEPARATOR);
|
||||
end = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.calling_num, token, end - token + 1);
|
||||
// called number
|
||||
token = end + SEPARATOR_SIZE;
|
||||
end = DM_STRSTR(token, SEPARATOR);
|
||||
end = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.called_num, token, end - token + 1);
|
||||
// source
|
||||
token = end + SEPARATOR_SIZE; // sip0 in the last example
|
||||
token = DM_STRSTR(token, SEPARATOR);
|
||||
token = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(token);
|
||||
token += SEPARATOR_SIZE; // ""8001"" <8001> in the last example
|
||||
token = DM_STRSTR(token, SEPARATOR);
|
||||
token = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(token);
|
||||
token += SEPARATOR_SIZE; // TELCHAN/5/1 in the last example
|
||||
end = DM_STRSTR(token, SEPARATOR);
|
||||
end = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.source, token, end - token + 1);
|
||||
// destination
|
||||
token = end + SEPARATOR_SIZE; // SIP/sip0-00000001 in the last example
|
||||
end = DM_STRSTR(token, SEPARATOR);
|
||||
end = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.destination, token, end - token + 1);
|
||||
// start time and end time
|
||||
token = end + SEPARATOR_SIZE; // Dial in the last example
|
||||
token = DM_STRSTR(token, SEPARATOR);
|
||||
token = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(token);
|
||||
token += SEPARATOR_SIZE; // SIP/7001@sip0,,gT in the last example
|
||||
token = DM_STRSTR(token, SEPARATOR);
|
||||
token = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(token);
|
||||
token += SEPARATOR_SIZE; // The first date
|
||||
end = DM_STRSTR(token, "\",,\"");
|
||||
end = DM_LSTRSTR(token, "\",,\"");
|
||||
if (end) {
|
||||
// Not answered, e.g. "2020-08-27 11:02:40",,"2020-08-27 11:02:40",21,11,
|
||||
DM_STRNCPY(cdr.start_time, token, end - token + 1);
|
||||
token = end + 4;
|
||||
} else {
|
||||
// Answered, e.g. "2020-08-25 16:11:41","2020-08-25 16:11:50","2020-08-25 16:12:02",21,11,
|
||||
end = DM_STRSTR(token, SEPARATOR);
|
||||
end = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.start_time, token, end - token + 1);
|
||||
token = DM_STRSTR(end + SEPARATOR_SIZE, SEPARATOR); // Skip the middle date and come to the last date
|
||||
token = DM_LSTRSTR(end + SEPARATOR_SIZE, SEPARATOR); // Skip the middle date and come to the last date
|
||||
CHECK_RESULT(token);
|
||||
token += SEPARATOR_SIZE;
|
||||
}
|
||||
end = DM_STRSTR(token, "\",");
|
||||
end = DM_LSTRSTR(token, "\",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(end_time, token, end - token + 1);
|
||||
// termination cause
|
||||
token = DM_STRSTR(end + 2, ",\""); // ANSWERED in the last example
|
||||
token = DM_LSTRSTR(end + 2, ",\""); // ANSWERED in the last example
|
||||
CHECK_RESULT(token);
|
||||
token += 2;
|
||||
end = DM_STRSTR(token, SEPARATOR);
|
||||
end = DM_LSTRSTR(token, SEPARATOR);
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.termination_cause, token, end - token + 1);
|
||||
|
||||
// session id
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.sessionId, token, end - token + 1);
|
||||
|
||||
// SIP IP Address
|
||||
token = DM_STRSTR(token, ",\"");
|
||||
token = DM_LSTRSTR(token, ",\"");
|
||||
CHECK_RESULT(token);
|
||||
token += 2;
|
||||
end = DM_STRSTR(token, "\",");
|
||||
end = DM_LSTRSTR(token, "\",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.sipIpAddress, token, end - token + 1);
|
||||
|
||||
// Far End IP Address
|
||||
token = DM_STRSTR(token, ",\"");
|
||||
token = DM_LSTRSTR(token, ",\"");
|
||||
CHECK_RESULT(token);
|
||||
token += 2;
|
||||
end = DM_STRSTR(token, "\",");
|
||||
end = DM_LSTRSTR(token, "\",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.farEndIPAddress, token, end - token + 1);
|
||||
|
||||
// Sip Response Code
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.sipResponseCode, token, end - token + 1);
|
||||
|
||||
// Codec
|
||||
token = DM_STRSTR(token, ",\"");
|
||||
token = DM_LSTRSTR(token, ",\"");
|
||||
CHECK_RESULT(token);
|
||||
token += 2;
|
||||
end = DM_STRSTR(token, "\",");
|
||||
end = DM_LSTRSTR(token, "\",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.codec, token, end - token + 1);
|
||||
|
||||
// RTP statistic values
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.localBurstDensity, token, end - token + 1);
|
||||
// for incoming unanswered call cdr does not contain RTP stats
|
||||
if (strcasecmp(cdr.localBurstDensity, "\"DOCUMENTATION\"") == 0) {
|
||||
cdr.localBurstDensity[0] = '\0';
|
||||
} else {
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.remoteBurstDensity, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.localBurstDuration, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.remoteBurstDuration, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.localGapDensity, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.remoteGapDensity, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.localGapDuration, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.remoteGapDuration, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.localJbRate, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.remoteJbRate, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.localJbMax, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.remoteJbMax, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.localJbNominal, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.remoteJbNominal, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.localJbAbsMax, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.remoteJbAbsMax, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.jbAvg, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.uLossRate, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.discarded, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.lost, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.rxpkts, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.txpkts, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.jitter, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.maxJitter, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.averageRoundTripDelay, token, end - token + 1);
|
||||
|
||||
token = DM_STRSTR(token, ",");
|
||||
token = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(token);
|
||||
token += 1;
|
||||
end = DM_STRSTR(token, ",");
|
||||
end = DM_LSTRSTR(token, ",");
|
||||
CHECK_RESULT(end);
|
||||
DM_STRNCPY(cdr.averageFarEndInterarrivalJitter, token, end - token + 1);
|
||||
}
|
||||
|
|
@ -545,8 +549,16 @@ int init_call_log(void)
|
|||
if (i < call_log_list_size) {
|
||||
if (i > 0) {
|
||||
pos = pos->next;
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
entry = list_entry(pos, struct call_log_entry, list);
|
||||
} else {
|
||||
/* list_first_entry() is an external macro and which cppcheck can't
|
||||
* track so throws warning of null pointer dereferencing for second
|
||||
* argument. Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
entry = list_first_entry(&call_log_list, struct call_log_entry, list);
|
||||
pos = &entry->list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -585,6 +585,10 @@ static int get_ServicesVoiceServiceCallControlLine_CallStatus(char *refparam, st
|
|||
|
||||
snprintf(line_str, sizeof(line_str), "%ld", instance ? DM_STRTOL(instance) - 1 : 0);
|
||||
dmubus_call("asterisk", "call_status", UBUS_ARGS{{"line", line_str, Integer}}, 1, &res);
|
||||
/* value of res is being changed inside dmubus_call through pointer referencing
|
||||
* which cppcheck can't track hence throws warning for 'res' value always false.
|
||||
* So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
*value = dmjson_get_value(res, 1, "call_status");
|
||||
} else {
|
||||
|
|
@ -933,7 +937,7 @@ static int get_ServicesVoiceServiceCallControlExtension_Provider(char *refparam,
|
|||
while (ptr != NULL) {
|
||||
char *linker = NULL;
|
||||
|
||||
adm_entry_get_linker_param(ctx, "Device.Services.VoiceService.", !DM_STRCMP(type, "fxs") ? section_name(((struct dmmap_dup *)data)->config_section) : ptr, &linker);
|
||||
adm_entry_get_linker_param(ctx, "Device.Services.VoiceService.", !DM_LSTRCMP(type, "fxs") ? section_name(((struct dmmap_dup *)data)->config_section) : ptr, &linker);
|
||||
if (linker && *linker)
|
||||
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", linker);
|
||||
|
||||
|
|
@ -975,7 +979,7 @@ static int set_ServicesVoiceServiceCallControlExtension_Provider(char *refparam,
|
|||
for (pch = strtok_r(value_buf, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch)) {
|
||||
char *linker = NULL;
|
||||
|
||||
if (strncmp(pch, !DM_STRCMP(type, "fxs") ? fxs_extension : dect_extension, !DM_STRCMP(type, "fxs") ? fxs_len : dect_len) != 0)
|
||||
if (strncmp(pch, !DM_LSTRCMP(type, "fxs") ? fxs_extension : dect_extension, !DM_LSTRCMP(type, "fxs") ? fxs_len : dect_len) != 0)
|
||||
return FAULT_9007;
|
||||
|
||||
adm_entry_get_linker_value(ctx, pch, &linker);
|
||||
|
|
@ -993,9 +997,9 @@ static int set_ServicesVoiceServiceCallControlExtension_Provider(char *refparam,
|
|||
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s", ",");
|
||||
|
||||
adm_entry_get_linker_value(ctx, pch, &linker);
|
||||
if(!DM_STRCMP(linker, "extension3"))
|
||||
if(!DM_LSTRCMP(linker, "extension3"))
|
||||
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s", "fxs1");
|
||||
else if(!DM_STRCMP(linker, "extension4"))
|
||||
else if(!DM_LSTRCMP(linker, "extension4"))
|
||||
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s", "fxs2");
|
||||
else
|
||||
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s", linker);
|
||||
|
|
@ -1071,6 +1075,10 @@ static int get_ServicesVoiceServiceCallControlExtension_CallStatus(char *refpara
|
|||
|
||||
snprintf(ext_str, sizeof(ext_str), "%ld", instance ? DM_STRTOL(instance) - 1 : 0);
|
||||
dmubus_call("asterisk", "call_status", UBUS_ARGS{{"extension", ext_str, Integer}}, 1, &res);
|
||||
/* value of res is being changed inside dmubus_call through pointer referencing
|
||||
* which cppcheck can't track hence throws warning for 'res' value always false.
|
||||
* So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
*value = dmjson_get_value(res, 1, "call_status");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ static int browseServicesVoiceServiceDECTBaseInst(struct dmctx *dmctx, DMNODE *p
|
|||
char *inst = NULL;
|
||||
|
||||
dmubus_call("dect", "status", UBUS_ARGS{0}, 0, &res);
|
||||
/* value of res is being changed inside dmubus_call through pointer referencing
|
||||
* which cppcheck can't track hence throws warning for 'res' value always false.
|
||||
* So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
int id = 0, i = 0;
|
||||
|
||||
|
|
@ -50,6 +54,10 @@ static int browseServicesVoiceServiceDECTPortableInst(struct dmctx *dmctx, DMNOD
|
|||
char *inst = NULL;
|
||||
|
||||
dmubus_call("dect", "status", UBUS_ARGS{0}, 0, &res);
|
||||
/* value of res is being changed inside dmubus_call through pointer referencing
|
||||
* which cppcheck can't track hence throws warning for 'res' value always false.
|
||||
* So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
int id = 0, i = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -188,6 +188,10 @@ static int get_ServicesVoiceServiceSIPClient_Status(char *refparam, struct dmctx
|
|||
json_object *res = NULL, *sip = NULL, *client = NULL;
|
||||
|
||||
dmubus_call("voice.asterisk", "status", UBUS_ARGS{0}, 0, &res);
|
||||
/* value of res is being changed inside dmubus_call through pointer referencing
|
||||
* which cppcheck can't track hence throws warning for 'res' value always false.
|
||||
* So suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
sip = dmjson_get_obj(res, 1, "sip");
|
||||
if (sip) {
|
||||
|
|
@ -367,7 +371,7 @@ static int get_ServicesVoiceServiceSIPClientContact_ExpireTime(char *refparam, s
|
|||
}
|
||||
if (period <= 0) {
|
||||
BBF_DEBUG("Use default registration expires\n");
|
||||
period = DM_STRTOL(DEFAULT_SIP_REGISTER_EXPIRY_STR);
|
||||
period = strtol(DEFAULT_SIP_REGISTER_EXPIRY_STR, NULL, 10);
|
||||
}
|
||||
time_expires = time_last + period;
|
||||
|
||||
|
|
@ -910,7 +914,7 @@ static int set_ServicesVoiceServiceSIPNetwork_CodecList(char *refparam, struct d
|
|||
static int get_ServicesVoiceServiceSIPNetworkFQDNServer_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("asterisk", "sip_options", "srvlookup", value);
|
||||
*value = (DM_STRCMP(*value, "yes") == 0) ? "1" : "0";
|
||||
*value = (DM_LSTRCMP(*value, "yes") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ static int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Requested") == 0) {
|
||||
if (DM_LSTRCMP(value, "Requested") == 0) {
|
||||
IPPING_STOP
|
||||
set_diagnostics_option("ipping", "DiagnosticState", value);
|
||||
bbf_set_end_session_flag(ctx, BBF_END_SESSION_IPPING_DIAGNOSTIC);
|
||||
|
|
@ -281,7 +281,7 @@ static int set_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct d
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Requested") == 0) {
|
||||
if (DM_LSTRCMP(value, "Requested") == 0) {
|
||||
TRACEROUTE_STOP
|
||||
set_diagnostics_option("traceroute", "DiagnosticState", value);
|
||||
bbf_set_end_session_flag(ctx, BBF_END_SESSION_TRACEROUTE_DIAGNOSTIC);
|
||||
|
|
@ -528,7 +528,7 @@ static int set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam,
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Requested") == 0) {
|
||||
if (DM_LSTRCMP(value, "Requested") == 0) {
|
||||
DOWNLOAD_DIAGNOSTIC_STOP
|
||||
set_diagnostics_option("download", "DiagnosticState", value);
|
||||
bbf_set_end_session_flag(ctx, BBF_END_SESSION_DOWNLOAD_DIAGNOSTIC);
|
||||
|
|
@ -858,7 +858,7 @@ static int set_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, s
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Requested") == 0) {
|
||||
if (DM_LSTRCMP(value, "Requested") == 0) {
|
||||
UPLOAD_DIAGNOSTIC_STOP
|
||||
set_diagnostics_option("upload", "DiagnosticState", value);
|
||||
bbf_set_end_session_flag(ctx, BBF_END_SESSION_UPLOAD_DIAGNOSTIC);
|
||||
|
|
@ -1205,7 +1205,7 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam,
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Requested") == 0) {
|
||||
if (DM_LSTRCMP(value, "Requested") == 0) {
|
||||
UDPECHO_STOP;
|
||||
set_diagnostics_option("udpechodiag", "DiagnosticState", value);
|
||||
bbf_set_end_session_flag(ctx, BBF_END_SESSION_UDPECHO_DIAGNOSTIC);
|
||||
|
|
@ -1468,7 +1468,7 @@ static int set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *re
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Requested") == 0) {
|
||||
if (DM_LSTRCMP(value, "Requested") == 0) {
|
||||
SERVERSELECTION_STOP
|
||||
set_diagnostics_option("serverselection", "DiagnosticState", value);
|
||||
bbf_set_end_session_flag(ctx, BBF_END_SESSION_SERVERSELECTION_DIAGNOSTIC);
|
||||
|
|
@ -2181,7 +2181,7 @@ static int operate_IPDiagnostics_ServerSelectionDiagnostics(char *refparam, stru
|
|||
|
||||
char *port = dmjson_get_value((json_object *)value, 1, "Port");
|
||||
char *proto = dmjson_get_value((json_object *)value, 1, "Protocol");
|
||||
if (DM_STRCMP(proto, "ICMP") && port[0] == '\0')
|
||||
if (DM_LSTRCMP(proto, "ICMP") && port[0] == '\0')
|
||||
return CMD_INVALID_ARGUMENTS;
|
||||
|
||||
char *protocol_version = dmjson_get_value((json_object *)value, 1, "ProtocolVersion");
|
||||
|
|
|
|||
|
|
@ -42,19 +42,23 @@ static inline int init_atm_link(struct atm_args *args, struct dmmap_dup *s, char
|
|||
**************************************************************/
|
||||
void remove_device_from_interface(struct uci_section *interface_s, char *device)
|
||||
{
|
||||
char *curr_device = NULL, *pch = NULL, *spch = NULL;
|
||||
char *curr_device = NULL;
|
||||
char new_device[64] = {0};
|
||||
unsigned pos = 0;
|
||||
|
||||
dmuci_get_value_by_section_string(interface_s, "device", &curr_device);
|
||||
|
||||
new_device[0] = '\0';
|
||||
for (pch = strtok_r(curr_device, " ", &spch); pch; pch = strtok_r(NULL, " ", &spch)) {
|
||||
|
||||
if (DM_STRCMP(pch, device) == 0)
|
||||
continue;
|
||||
if (device != NULL) {
|
||||
char *pch = NULL, *spch = NULL;
|
||||
for (pch = strtok_r(curr_device, " ", &spch); pch; pch = strtok_r(NULL, " ", &spch)) {
|
||||
|
||||
pos += snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
|
||||
if (strcmp(pch, device) == 0)
|
||||
continue;
|
||||
|
||||
pos += snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
|
||||
}
|
||||
}
|
||||
|
||||
if (pos)
|
||||
|
|
@ -203,7 +207,7 @@ static int get_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
dmuci_get_value_by_section_string((((struct atm_args *)data)->sections)->config_section, "encapsulation", &encapsulation);
|
||||
|
||||
*value = (DM_STRCMP(encapsulation, "vcmux") == 0) ? "VCMUX" : "LLC";
|
||||
*value = (DM_LSTRCMP(encapsulation, "vcmux") == 0) ? "VCMUX" : "LLC";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +219,7 @@ static int set_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data,
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "encapsulation", (DM_STRCMP(value, "LLC") == 0) ? "llc" : "vcmux");
|
||||
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "encapsulation", (DM_LSTRCMP(value, "LLC") == 0) ? "llc" : "vcmux");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -227,13 +231,13 @@ static int get_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char
|
|||
char *link_type;
|
||||
|
||||
dmuci_get_value_by_section_string((((struct atm_args *)data)->sections)->config_section, "link_type", &link_type);
|
||||
if (DM_STRCMP(link_type, "eoa") == 0)
|
||||
if (DM_LSTRCMP(link_type, "eoa") == 0)
|
||||
*value = "EoA";
|
||||
else if (DM_STRCMP(link_type, "ipoa") == 0)
|
||||
else if (DM_LSTRCMP(link_type, "ipoa") == 0)
|
||||
*value = "IPoA";
|
||||
else if (DM_STRCMP(link_type, "pppoa") == 0)
|
||||
else if (DM_LSTRCMP(link_type, "pppoa") == 0)
|
||||
*value = "PPPoA";
|
||||
else if (DM_STRCMP(link_type, "cip") == 0)
|
||||
else if (DM_LSTRCMP(link_type, "cip") == 0)
|
||||
*value = "CIP";
|
||||
else
|
||||
*value = "Unconfigured";
|
||||
|
|
@ -248,13 +252,13 @@ static int set_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "EoA") == 0)
|
||||
if (DM_LSTRCMP(value, "EoA") == 0)
|
||||
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "eoa");
|
||||
else if (DM_STRCMP(value, "IPoA") == 0)
|
||||
else if (DM_LSTRCMP(value, "IPoA") == 0)
|
||||
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "ipoa");
|
||||
else if (DM_STRCMP(value, "PPPoA") == 0)
|
||||
else if (DM_LSTRCMP(value, "PPPoA") == 0)
|
||||
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "pppoa");
|
||||
else if (DM_STRCMP(value, "CIP") == 0)
|
||||
else if (DM_LSTRCMP(value, "CIP") == 0)
|
||||
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "cip");
|
||||
else
|
||||
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "");
|
||||
|
|
@ -285,7 +289,7 @@ static int set_atm_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (DM_STRNCMP(value, "Device.DSL.Channel.1", DM_STRLEN("Device.DSL.Channel.1")) != 0)
|
||||
if (DM_LSTRNCMP(value, "Device.DSL.Channel.1", strlen("Device.DSL.Channel.1")) != 0)
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -183,8 +183,8 @@ void bridging_get_vlan_tvid(char *uci_opt_name, void *data, char **value)
|
|||
|
||||
void bridging_set_vlan_tvid(char *uci_opt_name, void *data, char *value)
|
||||
{
|
||||
dmuci_set_value_by_section(((struct bridge_vlan_args *)data)->bridge_sec, uci_opt_name, !DM_STRCMP(value, "0") ? "" : value);
|
||||
dmuci_set_value_by_section(((struct bridge_vlan_args *)data)->bridge_vlan_sec, uci_opt_name, !DM_STRCMP(value, "0") ? "" : value);
|
||||
dmuci_set_value_by_section(((struct bridge_vlan_args *)data)->bridge_sec, uci_opt_name, !DM_LSTRCMP(value, "0") ? "" : value);
|
||||
dmuci_set_value_by_section(((struct bridge_vlan_args *)data)->bridge_vlan_sec, uci_opt_name, !DM_LSTRCMP(value, "0") ? "" : value);
|
||||
}
|
||||
|
||||
static void bridge_remove_related_device_section(struct uci_list *br_ports_list)
|
||||
|
|
@ -293,11 +293,11 @@ static void set_Provider_bridge_component(char *refparam, struct dmctx *ctx, voi
|
|||
}
|
||||
}
|
||||
|
||||
if (DM_STRCMP(component, "CVLAN") == 0) {
|
||||
if (DM_LSTRCMP(component, "CVLAN") == 0) {
|
||||
// Set svlan_br_inst in dmmap_provider_bridge->provider_bridge section
|
||||
|
||||
dmuci_add_list_value_by_section(((struct provider_bridge_args *)data)->provider_bridge_sec, "cvlan_br_inst", br_inst ? br_inst+1 : "");
|
||||
} else if (DM_STRCMP(component, "SVLAN") == 0) {
|
||||
} else if (DM_LSTRCMP(component, "SVLAN") == 0) {
|
||||
// Set svlan_br_inst in dmmap_provider_bridgei->provider_bridge section
|
||||
|
||||
dmuci_set_value_by_section(((struct provider_bridge_args *)data)->provider_bridge_sec, "svlan_br_inst", br_inst ? br_inst+1 : "");
|
||||
|
|
@ -308,7 +308,7 @@ static void set_Provider_bridge_component(char *refparam, struct dmctx *ctx, voi
|
|||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0)
|
||||
if (management && DM_LSTRCMP(management, "1") == 0)
|
||||
dmmap_bridge_section = s;// later used to find network->device(bridge) section name
|
||||
dmuci_set_value_by_section(s, "provider_br_inst", instance);
|
||||
}
|
||||
|
|
@ -496,7 +496,7 @@ static void dmmap_synchronizeBridgingProviderBridge(struct dmctx *dmctx, DMNODE
|
|||
dmuci_get_value_by_section_string(ss, "type", &type);
|
||||
|
||||
// If type is 8021ad, add to svlan
|
||||
if (type && DM_STRCMP(type,"8021ad") == 0 && !is_bridge_section_exist(e->name)) {
|
||||
if (type && DM_LSTRCMP(type,"8021ad") == 0 && !is_bridge_section_exist(e->name)) {
|
||||
|
||||
// Create device bridge dmmap section
|
||||
char *svlan_br_inst = create_dmmap_bridge_section(e->name);
|
||||
|
|
@ -506,7 +506,7 @@ static void dmmap_synchronizeBridgingProviderBridge(struct dmctx *dmctx, DMNODE
|
|||
}
|
||||
|
||||
// If type is 8021q, add to cvlan
|
||||
if (type && DM_STRCMP(type,"8021q") == 0 && !is_bridge_section_exist(e->name)) {
|
||||
if (type && DM_LSTRCMP(type,"8021q") == 0 && !is_bridge_section_exist(e->name)) {
|
||||
|
||||
// Create device bridge dmmap section
|
||||
char *cvlan_br_inst = create_dmmap_bridge_section(e->name);
|
||||
|
|
@ -548,7 +548,7 @@ static void dmmap_synchronizeBridgingBridgeVLAN(struct dmctx *dmctx, DMNODE *par
|
|||
// section added by user ==> skip it
|
||||
char *s_user = NULL;
|
||||
dmuci_get_value_by_section_string(s, "added_by_user", &s_user);
|
||||
if (s_user && DM_STRCMP(s_user, "1") == 0)
|
||||
if (s_user && DM_LSTRCMP(s_user, "1") == 0)
|
||||
continue;
|
||||
|
||||
// vid is available in ports list ==> skip it
|
||||
|
|
@ -633,7 +633,7 @@ static void dmmap_synchronizeBridgingBridgeVLANPort(struct dmctx *dmctx, DMNODE
|
|||
// section added by user ==> skip it
|
||||
char *s_user = NULL;
|
||||
dmuci_get_value_by_section_string(s, "added_by_user", &s_user);
|
||||
if (s_user && DM_STRCMP(s_user, "1") == 0)
|
||||
if (s_user && DM_LSTRCMP(s_user, "1") == 0)
|
||||
continue;
|
||||
|
||||
// port device is available in ports list ==> skip it
|
||||
|
|
@ -724,7 +724,7 @@ static bool is_bridge_management_port_exist(char *br_inst)
|
|||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0)
|
||||
if (management && DM_LSTRCMP(management, "1") == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -765,7 +765,7 @@ static void update_bridge_management_port(char *br_inst, char *linker)
|
|||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0) {
|
||||
if (management && DM_LSTRCMP(management, "1") == 0) {
|
||||
dmuci_set_value_by_section(s, "port", linker);
|
||||
return;
|
||||
}
|
||||
|
|
@ -809,13 +809,13 @@ static void dmmap_synchronizeBridgingBridgePort(struct dmctx *dmctx, DMNODE *par
|
|||
|
||||
// section added by user ==> skip it
|
||||
dmuci_get_value_by_section_string(s, "added_by_user", &s_user);
|
||||
if (s_user && DM_STRCMP(s_user, "1") == 0)
|
||||
if (s_user && DM_LSTRCMP(s_user, "1") == 0)
|
||||
continue;
|
||||
|
||||
// section for management ==> skip it
|
||||
char *management = NULL;
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0)
|
||||
if (management && DM_LSTRCMP(management, "1") == 0)
|
||||
continue;
|
||||
|
||||
// port device is available in ports list ==> skip it
|
||||
|
|
@ -835,7 +835,7 @@ static void dmmap_synchronizeBridgingBridgePort(struct dmctx *dmctx, DMNODE *par
|
|||
// section added by user ==> skip it
|
||||
get_dmmap_section_of_config_section("dmmap_bridge", "device", br_args->bridge_sec_name, &s);
|
||||
dmuci_get_value_by_section_string(s, "added_by_user", &s_user);
|
||||
if (s_user && DM_STRCMP(s_user, "1") != 0 && !is_bridge_management_port_exist(br_args->br_inst))
|
||||
if (s_user && DM_LSTRCMP(s_user, "1") != 0 && !is_bridge_management_port_exist(br_args->br_inst))
|
||||
create_new_bridge_port_section("network", "", br_args->br_inst, dev_name, br_args->bridge_sec_name, "1");
|
||||
|
||||
linker_buf[0] = 0;
|
||||
|
|
@ -878,7 +878,7 @@ end:
|
|||
linker_buf[pos - 1] = 0;
|
||||
|
||||
// Update the device linker for management port if it is not added by user
|
||||
if (s_user && DM_STRCMP(s_user, "1") != 0)
|
||||
if (s_user && DM_LSTRCMP(s_user, "1") != 0)
|
||||
update_bridge_management_port(br_args->br_inst, linker_buf);
|
||||
}
|
||||
|
||||
|
|
@ -1014,7 +1014,7 @@ static void update_device_management_port(char *old_name, char *new_name, char *
|
|||
char *management = NULL, *port = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
if (management && DM_STRCMP(management, "0") == 0)
|
||||
if (management && DM_LSTRCMP(management, "0") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "port", &port);
|
||||
|
|
@ -1024,7 +1024,9 @@ static void update_device_management_port(char *old_name, char *new_name, char *
|
|||
|
||||
new_port[0] = 0;
|
||||
for (pch = strtok_r(port, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch)) {
|
||||
if (!DM_STRSTR(pch, old_name)) {
|
||||
if (old_name == NULL) {
|
||||
pos += snprintf(&new_port[pos], sizeof(new_port) - pos, "%s,", pch);
|
||||
} else if (!strstr(pch, old_name)) {
|
||||
pos += snprintf(&new_port[pos], sizeof(new_port) - pos, "%s,", pch);
|
||||
} else {
|
||||
char *sec = DM_STRCHR(pch, '+');
|
||||
|
|
@ -1052,7 +1054,7 @@ static void remove_device_from_management_port(const struct bridge_port_args *da
|
|||
char *management = NULL, *port_linker = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
if (management && DM_STRCMP(management, "0") == 0)
|
||||
if (management && DM_LSTRCMP(management, "0") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "port", &port_linker);
|
||||
|
|
@ -1063,7 +1065,7 @@ static void remove_device_from_management_port(const struct bridge_port_args *da
|
|||
new_port[0] = 0;
|
||||
for (pch = strtok_r(port_linker, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch)) {
|
||||
|
||||
if (DM_STRCMP(pch, curr_linker) == 0)
|
||||
if (strcmp(pch, curr_linker) == 0)
|
||||
continue;
|
||||
|
||||
pos += snprintf(&new_port[pos], sizeof(new_port) - pos, "%s,", pch);
|
||||
|
|
@ -1219,7 +1221,7 @@ static char *fetch_and_configure_inner_vid(char *br_inst, char *type_val, char *
|
|||
|
||||
//Check if the bridge instances are same or not, if yes, then get the vid.
|
||||
if (instance && br_inst && DM_STRCMP(br_inst, instance) == 0) {
|
||||
if (type_val && DM_STRCMP(type_val, "8021ad") == 0)
|
||||
if (type_val && DM_LSTRCMP(type_val, "8021ad") == 0)
|
||||
dmuci_set_value_by_section(dev_s, "inner_vid", vid);
|
||||
else
|
||||
dmuci_get_value_by_section_string(dev_s, "vid", &cur_vid);
|
||||
|
|
@ -1265,7 +1267,7 @@ static int configure_device_type(const struct bridge_port_args *data, char *type
|
|||
|
||||
dmuci_set_value_by_section(data->bridge_port_sec, "type", type_value);
|
||||
|
||||
if (DM_STRNCMP(type_value, "8021q", 5) == 0) {
|
||||
if (DM_LSTRNCMP(type_value, "8021q", 5) == 0) {
|
||||
|
||||
//Check if the device has inner-vid if so then delete
|
||||
uci_foreach_sections("network", "device", s) {
|
||||
|
|
@ -1290,7 +1292,7 @@ static int configure_device_type(const struct bridge_port_args *data, char *type
|
|||
if (vid != NULL && vid[0] != '\0')
|
||||
fetch_and_configure_inner_vid(data->br_inst, "8021ad", vid);
|
||||
|
||||
} else if (DM_STRNCMP(type_value, "8021ad", 6) == 0) {
|
||||
} else if (DM_LSTRNCMP(type_value, "8021ad", 6) == 0) {
|
||||
char *cur_vid = NULL;
|
||||
|
||||
cur_vid = fetch_and_configure_inner_vid(data->br_inst, "8021q", "");
|
||||
|
|
@ -1316,7 +1318,7 @@ static void restore_bridge_config(char *vlan_br_inst)
|
|||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0) {
|
||||
if (management && DM_LSTRCMP(management, "1") == 0) {
|
||||
dmmap_br_sec = s;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1439,7 +1441,7 @@ void static get_rem_pr_br_instance(struct uci_section *pr_br_sec, char *bridge_i
|
|||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0) {
|
||||
if (management && DM_LSTRCMP(management, "1") == 0) {
|
||||
dmmap_br_port_sec = s;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1692,7 +1694,7 @@ static int delObjBridgingBridgePort(char *refparam, struct dmctx *ctx, void *dat
|
|||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "port", &port);
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "management", &management);
|
||||
|
||||
if ((port && port[0] == '\0') || (management && DM_STRCMP(management, "1") == 0)) {
|
||||
if ((port && port[0] == '\0') || (management && DM_LSTRCMP(management, "1") == 0)) {
|
||||
// Remove only dmmap section
|
||||
dmuci_delete_by_section_bbfdm(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, NULL, NULL);
|
||||
} else if (port && *port) {
|
||||
|
|
@ -1734,7 +1736,7 @@ static int delObjBridgingBridgePort(char *refparam, struct dmctx *ctx, void *dat
|
|||
dmuci_get_value_by_section_string(s, "port", &port);
|
||||
dmuci_get_value_by_section_string(s, "management", &management);
|
||||
|
||||
if ((port && port[0] != '\0') && (management && DM_STRCMP(management, "0") == 0)) {
|
||||
if ((port && port[0] != '\0') && (management && DM_LSTRCMP(management, "0") == 0)) {
|
||||
struct uci_section *ss = NULL;
|
||||
|
||||
// Remove network option from wireless wifi-iface section
|
||||
|
|
@ -2006,7 +2008,7 @@ static int set_BridgingBridge_Enable(char *refparam, struct dmctx *ctx, void *da
|
|||
static int get_BridgingBridge_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_BridgingBridge_Enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2099,7 +2101,7 @@ static int get_BridgingBridgePort_Enable(char *refparam, struct dmctx *ctx, void
|
|||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0) {
|
||||
if (management && DM_LSTRCMP(management, "1") == 0) {
|
||||
*value = "1";
|
||||
} else {
|
||||
char *eth_ports = NULL;
|
||||
|
|
@ -2114,7 +2116,7 @@ static int get_BridgingBridgePort_Enable(char *refparam, struct dmctx *ctx, void
|
|||
// ports config => ethport sections
|
||||
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct bridge_port_args *)data)->bridge_port_sec, "enabled", "1");
|
||||
} else if (config && !DM_STRCMP(config, "wireless")) {
|
||||
} else if (config && !DM_LSTRCMP(config, "wireless")) {
|
||||
// wireless config => wifi-iface sections
|
||||
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_sec, "disabled", value);
|
||||
|
|
@ -2146,7 +2148,7 @@ static int set_BridgingBridgePort_Enable(char *refparam, struct dmctx *ctx, void
|
|||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0) {
|
||||
if (management && DM_LSTRCMP(management, "1") == 0) {
|
||||
break;
|
||||
} else {
|
||||
char *eth_ports = NULL;
|
||||
|
|
@ -2161,7 +2163,7 @@ static int set_BridgingBridgePort_Enable(char *refparam, struct dmctx *ctx, void
|
|||
// ports config => ethport sections
|
||||
|
||||
dmuci_set_value_by_section(((struct bridge_port_args *)data)->bridge_port_sec, "enabled", b ? "1" : "0");
|
||||
} else if (config && !DM_STRCMP(config, "wireless")) {
|
||||
} else if (config && !DM_LSTRCMP(config, "wireless")) {
|
||||
// wireless config => wifi-iface sections
|
||||
|
||||
dmuci_set_value_by_section(((struct bridge_port_args *)data)->bridge_port_sec, "disabled", b ? "0" : "1");
|
||||
|
|
@ -2175,7 +2177,7 @@ static int set_BridgingBridgePort_Enable(char *refparam, struct dmctx *ctx, void
|
|||
static int get_BridgingBridgePort_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_BridgingBridgePort_Enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Up" : "Down";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Up" : "Down";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2211,7 +2213,7 @@ static int get_BridgingBridgePort_Name(char *refparam, struct dmctx *ctx, void *
|
|||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") != 0)
|
||||
if (management && DM_LSTRCMP(management, "1") != 0)
|
||||
*value = dmstrdup(((struct bridge_port_args *)data)->br_port_device);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2223,7 +2225,7 @@ static int get_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx,
|
|||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "management", &management);
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "port", &port_device);
|
||||
|
||||
if (management && DM_STRCMP(management, "1") == 0) {
|
||||
if (management && DM_LSTRCMP(management, "1") == 0) {
|
||||
char *pch = NULL, *spch = NULL;
|
||||
char lbuf[1024] = { 0, 0 };
|
||||
unsigned pos = 0;
|
||||
|
|
@ -2244,7 +2246,7 @@ static int get_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx,
|
|||
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "config", &config);
|
||||
|
||||
if (config && DM_STRCMP(config, "network") == 0) {
|
||||
if (config && DM_LSTRCMP(config, "network") == 0) {
|
||||
char *tag = port_device ? DM_STRCHR(port_device, '.') : NULL;
|
||||
if (tag) tag[0] = '\0';
|
||||
}
|
||||
|
|
@ -2277,7 +2279,7 @@ static int set_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx,
|
|||
if (dm_validate_string_list(value, -1, -1, 1024, -1, -1, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
if (management && DM_STRCMP(management, "1") == 0)
|
||||
if (management && DM_LSTRCMP(management, "1") == 0)
|
||||
break;
|
||||
|
||||
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
|
||||
|
|
@ -2285,7 +2287,7 @@ static int set_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx,
|
|||
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (management && DM_STRCMP(management, "1") == 0) {
|
||||
if (management && DM_LSTRCMP(management, "1") == 0) {
|
||||
/* Management Port ==> true */
|
||||
return set_lowerlayers_management_port(ctx, data, value);
|
||||
} else {
|
||||
|
|
@ -2300,7 +2302,7 @@ static int set_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx,
|
|||
}
|
||||
|
||||
// Update config section on dmmap_bridge_port if the linker is wirelss port or network port
|
||||
if (DM_STRNCMP(value, "Device.WiFi.SSID.", 17) == 0) {
|
||||
if (DM_LSTRNCMP(value, "Device.WiFi.SSID.", 17) == 0) {
|
||||
dmuci_set_value_by_section(((struct bridge_port_args *)data)->bridge_port_dmmap_sec, "config", "wireless");
|
||||
is_wireless_config = true;
|
||||
} else
|
||||
|
|
@ -2446,7 +2448,7 @@ static int set_BridgingBridgePort_DefaultUserPriority(char *refparam, struct dmc
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_sec, "type", &type);
|
||||
if (type[0] != '\0' && (DM_STRCMP(type, "untagged") == 0 || DM_STRCMP(type, "8021q") == 0))
|
||||
if (type[0] != '\0' && (DM_LSTRCMP(type, "untagged") == 0 || DM_LSTRCMP(type, "8021q") == 0))
|
||||
dmuci_set_value_by_section(((struct bridge_port_args *)data)->bridge_port_sec, "priority", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2491,7 +2493,7 @@ static int set_BridgingBridgePort_PVID(char *refparam, struct dmctx *ctx, void *
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_sec, "type", &type);
|
||||
if (type && type[0] != '\0' && (DM_STRCMP(type, "untagged") == 0 || DM_STRCMP(type, "8021q") == 0)) {
|
||||
if (type && type[0] != '\0' && (DM_LSTRCMP(type, "untagged") == 0 || DM_LSTRCMP(type, "8021q") == 0)) {
|
||||
char new_name[32] = {0};
|
||||
char *ifname = NULL;
|
||||
|
||||
|
|
@ -2531,9 +2533,9 @@ static int get_BridgingBridgePort_TPID(char *refparam, struct dmctx *ctx, void *
|
|||
char *type = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_sec, "type", &type);
|
||||
if (type && (DM_STRCMP(type, "8021q") == 0 || DM_STRCMP(type, "untagged") == 0))
|
||||
if (type && (DM_LSTRCMP(type, "8021q") == 0 || DM_LSTRCMP(type, "untagged") == 0))
|
||||
*value = "33024";
|
||||
else if (type && DM_STRCMP(type, "8021ad") == 0)
|
||||
else if (type && DM_LSTRCMP(type, "8021ad") == 0)
|
||||
*value = "34984";
|
||||
else
|
||||
*value = "37120";
|
||||
|
|
@ -2548,9 +2550,9 @@ static int set_BridgingBridgePort_TPID(char *refparam, struct dmctx *ctx, void *
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "33024") == 0)
|
||||
if (DM_LSTRCMP(value, "33024") == 0)
|
||||
configure_device_type((struct bridge_port_args *)data, "8021q");
|
||||
else if (DM_STRCMP(value, "34984") == 0)
|
||||
else if (DM_LSTRCMP(value, "34984") == 0)
|
||||
configure_device_type((struct bridge_port_args *)data, "8021ad");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2893,7 +2895,7 @@ static int set_BridgingBridgeVLANPort_VLAN(char *refparam, struct dmctx *ctx, vo
|
|||
|
||||
dmuci_set_value_by_section(((struct bridge_vlanport_args *)data)->bridge_vlanport_sec, "vid", "");
|
||||
} else {
|
||||
char *br = DM_STRSTR(linker, ":vlan_");
|
||||
char *br = DM_LSTRSTR(linker, ":vlan_");
|
||||
if (br) {
|
||||
char *new_vid = dmstrdup(br+6);
|
||||
|
||||
|
|
@ -3010,10 +3012,13 @@ static int set_BridgingBridgeVLANPort_Port(char *refparam, struct dmctx *ctx, vo
|
|||
dmuci_get_value_by_section_string(((struct bridge_vlanport_args *)data)->bridge_vlanport_dmmap_sec, "port_name", &port_name);
|
||||
dmuci_get_value_by_section_string(((struct bridge_vlanport_args *)data)->bridge_vlanport_sec, "name", &curr_name);
|
||||
|
||||
if (curr_name && *curr_name == 0)
|
||||
if (curr_name == NULL)
|
||||
return 0;
|
||||
|
||||
DM_STRNCPY(name, curr_name, sizeof(name));
|
||||
if (*curr_name == 0)
|
||||
return 0;
|
||||
|
||||
strncpy(name, curr_name, sizeof(name));
|
||||
char *tag = DM_STRCHR(curr_name, '.');
|
||||
if (tag) tag[0] = '\0';
|
||||
|
||||
|
|
@ -3115,7 +3120,7 @@ static int get_BridgingBridgeVLANPort_Untagged(char *refparam, struct dmctx *ctx
|
|||
{
|
||||
char *type;
|
||||
dmuci_get_value_by_section_string(((struct bridge_vlanport_args *)data)->bridge_vlanport_sec, "type", &type);
|
||||
*value = (DM_STRCMP(type, "untagged") == 0) ? "1" : "0";
|
||||
*value = (DM_LSTRCMP(type, "untagged") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -3162,7 +3167,7 @@ static int set_BridgingBridgeProviderBridge_Enable(char *refparam, struct dmctx
|
|||
static int get_BridgingBridgeProviderBridge_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct provider_bridge_args *)data)->provider_bridge_sec, "enable", value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ static int get_device_active_fwimage(char *refparam, struct dmctx *ctx, void *da
|
|||
dmubus_call("fwbank", "dump", UBUS_ARGS{0}, 0, &res);
|
||||
dmjson_foreach_obj_in_array(res, arrobj, bank_obj, i, 1, "bank") {
|
||||
active = dmjson_get_value(bank_obj, 1, "active");
|
||||
if (active && DM_STRCMP(active, "true") == 0) {
|
||||
if (active && DM_LSTRCMP(active, "true") == 0) {
|
||||
id = dmjson_get_value(bank_obj, 1, "id");
|
||||
break;
|
||||
}
|
||||
|
|
@ -273,7 +273,7 @@ static int get_device_boot_fwimage(char *refparam, struct dmctx *ctx, void *data
|
|||
dmubus_call("fwbank", "dump", UBUS_ARGS{0}, 0, &res);
|
||||
dmjson_foreach_obj_in_array(res, arrobj, bank_obj, i, 1, "bank") {
|
||||
boot = dmjson_get_value(bank_obj, 1, "boot");
|
||||
if (boot && DM_STRCMP(boot, "true") == 0) {
|
||||
if (boot && DM_LSTRCMP(boot, "true") == 0) {
|
||||
id = dmjson_get_value(bank_obj, 1, "id");
|
||||
break;
|
||||
}
|
||||
|
|
@ -307,7 +307,7 @@ static int set_device_boot_fwimage(char *refparam, struct dmctx *ctx, void *data
|
|||
|
||||
dmubus_call("fwbank", "set_bootbank", UBUS_ARGS{{"bank", bank_id+1, Integer}}, 1, &res);
|
||||
char *success = dmjson_get_value(res, 1, "success");
|
||||
if (DM_STRCMP(success, "true") != 0)
|
||||
if (DM_LSTRCMP(success, "true") != 0)
|
||||
return FAULT_9001;
|
||||
}
|
||||
}
|
||||
|
|
@ -589,9 +589,9 @@ static int get_DeviceInfoProcessor_Architecture(char *refparam, struct dmctx *ct
|
|||
if (uname(&utsname) < 0)
|
||||
return 0;
|
||||
|
||||
if (DM_STRSTR(utsname.machine, "arm") || DM_STRSTR(utsname.machine, "aarch64")) {
|
||||
if (DM_LSTRSTR(utsname.machine, "arm") || DM_LSTRSTR(utsname.machine, "aarch64")) {
|
||||
*value = "arm";
|
||||
} else if(DM_STRSTR(utsname.machine, "mips")) {
|
||||
} else if(DM_LSTRSTR(utsname.machine, "mips")) {
|
||||
const bool is_big_endian = IS_BIG_ENDIAN;
|
||||
*value = (is_big_endian) ? "mipseb" : "mipsel";
|
||||
} else
|
||||
|
|
@ -804,7 +804,7 @@ static int get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, c
|
|||
static int get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *state = dmjson_get_value((json_object *)data, 1, "state");
|
||||
*value = (state && DM_STRCMP(state, "Unknown") == 0) ? "Idle" : state;
|
||||
*value = (state && DM_LSTRCMP(state, "Unknown") == 0) ? "Idle" : state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
struct dhcp_lease {
|
||||
uint64_t ts;
|
||||
char hwaddr[20];
|
||||
char hwaddr[24];
|
||||
char ipaddr[16];
|
||||
struct list_head list;
|
||||
};
|
||||
|
|
@ -129,11 +129,11 @@ int set_section_order(char *package, char *dmpackage, char *sect_type, struct uc
|
|||
} else
|
||||
s = conf;
|
||||
|
||||
if (DM_STRCMP(order, "1") != 0 && s != NULL) {
|
||||
if (DM_LSTRCMP(order, "1") != 0 && s != NULL) {
|
||||
dmuci_set_value_by_section(s, "force", "");
|
||||
}
|
||||
|
||||
if (set_force == 1 && DM_STRCMP(order, "1") == 0 && s != NULL) {
|
||||
if (set_force == 1 && DM_LSTRCMP(order, "1") == 0 && s != NULL) {
|
||||
dmuci_set_value_by_section(s, "force", "1");
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ int set_section_order(char *package, char *dmpackage, char *sect_type, struct uc
|
|||
dmuci_get_value_by_section_string(dm, "section_name", §_name);
|
||||
get_config_section_of_dmmap_section(package, sect_type, sect_name, &s);
|
||||
dmasprintf(&incrorder, "%ld", DM_STRTOL(order)+1);
|
||||
if (s != NULL && DM_STRCMP(order, "1") == 0) {
|
||||
if (s != NULL && DM_LSTRCMP(order, "1") == 0) {
|
||||
dmuci_set_value_by_section(s, "force", "");
|
||||
}
|
||||
set_section_order(package, dmpackage, sect_type, dm, s, set_force, incrorder);
|
||||
|
|
@ -163,7 +163,7 @@ int get_value_in_mac_format(struct uci_section *s, char *option_name, bool type,
|
|||
macarray = strsplit(option_value, ":", &length);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s:", (macarray[i] && DM_STRCMP(macarray[i], "*") == 0) ? "00" : type ? "FF" : macarray[i]);
|
||||
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s:", (macarray[i] && DM_LSTRCMP(macarray[i], "*") == 0) ? "00" : type ? "FF" : macarray[i]);
|
||||
|
||||
if (pos)
|
||||
buf[pos - 1] = 0;
|
||||
|
|
@ -193,7 +193,7 @@ static void dmmap_synchronizeDHCPv4Client(struct dmctx *dmctx, DMNODE *parent_no
|
|||
char *iface_name = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "added_by_controller", &added_by_controller);
|
||||
if (DM_STRCMP(added_by_controller, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_controller, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
|
||||
|
|
@ -209,7 +209,7 @@ static void dmmap_synchronizeDHCPv4Client(struct dmctx *dmctx, DMNODE *parent_no
|
|||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "dhcp") != 0)
|
||||
if (DM_LSTRCMP(proto, "dhcp") != 0)
|
||||
continue;
|
||||
|
||||
if (is_dhcp_section_exist("dmmap_dhcp_client", section_name(s)))
|
||||
|
|
@ -231,7 +231,7 @@ static void dmmap_synchronizeDHCPv4RelayForwarding(struct dmctx *dmctx, DMNODE *
|
|||
char *iface_name = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "added_by_controller", &added_by_controller);
|
||||
if (DM_STRCMP(added_by_controller, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_controller, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
|
||||
|
|
@ -247,7 +247,7 @@ static void dmmap_synchronizeDHCPv4RelayForwarding(struct dmctx *dmctx, DMNODE *
|
|||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "relay") != 0)
|
||||
if (DM_LSTRCMP(proto, "relay") != 0)
|
||||
continue;
|
||||
|
||||
if (is_dhcp_section_exist("dmmap_dhcp_relay", section_name(s)))
|
||||
|
|
@ -291,6 +291,10 @@ static int interface_get_ipv4(const char *iface, uint32_t *addr, unsigned *bits)
|
|||
int addr_cidr = -1;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS {{"interface", iface, String}}, 1, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res is always false. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
json_object *jobj;
|
||||
|
||||
|
|
@ -299,9 +303,9 @@ static int interface_get_ipv4(const char *iface, uint32_t *addr, unsigned *bits)
|
|||
return -1;
|
||||
|
||||
json_object_object_foreach(jobj, key, val) {
|
||||
if (!DM_STRCMP(key, "address"))
|
||||
if (!DM_LSTRCMP(key, "address"))
|
||||
addr_str = json_object_get_string(val);
|
||||
else if (!DM_STRCMP(key, "mask"))
|
||||
else if (!DM_LSTRCMP(key, "mask"))
|
||||
addr_cidr = json_object_get_int(val);
|
||||
}
|
||||
}
|
||||
|
|
@ -431,7 +435,7 @@ static char *get_dhcp_network_from_relay_list(char *net_list)
|
|||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (strcmp(net_list_arr[i], section_name(s)) == 0 && DM_STRCMP(proto, "dhcp") == 0)
|
||||
if (strcmp(net_list_arr[i], section_name(s)) == 0 && DM_LSTRCMP(proto, "dhcp") == 0)
|
||||
return net_list_arr[i];
|
||||
}
|
||||
}
|
||||
|
|
@ -518,6 +522,9 @@ static int set_DHCPv4ServerPool_Option_Value(struct uci_section *s, const char *
|
|||
struct uci_list *dhcp_option = NULL;
|
||||
char new_dhcp_option[256] = {0};
|
||||
|
||||
if (option == NULL || value == NULL)
|
||||
return 0;
|
||||
|
||||
dmuci_get_value_by_section_list(s, "dhcp_option", &dhcp_option);
|
||||
if (dhcp_option) {
|
||||
struct uci_element *e = NULL, *tmp = NULL;
|
||||
|
|
@ -578,7 +585,7 @@ static int browseDHCPv4ServerPoolInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
|
||||
// skip the section if option ignore = '1'
|
||||
dmuci_get_value_by_section_string(p->config_section, "ignore", &ignore);
|
||||
if (ignore && DM_STRCMP(ignore, "1") == 0)
|
||||
if (ignore && DM_LSTRCMP(ignore, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "interface", &interface);
|
||||
|
|
@ -613,7 +620,7 @@ static int browseDHCPv4ServerPoolStaticAddressInst(struct dmctx *dmctx, DMNODE *
|
|||
// Skip all reserved hosts
|
||||
char *host_name = NULL;
|
||||
dmuci_get_value_by_section_string(p->config_section, "name", &host_name);
|
||||
if (host_name && DM_STRCMP(host_name, "reserved") == 0)
|
||||
if (host_name && DM_LSTRCMP(host_name, "reserved") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_set_value_by_section(p->dmmap_section, "dhcp", ((struct dhcp_args *)prev_data)->interface);
|
||||
|
|
@ -674,7 +681,7 @@ static int browseDHCPv4ServerPoolClientOptionInst(struct dmctx *dmctx, DMNODE *p
|
|||
|
||||
if (DM_STRNCMP(macaddr, (char *)args->lease->hwaddr, 24) == 0) {
|
||||
|
||||
if (DM_STRCMP(vcid, "-") != 0) {
|
||||
if (DM_LSTRCMP(vcid, "-") != 0) {
|
||||
init_client_options_args(&curr_client_options_args, "60", dmstrdup(vcid));
|
||||
|
||||
inst = handle_instance_without_section(dmctx, parent_node, ++id);
|
||||
|
|
@ -683,7 +690,7 @@ static int browseDHCPv4ServerPoolClientOptionInst(struct dmctx *dmctx, DMNODE *p
|
|||
break;
|
||||
}
|
||||
|
||||
if (DM_STRCMP(clid, "-") != 0) {
|
||||
if (DM_LSTRCMP(clid, "-") != 0) {
|
||||
init_client_options_args(&curr_client_options_args, "61", dmstrdup(clid));
|
||||
|
||||
inst = handle_instance_without_section(dmctx, parent_node, ++id);
|
||||
|
|
@ -693,7 +700,7 @@ static int browseDHCPv4ServerPoolClientOptionInst(struct dmctx *dmctx, DMNODE *p
|
|||
}
|
||||
|
||||
|
||||
if (DM_STRCMP(ucid, "-") != 0) {
|
||||
if (DM_LSTRCMP(ucid, "-") != 0) {
|
||||
init_client_options_args(&curr_client_options_args, "77", dmstrdup(ucid));
|
||||
|
||||
inst = handle_instance_without_section(dmctx, parent_node, ++id);
|
||||
|
|
@ -1162,7 +1169,7 @@ static int delObjDHCPv4ClientSentOption(char *refparam, struct dmctx *ctx, void
|
|||
if (((struct dhcp_client_option_args *)data)->client_sect) {
|
||||
char *option_name = get_dhcp_option_name(DM_STRTOL(((struct dhcp_client_option_args *)data)->option_tag));
|
||||
|
||||
if (DM_STRCMP(option_name, "sendopts") == 0) {
|
||||
if (DM_LSTRCMP(option_name, "sendopts") == 0) {
|
||||
char *sendopts = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dhcp_client_option_args *)data)->client_sect, "sendopts", &sendopts);
|
||||
|
|
@ -1337,7 +1344,7 @@ static int delObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *
|
|||
static int get_DHCPv4ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((((struct dhcp_args *)data)->sections)->config_section, "dhcpv4", value);
|
||||
*value = (*value && DM_STRCMP(*value, "disabled") == 0) ? "0" : "1";
|
||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1362,7 +1369,7 @@ static int set_DHCPv4ServerPool_Enable(char *refparam, struct dmctx *ctx, void *
|
|||
static int get_DHCPv4ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((((struct dhcp_args *)data)->sections)->config_section, "dhcpv4", value);
|
||||
*value = (*value && DM_STRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
|
||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1478,16 +1485,16 @@ static int set_DHCPv4ServerPool_MinAddress(char *refparam, struct dmctx *ctx, vo
|
|||
char buf[32] = {0};
|
||||
|
||||
unsigned dhcp_start = ntohl(value_addr) - iface_net;
|
||||
unsigned dhcp_limit = start + limit - dhcp_start;
|
||||
int dhcp_limit = start + limit - dhcp_start;
|
||||
|
||||
// check if MinAddress > MaxAddress
|
||||
if ((int)dhcp_limit < 0)
|
||||
if (dhcp_limit < 0)
|
||||
return -1;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", dhcp_start);
|
||||
dmuci_set_value_by_section((((struct dhcp_args *)data)->sections)->config_section, "start", buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", dhcp_limit);
|
||||
snprintf(buf, sizeof(buf), "%d", dhcp_limit);
|
||||
dmuci_set_value_by_section((((struct dhcp_args *)data)->sections)->config_section, "limit", buf);
|
||||
|
||||
}
|
||||
|
|
@ -1567,7 +1574,7 @@ static int get_DHCPv4ServerPool_ReservedAddresses(char *refparam, struct dmctx *
|
|||
|
||||
char *host_name = NULL;
|
||||
dmuci_get_value_by_section_string(s, "name", &host_name);
|
||||
if (host_name && DM_STRCMP(host_name, "reserved") != 0)
|
||||
if (host_name && DM_LSTRCMP(host_name, "reserved") != 0)
|
||||
continue;
|
||||
|
||||
char *ip = NULL;
|
||||
|
|
@ -1617,7 +1624,7 @@ static int set_DHCPv4ServerPool_ReservedAddresses(char *refparam, struct dmctx *
|
|||
|
||||
char *host_name = NULL;
|
||||
dmuci_get_value_by_section_string(s, "name", &host_name);
|
||||
if (host_name && DM_STRCMP(host_name, "reserved") != 0)
|
||||
if (host_name && DM_LSTRCMP(host_name, "reserved") != 0)
|
||||
continue;
|
||||
|
||||
char *ip = NULL;
|
||||
|
|
@ -1869,7 +1876,7 @@ static int set_DHCPv4ServerPoolStaticAddress_Alias(char *refparam, struct dmctx
|
|||
|
||||
// Check if alias is assigned by user
|
||||
dmuci_get_value_by_section_string((((struct dhcp_host_args *)data)->host_sections)->dmmap_section, "dhcp_host_alias_assigned", &alias_assigned);
|
||||
if (alias_assigned && DM_STRCMP(alias_assigned, "1") == 0)
|
||||
if (alias_assigned && DM_LSTRCMP(alias_assigned, "1") == 0)
|
||||
return FAULT_9007;
|
||||
|
||||
// Check if alias exists
|
||||
|
|
@ -2196,7 +2203,7 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
|
|||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(interface_s, "proto", &proto);
|
||||
if (DM_STRNCMP(proto, "dhcp", 4) == 0) {
|
||||
if (DM_LSTRNCMP(proto, "dhcp", 4) == 0) {
|
||||
char dev_name[32];
|
||||
|
||||
snprintf(iface_name, sizeof(iface_name), "%s_4", linker);
|
||||
|
|
@ -2217,7 +2224,7 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
|
|||
|
||||
|
||||
dmuci_get_value_by_section_string(option_s, "enable", &enable);
|
||||
if (DM_STRCMP(enable, "1") == 0) {
|
||||
if (DM_LSTRCMP(enable, "1") == 0) {
|
||||
char *opt_tag = NULL;
|
||||
char *opt_value = NULL;
|
||||
|
||||
|
|
@ -2238,7 +2245,7 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
|
|||
char *enable = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(option_s, "enable", &enable);
|
||||
if (DM_STRCMP(enable, "1") == 0) {
|
||||
if (DM_LSTRCMP(enable, "1") == 0) {
|
||||
char *opt_tag = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(option_s, "option_tag", &opt_tag);
|
||||
|
|
@ -2264,7 +2271,7 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
|
|||
static int get_DHCPv4Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_DHCPv4Client_Enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2276,7 +2283,8 @@ static int get_DHCPv4Client_DHCPStatus(char *refparam, struct dmctx *ctx, void *
|
|||
if (dhcpv4_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcpv4_s), String}}, 1, &res);
|
||||
char *if_name = section_name(dhcpv4_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "Requesting");
|
||||
json_object *jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
|
||||
char *ipaddr = dmjson_get_value(jobj, 1, "address");
|
||||
|
|
@ -2306,8 +2314,10 @@ static int set_DHCPv4Client_Renew(char *refparam, struct dmctx *ctx, void *data,
|
|||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
if (!b) break;
|
||||
if (dhcpv4_s)
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", section_name(dhcpv4_s), String}}, 1);
|
||||
if (dhcpv4_s) {
|
||||
char *if_name = section_name(dhcpv4_s);
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", if_name, String}}, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2324,7 +2334,12 @@ static int get_DHCPv4Client_IPAddress(char *refparam, struct dmctx *ctx, void *d
|
|||
if (!ipaddr || *ipaddr == 0) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcpv4_s), String}}, 1, &res);
|
||||
char *if_name = section_name(dhcpv4_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res is always false. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
json_object *jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
|
||||
ipaddr = dmjson_get_value(jobj, 1, "address");
|
||||
|
|
@ -2347,7 +2362,12 @@ static int get_DHCPv4Client_SubnetMask(char *refparam, struct dmctx *ctx, void *
|
|||
if (!mask || *mask == 0) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcpv4_s), String}}, 1, &res);
|
||||
char *if_name = section_name(dhcpv4_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res is always false. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
json_object *jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
|
||||
mask = dmjson_get_value(jobj, 1, "mask");
|
||||
|
|
@ -2370,7 +2390,8 @@ static int get_DHCPv4Client_IPRouters(char *refparam, struct dmctx *ctx, void *d
|
|||
unsigned pos = 0, idx = 0;
|
||||
char list_ip[256] = {0};
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcpv4_s), String}}, 1, &res);
|
||||
char *if_name = section_name(dhcpv4_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
|
||||
list_ip[0] = 0;
|
||||
|
|
@ -2396,7 +2417,8 @@ static int get_DHCPv4Client_DNSServers(char *refparam, struct dmctx *ctx, void *
|
|||
if (dhcpv4_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcpv4_s), String}}, 1, &res);
|
||||
char *if_name = section_name(dhcpv4_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
*value = dmjson_get_value_array_all(res, ",", 1, "dns-server");
|
||||
}
|
||||
|
|
@ -2411,7 +2433,8 @@ static int get_DHCPv4Client_LeaseTimeRemaining(char *refparam, struct dmctx *ctx
|
|||
if (dhcpv4_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcpv4_s), String}}, 1, &res);
|
||||
char *if_name = section_name(dhcpv4_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 2, "data", "leasetime");
|
||||
}
|
||||
|
|
@ -2457,7 +2480,7 @@ static int set_DHCPv4ClientSentOption_Enable(char *refparam, struct dmctx *ctx,
|
|||
if (dhcp_client_s->client_sect) {
|
||||
option_name = get_dhcp_option_name(DM_STRTOL(dhcp_client_s->option_tag));
|
||||
|
||||
if (DM_STRCMP(option_name, "sendopts") == 0) {
|
||||
if (DM_LSTRCMP(option_name, "sendopts") == 0) {
|
||||
char tag_value[128] = {0};
|
||||
char *sendopts = NULL;
|
||||
|
||||
|
|
@ -2530,7 +2553,7 @@ static int set_DHCPv4ClientSentOption_Tag(char *refparam, struct dmctx *ctx, voi
|
|||
dmuci_get_value_by_section_string(dhcp_client_s->dmmap_sect, "dhcp_client_key", &dhcp_client_key);
|
||||
|
||||
new_option_name = get_dhcp_option_name(DM_STRTOL(value));
|
||||
if (DM_STRCMP(new_option_name ,"sendopts") == 0) {
|
||||
if (DM_LSTRCMP(new_option_name ,"sendopts") == 0) {
|
||||
if (tag_option_exists("dmmap_dhcp_client", "send_option", "dhcp_client_key", dhcp_client_key, "option_tag", value))
|
||||
return FAULT_9007;
|
||||
} else {
|
||||
|
|
@ -2549,7 +2572,7 @@ static int set_DHCPv4ClientSentOption_Tag(char *refparam, struct dmctx *ctx, voi
|
|||
old_option_name = get_dhcp_option_name(DM_STRTOL(dhcp_client_s->option_tag));
|
||||
new_option_name = get_dhcp_option_name(DM_STRTOL(value));
|
||||
|
||||
if (DM_STRCMP(old_option_name, "sendopts") == 0) {
|
||||
if (DM_LSTRCMP(old_option_name, "sendopts") == 0) {
|
||||
char old_tag_value[128] = {0};
|
||||
char *sendopts = NULL;
|
||||
|
||||
|
|
@ -2560,7 +2583,7 @@ static int set_DHCPv4ClientSentOption_Tag(char *refparam, struct dmctx *ctx, voi
|
|||
remove_elt_from_str_list(&sendopts, old_tag_value);
|
||||
dmuci_set_value_by_section(dhcp_client_s->client_sect, "sendopts", sendopts);
|
||||
|
||||
if (DM_STRCMP(new_option_name, "sendopts") == 0) {
|
||||
if (DM_LSTRCMP(new_option_name, "sendopts") == 0) {
|
||||
char new_tag_value[128] = {0};
|
||||
|
||||
snprintf(new_tag_value, sizeof(new_tag_value), "%s:%s", value, dhcp_client_s->value);
|
||||
|
|
@ -2577,7 +2600,7 @@ static int set_DHCPv4ClientSentOption_Tag(char *refparam, struct dmctx *ctx, voi
|
|||
if (option_value && *option_value) {
|
||||
dmuci_set_value_by_section(dhcp_client_s->client_sect, old_option_name, "");
|
||||
|
||||
if (DM_STRCMP(new_option_name, "sendopts") == 0) {
|
||||
if (DM_LSTRCMP(new_option_name, "sendopts") == 0) {
|
||||
char new_tag_value[128] = {0};
|
||||
char *sendopts = NULL;
|
||||
|
||||
|
|
@ -2626,7 +2649,7 @@ static int set_DHCPv4ClientSentOption_Value(char *refparam, struct dmctx *ctx, v
|
|||
if (dhcp_client_s->client_sect) {
|
||||
option_name = get_dhcp_option_name(DM_STRTOL(dhcp_client_s->option_tag));
|
||||
|
||||
if (DM_STRCMP(option_name, "sendopts") == 0) {
|
||||
if (DM_LSTRCMP(option_name, "sendopts") == 0) {
|
||||
char old_tag_value[128] = {0};
|
||||
char *sendopts = NULL;
|
||||
|
||||
|
|
@ -3069,7 +3092,7 @@ static int set_DHCPv4RelayForwarding_Enable(char *refparam, struct dmctx *ctx, v
|
|||
static int get_DHCPv4RelayForwarding_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_DHCPv4RelayForwarding_Enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -3289,8 +3312,10 @@ static int operate_DHCPv4Client_Renew(char *refparam, struct dmctx *ctx, void *d
|
|||
{
|
||||
struct uci_section *dhcpv4_s = ((struct dhcp_client_args *)data)->iface_s;
|
||||
|
||||
if (dhcpv4_s)
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", section_name(dhcpv4_s), String}}, 1);
|
||||
if (dhcpv4_s) {
|
||||
char *if_name = section_name(dhcpv4_s);
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", if_name, String}}, 1);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static void dmmap_synchronizeDHCPv6Client(struct dmctx *dmctx, DMNODE *parent_no
|
|||
char *iface_name = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "added_by_controller", &added_by_controller);
|
||||
if (DM_STRCMP(added_by_controller, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_controller, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
|
||||
|
|
@ -80,7 +80,7 @@ static void dmmap_synchronizeDHCPv6Client(struct dmctx *dmctx, DMNODE *parent_no
|
|||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "dhcpv6") != 0)
|
||||
if (DM_LSTRCMP(proto, "dhcpv6") != 0)
|
||||
continue;
|
||||
|
||||
if (is_dhcpv6_client_section_exist(section_name(s)))
|
||||
|
|
@ -178,7 +178,7 @@ static int browseDHCPv6ServerPoolInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
|
||||
// skip the section if option ignore = '1'
|
||||
dmuci_get_value_by_section_string(p->config_section, "ignore", &ignore);
|
||||
if (ignore && DM_STRCMP(ignore, "1") == 0)
|
||||
if (ignore && DM_LSTRCMP(ignore, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "interface", &interface);
|
||||
|
|
@ -206,7 +206,12 @@ static int browseDHCPv6ServerPoolClientInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
int i = 0;
|
||||
char *inst = NULL, *device;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcp_arg->dhcp_sections->config_section), String}}, 1, &res1);
|
||||
char *if_name = section_name(dhcp_arg->dhcp_sections->config_section);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res1);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as !res1 is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res1) return 0;
|
||||
device = dmjson_get_value(res1, 1, "device");
|
||||
dmubus_call("dhcp", "ipv6leases", UBUS_ARGS{0}, 0, &res);
|
||||
|
|
@ -418,7 +423,7 @@ static int delObjDHCPv6ServerPool(char *refparam, struct dmctx *ctx, void *data,
|
|||
char *dhcpv6 = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "dhcpv6", &dhcpv6);
|
||||
if (DM_STRCMP(dhcpv6, "server") == 0) {
|
||||
if (DM_LSTRCMP(dhcpv6, "server") == 0) {
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_dhcpv6", "dhcp", section_name(s), &dmmap_section);
|
||||
|
|
@ -617,7 +622,7 @@ static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
|
|||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(interface_s, "proto", &proto);
|
||||
if (DM_STRNCMP(proto, "dhcp", 4) == 0) {
|
||||
if (DM_LSTRNCMP(proto, "dhcp", 4) == 0) {
|
||||
char dev_name[32];
|
||||
|
||||
snprintf(iface_name, sizeof(iface_name), "%s_6", linker);
|
||||
|
|
@ -648,7 +653,7 @@ static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
|
|||
static int get_DHCPv6Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_DHCPv6Client_Enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -659,7 +664,12 @@ static int get_DHCPv6Client_DUID(char *refparam, struct dmctx *ctx, void *data,
|
|||
if (dhcpv6_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcpv6_s), String}}, 1, &res);
|
||||
char *if_name = section_name(dhcpv6_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(res) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
*value = res ? dmjson_get_value(res, 2, "data", "passthru") : "";
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -672,7 +682,7 @@ static int get_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx,
|
|||
char *reqaddress = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqaddress", &reqaddress);
|
||||
*value = (reqaddress && DM_STRCMP(reqaddress, "none") == 0) ? "0" : "1";
|
||||
*value = (reqaddress && DM_LSTRCMP(reqaddress, "none") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -703,7 +713,7 @@ static int get_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, v
|
|||
char *reqprefix = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqprefix", &reqprefix);
|
||||
*value = (reqprefix && DM_STRCMP(reqprefix, "auto") == 0) ? "1" : "0";
|
||||
*value = (reqprefix && DM_LSTRCMP(reqprefix, "auto") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -746,8 +756,10 @@ static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
|
|||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
if (!b) break;
|
||||
if (dhcpv6_s)
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", section_name(dhcpv6_s), String}}, 1);
|
||||
if (dhcpv6_s) {
|
||||
char *if_name = section_name(dhcpv6_s);
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", if_name, String}}, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -818,7 +830,7 @@ static int get_DHCPv6Server_PoolNumberOfEntries(char *refparam, struct dmctx *ct
|
|||
static int get_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "dhcpv6", value);
|
||||
*value = (*value && DM_STRCMP(*value, "disabled") == 0) ? "0" : "1";
|
||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -843,7 +855,7 @@ static int set_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *
|
|||
static int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "dhcpv6", value);
|
||||
*value = (*value && DM_STRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
|
||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1271,7 +1283,8 @@ static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, voi
|
|||
if (dhcpv6_client_s->option_tag && DM_STRCMP(dhcpv6_client_s->option_tag, value) == 0)
|
||||
break;
|
||||
|
||||
if (tag_option_exists("dmmap_dhcpv6", "servpool_option", "section_name", section_name(dhcpv6_client_s->client_sect), "option_tag", value))
|
||||
char *name = section_name(dhcpv6_client_s->client_sect);
|
||||
if (tag_option_exists("dmmap_dhcpv6", "servpool_option", "section_name", name, "option_tag", value))
|
||||
return FAULT_9007;
|
||||
|
||||
break;
|
||||
|
|
@ -1370,8 +1383,10 @@ static int operate_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *d
|
|||
{
|
||||
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s;
|
||||
|
||||
if (dhcpv6_s)
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", section_name(dhcpv6_s), String}}, 1);
|
||||
if (dhcpv6_s) {
|
||||
char *if_name = section_name(dhcpv6_s);
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", if_name, String}}, 1);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static int dmmap_synchronizeDNSClientRelayServer(struct dmctx *dmctx, DMNODE *pa
|
|||
bool found = false;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "added_by_controller", &added_by_controller);
|
||||
if (DM_STRCMP(added_by_controller, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_controller, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "ip", &ip);
|
||||
|
|
@ -72,7 +72,8 @@ static int dmmap_synchronizeDNSClientRelayServer(struct dmctx *dmctx, DMNODE *pa
|
|||
if (found)
|
||||
break;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ss), String}}, 1, &jobj);
|
||||
char *if_name = section_name(ss);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
|
||||
if (!jobj) break;
|
||||
dmjson_foreach_value_in_array(jobj, arrobj, ipdns, j, 1, "dns-server") {
|
||||
if (DM_STRCMP(ipdns, ip) == 0) {
|
||||
|
|
@ -109,7 +110,8 @@ static int dmmap_synchronizeDNSClientRelayServer(struct dmctx *dmctx, DMNODE *pa
|
|||
if (peerdns[0] == '0')
|
||||
continue;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &jobj);
|
||||
char *if_name = section_name(s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
|
||||
if (!jobj) break;
|
||||
dmjson_foreach_value_in_array(jobj, arrobj, ipdns, j, 1, "dns-server") {
|
||||
|
||||
|
|
@ -632,7 +634,7 @@ static int set_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmct
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Requested") == 0) {
|
||||
if (DM_LSTRCMP(value, "Requested") == 0) {
|
||||
NSLOOKUP_STOP
|
||||
set_diagnostics_option("nslookup", "DiagnosticState", value);
|
||||
bbf_set_end_session_flag(ctx, BBF_END_SESSION_NSLOOKUP_DIAGNOSTIC);
|
||||
|
|
|
|||
|
|
@ -172,6 +172,10 @@ static char *get_dsl_value_without_argument(char *command1, char *id, char *comm
|
|||
|
||||
snprintf(command, sizeof(command), "%s.%s", command1, id);
|
||||
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res is always false. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) return "";
|
||||
value = dmjson_get_value(res, 1, key);
|
||||
return value;
|
||||
|
|
@ -184,6 +188,10 @@ static char *get_dsl_value_without_argument_and_with_two_key(char *command1, cha
|
|||
|
||||
snprintf(command, sizeof(command), "%s.%s", command1, id);
|
||||
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res is always false. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) return "";
|
||||
value = dmjson_get_value(res, 2, key1, key2);
|
||||
return value;
|
||||
|
|
@ -196,6 +204,10 @@ char *get_value_with_argument(char *command1, char *id, char *command2, char *ar
|
|||
|
||||
snprintf(command, sizeof(command), "%s.%s", command1, id);
|
||||
dmubus_call(command, command2, UBUS_ARGS{{"interval", argument, String}}, 1, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res is always false. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) return "";
|
||||
value = dmjson_get_value(res, 1, key);
|
||||
return value;
|
||||
|
|
@ -208,6 +220,10 @@ static char *get_dsl_value_array_without_argument(char *command1, char *id, char
|
|||
|
||||
snprintf(command, sizeof(command), "%s.%s", command1, id);
|
||||
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res is always false. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) return "";
|
||||
value = dmjson_get_value_array_all(res, ",", 1, key);
|
||||
return value;
|
||||
|
|
@ -217,17 +233,17 @@ int get_line_linkstatus(char *method, char *id, char **value)
|
|||
{
|
||||
char *link_status = get_dsl_value_without_argument(method, id, "status", "link_status");
|
||||
|
||||
if (DM_STRCMP(link_status, "up") == 0)
|
||||
if (DM_LSTRCMP(link_status, "up") == 0)
|
||||
*value = "Up";
|
||||
else if (DM_STRCMP(link_status, "initializing") == 0)
|
||||
else if (DM_LSTRCMP(link_status, "initializing") == 0)
|
||||
*value = "Initializing";
|
||||
else if (DM_STRCMP(link_status, "no_signal") == 0)
|
||||
else if (DM_LSTRCMP(link_status, "no_signal") == 0)
|
||||
*value = "NoSignal";
|
||||
else if (DM_STRCMP(link_status, "disabled") == 0)
|
||||
else if (DM_LSTRCMP(link_status, "disabled") == 0)
|
||||
*value = "Disabled";
|
||||
else if (DM_STRCMP(link_status, "establishing") == 0)
|
||||
else if (DM_LSTRCMP(link_status, "establishing") == 0)
|
||||
*value = "EstablishingLink";
|
||||
else if (DM_STRCMP(link_status, "error") == 0)
|
||||
else if (DM_LSTRCMP(link_status, "error") == 0)
|
||||
*value = "Error";
|
||||
else
|
||||
*value = link_status;
|
||||
|
|
@ -255,7 +271,7 @@ static int get_DSL_ChannelNumberOfEntries(char *refparam, struct dmctx *ctx, voi
|
|||
static int get_DSLLine_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *status = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "status");
|
||||
*value = (DM_STRCMP(status, "up") == 0) ? "1" : "0";
|
||||
*value = (DM_LSTRCMP(status, "up") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +292,7 @@ static int set_DSLLine_Enable(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
static int get_DSLLine_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *status = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "status");
|
||||
*value = (DM_STRCMP(status, "up") == 0) ? "Up" : "Down";
|
||||
*value = (DM_LSTRCMP(status, "up") == 0) ? "Up" : "Down";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -351,55 +367,55 @@ static char *get_dsl_standard(char *str)
|
|||
{
|
||||
char *dsl_standard;
|
||||
|
||||
if(DM_STRCMP(str, "gdmt_annexa") == 0)
|
||||
if(DM_LSTRCMP(str, "gdmt_annexa") == 0)
|
||||
dsl_standard = "G.992.1_Annex_A";
|
||||
else if(DM_STRCMP(str, "gdmt_annexb") == 0)
|
||||
else if(DM_LSTRCMP(str, "gdmt_annexb") == 0)
|
||||
dsl_standard = "G.992.1_Annex_B";
|
||||
else if(DM_STRCMP(str, "gdmt_annexc") == 0)
|
||||
else if(DM_LSTRCMP(str, "gdmt_annexc") == 0)
|
||||
dsl_standard = "G.992.1_Annex_C";
|
||||
else if(DM_STRCMP(str, "t1413") == 0)
|
||||
else if(DM_LSTRCMP(str, "t1413") == 0)
|
||||
dsl_standard = "T1.413";
|
||||
else if(DM_STRCMP(str, "t1413_i2") == 0)
|
||||
else if(DM_LSTRCMP(str, "t1413_i2") == 0)
|
||||
dsl_standard = "T1.413i2";
|
||||
else if(DM_STRCMP(str, "glite") == 0)
|
||||
else if(DM_LSTRCMP(str, "glite") == 0)
|
||||
dsl_standard = "G.992.2";
|
||||
else if(DM_STRCMP(str, "etsi_101_388") == 0)
|
||||
else if(DM_LSTRCMP(str, "etsi_101_388") == 0)
|
||||
dsl_standard = "ETSI_101_388";
|
||||
else if(DM_STRCMP(str, "adsl2_annexa") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2_annexa") == 0)
|
||||
dsl_standard = "G.992.3_Annex_A";
|
||||
else if(DM_STRCMP(str, "adsl2_annexb") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2_annexb") == 0)
|
||||
dsl_standard = "G.992.3_Annex_B";
|
||||
else if(DM_STRCMP(str, "adsl2_annexc") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2_annexc") == 0)
|
||||
dsl_standard = "G.992.3_Annex_C";
|
||||
else if(DM_STRCMP(str, "adsl2_annexi") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2_annexi") == 0)
|
||||
dsl_standard = "G.992.3_Annex_I";
|
||||
else if(DM_STRCMP(str, "adsl2_annexj") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2_annexj") == 0)
|
||||
dsl_standard = "G.992.3_Annex_J";
|
||||
else if(DM_STRCMP(str, "adsl2_annexl") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2_annexl") == 0)
|
||||
dsl_standard = "G.992.3_Annex_L";
|
||||
else if(DM_STRCMP(str, "adsl2_annexm") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2_annexm") == 0)
|
||||
dsl_standard = "G.992.3_Annex_M";
|
||||
else if(DM_STRCMP(str, "splitterless_adsl2") == 0)
|
||||
else if(DM_LSTRCMP(str, "splitterless_adsl2") == 0)
|
||||
dsl_standard = "G.992.4";
|
||||
else if(DM_STRCMP(str, "adsl2p_annexa") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2p_annexa") == 0)
|
||||
dsl_standard = "G.992.5_Annex_A";
|
||||
else if(DM_STRCMP(str, "adsl2p_annexb") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2p_annexb") == 0)
|
||||
dsl_standard = "G.992.5_Annex_B";
|
||||
else if(DM_STRCMP(str, "adsl2p_annexc") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2p_annexc") == 0)
|
||||
dsl_standard = "G.992.5_Annex_C";
|
||||
else if(DM_STRCMP(str, "adsl2p_annexi") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2p_annexi") == 0)
|
||||
dsl_standard = "G.992.5_Annex_I";
|
||||
else if(DM_STRCMP(str, "adsl2p_annexj") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2p_annexj") == 0)
|
||||
dsl_standard = "G.992.5_Annex_J";
|
||||
else if(DM_STRCMP(str, "adsl2p_annexm") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2p_annexm") == 0)
|
||||
dsl_standard = "G.992.5_Annex_M";
|
||||
else if(DM_STRCMP(str, "vdsl") == 0)
|
||||
else if(DM_LSTRCMP(str, "vdsl") == 0)
|
||||
dsl_standard = "G.993.1";
|
||||
else if(DM_STRCMP(str, "vdsl2_annexa") == 0)
|
||||
else if(DM_LSTRCMP(str, "vdsl2_annexa") == 0)
|
||||
dsl_standard = "G.993.2_Annex_A";
|
||||
else if(DM_STRCMP(str, "vdsl2_annexb") == 0)
|
||||
else if(DM_LSTRCMP(str, "vdsl2_annexb") == 0)
|
||||
dsl_standard = "G.993.2_Annex_B";
|
||||
else if(DM_STRCMP(str, "vdsl2_annexc") == 0)
|
||||
else if(DM_LSTRCMP(str, "vdsl2_annexc") == 0)
|
||||
dsl_standard = "G.993.2_Annex_C";
|
||||
else
|
||||
dsl_standard = str;
|
||||
|
|
@ -489,17 +505,17 @@ static int get_DSLLine_XTSUsed(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
static int get_DSLLine_LineEncoding(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *line_encoding = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "line_encoding");
|
||||
if(DM_STRCMP(line_encoding, "dmt") == 0)
|
||||
if(DM_LSTRCMP(line_encoding, "dmt") == 0)
|
||||
*value = "DMT";
|
||||
else if(DM_STRCMP(line_encoding, "cap") == 0)
|
||||
else if(DM_LSTRCMP(line_encoding, "cap") == 0)
|
||||
*value = "CAP";
|
||||
else if(DM_STRCMP(line_encoding, "2b1q") == 0)
|
||||
else if(DM_LSTRCMP(line_encoding, "2b1q") == 0)
|
||||
*value = "2B1Q";
|
||||
else if(DM_STRCMP(line_encoding, "43bt") == 0)
|
||||
else if(DM_LSTRCMP(line_encoding, "43bt") == 0)
|
||||
*value = "43BT";
|
||||
else if(DM_STRCMP(line_encoding, "pam") == 0)
|
||||
else if(DM_LSTRCMP(line_encoding, "pam") == 0)
|
||||
*value = "PAM";
|
||||
else if(DM_STRCMP(line_encoding, "qam") == 0)
|
||||
else if(DM_LSTRCMP(line_encoding, "qam") == 0)
|
||||
*value = "QAM";
|
||||
else
|
||||
*value = line_encoding;
|
||||
|
|
@ -517,7 +533,7 @@ static int get_DSLLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void *
|
|||
static int get_DSLLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *current_profile = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "current_profile");
|
||||
*value = (current_profile && DM_STRCMP(current_profile, "unknown") == 0) ? "" : current_profile;
|
||||
*value = (current_profile && DM_LSTRCMP(current_profile, "unknown") == 0) ? "" : current_profile;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -525,15 +541,15 @@ static int get_DSLLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *d
|
|||
static int get_DSLLine_PowerManagementState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *power_mng_state = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "power_management_state");
|
||||
if(DM_STRCMP(power_mng_state, "l0") == 0)
|
||||
if(DM_LSTRCMP(power_mng_state, "l0") == 0)
|
||||
*value = "L0";
|
||||
else if(DM_STRCMP(power_mng_state, "l1") == 0)
|
||||
else if(DM_LSTRCMP(power_mng_state, "l1") == 0)
|
||||
*value = "L1";
|
||||
else if(DM_STRCMP(power_mng_state, "l2") == 0)
|
||||
else if(DM_LSTRCMP(power_mng_state, "l2") == 0)
|
||||
*value = "L2";
|
||||
else if(DM_STRCMP(power_mng_state, "l3") == 0)
|
||||
else if(DM_LSTRCMP(power_mng_state, "l3") == 0)
|
||||
*value = "L3";
|
||||
else if(DM_STRCMP(power_mng_state, "l4") == 0)
|
||||
else if(DM_LSTRCMP(power_mng_state, "l4") == 0)
|
||||
*value = "L4";
|
||||
else
|
||||
*value = power_mng_state;
|
||||
|
|
@ -934,7 +950,7 @@ static int get_DSLLineStatsQuarterHour_SeverelyErroredSecs(char *refparam, struc
|
|||
static int get_DSLChannel_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *status = get_dsl_value_without_argument("dsl.channel", ((struct dsl_channel_args*)data)->id, "status", "status");
|
||||
*value = (DM_STRCMP(status, "up") == 0) ? "1" : "0";
|
||||
*value = (DM_LSTRCMP(status, "up") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -955,17 +971,17 @@ static int set_DSLChannel_Enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
static int get_DSLChannel_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *status = get_dsl_value_without_argument("dsl.channel", ((struct dsl_channel_args*)data)->id, "status", "status");
|
||||
if (DM_STRCMP(status, "up") == 0)
|
||||
if (DM_LSTRCMP(status, "up") == 0)
|
||||
*value = "Up";
|
||||
else if (DM_STRCMP(status, "down") == 0)
|
||||
else if (DM_LSTRCMP(status, "down") == 0)
|
||||
*value = "Down";
|
||||
else if (DM_STRCMP(status, "dormant") == 0)
|
||||
else if (DM_LSTRCMP(status, "dormant") == 0)
|
||||
*value = "Dormant";
|
||||
else if (DM_STRCMP(status, "not_present") == 0)
|
||||
else if (DM_LSTRCMP(status, "not_present") == 0)
|
||||
*value = "NotPresent";
|
||||
else if (DM_STRCMP(status, "lower_layer_down") == 0)
|
||||
else if (DM_LSTRCMP(status, "lower_layer_down") == 0)
|
||||
*value = "LowerLayerDown";
|
||||
else if (DM_STRCMP(status, "error") == 0)
|
||||
else if (DM_LSTRCMP(status, "error") == 0)
|
||||
*value = "Error";
|
||||
else
|
||||
*value = "Unknown";
|
||||
|
|
@ -1013,13 +1029,13 @@ static char *get_dsl_link_encapsulation_standard(char *str)
|
|||
{
|
||||
char *dsl_link_encapsulation_standard = "";
|
||||
|
||||
if(DM_STRCMP(str, "adsl2_atm") == 0)
|
||||
if(DM_LSTRCMP(str, "adsl2_atm") == 0)
|
||||
dsl_link_encapsulation_standard = "G.992.3_Annex_K_ATM";
|
||||
else if(DM_STRCMP(str, "adsl2_ptm") == 0)
|
||||
else if(DM_LSTRCMP(str, "adsl2_ptm") == 0)
|
||||
dsl_link_encapsulation_standard = "G.992.3_Annex_K_PTM";
|
||||
else if(DM_STRCMP(str, "vdsl2_atm") == 0)
|
||||
else if(DM_LSTRCMP(str, "vdsl2_atm") == 0)
|
||||
dsl_link_encapsulation_standard = "G.993.2_Annex_K_ATM";
|
||||
else if(DM_STRCMP(str, "vdsl2_ptm") == 0)
|
||||
else if(DM_LSTRCMP(str, "vdsl2_ptm") == 0)
|
||||
dsl_link_encapsulation_standard = "G.993.2_Annex_K_PTM";
|
||||
else
|
||||
dsl_link_encapsulation_standard = "G.994.1";
|
||||
|
|
@ -1055,7 +1071,7 @@ static int get_DSLChannel_LinkEncapsulationSupported(char *refparam, struct dmct
|
|||
static int get_DSLChannel_LinkEncapsulationUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *link_encapsulation_used = get_dsl_value_without_argument("dsl.channel", ((struct dsl_channel_args*)data)->id, "status", "link_encapsulation_used");
|
||||
*value = (DM_STRCMP(link_encapsulation_used, "auto") != 0) ? get_dsl_link_encapsulation_standard(link_encapsulation_used) : "G.993.2_Annex_K_PTM";
|
||||
*value = (DM_LSTRCMP(link_encapsulation_used, "auto") != 0) ? get_dsl_link_encapsulation_standard(link_encapsulation_used) : "G.993.2_Annex_K_PTM";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ static int dmmap_synchronizeDynamicDNSServer(struct dmctx *dmctx, DMNODE *parent
|
|||
|
||||
uci_foreach_sections("ddns", "service", s) {
|
||||
dmuci_get_value_by_section_string(s, "service_name", &service_name);
|
||||
if (service_name == NULL)
|
||||
continue;
|
||||
|
||||
if (*service_name == '\0')
|
||||
continue;
|
||||
dmuci_get_value_by_section_string(s, "enabled", &enabled);
|
||||
|
|
@ -88,7 +91,10 @@ static int dmmap_synchronizeDynamicDNSServer(struct dmctx *dmctx, DMNODE *parent
|
|||
found = 0;
|
||||
uci_path_foreach_sections(bbfdm, "dmmap_ddns", "ddns_server", ss) {
|
||||
dmuci_get_value_by_section_string(ss, "service_name", &dmmap_service_name);
|
||||
if (DM_STRCMP(service_name, dmmap_service_name) == 0) {
|
||||
if (dmmap_service_name == NULL)
|
||||
continue;
|
||||
|
||||
if (strcmp(service_name, dmmap_service_name) == 0) {
|
||||
found = 1;
|
||||
//Update dmmap with ddns config
|
||||
dmuci_set_value_by_section(ss, "section_name", section_name(s));
|
||||
|
|
@ -284,9 +290,9 @@ static int get_DynamicDNS_SupportedServices(char *refparam, struct dmctx *ctx, v
|
|||
continue;
|
||||
|
||||
pch = strtok_r(line, "\t", &spch);
|
||||
pch = DM_STRSTR(pch, "\"") + 1;
|
||||
pch = DM_LSTRSTR(pch, "\"") + 1;
|
||||
pch[DM_STRCHR(pch, '\"')-pch] = 0;
|
||||
if (DM_STRCMP(buf, "") == 0) {
|
||||
if (DM_LSTRCMP(buf, "") == 0) {
|
||||
snprintf(buf, sizeof(buf), "%s", pch);
|
||||
} else {
|
||||
DM_STRNCPY(buf_tmp, buf, sizeof(buf_tmp));
|
||||
|
|
@ -329,7 +335,7 @@ static int get_DynamicDNSClient_Status(char *refparam, struct dmctx *ctx, void *
|
|||
char status[32] = {0}, *enable, *logdir = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "enabled", &enable);
|
||||
if (*enable == '\0' || DM_STRCMP(enable, "0") == 0) {
|
||||
if (*enable == '\0' || DM_LSTRCMP(enable, "0") == 0) {
|
||||
DM_STRNCPY(status, "Disabled", sizeof(status));
|
||||
} else {
|
||||
char path[64] = {0};
|
||||
|
|
@ -344,13 +350,13 @@ static int get_DynamicDNSClient_Status(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
DM_STRNCPY(status, "Connecting", sizeof(status));
|
||||
while (fgets(buf, 512, fp) != NULL) {
|
||||
if (DM_STRSTR(buf, "Update successful"))
|
||||
if (DM_LSTRSTR(buf, "Update successful"))
|
||||
DM_STRNCPY(status, "Updated", sizeof(status));
|
||||
else if (DM_STRSTR(buf, "ERROR") && DM_STRSTR(buf, "Please check your configuration"))
|
||||
else if (DM_LSTRSTR(buf, "ERROR") && DM_LSTRSTR(buf, "Please check your configuration"))
|
||||
DM_STRNCPY(status, "Error_Misconfigured", sizeof(status));
|
||||
else if (DM_STRSTR(buf, "Registered IP"))
|
||||
else if (DM_LSTRSTR(buf, "Registered IP"))
|
||||
DM_STRNCPY(status, "Connecting", sizeof(status));
|
||||
else if (DM_STRSTR(buf, "failed"))
|
||||
else if (DM_LSTRSTR(buf, "failed"))
|
||||
DM_STRNCPY(status, "Error", sizeof(status));
|
||||
}
|
||||
fclose(fp);
|
||||
|
|
@ -389,7 +395,7 @@ static int get_DynamicDNSClient_LastError(char *refparam, struct dmctx *ctx, voi
|
|||
char last_err[64] = {0}, *enable = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "enabled", &enable);
|
||||
if (enable && (*enable == '\0' || DM_STRCMP(enable, "0") == 0)) {
|
||||
if (enable && (*enable == '\0' || DM_LSTRCMP(enable, "0") == 0)) {
|
||||
DM_STRNCPY(last_err, "NO_ERROR", sizeof(last_err));
|
||||
} else {
|
||||
char path[128] = {0}, *logdir = NULL;
|
||||
|
|
@ -403,15 +409,15 @@ static int get_DynamicDNSClient_LastError(char *refparam, struct dmctx *ctx, voi
|
|||
|
||||
DM_STRNCPY(last_err, "NO_ERROR", sizeof(last_err));
|
||||
while (fgets(buf, 512, fp) != NULL) {
|
||||
if (DM_STRSTR(buf, "ERROR") && DM_STRSTR(buf, "Please check your configuration"))
|
||||
if (DM_LSTRSTR(buf, "ERROR") && DM_LSTRSTR(buf, "Please check your configuration"))
|
||||
DM_STRNCPY(last_err, "MISCONFIGURATION_ERROR", sizeof(last_err));
|
||||
else if (DM_STRSTR(buf, "NO valid IP found"))
|
||||
else if (DM_LSTRSTR(buf, "NO valid IP found"))
|
||||
DM_STRNCPY(last_err, "DNS_ERROR", sizeof(last_err));
|
||||
else if (DM_STRSTR(buf, "Authentication Failed"))
|
||||
else if (DM_LSTRSTR(buf, "Authentication Failed"))
|
||||
DM_STRNCPY(last_err, "AUTHENTICATION_ERROR", sizeof(last_err));
|
||||
else if (DM_STRSTR(buf, "Transfer failed") || (DM_STRSTR(buf, "WARN") && DM_STRSTR(buf, "failed")))
|
||||
else if (DM_LSTRSTR(buf, "Transfer failed") || (DM_LSTRSTR(buf, "WARN") && DM_LSTRSTR(buf, "failed")))
|
||||
DM_STRNCPY(last_err, "CONNECTION_ERROR", sizeof(last_err));
|
||||
else if (DM_STRSTR(buf, "Registered IP") || DM_STRSTR(buf, "Update successful"))
|
||||
else if (DM_LSTRSTR(buf, "Registered IP") || DM_LSTRSTR(buf, "Update successful"))
|
||||
DM_STRNCPY(last_err, "NO_ERROR", sizeof(last_err));
|
||||
}
|
||||
fclose(fp);
|
||||
|
|
@ -564,7 +570,7 @@ static int get_DynamicDNSClientHostname_Status(char *refparam, struct dmctx *ctx
|
|||
char status[32] = {0}, *enable = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "enabled", &enable);
|
||||
if (enable && (*enable == '\0' || DM_STRCMP(enable, "0") == 0)) {
|
||||
if (enable && (*enable == '\0' || DM_LSTRCMP(enable, "0") == 0)) {
|
||||
DM_STRNCPY(status, "Disabled", sizeof(status));
|
||||
} else {
|
||||
char path[128] = {0}, *logdir = NULL;
|
||||
|
|
@ -577,11 +583,11 @@ static int get_DynamicDNSClientHostname_Status(char *refparam, struct dmctx *ctx
|
|||
|
||||
DM_STRNCPY(status, "Registered", sizeof(status));
|
||||
while (fgets(buf, 512, fp) != NULL) {
|
||||
if (DM_STRSTR(buf, "Registered IP") || DM_STRSTR(buf, "Update successful"))
|
||||
if (DM_LSTRSTR(buf, "Registered IP") || DM_LSTRSTR(buf, "Update successful"))
|
||||
DM_STRNCPY(status, "Registered", sizeof(status));
|
||||
else if (DM_STRSTR(buf, "Update needed"))
|
||||
else if (DM_LSTRSTR(buf, "Update needed"))
|
||||
DM_STRNCPY(status, "UpdateNeeded", sizeof(status));
|
||||
else if (DM_STRSTR(buf, "NO valid IP found"))
|
||||
else if (DM_LSTRSTR(buf, "NO valid IP found"))
|
||||
DM_STRNCPY(status, "Error", sizeof(status));
|
||||
}
|
||||
fclose(fp);
|
||||
|
|
@ -899,7 +905,7 @@ static int get_DynamicDNSServer_SupportedProtocols(char *refparam, struct dmctx
|
|||
static int get_DynamicDNSServer_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "use_https", value);
|
||||
if (*value[0] == '\0' || DM_STRCMP(*value, "0") == 0)
|
||||
if (*value[0] == '\0' || DM_LSTRCMP(*value, "0") == 0)
|
||||
*value = "HTTP";
|
||||
else
|
||||
*value = "HTTPS";
|
||||
|
|
@ -917,10 +923,10 @@ static int set_DynamicDNSServer_Protocol(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "use_https", (DM_STRCMP(value, "HTTPS") == 0) ? "1" : "0");
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "use_https", (DM_LSTRCMP(value, "HTTPS") == 0) ? "1" : "0");
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "service_name", &service_name);
|
||||
uci_foreach_option_eq("ddns", "service", "service_name", service_name, s) {
|
||||
dmuci_set_value_by_section(s, "use_https", (DM_STRCMP(value, "HTTPS") == 0) ? "1" : "0");
|
||||
dmuci_set_value_by_section(s, "use_https", (DM_LSTRCMP(value, "HTTPS") == 0) ? "1" : "0");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -947,9 +953,9 @@ static int set_DynamicDNSServer_CheckInterval(char *refparam, struct dmctx *ctx,
|
|||
break;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "check_unit", &check_unit);
|
||||
if (DM_STRCMP(check_unit, "hours") == 0)
|
||||
if (DM_LSTRCMP(check_unit, "hours") == 0)
|
||||
check_interval = DM_STRTOL(value) * 3600;
|
||||
else if (DM_STRCMP(check_unit, "minutes") == 0)
|
||||
else if (DM_LSTRCMP(check_unit, "minutes") == 0)
|
||||
check_interval = DM_STRTOL(value) * 60;
|
||||
else
|
||||
check_interval = DM_STRTOL(value);
|
||||
|
|
@ -985,9 +991,9 @@ static int set_DynamicDNSServer_RetryInterval(char *refparam, struct dmctx *ctx,
|
|||
break;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "retry_unit", &retry_unit);
|
||||
if (DM_STRCMP(retry_unit, "hours") == 0)
|
||||
if (DM_LSTRCMP(retry_unit, "hours") == 0)
|
||||
retry_interval = DM_STRTOL(value) * 3600;
|
||||
else if (DM_STRCMP(retry_unit, "minutes") == 0)
|
||||
else if (DM_LSTRCMP(retry_unit, "minutes") == 0)
|
||||
retry_interval = DM_STRTOL(value) * 60;
|
||||
else
|
||||
retry_interval = DM_STRTOL(value);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ static void get_bridge_port_linker(struct dmctx *ctx, char *device_s_name, char
|
|||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(bridge_port, "management", &management);
|
||||
if (management && DM_STRCMP(management, "1") == 0) {
|
||||
if (management && DM_LSTRCMP(management, "1") == 0) {
|
||||
char linker[512] = {0};
|
||||
char *port = NULL;
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ static void add_new_dmmap_section(char *macaddr, char*interface, char *section_n
|
|||
dmuci_add_section_bbfdm(DMMAP, "link", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "mac", macaddr);
|
||||
dmuci_set_value_by_section(dmmap, "device", interface);
|
||||
dmuci_set_value_by_section(dmmap, "is_eth", (!DM_STRNCMP(interface, "atm", 3) || !DM_STRNCMP(interface, "ptm", 3)) ? "0" : "1");
|
||||
dmuci_set_value_by_section(dmmap, "is_eth", (!DM_LSTRNCMP(interface, "atm", 3) || !DM_LSTRNCMP(interface, "ptm", 3)) ? "0" : "1");
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name);
|
||||
}
|
||||
|
||||
|
|
@ -304,9 +304,9 @@ static int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent
|
|||
dmuci_get_value_by_section_string(p->config_section, "type", &type);
|
||||
dmuci_get_value_by_section_string(p->config_section, "name", &name);
|
||||
dmuci_get_value_by_section_string(p->dmmap_section, "is_vlan_ter", &is_vlan);
|
||||
if (DM_STRCMP(type, "bridge") == 0 ||
|
||||
DM_STRCMP(type, "untagged") == 0 ||
|
||||
(*name == 0 && DM_STRCMP(is_vlan, "1") != 0) ||
|
||||
if (DM_LSTRCMP(type, "bridge") == 0 ||
|
||||
DM_LSTRCMP(type, "untagged") == 0 ||
|
||||
(*name == 0 && DM_LSTRCMP(is_vlan, "1") != 0) ||
|
||||
(*name != 0 && !ethernet___check_vlan_termination_section(name)))
|
||||
continue;
|
||||
|
||||
|
|
@ -333,6 +333,10 @@ static int browseEthernetRMONStatsInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
||||
|
||||
dmubus_call("ethernet", "rmonstats", UBUS_ARGS{{"ifname", ifname, String}}, 1, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as !res is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) continue;
|
||||
|
||||
init_eth_rmon(&curr_eth_rmon_args, p, res);
|
||||
|
|
@ -473,9 +477,9 @@ static int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
dmuci_get_value_by_section_string(s_dev, "type", &type);
|
||||
dmuci_get_value_by_section_string(s_dev, "name", &name);
|
||||
if (DM_STRCMP(type, "bridge") == 0 ||
|
||||
DM_STRCMP(type, "untagged") == 0 ||
|
||||
(*name == 0 && DM_STRCMP(is_vlan, "1") != 0) ||
|
||||
if (DM_LSTRCMP(type, "bridge") == 0 ||
|
||||
DM_LSTRCMP(type, "untagged") == 0 ||
|
||||
(*name == 0 && DM_LSTRCMP(is_vlan, "1") != 0) ||
|
||||
(*name != 0 && !ethernet___check_vlan_termination_section(name)))
|
||||
continue;
|
||||
|
||||
|
|
@ -603,7 +607,7 @@ static int get_EthernetInterface_LastChange(char *refparam, struct dmctx *ctx, v
|
|||
*value ="0";
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
if (0 == DM_STRNCMP(device, "br-", 3)) {
|
||||
if (0 == DM_LSTRNCMP(device, "br-", 3)) {
|
||||
uci_foreach_option_eq("network", "device", "name", device, dev_s) {
|
||||
dmuci_get_value_by_section_list(dev_s, "ports", &uci_list);
|
||||
if (value_exists_in_uci_list(uci_list, ((struct eth_port_args *)data)->ifname)) {
|
||||
|
|
@ -617,7 +621,8 @@ static int get_EthernetInterface_LastChange(char *refparam, struct dmctx *ctx, v
|
|||
}
|
||||
|
||||
if (1 == intf_found) {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
||||
char *if_name = section_name(s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "uptime");
|
||||
if((*value)[0] == '\0')
|
||||
|
|
@ -675,7 +680,7 @@ static int get_EthernetInterface_MaxBitRate(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "autoneg", &autoneg);
|
||||
|
||||
if (autoneg && DM_STRCMP(autoneg, "0") == 0)
|
||||
if (autoneg && DM_LSTRCMP(autoneg, "0") == 0)
|
||||
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "speed", value);
|
||||
else
|
||||
*value = "-1";
|
||||
|
|
@ -691,7 +696,7 @@ static int set_EthernetInterface_MaxBitRate(char *refparam, struct dmctx *ctx, v
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "-1") == 0)
|
||||
if (DM_LSTRCMP(value, "-1") == 0)
|
||||
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "autoneg", "1");
|
||||
else {
|
||||
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "autoneg", "0");
|
||||
|
|
@ -723,11 +728,11 @@ static int get_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "autoneg", &autoneg);
|
||||
|
||||
if (autoneg && DM_STRCMP(autoneg, "0") == 0) {
|
||||
if (autoneg && DM_LSTRCMP(autoneg, "0") == 0) {
|
||||
char *duplex = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string((((struct eth_port_args *)data)->sections)->config_section, "duplex", &duplex);
|
||||
*value = (duplex && DM_STRCMP(duplex, "full") == 0) ? "Full" : "Half";
|
||||
*value = (duplex && DM_LSTRCMP(duplex, "full") == 0) ? "Full" : "Half";
|
||||
} else {
|
||||
*value = "Auto";
|
||||
}
|
||||
|
|
@ -742,7 +747,7 @@ static int set_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, v
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Auto") == 0)
|
||||
if (DM_LSTRCMP(value, "Auto") == 0)
|
||||
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "autoneg", "1");
|
||||
else {
|
||||
dmuci_set_value_by_section((((struct eth_port_args *)data)->sections)->config_section, "autoneg", "0");
|
||||
|
|
@ -841,7 +846,11 @@ static int eth_port_ubus(const struct eth_port_args *args, const char *name, cha
|
|||
{
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("ethernet", "ifstats", UBUS_ARGS{{"ifname", args->ifname, String}}, 1, &res);
|
||||
if (args == NULL)
|
||||
DM_ASSERT(res, *value = "0");
|
||||
|
||||
char *if_name = args->ifname;
|
||||
dmubus_call("ethernet", "ifstats", UBUS_ARGS{{"ifname", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, name);
|
||||
return 0;
|
||||
|
|
@ -891,7 +900,7 @@ static int get_EthernetLink_Enable(char *refparam, struct dmctx *ctx, void *data
|
|||
dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &int_name);
|
||||
s = get_origin_section_from_config("network", "interface", int_name);
|
||||
dmuci_get_value_by_section_string(s, "disabled", value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "0" : "1";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -928,7 +937,7 @@ static int get_EthernetLink_FlowControl(char *refparam, struct dmctx *ctx, void
|
|||
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
|
||||
if (DM_STRLEN(device)) {
|
||||
struct uci_section *port_s = NULL;
|
||||
char *is_bridge = DM_STRSTR(device, "br-");
|
||||
char *is_bridge = DM_LSTRSTR(device, "br-");
|
||||
|
||||
if (is_bridge) {
|
||||
/* Ethernet.Link.{i}. ---> Bridging.Bridge.{i}.Port.{i}. */
|
||||
|
|
@ -1009,7 +1018,7 @@ static int set_EthernetLink_FlowControl(char *refparam, struct dmctx *ctx, void
|
|||
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
|
||||
if (DM_STRLEN(device)) {
|
||||
struct uci_section *port_s = NULL;
|
||||
char *is_bridge = DM_STRSTR(device, "br-");
|
||||
char *is_bridge = DM_LSTRSTR(device, "br-");
|
||||
|
||||
if (is_bridge) {
|
||||
/* Ethernet.Link.{i}. ---> Bridging.Bridge.{i}.Port.{i}. */
|
||||
|
|
@ -1100,7 +1109,7 @@ static int get_EthernetLink_Name(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int get_EthernetLink_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
json_object *res = NULL;
|
||||
char *interface;
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &interface);
|
||||
|
|
@ -1138,7 +1147,7 @@ static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
if (br_device_s) dmuci_get_value_by_section_string(br_device_s, "type", &device_s_type);
|
||||
|
||||
if (br_device_s && DM_STRCMP(device_s_type, "bridge") == 0) {
|
||||
if (br_device_s && DM_LSTRCMP(device_s_type, "bridge") == 0) {
|
||||
get_bridge_port_linker(ctx, section_name(br_device_s), value);
|
||||
} else {
|
||||
char *vid = DM_STRCHR(linker, '.');
|
||||
|
|
@ -1468,7 +1477,8 @@ static int get_EthernetVLANTermination_LastChange(char *refparam, struct dmctx *
|
|||
*value = "0";
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &devname);
|
||||
uci_foreach_option_eq("network", "interface", "device", devname, s) {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
||||
char *if_name = section_name(s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "uptime");
|
||||
if((*value)[0] == '\0')
|
||||
|
|
@ -1486,7 +1496,7 @@ static int get_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "type", &type);
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &ifname);
|
||||
|
||||
if (DM_STRNCMP(type, "8021ad", 6) == 0) {
|
||||
if (DM_LSTRNCMP(type, "8021ad", 6) == 0) {
|
||||
// 8021ad device, will have a vlan termination object as its lowerlayer
|
||||
|
||||
char *inner_vid, *dev_name;
|
||||
|
|
@ -1542,7 +1552,7 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &old_name);
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
|
||||
|
||||
if ((DM_STRCMP(type, "macvlan") == 0)) {
|
||||
if ((DM_LSTRCMP(type, "macvlan") == 0)) {
|
||||
/* type == macvlan */
|
||||
|
||||
struct uci_section *s = NULL, *dmmap_s = NULL;
|
||||
|
|
@ -1630,6 +1640,11 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
dmuci_get_value_by_section_string(ss, "ifname", &dev_name);
|
||||
break;
|
||||
}
|
||||
|
||||
/* dev_name, inner_vud are assigned by dmuci_get_value_by_section_string() by
|
||||
* pointer referencing and cppcheck can't track it so throws warning of
|
||||
* uninitialized variable. so suppressed the warning */
|
||||
// cppcheck-suppress uninitvar
|
||||
snprintf(new_name, sizeof(new_name), "%s.%s.%s", dev_name, inner_vid, vid);
|
||||
if (ethernet___name_exists_in_devices(new_name))
|
||||
return -1;
|
||||
|
|
@ -1663,7 +1678,7 @@ static int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx,
|
|||
// Get type option from device section
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "type", &type);
|
||||
|
||||
if (DM_STRCMP(type, "macvlan") != 0) {
|
||||
if (DM_LSTRCMP(type, "macvlan") != 0) {
|
||||
/* only when type != macvlan */
|
||||
char *ifname = NULL;
|
||||
|
||||
|
|
@ -1678,7 +1693,7 @@ static int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx,
|
|||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &old_vid);
|
||||
|
||||
if (DM_STRCMP(type, "8021ad") == 0) {
|
||||
if (DM_LSTRCMP(type, "8021ad") == 0) {
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "inner_vid", &inner_vid);
|
||||
snprintf(old_name, sizeof(old_name), "%s.%s.%s", ifname, inner_vid, old_vid);
|
||||
snprintf(new_name, sizeof(new_name), "%s.%s.%s", ifname, inner_vid, value);
|
||||
|
|
@ -1755,9 +1770,9 @@ static int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx,
|
|||
static int get_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "type", value);
|
||||
if (DM_STRCMP(*value, "8021q") == 0)
|
||||
if (DM_LSTRCMP(*value, "8021q") == 0)
|
||||
*value = "33024";
|
||||
else if (DM_STRCMP(*value, "8021ad") == 0)
|
||||
else if (DM_LSTRCMP(*value, "8021ad") == 0)
|
||||
*value = "34984";
|
||||
else
|
||||
*value = "37120";
|
||||
|
|
@ -1772,9 +1787,9 @@ static int set_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, v
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "33024") == 0)
|
||||
if (DM_LSTRCMP(value, "33024") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "type", "8021q");
|
||||
else if (DM_STRCMP(value, "34984") == 0)
|
||||
else if (DM_LSTRCMP(value, "34984") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "type", "8021ad");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1862,7 +1877,7 @@ static int set_EthernetRMONStats_Enable(char *refparam, struct dmctx *ctx, void
|
|||
static int get_EthernetRMONStats_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_EthernetRMONStats_Enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,6 +101,10 @@ static char *get_fast_value_without_argument(char *command1, char *id, char *com
|
|||
|
||||
snprintf(command, sizeof(command), "%s.%s", command1, id);
|
||||
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as !res is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) return "";
|
||||
value = dmjson_get_value(res, 1, key);
|
||||
return value;
|
||||
|
|
@ -113,6 +117,10 @@ static char *get_fast_value_without_argument_and_with_two_key(char *command1, ch
|
|||
|
||||
snprintf(command, sizeof(command), "%s.%s", command1, id);
|
||||
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as !res is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) return "";
|
||||
value = dmjson_get_value(res, 2, key1, key2);
|
||||
return value;
|
||||
|
|
@ -125,6 +133,10 @@ static char *get_fast_value_array_without_argument(char *command1, char *id, cha
|
|||
|
||||
snprintf(command, sizeof(command), "%s.%s", command1, id);
|
||||
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as !res is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) return "";
|
||||
value = dmjson_get_value_array_all(res, ",", 1, key);
|
||||
return value;
|
||||
|
|
@ -144,7 +156,7 @@ static int get_FAST_LineNumberOfEntries(char *refparam, struct dmctx *ctx, void
|
|||
static int get_FASTLine_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *status = get_fast_value_without_argument("fast.line", ((struct fast_line_args*)data)->id, "status", "status");
|
||||
*value = (DM_STRCMP(status, "up") == 0) ? "1" : "0";
|
||||
*value = (DM_LSTRCMP(status, "up") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +177,7 @@ static int set_FASTLine_Enable(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
static int get_FASTLine_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *status = get_fast_value_without_argument("fast.line", ((struct fast_line_args*)data)->id, "status", "status");
|
||||
*value = (DM_STRCMP(status, "up") == 0) ? "Up" : "Down";
|
||||
*value = (DM_LSTRCMP(status, "up") == 0) ? "Up" : "Down";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +261,7 @@ static int get_FASTLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
list_profile[0] = 0;
|
||||
dmjson_foreach_value_in_array(res, allowed_profiles, profile, idx, 1, "allowed_profiles") {
|
||||
if (profile && (DM_STRCMP(profile, "106a") == 0 || DM_STRCMP(profile, "212a") == 0))
|
||||
if (profile && (DM_LSTRCMP(profile, "106a") == 0 || DM_LSTRCMP(profile, "212a") == 0))
|
||||
pos += snprintf(&list_profile[pos], sizeof(list_profile) - pos, "%s,", profile);
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +277,7 @@ static int get_FASTLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void
|
|||
static int get_FASTLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *current_profile = get_fast_value_without_argument("fast.line", ((struct fast_line_args*)data)->id, "status", "current_profile");
|
||||
*value = (current_profile && DM_STRCMP(current_profile, "unknown") == 0) ? "" : current_profile;
|
||||
*value = (current_profile && DM_LSTRCMP(current_profile, "unknown") == 0) ? "" : current_profile;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -273,13 +285,13 @@ static int get_FASTLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *
|
|||
static int get_FASTLine_PowerManagementState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *power_mng_state = get_fast_value_without_argument("fast.line", ((struct fast_line_args*)data)->id, "status", "power_management_state");
|
||||
if(DM_STRCMP(power_mng_state, "l0") == 0)
|
||||
if(DM_LSTRCMP(power_mng_state, "l0") == 0)
|
||||
*value = "L0";
|
||||
else if(DM_STRCMP(power_mng_state, "l1") == 0)
|
||||
else if(DM_LSTRCMP(power_mng_state, "l1") == 0)
|
||||
*value = "L2.1";
|
||||
else if(DM_STRCMP(power_mng_state, "l2") == 0)
|
||||
else if(DM_LSTRCMP(power_mng_state, "l2") == 0)
|
||||
*value = "L2.2";
|
||||
else if(DM_STRCMP(power_mng_state, "l3") == 0)
|
||||
else if(DM_LSTRCMP(power_mng_state, "l3") == 0)
|
||||
*value = "L3";
|
||||
else
|
||||
*value = power_mng_state;
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ static int get_rule_target(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
char *rule_perm = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "is_rule", &rule_perm);
|
||||
*value = (DM_STRCMP(rule_perm, "1") == 0) ? "Drop" : "Accept";
|
||||
*value = (DM_LSTRCMP(rule_perm, "1") == 0) ? "Drop" : "Accept";
|
||||
} else {
|
||||
if (strcasecmp(target, "Accept") == 0)
|
||||
*value = "Accept";
|
||||
|
|
@ -417,7 +417,7 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da
|
|||
if (src == NULL || *src == '\0')
|
||||
return 0;
|
||||
|
||||
if (DM_STRCMP(src, "*") == 0) {
|
||||
if (DM_LSTRCMP(src, "*") == 0) {
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "src", &src);
|
||||
} else {
|
||||
struct uci_section *s = NULL;
|
||||
|
|
@ -472,7 +472,7 @@ static int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data
|
|||
if (dest == NULL || *dest == '\0')
|
||||
return 0;
|
||||
|
||||
if (DM_STRCMP(dest, "*") == 0) {
|
||||
if (DM_LSTRCMP(dest, "*") == 0) {
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "dest", &dest);
|
||||
} else {
|
||||
struct uci_section *s = NULL;
|
||||
|
|
@ -563,7 +563,7 @@ static int get_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
char *family;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "family", &family);
|
||||
dmasprintf(value, "%s/%s", destip, DM_STRCMP(family, "ipv6") == 0 ? "128" : "32");
|
||||
dmasprintf(value, "%s/%s", destip, DM_LSTRCMP(family, "ipv6") == 0 ? "128" : "32");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -598,7 +598,7 @@ static int get_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, c
|
|||
char *family;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "family", &family);
|
||||
dmasprintf(value, "%s/%s", srcip, DM_STRCMP(family, "ipv6") == 0 ? "128" : "32");
|
||||
dmasprintf(value, "%s/%s", srcip, DM_LSTRCMP(family, "ipv6") == 0 ? "128" : "32");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -826,10 +826,10 @@ static int set_level_default_policy(char *refparam, struct dmctx *ctx, void *dat
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Drop") == 0) {
|
||||
if (DM_LSTRCMP(value, "Drop") == 0) {
|
||||
dmuci_set_value("firewall", "@defaults[0]", "input", "DROP");
|
||||
dmuci_set_value("firewall", "@defaults[0]", "output", "DROP");
|
||||
} else if (DM_STRCMP(value, "Accept") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "Accept") == 0) {
|
||||
dmuci_set_value("firewall", "@defaults[0]", "input", "ACCEPT");
|
||||
dmuci_set_value("firewall", "@defaults[0]", "output", "ACCEPT");
|
||||
} else {
|
||||
|
|
@ -1022,7 +1022,7 @@ static int set_rule_interface(struct dmctx *ctx, void *data, char *type, char *v
|
|||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, type, &option);
|
||||
|
||||
if (*value == '\0') {
|
||||
dmuci_set_value_by_section((option && DM_STRCMP(option, "*") == 0) ? ((struct dmmap_dup *)data)->dmmap_section : ((struct dmmap_dup *)data)->config_section, type, "");
|
||||
dmuci_set_value_by_section((option && DM_LSTRCMP(option, "*") == 0) ? ((struct dmmap_dup *)data)->dmmap_section : ((struct dmmap_dup *)data)->config_section, type, "");
|
||||
} else {
|
||||
adm_entry_get_linker_value(ctx, value, &iface);
|
||||
if (iface && iface[0] != '\0') {
|
||||
|
|
@ -1035,7 +1035,7 @@ static int set_rule_interface(struct dmctx *ctx, void *data, char *type, char *v
|
|||
char *zone_name;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "name", &zone_name);
|
||||
dmuci_set_value_by_section((option && DM_STRCMP(option, "*") == 0) ? ((struct dmmap_dup *)data)->dmmap_section : ((struct dmmap_dup *)data)->config_section, type, zone_name);
|
||||
dmuci_set_value_by_section((option && DM_LSTRCMP(option, "*") == 0) ? ((struct dmmap_dup *)data)->dmmap_section : ((struct dmmap_dup *)data)->config_section, type, zone_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1131,11 +1131,11 @@ static int set_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, c
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "4") == 0)
|
||||
if (DM_LSTRCMP(value, "4") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "ipv4");
|
||||
else if (DM_STRCMP(value, "6") == 0)
|
||||
else if (DM_LSTRCMP(value, "6") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "ipv6");
|
||||
else if (DM_STRCMP(value, "-1") == 0)
|
||||
else if (DM_LSTRCMP(value, "-1") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "");
|
||||
break;
|
||||
}
|
||||
|
|
@ -1181,6 +1181,8 @@ static int set_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
*pch = '\0';
|
||||
|
||||
pch = DM_STRCHR(value, '/');
|
||||
if (pch == NULL)
|
||||
return FAULT_9007;
|
||||
|
||||
snprintf(new, sizeof(new), "%s%s", destip, pch);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dest_ip", new);
|
||||
|
|
@ -1228,6 +1230,8 @@ static int set_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, c
|
|||
*pch = '\0';
|
||||
|
||||
pch = DM_STRCHR(value, '/');
|
||||
if (pch == NULL)
|
||||
return FAULT_9007;
|
||||
|
||||
snprintf(new, sizeof(new), "%s%s", srcip, pch);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_ip", new);
|
||||
|
|
|
|||
|
|
@ -173,6 +173,10 @@ static char *get_gre_tunnel_interface_statistics(char *interface, char *key)
|
|||
char *device, *value = "0";
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface, String}}, 1, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as !res is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res) return value;
|
||||
device = dmjson_get_value(res, 1, "device");
|
||||
if(device[0] != '\0') {
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ static int get_HostsHost_Layer1Interface(char *refparam, struct dmctx *ctx, void
|
|||
{
|
||||
char *linker = dmjson_get_value((json_object *)data, 1, "device");
|
||||
char *type = dmjson_get_value((json_object *)data, 1, "interface_type");
|
||||
if (DM_STRCMP(type, "Wi-Fi") == 0)
|
||||
if (DM_LSTRCMP(type, "Wi-Fi") == 0)
|
||||
adm_entry_get_linker_param(ctx, "Device.WiFi.Radio.", linker, value);
|
||||
else
|
||||
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", linker, value);
|
||||
|
|
|
|||
|
|
@ -318,35 +318,35 @@ static int ubus_ieee1905_info_options(const char *option1, const char *option2,
|
|||
|
||||
static char *get_datamodel_media_type(const char *media)
|
||||
{
|
||||
if (!DM_STRCMP(media, "IEEE 802_3U_FAST_ETHERNET"))
|
||||
if (!DM_LSTRCMP(media, "IEEE 802_3U_FAST_ETHERNET"))
|
||||
return "IEEE 802.3u";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_3AB_GIGABIT_ETHERNET"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_3AB_GIGABIT_ETHERNET"))
|
||||
return "IEEE 802.3ab";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11B_2_4_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11B_2_4_GHZ"))
|
||||
return "IEEE 802.11b";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11G_2_4_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11G_2_4_GHZ"))
|
||||
return "IEEE 802.11g";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11A_5_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11A_5_GHZ"))
|
||||
return "IEEE 802.11a";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11N_2_4_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11N_2_4_GHZ"))
|
||||
return "IEEE 802.11n 2.4";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11N_5_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11N_5_GHZ"))
|
||||
return "IEEE 802.11n 5.0";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11AC_5_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11AC_5_GHZ"))
|
||||
return "IEEE 802.11ac";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11AX_2_4_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11AX_2_4_GHZ"))
|
||||
return "IEEE 802.11ax 2.4";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11AX_5_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11AX_5_GHZ"))
|
||||
return "IEEE 802.11ax 5.0";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11AD_60_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11AD_60_GHZ"))
|
||||
return "IEEE 802.11ad";
|
||||
else if (!DM_STRCMP(media, "IEEE 802_11AF_GHZ"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 802_11AF_GHZ"))
|
||||
return "IEEE 802.11af";
|
||||
else if (!DM_STRCMP(media, "IEEE 1901_WAVELET"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 1901_WAVELET"))
|
||||
return "IEEE 1901 Wavelet";
|
||||
else if (!DM_STRCMP(media, "IEEE 1901_FFT"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE 1901_FFT"))
|
||||
return "IEEE 1901 FFT";
|
||||
else if (!DM_STRCMP(media, "IEEE MOCA_V1_1"))
|
||||
else if (!DM_LSTRCMP(media, "IEEE MOCA_V1_1"))
|
||||
return "MoCAv1.1";
|
||||
else
|
||||
return (char *)media;
|
||||
|
|
@ -1288,15 +1288,15 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_Role(char *refpa
|
|||
{
|
||||
char *role = dmjson_get_value((json_object *)data, 1, "role");
|
||||
|
||||
if (!DM_STRCMP(role, "ap"))
|
||||
if (!DM_LSTRCMP(role, "ap"))
|
||||
*value = "AP";
|
||||
else if (!DM_STRCMP(role, "sta"))
|
||||
else if (!DM_LSTRCMP(role, "sta"))
|
||||
*value = "non-AP/non-PCP STA";
|
||||
else if (!DM_STRCMP(role, "p2p_client"))
|
||||
else if (!DM_LSTRCMP(role, "p2p_client"))
|
||||
*value = "Wi-Fi P2P Client";
|
||||
else if (!DM_STRCMP(role, "p2p_go"))
|
||||
else if (!DM_LSTRCMP(role, "p2p_go"))
|
||||
*value = "Wi-Fi P2P Group Owner";
|
||||
else if (!DM_STRCMP(role, "pcp"))
|
||||
else if (!DM_LSTRCMP(role, "pcp"))
|
||||
*value = "802.11adPCP";
|
||||
else
|
||||
*value = role;
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
higheralias = get_alias_by_section("dmmap_network", "interface", s, "ip_int_alias");
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
|
||||
|
||||
if (DM_STRSTR(proto, "ppp")) {
|
||||
if (DM_LSTRSTR(proto, "ppp")) {
|
||||
// The lower layer is Device.PPP.Interface.{i}.
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", "section_name", section_name(s), "ppp_int_instance", "ppp_int_alias");
|
||||
if (*layer_inst == '\0')
|
||||
|
|
@ -208,7 +208,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
uci_foreach_sections("network", "interface", s) {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (!DM_STRSTR(proto, "ppp"))
|
||||
if (!DM_LSTRSTR(proto, "ppp"))
|
||||
continue;
|
||||
|
||||
// The higher layer is Device.PPP.Interface.{i}.
|
||||
|
|
@ -272,9 +272,9 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
dmuci_get_value_by_section_string(s, "name", &name);
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
if (DM_STRCMP(type, "bridge") == 0 ||
|
||||
DM_STRCMP(type, "untagged") == 0 ||
|
||||
(*name == 0 && DM_STRCMP(is_vlan, "1") != 0) ||
|
||||
if (DM_LSTRCMP(type, "bridge") == 0 ||
|
||||
DM_LSTRCMP(type, "untagged") == 0 ||
|
||||
(*name == 0 && DM_LSTRCMP(is_vlan, "1") != 0) ||
|
||||
(*name != 0 && !ethernet___check_vlan_termination_section(name)))
|
||||
continue;
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
|
||||
|
||||
// The lower layer can be Device.Ethernet.VLANTermination.{i}. or Device.Ethernet.Link.{i}.
|
||||
if (DM_STRNCMP(type, "8021ad", 6) == 0) {
|
||||
if (DM_LSTRNCMP(type, "8021ad", 6) == 0) {
|
||||
// The lower layer is Device.Ethernet.VLANTermination.{i}.
|
||||
struct uci_section *vlan_sect = NULL;
|
||||
char *inner_vid = NULL;
|
||||
|
|
@ -347,7 +347,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
struct uci_section *br_device_s = ethernet___get_device_section(linker);
|
||||
if (br_device_s) dmuci_get_value_by_section_string(br_device_s, "type", &device_s_type);
|
||||
|
||||
if (br_device_s && DM_STRCMP(device_s_type, "bridge") == 0) {
|
||||
if (br_device_s && DM_LSTRCMP(device_s_type, "bridge") == 0) {
|
||||
// The lower layer is Device.Bridging.Bridge.{i}.Port.{i}.
|
||||
struct uci_section *dmmap_section, *port = NULL;
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
dmuci_get_value_by_section_string(dmmap_section, "bridge_instance", &br_inst);
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, port) {
|
||||
dmuci_get_value_by_section_string(port, "management", &mg);
|
||||
if (mg && DM_STRCMP(mg, "1") == 0) {
|
||||
if (mg && DM_LSTRCMP(mg, "1") == 0) {
|
||||
char *device, linker_buf[512] = {0};
|
||||
|
||||
dmuci_get_value_by_section_string(port, "port", &device);
|
||||
|
|
@ -419,7 +419,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
char *mg = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(port, "management", &mg);
|
||||
if (mg && DM_STRCMP(mg, "1") == 0) {
|
||||
if (mg && DM_LSTRCMP(mg, "1") == 0) {
|
||||
char *device, linker[512] = {0};
|
||||
|
||||
dmuci_get_value_by_section_string(port, "port", &device);
|
||||
|
|
@ -440,7 +440,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, sd) {
|
||||
char *mg = NULL;
|
||||
dmuci_get_value_by_section_string(sd, "management", &mg);
|
||||
if (mg && DM_STRCMP(mg, "1") == 0)
|
||||
if (mg && DM_LSTRCMP(mg, "1") == 0)
|
||||
continue;
|
||||
|
||||
char *vb = NULL, *device, linker[512] = {0};
|
||||
|
|
@ -555,7 +555,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
goto end;
|
||||
|
||||
// The lower layer is Device.WiFi.Radio.{i}.
|
||||
if(DM_STRCMP(package, "wireless") == 0) {
|
||||
if(DM_LSTRCMP(package, "wireless") == 0) {
|
||||
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *loweralias ? loweralias : *bridge_port_inst ? "cpe-" : "", (*loweralias == '\0' && *bridge_port_inst) ? bridge_port_inst : "");
|
||||
|
||||
|
|
@ -588,7 +588,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
}
|
||||
|
||||
// The lower layer is Device.DSL.Channel.{i}.
|
||||
if(DM_STRCMP(package, "dsl:atm") == 0) {
|
||||
if(DM_LSTRCMP(package, "dsl:atm") == 0) {
|
||||
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *loweralias ? loweralias : *bridge_port_inst ? "cpe-" : "", (*loweralias == '\0' && *bridge_port_inst) ? bridge_port_inst : "");
|
||||
|
||||
|
|
@ -610,7 +610,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
}
|
||||
|
||||
// The lower layer is Device.DSL.Line.{i}.
|
||||
if(DM_STRCMP(package, "dsl:ptm") == 0) {
|
||||
if(DM_LSTRCMP(package, "dsl:ptm") == 0) {
|
||||
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *loweralias ? loweralias : *bridge_port_inst ? "cpe-" : "", (*loweralias == '\0' && *bridge_port_inst) ? bridge_port_inst : "");
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ static int get_linker_ipv6_prefix(char *refparam, struct dmctx *dmctx, void *dat
|
|||
char *assign = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "assign", &assign);
|
||||
if (assign && DM_STRCMP(assign, "0") == 0) {
|
||||
if (assign && DM_LSTRCMP(assign, "0") == 0) {
|
||||
char *address = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 3, "assigned", "lan", "address");
|
||||
char *mask = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 3, "assigned", "lan", "mask");
|
||||
dmasprintf(linker, "%s/%s", address, mask);
|
||||
|
|
@ -112,7 +112,7 @@ static void remove_unused_firewall_zone_sections(void)
|
|||
|
||||
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name(s), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "added_by_controller", &zone_added);
|
||||
if (zone_added && DM_STRCMP(zone_added, "1") == 0)
|
||||
if (zone_added && DM_LSTRCMP(zone_added, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "name", &name);
|
||||
|
|
@ -163,7 +163,7 @@ static void dmmap_synchronize_ipv6_address_link_local(char *parent_section)
|
|||
dmuci_get_value_by_section_string(s, "link_local", &link_local);
|
||||
|
||||
if ((parent_s && DM_STRCMP(parent_s, parent_section) != 0) ||
|
||||
(link_local && DM_STRCMP(link_local, "1") != 0))
|
||||
(link_local && DM_LSTRCMP(link_local, "1") != 0))
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "address", &address);
|
||||
|
|
@ -268,7 +268,7 @@ static void synchronize_intf_ipv6_sections_with_dmmap(void)
|
|||
|
||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_network_ipv6", "intf_ipv6", stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, "link_local", &link_local);
|
||||
if (link_local && *link_local != '\0' && DM_STRCMP(link_local, "1") == 0)
|
||||
if (link_local && *link_local != '\0' && DM_LSTRCMP(link_local, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "section_name", &dmmap_intf_s);
|
||||
|
|
@ -390,7 +390,7 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
|
||||
/* Remove the device section corresponding to this interface if exists and no interface used it
|
||||
And it doesn't link to Device.Bridging.Bridge. Object */
|
||||
if (device && *device && DM_STRNCMP(device, "br-", 3) != 0) {
|
||||
if (device && *device && DM_LSTRNCMP(device, "br-", 3) != 0) {
|
||||
bool device_found = false;
|
||||
|
||||
uci_foreach_sections("network", "interface", ss) {
|
||||
|
|
@ -405,7 +405,7 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
uci_foreach_option_eq_safe("network", "device", "name", device, stmp, ss) {
|
||||
char *device_type;
|
||||
dmuci_get_value_by_section_string(ss, "type", &device_type);
|
||||
if (DM_STRCMP(device_type, "untagged") == 0) dmuci_delete_by_section(ss, NULL, NULL);
|
||||
if (DM_LSTRCMP(device_type, "untagged") == 0) dmuci_delete_by_section(ss, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
|
||||
dmuci_get_value_by_section_string(int_ss, "proto", &proto);
|
||||
|
||||
if (DM_STRCMP(proto, "dhcp") == 0) {
|
||||
if (DM_LSTRCMP(proto, "dhcp") == 0) {
|
||||
struct uci_section *dhcpv4_client_s = get_dup_section_in_dmmap_opt("dmmap_dhcp_client", "interface", "iface_name", section_name(int_ss));
|
||||
|
||||
if (dhcpv4_client_s) {
|
||||
|
|
@ -455,7 +455,7 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
}
|
||||
}
|
||||
|
||||
if (DM_STRCMP(proto, "dhcpv6") == 0) {
|
||||
if (DM_LSTRCMP(proto, "dhcpv6") == 0) {
|
||||
struct uci_section *dhcpv6_client_s = get_dup_section_in_dmmap_opt("dmmap_dhcpv6", "interface", "iface_name", section_name(int_ss));
|
||||
|
||||
if (dhcpv6_client_s) {
|
||||
|
|
@ -465,7 +465,7 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
}
|
||||
}
|
||||
|
||||
if (DM_STRNCMP(proto, "ppp", 3) == 0) {
|
||||
if (DM_LSTRNCMP(proto, "ppp", 3) == 0) {
|
||||
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "iface_name", section_name(int_ss));
|
||||
|
||||
if (ppp_s) {
|
||||
|
|
@ -500,7 +500,7 @@ static bool interface_section_with_dhcpv6_exists(const char *sec_name)
|
|||
if (DM_STRCMP(device, buf) == 0) {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "dhcpv6") == 0)
|
||||
if (DM_LSTRCMP(proto, "dhcpv6") == 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -552,7 +552,7 @@ static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, char *dmm
|
|||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "static") != 0 || interface_section_with_dhcpv6_exists(section_name(((struct intf_ip_args *)data)->interface_sec)))
|
||||
if (DM_LSTRCMP(proto, "static") != 0 || interface_section_with_dhcpv6_exists(section_name(((struct intf_ip_args *)data)->interface_sec)))
|
||||
return FAULT_9001;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "device", &device);
|
||||
|
|
@ -566,7 +566,7 @@ static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, char *dmm
|
|||
break;
|
||||
case DEL_ALL:
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "static") != 0 || interface_section_with_dhcpv6_exists(section_name((struct uci_section *)data)))
|
||||
if (DM_LSTRCMP(proto, "static") != 0 || interface_section_with_dhcpv6_exists(section_name((struct uci_section *)data)))
|
||||
return FAULT_9001;
|
||||
|
||||
snprintf(buf, sizeof(buf), "@%s", section_name((struct uci_section *)data));
|
||||
|
|
@ -646,7 +646,7 @@ static int browseIPInterfaceIPv4AddressInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(intf_s, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "none") == 0)
|
||||
if (DM_LSTRCMP(proto, "none") == 0)
|
||||
continue;
|
||||
|
||||
dmmap_s = check_dmmap_network_interface_ipv4("dmmap_network_ipv4", "intf_ipv4", section_name(parent_sec), section_name(intf_s));
|
||||
|
|
@ -654,12 +654,13 @@ static int browseIPInterfaceIPv4AddressInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
|
||||
dmuci_get_value_by_section_string(intf_s, "ipaddr", &ipaddr);
|
||||
if (*ipaddr == '\0') {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(intf_s), String}}, 1, &res);
|
||||
char *if_name = section_name(intf_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
ipv4_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
|
||||
ipaddr = dmjson_get_value(ipv4_obj, 1, "address");
|
||||
}
|
||||
|
||||
if (*ipaddr == '\0' && added_by_controller && DM_STRCMP(added_by_controller, "1") != 0)
|
||||
if (*ipaddr == '\0' && added_by_controller && DM_LSTRCMP(added_by_controller, "1") != 0)
|
||||
continue;
|
||||
|
||||
if (dmmap_s == NULL)
|
||||
|
|
@ -694,7 +695,8 @@ static int browseIPInterfaceIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
|
||||
dmuci_get_value_by_section_string(intf_s, "ip6addr", &ip6addr);
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(intf_s), String}}, 1, &res);
|
||||
char *if_name = section_name(intf_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
|
||||
if (*ip6addr == '\0') {
|
||||
|
||||
|
|
@ -752,7 +754,7 @@ static int browseIPInterfaceIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
char *link_local = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(dmmap_s, "link_local", &link_local);
|
||||
if (link_local && DM_STRCMP(link_local, "1") != 0)
|
||||
if (link_local && DM_LSTRCMP(link_local, "1") != 0)
|
||||
continue;
|
||||
|
||||
init_interface_ip_args(&curr_intf_ip_args, NULL, dmmap_s, NULL);
|
||||
|
|
@ -788,7 +790,8 @@ static int browseIPInterfaceIPv6PrefixInst(struct dmctx *dmctx, DMNODE *parent_n
|
|||
|
||||
dmuci_get_value_by_section_string(intf_s, "ip6prefix", &ip6prefix);
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(intf_s), String}}, 1, &res);
|
||||
char *if_name = section_name(intf_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
|
||||
if (*ip6prefix == '\0') {
|
||||
|
||||
|
|
@ -904,7 +907,7 @@ static int addObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_ip_interface);
|
||||
dmuci_get_value_by_section_string(dmmap_ip_interface, "ip_int_instance", &ip_inst);
|
||||
|
||||
if (DM_STRCMP(*instance, "1") != 0) {
|
||||
if (DM_LSTRCMP(*instance, "1") != 0) {
|
||||
char device_buf[32] = {0};
|
||||
|
||||
snprintf(ipv4_name, sizeof(ipv4_name), "iface%s_ipv4_%s", ip_inst, *instance);
|
||||
|
|
@ -922,7 +925,7 @@ static int addObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
dmuci_add_section_bbfdm("dmmap_network_ipv4", "intf_ipv4", &dmmap_ip_interface_ipv4);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv4, "parent_section", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv4, "section_name", (DM_STRCMP(*instance, "1") != 0) ? ipv4_name : section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv4, "section_name", (DM_LSTRCMP(*instance, "1") != 0) ? ipv4_name : section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv4, "added_by_controller", "1");
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv4, "ipv4_instance", *instance);
|
||||
return 0;
|
||||
|
|
@ -936,7 +939,7 @@ static int delObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "static") != 0)
|
||||
if (DM_LSTRCMP(proto, "static") != 0)
|
||||
return FAULT_9001;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "device", &device);
|
||||
|
|
@ -951,7 +954,7 @@ static int delObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
break;
|
||||
case DEL_ALL:
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "static") != 0)
|
||||
if (DM_LSTRCMP(proto, "static") != 0)
|
||||
return FAULT_9001;
|
||||
|
||||
snprintf(buf, sizeof(buf), "@%s", section_name((struct uci_section *)data));
|
||||
|
|
@ -1089,7 +1092,7 @@ static int get_IP_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char
|
|||
char buf[16] = {0};
|
||||
|
||||
dm_read_sysfs_file("/proc/sys/net/ipv6/conf/all/disable_ipv6", buf, sizeof(buf));
|
||||
*value = (DM_STRCMP(buf, "1") == 0) ? "0" : "1";
|
||||
*value = (DM_LSTRCMP(buf, "1") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1126,7 +1129,7 @@ static int set_IP_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char
|
|||
break;
|
||||
}
|
||||
|
||||
char *ptr = DM_STRSTR(buffer, "net.ipv6.conf.all.disable_ipv6");
|
||||
char *ptr = DM_LSTRSTR(buffer, "net.ipv6.conf.all.disable_ipv6");
|
||||
if (ptr) {
|
||||
*(ptr+31) = (b) ? '0' : '1';
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
|
@ -1146,7 +1149,7 @@ static int set_IP_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char
|
|||
static int get_IP_IPv6Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_IP_IPv6Enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1283,10 +1286,11 @@ static int get_IPInterface_Status(char *refparam, struct dmctx *ctx, void *data,
|
|||
{
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name((struct uci_section *)data), String}}, 1, &res);
|
||||
char *if_name = section_name((struct uci_section *)data);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "Down");
|
||||
char *up = dmjson_get_value(res, 1, "up");
|
||||
*value = (DM_STRCMP(up, "true") == 0) ? "Up" : "Down";
|
||||
*value = (DM_LSTRCMP(up, "true") == 0) ? "Up" : "Down";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1330,7 +1334,8 @@ static int get_IPInterface_LastChange(char *refparam, struct dmctx *ctx, void *d
|
|||
{
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name((struct uci_section *)data), String}}, 1, &res);
|
||||
char *if_name = section_name((struct uci_section *)data);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "uptime");
|
||||
return 0;
|
||||
|
|
@ -1348,7 +1353,7 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
char *proto;
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &proto);
|
||||
if (DM_STRNCMP(proto, "ppp", 3) == 0) {
|
||||
if (DM_LSTRNCMP(proto, "ppp", 3) == 0) {
|
||||
snprintf(linker, sizeof(linker), "%s", section_name((struct uci_section *)data));
|
||||
adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", linker, value);
|
||||
if (*value != NULL && (*value)[0] != 0)
|
||||
|
|
@ -1427,7 +1432,7 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
dmuci_set_value_by_section((struct uci_section *)data, "device", "");
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &curr_proto);
|
||||
if (DM_STRNCMP(curr_proto, "ppp", 3) == 0) {
|
||||
if (DM_LSTRNCMP(curr_proto, "ppp", 3) == 0) {
|
||||
struct uci_section *ppp_s = NULL;
|
||||
|
||||
ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "iface_name", section_name((struct uci_section *)data));
|
||||
|
|
@ -1457,7 +1462,7 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
uci_foreach_option_eq_safe("network", "device", "name", device, stmp, s) {
|
||||
char *type;
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
if (DM_STRCMP(type, "untagged") == 0) dmuci_delete_by_section(s, NULL, NULL);
|
||||
if (DM_LSTRCMP(type, "untagged") == 0) dmuci_delete_by_section(s, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1505,7 +1510,7 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
dmuci_set_value_by_section(eth_link_s, "section_name", section_name((struct uci_section *)data));
|
||||
|
||||
if (!eth_link_without_dev) {
|
||||
bool is_br_sec = (DM_STRNCMP(linker_buf, "br-", 3) == 0) ? true : false;
|
||||
bool is_br_sec = (DM_LSTRNCMP(linker_buf, "br-", 3) == 0) ? true : false;
|
||||
|
||||
// Check if the Ethernet.Link. maps to bridge, if yes then check the device name
|
||||
if (is_br_sec) {
|
||||
|
|
@ -1694,7 +1699,7 @@ static int get_IPInterfaceIPv4Address_Enable(char *refparam, struct dmctx *ctx,
|
|||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "none") != 0) {
|
||||
if (DM_LSTRCMP(proto, "none") != 0) {
|
||||
char *disabled = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "disabled", &disabled);
|
||||
|
|
@ -1718,7 +1723,7 @@ static int set_IPInterfaceIPv4Address_Enable(char *refparam, struct dmctx *ctx,
|
|||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "none") == 0) {
|
||||
if (DM_LSTRCMP(proto, "none") == 0) {
|
||||
char *ip_addr;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "ipaddr", &ip_addr);
|
||||
|
|
@ -1759,7 +1764,7 @@ static int set_IPInterfaceIPv4Address_Alias(char *refparam, struct dmctx *ctx, v
|
|||
break;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
if (proto && DM_STRCMP(proto, "static") == 0)
|
||||
if (proto && DM_LSTRCMP(proto, "static") == 0)
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->dmmap_sec, "ipv4_alias", value);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1793,7 +1798,7 @@ static int set_IPInterfaceIPv4Address_IPAddress(char *refparam, struct dmctx *ct
|
|||
break;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto_intf);
|
||||
if (proto_intf && DM_STRCMP(proto_intf, "static") == 0)
|
||||
if (proto_intf && DM_LSTRCMP(proto_intf, "static") == 0)
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->interface_sec, "ipaddr", value);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1828,7 +1833,7 @@ static int set_IPInterfaceIPv4Address_SubnetMask(char *refparam, struct dmctx *c
|
|||
break;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
if (proto && DM_STRCMP(proto, "static") == 0)
|
||||
if (proto && DM_LSTRCMP(proto, "static") == 0)
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->interface_sec, "netmask", value);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1841,9 +1846,9 @@ static int get_IPInterfaceIPv4Address_AddressingType(char *refparam, struct dmct
|
|||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
if (proto && DM_STRCMP(proto, "static") == 0)
|
||||
if (proto && DM_LSTRCMP(proto, "static") == 0)
|
||||
*value = "Static";
|
||||
else if (proto && DM_STRNCMP(proto, "ppp", 3) == 0)
|
||||
else if (proto && DM_LSTRNCMP(proto, "ppp", 3) == 0)
|
||||
*value = "IPCP";
|
||||
else
|
||||
*value = "DHCP";
|
||||
|
|
@ -1856,7 +1861,7 @@ static int get_IPInterfaceIPv6Address_Enable(char *refparam, struct dmctx *ctx,
|
|||
char *link_local = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "link_local", &link_local);
|
||||
if (link_local && DM_STRCMP(link_local, "1") == 0) {
|
||||
if (link_local && DM_LSTRCMP(link_local, "1") == 0) {
|
||||
*value = "1";
|
||||
} else {
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct intf_ip_args *)data)->interface_sec, "ipv6", "1");
|
||||
|
|
@ -1878,7 +1883,7 @@ static int set_IPInterfaceIPv6Address_Enable(char *refparam, struct dmctx *ctx,
|
|||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "link_local", &link_local);
|
||||
if (link_local && DM_STRCMP(link_local, "1") != 0)
|
||||
if (link_local && DM_LSTRCMP(link_local, "1") != 0)
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->interface_sec, "ipv6", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
|
|
@ -1898,7 +1903,7 @@ static int get_IPInterfaceIPv6Address_IPAddressStatus(char *refparam, struct dmc
|
|||
char *assign = NULL, *preferred = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "assign", &assign);
|
||||
if (assign && DM_STRCMP(assign, "1") == 0)
|
||||
if (assign && DM_LSTRCMP(assign, "1") == 0)
|
||||
preferred = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 2, "local-address", "preferred");
|
||||
else
|
||||
preferred = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 1, "preferred");
|
||||
|
|
@ -1951,7 +1956,7 @@ static int set_IPInterfaceIPv6Address_IPAddress(char *refparam, struct dmctx *ct
|
|||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "link_local", &link_local);
|
||||
if (proto && DM_STRCMP(proto, "static") == 0 && link_local && DM_STRCMP(link_local, "1") != 0) {
|
||||
if (proto && DM_LSTRCMP(proto, "static") == 0 && link_local && DM_LSTRCMP(link_local, "1") != 0) {
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->interface_sec, "ip6addr", value);
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->dmmap_sec, "address", value);
|
||||
}
|
||||
|
|
@ -1967,12 +1972,12 @@ static int get_IPInterfaceIPv6Address_Origin(char *refparam, struct dmctx *ctx,
|
|||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "assign", &assign);
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "link_local", &link_local);
|
||||
|
||||
if ((assign && DM_STRCMP(assign, "1") == 0) || (link_local && DM_STRCMP(link_local, "1") == 0)) {
|
||||
if ((assign && DM_LSTRCMP(assign, "1") == 0) || (link_local && DM_LSTRCMP(link_local, "1") == 0)) {
|
||||
*value = "AutoConfigured";
|
||||
} else {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
*value = (DM_STRCMP(proto, "dhcpv6") == 0) ? "DHCPv6" : "Static";
|
||||
*value = (DM_LSTRCMP(proto, "dhcpv6") == 0) ? "DHCPv6" : "Static";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1982,7 +1987,7 @@ static int get_IPInterfaceIPv6Address_Prefix(char *refparam, struct dmctx *ctx,
|
|||
char *assign = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "assign", &assign);
|
||||
if (assign && DM_STRCMP(assign, "1") == 0) {
|
||||
if (assign && DM_LSTRCMP(assign, "1") == 0) {
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
char *ip_inst = NULL, *ipv6_prefix_inst = NULL, *parent_section, *section_name;
|
||||
char curr_address[64] = {0}, *address = NULL;
|
||||
|
|
@ -2027,7 +2032,7 @@ static int get_IPInterfaceIPv6Address_PreferredLifetime(char *refparam, struct d
|
|||
char *assign = NULL, *preferred = NULL, local_time[32] = {0};
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "assign", &assign);
|
||||
if (assign && DM_STRCMP(assign, "1") == 0)
|
||||
if (assign && DM_LSTRCMP(assign, "1") == 0)
|
||||
preferred = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 2, "local-address", "preferred");
|
||||
else
|
||||
preferred = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 1, "preferred");
|
||||
|
|
@ -2057,7 +2062,7 @@ static int get_IPInterfaceIPv6Address_ValidLifetime(char *refparam, struct dmctx
|
|||
char *assign = NULL, *preferred = NULL, local_time[32] = {0};
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "assign", &assign);
|
||||
if (assign && DM_STRCMP(assign, "1") == 0)
|
||||
if (assign && DM_LSTRCMP(assign, "1") == 0)
|
||||
preferred = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 2, "local-address", "valid");
|
||||
else
|
||||
preferred = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 1, "valid");
|
||||
|
|
@ -2164,7 +2169,7 @@ static int set_IPInterfaceIPv6Prefix_Prefix(char *refparam, struct dmctx *ctx, v
|
|||
break;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
if (proto && DM_STRCMP(proto, "static") == 0) {
|
||||
if (proto && DM_LSTRCMP(proto, "static") == 0) {
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->interface_sec, "ip6prefix", value);
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->dmmap_sec, "address", value);
|
||||
}
|
||||
|
|
@ -2178,12 +2183,12 @@ static int get_IPInterfaceIPv6Prefix_Origin(char *refparam, struct dmctx *ctx, v
|
|||
char *assign = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "assign", &assign);
|
||||
if (assign && DM_STRCMP(assign, "1") == 0) {
|
||||
if (assign && DM_LSTRCMP(assign, "1") == 0) {
|
||||
*value = "AutoConfigured";
|
||||
} else {
|
||||
char *proto = NULL;
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto);
|
||||
*value = (proto && DM_STRCMP(proto, "dhcpv6") == 0) ? "PrefixDelegation" : "Static";
|
||||
*value = (proto && DM_LSTRCMP(proto, "dhcpv6") == 0) ? "PrefixDelegation" : "Static";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2215,7 +2220,7 @@ static int get_IPInterfaceIPv6Prefix_ChildPrefixBits(char *refparam, struct dmct
|
|||
char *assign = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "assign", &assign);
|
||||
if (assign && DM_STRCMP(assign, "0") == 0) {
|
||||
if (assign && DM_LSTRCMP(assign, "0") == 0) {
|
||||
char *address = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 3, "assigned", "lan", "address");
|
||||
char *mask = dmjson_get_value(((struct intf_ip_args *)data)->interface_obj, 3, "assigned", "lan", "mask");
|
||||
if (address && *address && mask && *mask)
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ static int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data,
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value,"UDP") == 0)
|
||||
if (DM_LSTRCMP(value,"UDP") == 0)
|
||||
dmuci_set_value("cwmp", "lwn", "enable", "1");
|
||||
else
|
||||
dmuci_set_value("cwmp", "lwn", "enable", "0");
|
||||
|
|
@ -567,7 +567,7 @@ static int set_management_server_conn_req_xmpp_connection(char *refparam, struct
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if ((str = DM_STRSTR(value, "Device.XMPP.Connection."))) {
|
||||
if ((str = DM_LSTRSTR(value, "Device.XMPP.Connection."))) {
|
||||
value = dmstrdup(str + sizeof("Device.XMPP.Connection.") - 1); //MEM WILL BE FREED IN DMMEMCLEAN
|
||||
}
|
||||
uci_foreach_sections("xmpp", "connection", s) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static int browsePortMappingInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
synchronize_specific_config_sections_with_dmmap("firewall", "redirect", "dmmap_firewall", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
dmuci_get_value_by_section_string(p->config_section, "target", &target);
|
||||
if (*target != '\0' && DM_STRCMP(target, "DNAT") != 0)
|
||||
if (*target != '\0' && DM_LSTRCMP(target, "DNAT") != 0)
|
||||
continue;
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "port_mapping_instance", "port_mapping_alias");
|
||||
|
|
@ -324,7 +324,7 @@ static int set_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *
|
|||
static int get_nat_port_mapping_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_nat_port_mapping_enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ static int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi
|
|||
unsigned pos = 0;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dip", &src_dip);
|
||||
if (src_dip && DM_STRCMP(src_dip, "*") == 0)
|
||||
if (src_dip && DM_LSTRCMP(src_dip, "*") == 0)
|
||||
return 0;
|
||||
|
||||
buf[0] = 0;
|
||||
|
|
@ -409,7 +409,7 @@ static int set_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi
|
|||
adm_entry_get_linker_value(ctx, value, &iface);
|
||||
if (iface && *iface) {
|
||||
struct uci_section *s = NULL;
|
||||
bool zone_enable = false, sect_enable = false;
|
||||
bool zone_enable, sect_enable;
|
||||
|
||||
uci_foreach_sections("firewall", "zone", s) {
|
||||
char *network = NULL;
|
||||
|
|
@ -631,7 +631,7 @@ static int get_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void
|
|||
{
|
||||
char *proto = NULL;
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "proto", &proto);
|
||||
*value = (proto && DM_STRCMP(proto, "udp") == 0) ? "UDP" : "TCP";
|
||||
*value = (proto && DM_LSTRCMP(proto, "udp") == 0) ? "UDP" : "TCP";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ static int set_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", (DM_STRCMP("UDP", value) == 0) ? "udp" : "tcp");
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", (DM_LSTRCMP(value, "UDP") == 0) ? "udp" : "tcp");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ static void dmmap_synchronizePPPInterface(struct dmctx *dmctx, DMNODE *parent_no
|
|||
char *iface_name = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "added_by_controller", &added_by_controller);
|
||||
if (DM_STRCMP(added_by_controller, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_controller, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
|
||||
|
|
@ -95,7 +95,7 @@ static void dmmap_synchronizePPPInterface(struct dmctx *dmctx, DMNODE *parent_no
|
|||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (DM_STRNCMP(proto, "ppp", 3) != 0)
|
||||
if (DM_LSTRNCMP(proto, "ppp", 3) != 0)
|
||||
continue;
|
||||
|
||||
if (is_ppp_section_exist(section_name(s)))
|
||||
|
|
@ -225,7 +225,7 @@ static int set_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
static int get_PPPInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_ppp_enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Up" : "Down";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Up" : "Down";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -260,7 +260,8 @@ static int get_PPPInterface_LastChange(char *refparam, struct dmctx *ctx, void *
|
|||
if (ppp_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
char *if_name = section_name(ppp_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "uptime");
|
||||
} else {
|
||||
|
|
@ -316,7 +317,8 @@ static int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
json_object *res = NULL, *jobj = NULL;
|
||||
bool bstatus = false, bpend = false;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
char *if_name = section_name(ppp_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "Unconfigured");
|
||||
jobj = dmjson_get_obj(res, 1, "up");
|
||||
if (jobj) {
|
||||
|
|
@ -347,7 +349,8 @@ static int get_PPPInterface_LastConnectionError(char *refparam, struct dmctx *ct
|
|||
if (ppp_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
char *if_name = section_name(ppp_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "ERROR_NONE");
|
||||
char *status = dmjson_get_value(res, 2, "data", "lastconnectionerror");
|
||||
|
||||
|
|
@ -446,7 +449,7 @@ static int get_PPPInterface_MaxMRUSize(char *refparam, struct dmctx *ctx, void *
|
|||
char *token = NULL , *end = NULL;
|
||||
token = strtok_r(pppd_opt, " ", &end);
|
||||
while (NULL != token) {
|
||||
if (0 == DM_STRCMP(token, "mru")) {
|
||||
if (0 == DM_LSTRCMP(token, "mru")) {
|
||||
char mru_val[1024] = {0}, mru_str[1024] = {0};
|
||||
DM_STRNCPY(mru_val, end, sizeof(mru_val));
|
||||
sscanf(mru_val, "%1023s", mru_str);
|
||||
|
|
@ -475,7 +478,7 @@ static int configure_pppd_mru(char *pppd_opt, char *mru_str, struct uci_section
|
|||
list_options[0] = 0;
|
||||
token = strtok_r(pppd_opt, " ", &end);
|
||||
while (NULL != token) {
|
||||
if (0 == DM_STRCMP(token, "mru")) {
|
||||
if (0 == DM_LSTRCMP(token, "mru")) {
|
||||
found = true;
|
||||
pos += snprintf(&list_options[pos], sizeof(list_options) - pos, "%s %s", token, value);
|
||||
DM_STRNCPY(mru_opt, end, sizeof(mru_opt));
|
||||
|
|
@ -594,7 +597,7 @@ static int configure_supported_ncp_options(struct uci_section *ss, char *value,
|
|||
char list_options[1024] = {0};
|
||||
|
||||
dmuci_get_value_by_section_string(ss, "proto", &proto);
|
||||
if (0 == DM_STRCMP(proto, "pppoe")) {
|
||||
if (0 == DM_LSTRCMP(proto, "pppoe")) {
|
||||
dmuci_get_value_by_section_string(ss, "pppd_options", &pppd_opt);
|
||||
}
|
||||
|
||||
|
|
@ -610,7 +613,7 @@ static int configure_supported_ncp_options(struct uci_section *ss, char *value,
|
|||
DM_STRNCPY(ncp_opt, token, sizeof(ncp_opt));
|
||||
if (0 == DM_STRNCMP(ncp_opt, option, sizeof(ncp_opt))) {
|
||||
found = true;
|
||||
if (0 == DM_STRCMP(value, "1") && NULL != end) {
|
||||
if (0 == DM_LSTRCMP(value, "1") && NULL != end) {
|
||||
if (pos != 0)
|
||||
pos += snprintf(&list_options[pos], sizeof(list_options) - pos, "%c", ' ');
|
||||
|
||||
|
|
@ -626,16 +629,16 @@ static int configure_supported_ncp_options(struct uci_section *ss, char *value,
|
|||
token = strtok_r(NULL, " ", &end);
|
||||
}
|
||||
|
||||
if ((0 == DM_STRCMP(value, "0")) && found == false) {
|
||||
if ((0 == DM_LSTRCMP(value, "0")) && found == false) {
|
||||
if (pos != 0)
|
||||
pos += snprintf(&list_options[pos], sizeof(list_options) - pos, "%c", ' ');
|
||||
|
||||
pos += snprintf(&list_options[pos], sizeof(list_options) - pos, "%s", option);
|
||||
snprintf(&list_options[pos], sizeof(list_options) - pos, "%s", option);
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section(ss, "pppd_options", list_options);
|
||||
} else {
|
||||
if (0 == DM_STRCMP(value, "0")) {
|
||||
if (0 == DM_LSTRCMP(value, "0")) {
|
||||
dmuci_set_value_by_section(ss, "pppd_options", option);
|
||||
}
|
||||
}
|
||||
|
|
@ -653,11 +656,11 @@ static int parse_pppd_options(char *pppd_opt, int option)
|
|||
char value[50] = {0};
|
||||
DM_STRNCPY(value, token, sizeof(value));
|
||||
|
||||
if ((4 == DM_STRLEN(value)) && 0 == DM_STRCMP(value, "noip")) {
|
||||
if ((4 == DM_STRLEN(value)) && 0 == DM_LSTRCMP(value, "noip")) {
|
||||
noip = 1;
|
||||
}
|
||||
|
||||
if (0 == DM_STRNCMP(value, "noipv6", 6)) {
|
||||
if (0 == DM_LSTRNCMP(value, "noipv6", 6)) {
|
||||
noipv6 = 1;
|
||||
}
|
||||
|
||||
|
|
@ -676,7 +679,7 @@ static int handle_supported_ncp_options(struct uci_section *s, char *instance, i
|
|||
char *pppd_opt = NULL, *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (proto && DM_STRCMP(proto, "pppoe") == 0)
|
||||
if (proto && DM_LSTRCMP(proto, "pppoe") == 0)
|
||||
dmuci_get_value_by_section_string(s, "pppd_options", &pppd_opt);
|
||||
|
||||
return pppd_opt ? parse_pppd_options(pppd_opt, option) : 0;
|
||||
|
|
@ -774,7 +777,8 @@ static int get_PPPInterfaceIPCP_LocalIPAddress(char *refparam, struct dmctx *ctx
|
|||
if (ppp_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
char *if_name = section_name(ppp_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
json_object *ipv4_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
|
||||
*value = dmjson_get_value(ipv4_obj, 1, "address");
|
||||
|
|
@ -789,7 +793,8 @@ static int get_PPPInterfaceIPCP_RemoteIPAddress(char *refparam, struct dmctx *ct
|
|||
if (ppp_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
char *if_name = section_name(ppp_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
json_object *ipv4_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
|
||||
*value = dmjson_get_value(ipv4_obj, 1, "ptpaddress");
|
||||
|
|
@ -808,7 +813,8 @@ static int get_PPPInterfaceIPCP_DNSServers(char *refparam, struct dmctx *ctx, vo
|
|||
if (ppp_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
char *if_name = section_name(ppp_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
*value = dmjson_get_value_array_all(res, ",", 1, "dns-server");
|
||||
}
|
||||
|
|
@ -822,7 +828,8 @@ static int get_PPPInterfaceIPv6CP_LocalInterfaceIdentifier(char *refparam, struc
|
|||
if (ppp_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
char *if_name = section_name(ppp_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
json_object *ipv4_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address");
|
||||
*value = dmjson_get_value(ipv4_obj, 1, "address");
|
||||
|
|
@ -837,7 +844,8 @@ static int get_PPPInterfaceIPv6CP_RemoteInterfaceIdentifier(char *refparam, stru
|
|||
if (ppp_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
char *if_name = section_name(ppp_s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
*value = dmjson_get_value(res, 2, "data", "llremote");
|
||||
}
|
||||
|
|
@ -852,7 +860,7 @@ static int ppp_read_sysfs(void *data, const char *name, char **value)
|
|||
char *proto;
|
||||
|
||||
dmuci_get_value_by_section_string(ppp_s, "proto", &proto);
|
||||
if (!DM_STRCMP(proto, "pppoe")) {
|
||||
if (!DM_LSTRCMP(proto, "pppoe")) {
|
||||
char *l3_device = get_l3_device(section_name(ppp_s));
|
||||
get_net_device_sysfs(l3_device, name, value);
|
||||
}
|
||||
|
|
@ -1030,9 +1038,9 @@ static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
dmuci_get_value_by_section_string(eth_link_s, "is_eth", &is_eth);
|
||||
|
||||
// Update proto option
|
||||
dmuci_set_value_by_section(ppp->dmmap_s, "proto", !DM_STRCMP(is_eth, "1") ? "pppoe" : "pppoa");
|
||||
dmuci_set_value_by_section(ppp->dmmap_s, "proto", !DM_LSTRCMP(is_eth, "1") ? "pppoe" : "pppoa");
|
||||
if (ppp->iface_s)
|
||||
dmuci_set_value_by_section(ppp->iface_s, "proto", !DM_STRCMP(is_eth, "1") ? "pppoe" : "pppoa");
|
||||
dmuci_set_value_by_section(ppp->iface_s, "proto", !DM_LSTRCMP(is_eth, "1") ? "pppoe" : "pppoa");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1060,7 +1068,7 @@ static int get_PPPInterfacePPPoE_ACName(char *refparam, struct dmctx *ctx, void
|
|||
char *proto;
|
||||
|
||||
dmuci_get_value_by_section_string(ppp->iface_s ? ppp->iface_s : ppp->dmmap_s, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "pppoe") == 0) {
|
||||
if (DM_LSTRCMP(proto, "pppoe") == 0) {
|
||||
dmuci_get_value_by_section_string(ppp->iface_s ? ppp->iface_s : ppp->dmmap_s, "ac", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1078,7 +1086,7 @@ static int set_PPPInterfacePPPoE_ACName(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
|
||||
dmuci_get_value_by_section_string(ppp->iface_s ? ppp->iface_s : ppp->dmmap_s, "proto", &proto_intf);
|
||||
if (DM_STRCMP(proto_intf, "pppoe") != 0)
|
||||
if (DM_LSTRCMP(proto_intf, "pppoe") != 0)
|
||||
return FAULT_9001;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
@ -1097,7 +1105,7 @@ static int get_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx,
|
|||
char *proto;
|
||||
|
||||
dmuci_get_value_by_section_string(ppp->iface_s ? ppp->iface_s : ppp->dmmap_s, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "pppoe") == 0) {
|
||||
if (DM_LSTRCMP(proto, "pppoe") == 0) {
|
||||
dmuci_get_value_by_section_string(ppp->iface_s ? ppp->iface_s : ppp->dmmap_s, "service", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1115,7 +1123,7 @@ static int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx,
|
|||
return FAULT_9007;
|
||||
|
||||
dmuci_get_value_by_section_string(ppp->iface_s ? ppp->iface_s : ppp->dmmap_s, "proto", &proto);
|
||||
if (DM_STRCMP(proto, "pppoe") != 0)
|
||||
if (DM_LSTRCMP(proto, "pppoe") != 0)
|
||||
return FAULT_9001;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -215,12 +215,16 @@ static int get_ptm_fast_line(struct dmctx *ctx, void *data, char *instance, char
|
|||
json_object *res = NULL, *line_obj = NULL;
|
||||
|
||||
dmubus_call("fast", "status", UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as !res is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!res)
|
||||
return 0;
|
||||
line_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "line");
|
||||
if (!line_obj)
|
||||
return 0;
|
||||
if ( DM_STRCMP(dmjson_get_value(line_obj, 1, "status"), "up") == 0) {
|
||||
if ( DM_LSTRCMP(dmjson_get_value(line_obj, 1, "status"), "up") == 0) {
|
||||
*value = "Device.FAST.Line.1";
|
||||
dmuci_set_value_by_section((((struct ptm_args *)data)->sections)->dmmap_section, "ptm_ll_link", "fast_line_1");
|
||||
}
|
||||
|
|
@ -243,11 +247,11 @@ static int set_ptm_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (DM_STRNCMP(value, "Device.DSL.Channel.1", DM_STRLEN("Device.DSL.Channel.1")) != 0 && DM_STRNCMP(value, "Device.FAST.Line.1", DM_STRLEN("Device.FAST.Line.1")) != 0)
|
||||
if (DM_LSTRNCMP(value, "Device.DSL.Channel.1", strlen("Device.DSL.Channel.1")) != 0 && DM_LSTRNCMP(value, "Device.FAST.Line.1", strlen("Device.FAST.Line.1")) != 0)
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Device.DSL.Channel.1") == 0)
|
||||
if (DM_LSTRCMP(value, "Device.DSL.Channel.1") == 0)
|
||||
dmuci_set_value_by_section((((struct ptm_args *)data)->sections)->dmmap_section, "ptm_ll_link", "dsl_channel_1");
|
||||
else
|
||||
dmuci_set_value_by_section((((struct ptm_args *)data)->sections)->dmmap_section, "ptm_ll_link", "fast_line_1");
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ static int browseQoSClassificationInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
//synchronizing option src_ip of uci classify section to src_mask/src_ip of dmmap's classify section
|
||||
dmuci_get_value_by_section_string(p->config_section, "src_ip", &value);
|
||||
//checking if src_ip is an ip-prefix or ip address and synchronizing accordingly
|
||||
ret = DM_STRSTR(value, "/");
|
||||
ret = DM_LSTRSTR(value, "/");
|
||||
if (ret)
|
||||
dmuci_set_value_by_section_bbfdm(p->dmmap_section, "src_mask", value);
|
||||
else
|
||||
|
|
@ -43,7 +43,7 @@ static int browseQoSClassificationInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
//synchronizing option dest_ip of uci classify section to dest_mask/dest_ip of dmmap's classify section
|
||||
dmuci_get_value_by_section_string(p->config_section, "dest_ip", &value);
|
||||
//checking if src_ip is an ip-prefix or ip address and synchronizing accordingly
|
||||
ret = DM_STRSTR(value, "/");
|
||||
ret = DM_LSTRSTR(value, "/");
|
||||
if (ret)
|
||||
dmuci_set_value_by_section_bbfdm(p->dmmap_section, "dest_mask", value);
|
||||
else
|
||||
|
|
@ -1092,7 +1092,7 @@ static int get_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void
|
|||
static int set_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *dmmap_s = NULL;
|
||||
char *linker = NULL, link_inst[8] = {0};
|
||||
char *linker = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -1100,13 +1100,14 @@ static int set_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRNCMP(value, "Device.QoS.Policer.", 19) != 0)
|
||||
return 0;
|
||||
if (DM_LSTRNCMP(value, "Device.QoS.Policer.", 19) == 0 && strlen(value) >= 20) {
|
||||
char link_inst[8] = {0};
|
||||
snprintf(link_inst, sizeof(link_inst), "%c", value[19]); // TODO implementation need to be revisited
|
||||
get_dmmap_section_of_config_section_eq("dmmap_qos", "policer", "policer_instance", link_inst, &dmmap_s);
|
||||
dmuci_get_value_by_section_string(dmmap_s, "section_name", &linker);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "policer", linker);
|
||||
}
|
||||
|
||||
snprintf(link_inst, sizeof(link_inst), "%c", value[19]);
|
||||
get_dmmap_section_of_config_section_eq("dmmap_qos", "policer", "policer_instance", link_inst, &dmmap_s);
|
||||
dmuci_get_value_by_section_string(dmmap_s, "section_name", &linker);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "policer", linker);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1266,9 +1267,9 @@ static int set_QoSPolicer_PeakBurstSize(char *refparam, struct dmctx *ctx, void
|
|||
static int get_QoSPolicer_MeterType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "meter_type", value);
|
||||
if (DM_STRNCMP(*value, "1", 1) == 0)
|
||||
if (DM_LSTRNCMP(*value, "1", 1) == 0)
|
||||
*value = "SingleRateThreeColor";
|
||||
else if (DM_STRNCMP(*value, "2", 1) == 0)
|
||||
else if (DM_LSTRNCMP(*value, "2", 1) == 0)
|
||||
*value = "TwoRateThreeColor";
|
||||
else
|
||||
*value = "SimpleTokenBucket";
|
||||
|
|
@ -1280,15 +1281,15 @@ static int set_QoSPolicer_MeterType(char *refparam, struct dmctx *ctx, void *dat
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if ((DM_STRCMP("SimpleTokenBucket", value) != 0) && (DM_STRCMP("SingleRateThreeColor", value) != 0) && (DM_STRCMP("TwoRateThreeColor", value) != 0))
|
||||
if ((DM_LSTRCMP(value, "SimpleTokenBucket") != 0) && (DM_LSTRCMP(value, "SingleRateThreeColor") != 0) && (DM_LSTRCMP(value, "TwoRateThreeColor") != 0))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP("SimpleTokenBucket", value) == 0)
|
||||
if (DM_LSTRCMP(value, "SimpleTokenBucket") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "meter_type", "0");
|
||||
else if (DM_STRCMP("SingleRateThreeColor", value) == 0)
|
||||
else if (DM_LSTRCMP(value, "SingleRateThreeColor") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "meter_type", "1");
|
||||
else if (DM_STRCMP("TwoRateThreeColor", value) == 0)
|
||||
else if (DM_LSTRCMP(value, "TwoRateThreeColor") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "meter_type", "2");
|
||||
break;
|
||||
}
|
||||
|
|
@ -1509,7 +1510,7 @@ static int set_QoSQueueStats_Enable(char *refparam, struct dmctx *ctx, void *dat
|
|||
static int get_QoSQueueStats_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
get_QoSQueueStats_Enable(refparam, ctx, data, instance, value);
|
||||
*value = (DM_STRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ static int browseRouterAdvertisementInterfaceSettingInst(struct dmctx *dmctx, DM
|
|||
|
||||
// skip the section if option ignore = '1'
|
||||
dmuci_get_value_by_section_string(p->config_section, "ignore", &ignore);
|
||||
if (ignore && DM_STRCMP(ignore, "1") == 0)
|
||||
if (ignore && DM_LSTRCMP(ignore, "1") == 0)
|
||||
continue;
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "radv_intf_instance", "radv_intf_alias");
|
||||
|
|
@ -225,7 +225,7 @@ static int get_RouterAdvertisement_InterfaceSettingNumberOfEntries(char *refpara
|
|||
static int get_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ra", value);
|
||||
*value = (*value && DM_STRCMP(*value, "disabled") == 0) ? "0" : "1";
|
||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ static int set_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct
|
|||
static int get_RouterAdvertisementInterfaceSetting_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ra", value);
|
||||
*value = (*value && DM_STRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
|
||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,10 @@ static bool is_proc_route_in_config(struct proc_routing *proute)
|
|||
char *mask;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "netmask", &mask);
|
||||
if (mask[0] == '\0' || DM_STRCMP(proute->mask, mask) == 0)
|
||||
if (DM_STRLEN(mask) == 0)
|
||||
return true;
|
||||
|
||||
if (DM_STRCMP(proute->mask, mask) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +81,10 @@ static bool is_proc_route_in_config(struct proc_routing *proute)
|
|||
char *mask;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "netmask", &mask);
|
||||
if (mask[0] == '\0' || DM_STRCMP(proute->mask, mask) == 0)
|
||||
if (DM_STRLEN(mask) == 0)
|
||||
return true;
|
||||
|
||||
if (DM_STRCMP(proute->mask, mask) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -107,6 +113,10 @@ static bool is_proc_route6_in_config(char *cdev, char *cip, char *cgw)
|
|||
dmuci_get_value_by_section_string(s, "gateway", &gw_r);
|
||||
dmuci_get_value_by_section_string(s, "interface", &intf_r);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", intf_r, String}}, 1, &jobj);
|
||||
/* value of 'jobj' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(jobj) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
char *dev_r = (jobj) ? dmjson_get_value(jobj, 1, "device") : "";
|
||||
if (DM_STRCMP(cdev, dev_r) == 0 && DM_STRCMP(cgw, gw_r) == 0 && DM_STRCMP(cip, ip_r) == 0)
|
||||
return true;
|
||||
|
|
@ -120,6 +130,10 @@ static bool is_proc_route6_in_config(char *cdev, char *cip, char *cgw)
|
|||
dmuci_get_value_by_section_string(s, "gateway", &gw_r6);
|
||||
dmuci_get_value_by_section_string(s, "interface", &intf_r6);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", intf_r6, String}}, 1, &jobj);
|
||||
/* value of 'jobj' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(jobj) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
char *dev_r6 = (jobj) ? dmjson_get_value(jobj, 1, "device") : "";
|
||||
if (DM_STRCMP(cdev, dev_r6) == 0 && DM_STRCMP(cgw, gw_r6) == 0 && DM_STRCMP(cip, ip_r6) == 0)
|
||||
return true;
|
||||
|
|
@ -171,7 +185,7 @@ static int parse_proc_route6_line(const char *line, char *ipstr, char *gwstr, ch
|
|||
&gw[0], &gw[1], &gw[2], &gw[3], metric,
|
||||
&refcnt, &use, &flags, dev);
|
||||
|
||||
if (DM_STRCMP(dev, "lo") == 0)
|
||||
if (DM_LSTRCMP(dev, "lo") == 0)
|
||||
return -1;
|
||||
|
||||
ip[0] = htonl(ip[0]);
|
||||
|
|
@ -236,7 +250,8 @@ static int dmmap_synchronizeRoutingRouterIPv4Forwarding(struct dmctx *dmctx, DMN
|
|||
continue;
|
||||
iface = "";
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &jobj);
|
||||
char *if_name = section_name(s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
|
||||
if (!jobj) {
|
||||
fclose(fp);
|
||||
return 0;
|
||||
|
|
@ -310,7 +325,12 @@ static int dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DMN
|
|||
uci_foreach_sections("network", "interface", s) {
|
||||
json_object *jobj = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &jobj);
|
||||
char *if_name = section_name(s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
|
||||
/* value of 'jobj' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(jobj) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!jobj) {
|
||||
fclose(fp);
|
||||
return 0;
|
||||
|
|
@ -452,17 +472,18 @@ static int browseRoutingRouteInformationInterfaceSettingInst(struct dmctx *dmctx
|
|||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *inst = NULL;
|
||||
int id = 0, i = 0;
|
||||
int id = 0, i;
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
char *proto = NULL, *ip6addr = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(s, "ip6addr", &ip6addr);
|
||||
if ((proto && DM_STRCMP(proto, "dhcpv6") == 0) || (ip6addr && ip6addr[0] != '\0')) {
|
||||
if ((proto && DM_LSTRCMP(proto, "dhcpv6") == 0) || (ip6addr && ip6addr[0] != '\0')) {
|
||||
json_object *res = NULL, *route_obj = NULL, *arrobj = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
||||
char *if_name = section_name(s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
dmjson_foreach_obj_in_array(res, arrobj, route_obj, i, 1, "route") {
|
||||
inst = handle_instance_without_section(dmctx, parent_node, ++id);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)route_obj, inst) == DM_STOP)
|
||||
|
|
@ -643,7 +664,7 @@ static int get_router_ipv4forwarding_origin(char *refparam, struct dmctx *ctx, v
|
|||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "DHCPv4");
|
||||
char *proto = dmjson_get_value(res, 1, "proto");
|
||||
*value = (proto && DM_STRNCMP(proto, "ppp", 3) == 0) ? "IPCP" : "DHCPv4";
|
||||
*value = (proto && DM_LSTRNCMP(proto, "ppp", 3) == 0) ? "IPCP" : "DHCPv4";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -885,10 +906,11 @@ static int get_RoutingRouteInformation_InterfaceSettingNumberOfEntries(char *ref
|
|||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(s, "ip6addr", &ip6addr);
|
||||
if ((proto && DM_STRCMP(proto, "dhcpv6") == 0) || (ip6addr && ip6addr[0] != '\0')) {
|
||||
if ((proto && DM_LSTRCMP(proto, "dhcpv6") == 0) || (ip6addr && ip6addr[0] != '\0')) {
|
||||
json_object *res = NULL, *routes = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
||||
char *if_name = section_name(s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
json_object_object_get_ex(res, "route", &routes);
|
||||
nbre_routes = (routes) ? json_object_array_length(routes) : 0;
|
||||
|
|
@ -946,7 +968,12 @@ static int get_RoutingRouteInformationInterfaceSetting_Interface(char *refparam,
|
|||
uci_foreach_sections("network", "interface", s) {
|
||||
json_object *jobj = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &jobj);
|
||||
char *if_name = section_name(s);
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
|
||||
/* value of 'jobj' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(jobj) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!jobj) return 0;
|
||||
char *str = dmjson_get_value(jobj, 1, "device");
|
||||
if (DM_STRCMP(str, dev) == 0) {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ static int get_time_ntpserver(char *refparam, struct dmctx *ctx, char **value, i
|
|||
*value = "";
|
||||
return 0;
|
||||
}
|
||||
if (DM_STRCMP(*value, "none") == 0) {
|
||||
if (DM_LSTRCMP(*value, "none") == 0) {
|
||||
*value = "";
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,10 @@ static int browseUPnPDiscoveryRootDeviceInst(struct dmctx *dmctx, DMNODE *parent
|
|||
int i;
|
||||
|
||||
dmubus_call("upnpc", "discovery", UBUS_ARGS{{}}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as !res is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "devices", &devices);
|
||||
|
|
@ -115,7 +119,7 @@ static int browseUPnPDiscoveryRootDeviceInst(struct dmctx *dmctx, DMNODE *parent
|
|||
for (i = 0; i < nbre_devices; i++) {
|
||||
device = json_object_array_get_idx(devices, i);
|
||||
is_root_device = dmjson_get_value(device, 1, "is_root_device");
|
||||
if(DM_STRCMP(is_root_device, "0") == 0)
|
||||
if(DM_LSTRCMP(is_root_device, "0") == 0)
|
||||
continue;
|
||||
|
||||
descurl = dmjson_get_value(device, 1, "descurl");
|
||||
|
|
@ -156,6 +160,10 @@ static int browseUPnPDiscoveryDeviceInst(struct dmctx *dmctx, DMNODE *parent_nod
|
|||
int i;
|
||||
|
||||
dmubus_call("upnpc", "discovery", UBUS_ARGS{{}}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res==NULL is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "devices", &devices);
|
||||
|
|
@ -201,6 +209,10 @@ static int browseUPnPDiscoveryServiceInst(struct dmctx *dmctx, DMNODE *parent_no
|
|||
int i;
|
||||
|
||||
dmubus_call("upnpc", "discovery", UBUS_ARGS{{}}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res==NULL is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "services", &services);
|
||||
|
|
@ -244,6 +256,10 @@ static int browseUPnPDescriptionDeviceDescriptionInst(struct dmctx *dmctx, DMNOD
|
|||
int i;
|
||||
|
||||
dmubus_call("upnpc", "description", UBUS_ARGS{{}}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res==NULL is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "descriptions", &descriptions);
|
||||
|
|
@ -277,6 +293,10 @@ static int browseUPnPDescriptionDeviceInstanceInst(struct dmctx *dmctx, DMNODE *
|
|||
int i;
|
||||
|
||||
dmubus_call("upnpc", "description", UBUS_ARGS{{}}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res==NULL is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "devicesinstances", &devices_instances);
|
||||
|
|
@ -321,6 +341,10 @@ static int browseUPnPDescriptionServiceInstanceInst(struct dmctx *dmctx, DMNODE
|
|||
int i;
|
||||
|
||||
dmubus_call("upnpc", "description", UBUS_ARGS{{}}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as res==NULL is always true. so
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "servicesinstances", &services_instances);
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ static int browseUSBInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
snprintf(port_link, sizeof(port_link), "%s", foldersplit[0]);
|
||||
}
|
||||
sysfs_foreach_file(netfolderpath, dir, ent) {
|
||||
if(DM_STRCMP(ent->d_name, ".")==0 || DM_STRCMP(ent->d_name, "..")==0)
|
||||
if(DM_LSTRCMP(ent->d_name, ".")==0 || DM_LSTRCMP(ent->d_name, "..")==0)
|
||||
continue;
|
||||
|
||||
snprintf(iface_name, sizeof(iface_name), "%s", ent->d_name);
|
||||
|
|
@ -188,7 +188,7 @@ static int browseUSBPortInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
|
||||
if (regexec(®ex1, p->sysfs_folder_name, 0, NULL, 0) != 0 &&
|
||||
regexec(®ex2, p->sysfs_folder_name, 0, NULL, 0) !=0 &&
|
||||
DM_STRSTR(p->sysfs_folder_name, "usb") != p->sysfs_folder_name)
|
||||
DM_LSTRSTR(p->sysfs_folder_name, "usb") != p->sysfs_folder_name)
|
||||
continue;
|
||||
|
||||
init_usb_port(p->dmmap_section, p->sysfs_folder_name, p->sysfs_folder_path, &port);
|
||||
|
|
@ -215,7 +215,7 @@ static int browseUSBUSBHostsHostInst(struct dmctx *dmctx, DMNODE *parent_node, v
|
|||
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
if(!DM_STRSTR(p->sysfs_folder_name, "usb"))
|
||||
if(!DM_LSTRSTR(p->sysfs_folder_name, "usb"))
|
||||
continue;
|
||||
|
||||
init_usb_port(p->dmmap_section, p->sysfs_folder_name, p->sysfs_folder_path, &port);
|
||||
|
|
@ -245,7 +245,7 @@ static int synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, ch
|
|||
LIST_HEAD(dup_list_no_inst);
|
||||
|
||||
sysfs_foreach_file(sysfsrep, dir, ent) {
|
||||
if (DM_STRCMP(ent->d_name, ".") == 0 || DM_STRCMP(ent->d_name, "..") == 0)
|
||||
if (DM_LSTRCMP(ent->d_name, ".") == 0 || DM_LSTRCMP(ent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
if (regexec(®ex1, ent->d_name, 0, NULL, 0) == 0 || regexec(®ex2, ent->d_name, 0, NULL, 0) ==0) {
|
||||
|
|
@ -255,7 +255,7 @@ static int synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, ch
|
|||
snprintf(deviceClassFile, sizeof(deviceClassFile), "%s/%s/bDeviceClass", sysfsrep, ent->d_name);
|
||||
dm_read_sysfs_file(deviceClassFile, deviceClass, sizeof(deviceClass));
|
||||
|
||||
if (DM_STRNCMP(deviceClass, "09", 2) == 0) {
|
||||
if (DM_LSTRNCMP(deviceClass, "09", 2) == 0) {
|
||||
char hubpath[270];
|
||||
|
||||
snprintf(hubpath, sizeof(hubpath), "%s/%s", sysfsrep, ent->d_name);
|
||||
|
|
@ -375,7 +375,7 @@ static int browseUSBUSBHostsHostDeviceConfigurationInterfaceInst(struct dmctx *d
|
|||
|
||||
sysfs_foreach_file(usb_dev->folder_path, dir, ent) {
|
||||
|
||||
if (DM_STRCMP(ent->d_name, ".") == 0 || DM_STRCMP(ent->d_name, "..") == 0)
|
||||
if (DM_LSTRCMP(ent->d_name, ".") == 0 || DM_LSTRCMP(ent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
if (regexec(®ex1, ent->d_name, 0, NULL, 0) == 0 || regexec(®ex2, ent->d_name, 0, NULL, 0) == 0) {
|
||||
|
|
@ -610,9 +610,9 @@ static int get_USBPort_Type(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
__read_sysfs_usb_port(port, "bDeviceClass", deviceclass, sizeof(deviceclass));
|
||||
|
||||
if(DM_STRSTR(port->folder_name, "usb") == port->folder_name)
|
||||
if(DM_LSTRSTR(port->folder_name, "usb") == port->folder_name)
|
||||
*value= "Host";
|
||||
else if (DM_STRCMP(deviceclass, "09") == 0)
|
||||
else if (DM_LSTRCMP(deviceclass, "09") == 0)
|
||||
*value= "Hub";
|
||||
else
|
||||
*value= "Device";
|
||||
|
|
@ -625,11 +625,11 @@ static int get_USBPort_Rate(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
__read_sysfs_usb_port(data, "speed", speed, sizeof(speed));
|
||||
|
||||
if(DM_STRCMP(speed, "1.5") == 0)
|
||||
if(DM_LSTRCMP(speed, "1.5") == 0)
|
||||
*value= "Low";
|
||||
else if(DM_STRCMP(speed, "12") == 0)
|
||||
else if(DM_LSTRCMP(speed, "12") == 0)
|
||||
*value= "Full";
|
||||
else if(DM_STRCMP(speed, "480") == 0)
|
||||
else if(DM_LSTRCMP(speed, "480") == 0)
|
||||
*value= "High";
|
||||
else
|
||||
*value= "Super";
|
||||
|
|
@ -644,7 +644,7 @@ static int get_USBPort_Power(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
if (pwrctl[0] == 0)
|
||||
*value = "Unknown";
|
||||
else if (!DM_STRCMP(pwrctl, "auto"))
|
||||
else if (!DM_LSTRCMP(pwrctl, "auto"))
|
||||
*value ="Self";
|
||||
else
|
||||
*value ="Bus";
|
||||
|
|
@ -688,7 +688,7 @@ static int get_USBUSBHostsHost_Enable(char *refparam, struct dmctx *ctx, void *d
|
|||
char up[32];
|
||||
|
||||
__read_sysfs_usb_port(data, "power/wakeup", up, sizeof(up));
|
||||
*value = DM_STRCMP(up, "enabled") == 0 ? "1" : "0";
|
||||
*value = DM_LSTRCMP(up, "enabled") == 0 ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -745,7 +745,7 @@ static int get_USBUSBHostsHost_PowerManagementEnable(char *refparam, struct dmct
|
|||
|
||||
__read_sysfs_usb_port(data, "power/level", power, sizeof(power));
|
||||
|
||||
if(power[0] == 0 || DM_STRCMP(power, "suspend") == 0)
|
||||
if(power[0] == 0 || DM_LSTRCMP(power, "suspend") == 0)
|
||||
*value= "false";
|
||||
else
|
||||
*value= "true";
|
||||
|
|
@ -936,7 +936,7 @@ static int get_USBUSBHostsHostDevice_IsSuspended(char *refparam, struct dmctx *c
|
|||
char status[16] = {0};
|
||||
|
||||
__read_sysfs_usb_port(data, "power/runtime_status", status, sizeof(status));
|
||||
if(DM_STRNCMP(status, "suspended", 9) == 0)
|
||||
if(DM_LSTRNCMP(status, "suspended", 9) == 0)
|
||||
*value= "1";
|
||||
else
|
||||
*value = "0";
|
||||
|
|
|
|||
|
|
@ -122,32 +122,36 @@ static char *get_radio_option_nocache(const char *device_name, char *option)
|
|||
snprintf(object, sizeof(object), "wifi.radio.%s", device_name);
|
||||
dmubus_call(object, "status", UBUS_ARGS{0}, 0, &res);
|
||||
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(res) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
return (res) ? dmjson_get_value(res, 1, option) : "";
|
||||
}
|
||||
|
||||
static char *get_data_model_mode(const char *ubus_mode)
|
||||
{
|
||||
if (DM_STRCMP(ubus_mode, "WEP64") == 0)
|
||||
if (DM_LSTRCMP(ubus_mode, "WEP64") == 0)
|
||||
return "WEP-64";
|
||||
else if (DM_STRCMP(ubus_mode, "WEP128") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WEP128") == 0)
|
||||
return "WEP-128";
|
||||
else if (DM_STRCMP(ubus_mode, "WPAPSK") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPAPSK") == 0)
|
||||
return "WPA-Personal";
|
||||
else if (DM_STRCMP(ubus_mode, "WPA2PSK") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPA2PSK") == 0)
|
||||
return "WPA2-Personal";
|
||||
else if (DM_STRCMP(ubus_mode, "WPA3PSK") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPA3PSK") == 0)
|
||||
return "WPA3-Personal";
|
||||
else if (DM_STRCMP(ubus_mode, "WPAPSK+WPA2PSK") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPAPSK+WPA2PSK") == 0)
|
||||
return "WPA-WPA2-Personal";
|
||||
else if (DM_STRCMP(ubus_mode, "WPA2PSK+WPA3PSK") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPA2PSK+WPA3PSK") == 0)
|
||||
return "WPA3-Personal-Transition";
|
||||
else if (DM_STRCMP(ubus_mode, "WPA") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPA") == 0)
|
||||
return "WPA-Enterprise";
|
||||
else if (DM_STRCMP(ubus_mode, "WPA2") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPA2") == 0)
|
||||
return "WPA2-Enterprise";
|
||||
else if (DM_STRCMP(ubus_mode, "WPA3") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPA3") == 0)
|
||||
return "WPA3-Enterprise";
|
||||
else if (DM_STRCMP(ubus_mode, "WPA+WPA2") == 0)
|
||||
else if (DM_LSTRCMP(ubus_mode, "WPA+WPA2") == 0)
|
||||
return "WPA-WPA2-Enterprise";
|
||||
else
|
||||
return "None";
|
||||
|
|
@ -196,7 +200,7 @@ static char *get_security_mode(struct uci_section *section)
|
|||
if (ptrch)
|
||||
*ptrch = '\0';
|
||||
|
||||
if (DM_STRSTR(encryption, "wep")) {
|
||||
if (DM_LSTRSTR(encryption, "wep")) {
|
||||
char *key_index = NULL, *key = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(section, "key", &key_index);
|
||||
|
|
@ -208,23 +212,23 @@ static char *get_security_mode(struct uci_section *section)
|
|||
}
|
||||
return (key && DM_STRLEN(key) == 10) ? "WEP-64" : "WEP-128";
|
||||
}
|
||||
else if (DM_STRNCMP(encryption, "psk-mixed", 9) == 0)
|
||||
else if (DM_LSTRNCMP(encryption, "psk-mixed", 9) == 0)
|
||||
return "WPA-WPA2-Personal";
|
||||
else if (DM_STRNCMP(encryption, "psk2", 4) == 0)
|
||||
else if (DM_LSTRNCMP(encryption, "psk2", 4) == 0)
|
||||
return "WPA2-Personal";
|
||||
else if (DM_STRNCMP(encryption, "psk", 3) == 0)
|
||||
else if (DM_LSTRNCMP(encryption, "psk", 3) == 0)
|
||||
return "WPA-Personal";
|
||||
else if (DM_STRCMP(encryption, "sae") == 0)
|
||||
else if (DM_LSTRCMP(encryption, "sae") == 0)
|
||||
return "WPA3-Personal";
|
||||
else if (DM_STRCMP(encryption, "sae-mixed") == 0)
|
||||
else if (DM_LSTRCMP(encryption, "sae-mixed") == 0)
|
||||
return "WPA3-Personal-Transition";
|
||||
else if (DM_STRNCMP(encryption, "wpa-mixed", 9) == 0)
|
||||
else if (DM_LSTRNCMP(encryption, "wpa-mixed", 9) == 0)
|
||||
return "WPA-WPA2-Enterprise";
|
||||
else if (DM_STRNCMP(encryption, "wpa2", 4) == 0)
|
||||
else if (DM_LSTRNCMP(encryption, "wpa2", 4) == 0)
|
||||
return "WPA2-Enterprise";
|
||||
else if (DM_STRNCMP(encryption, "wpa3", 4) == 0)
|
||||
else if (DM_LSTRNCMP(encryption, "wpa3", 4) == 0)
|
||||
return "WPA3-Enterprise";
|
||||
else if (DM_STRNCMP(encryption, "wpa", 3) == 0)
|
||||
else if (DM_LSTRNCMP(encryption, "wpa", 3) == 0)
|
||||
return "WPA-Enterprise";
|
||||
else
|
||||
return "None";
|
||||
|
|
@ -281,7 +285,7 @@ struct uci_section *find_mapcontroller_ssid_section(struct uci_section *wireless
|
|||
return NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(wireless_ssid_s, "multi_ap", &multi_ap);
|
||||
if (DM_STRCMP(multi_ap, "2") != 0)
|
||||
if (DM_LSTRCMP(multi_ap, "2") != 0)
|
||||
return NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(wireless_ssid_s, "network", &network);
|
||||
|
|
@ -350,7 +354,7 @@ static int delete_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(ssid_s), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "ap_added_by_user", &added_by_user);
|
||||
if (DM_STRCMP(added_by_user, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_user, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
|
@ -400,7 +404,7 @@ static int delete_wifi_accesspoint(char *refparam, struct dmctx *ctx, void *data
|
|||
|
||||
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(ap_s), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "ssid_added_by_user", &added_by_user);
|
||||
if (DM_STRCMP(added_by_user, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_user, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
|
@ -443,7 +447,7 @@ static int delObjWiFiEndPoint(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
char *mode;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "mode", &mode);
|
||||
if (DM_STRCMP(mode, "sta") != 0)
|
||||
if (DM_LSTRCMP(mode, "sta") != 0)
|
||||
continue;
|
||||
|
||||
dmuci_set_value_by_section(s, "mode", "");
|
||||
|
|
@ -509,7 +513,7 @@ static int browseWifiSsidInst(struct dmctx *dmctx, DMNODE *parent_node, void *pr
|
|||
char *added_by_user;
|
||||
|
||||
dmuci_get_value_by_section_string(p->dmmap_section, "ap_added_by_user", &added_by_user);
|
||||
if (DM_STRCMP(added_by_user, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_user, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(p->dmmap_section, "ifname", &ifname);
|
||||
|
|
@ -539,11 +543,11 @@ static int browseWifiAccessPointInst(struct dmctx *dmctx, DMNODE *parent_node, v
|
|||
char *mode, *ifname, *added_by_user;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "mode", &mode);
|
||||
if (DM_STRCMP(mode, "ap") != 0)
|
||||
if (DM_LSTRCMP(mode, "ap") != 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(p->dmmap_section, "ssid_added_by_user", &added_by_user);
|
||||
if (DM_STRCMP(added_by_user, "1") == 0)
|
||||
if (DM_LSTRCMP(added_by_user, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
||||
|
|
@ -573,7 +577,7 @@ static int browseWiFiEndPointInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "mode", &mode);
|
||||
if (DM_STRCMP(mode, "sta") != 0)
|
||||
if (DM_LSTRCMP(mode, "sta") != 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
||||
|
|
@ -609,7 +613,7 @@ static int browseWifiNeighboringWiFiDiagnosticResultInst(struct dmctx *dmctx, DM
|
|||
struct uci_section *s = NULL;
|
||||
json_object *res = NULL, *accesspoints = NULL, *arrobj = NULL;
|
||||
char object[32], *inst = NULL;
|
||||
int id = 0, i = 0;
|
||||
int id = 0, i;
|
||||
|
||||
uci_foreach_sections("wireless", "wifi-device", s) {
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(s));
|
||||
|
|
@ -650,7 +654,7 @@ static int browseWiFiDataElementsNetworkSSIDInst(struct dmctx *dmctx, DMNODE *pa
|
|||
char *type = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "type", &type);
|
||||
if (DM_STRCMP(type, "fronthaul") != 0)
|
||||
if (DM_LSTRCMP(type, "fronthaul") != 0)
|
||||
continue;
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "wifi_da_ssid_instance", "wifi_da_ssid_alias");
|
||||
|
|
@ -1320,7 +1324,7 @@ static int set_WiFiRadio_DTIMPeriod(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
dmuci_get_value_by_section_string(s, "mode", &mode);
|
||||
|
||||
if (DM_STRCMP(mode, "ap") != 0)
|
||||
if (DM_LSTRCMP(mode, "ap") != 0)
|
||||
continue;
|
||||
|
||||
dmuci_set_value_by_section(s, "dtim_period", value);
|
||||
|
|
@ -1343,7 +1347,7 @@ static int get_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx
|
|||
int freq;
|
||||
|
||||
sscanf(htmode, "%*[A-Z]%d", &freq);
|
||||
dmasprintf(value, "%dMHz", !DM_STRCMP(htmode, "NOHT") ? 20 : freq);
|
||||
dmasprintf(value, "%dMHz", !DM_LSTRCMP(htmode, "NOHT") ? 20 : freq);
|
||||
} else {
|
||||
*value = "Auto";
|
||||
}
|
||||
|
|
@ -1365,8 +1369,8 @@ static int get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, str
|
|||
bandwidth_list[0] = 0;
|
||||
dmjson_foreach_obj_in_array(res, arrobj, supp_channels, i, 1, "supp_channels") {
|
||||
char *bandwidth = dmjson_get_value(supp_channels, 1, "bandwidth");
|
||||
if (bandwidth && !strstr(bandwidth_list, !DM_STRCMP(bandwidth, "8080") ? "80+80" : !DM_STRCMP(bandwidth, "80") ? ",80MHz" : bandwidth)) {
|
||||
pos += snprintf(&bandwidth_list[pos], sizeof(bandwidth_list) - pos, "%sMHz,", !DM_STRCMP(bandwidth, "8080") ? "80+80" : bandwidth);
|
||||
if (bandwidth && !strstr(bandwidth_list, !DM_LSTRCMP(bandwidth, "8080") ? "80+80" : !DM_LSTRCMP(bandwidth, "80") ? ",80MHz" : bandwidth)) {
|
||||
pos += snprintf(&bandwidth_list[pos], sizeof(bandwidth_list) - pos, "%sMHz,", !DM_LSTRCMP(bandwidth, "8080") ? "80+80" : bandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1402,9 +1406,9 @@ static int set_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx
|
|||
|
||||
dmuci_get_value_by_section_string((((struct wifi_radio_args *)data)->sections)->config_section, "htmode", &curr_htmode);
|
||||
|
||||
if (DM_STRNCMP(curr_htmode, "VHT", 3) == 0)
|
||||
if (DM_LSTRNCMP(curr_htmode, "VHT", 3) == 0)
|
||||
snprintf(htmode, sizeof(htmode), "VHT%d", freq);
|
||||
else if (DM_STRNCMP(curr_htmode, "HT", 2) == 0 && (freq == 20 || freq == 40))
|
||||
else if (DM_LSTRNCMP(curr_htmode, "HT", 2) == 0 && (freq == 20 || freq == 40))
|
||||
snprintf(htmode, sizeof(htmode), "HT%d", freq);
|
||||
else
|
||||
snprintf(htmode, sizeof(htmode), "HE%d", freq);
|
||||
|
|
@ -1431,7 +1435,7 @@ static int set_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *d
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section((((struct wifi_radio_args *)data)->sections)->config_section, "short_preamble", (DM_STRCMP(value, "short") == 0) ? "1" : "0");
|
||||
dmuci_set_value_by_section((((struct wifi_radio_args *)data)->sections)->config_section, "short_preamble", (DM_LSTRCMP(value, "short") == 0) ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1533,7 +1537,7 @@ static int set_radio_channel(char *refparam, struct dmctx *ctx, void *data, char
|
|||
static int get_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((((struct wifi_radio_args *)data)->sections)->config_section, "channel", value);
|
||||
if (DM_STRCMP(*value, "auto") == 0 || (*value)[0] == '\0')
|
||||
if (DM_LSTRCMP(*value, "auto") == 0 || (*value)[0] == '\0')
|
||||
*value = "1";
|
||||
else
|
||||
*value = "0";
|
||||
|
|
@ -1618,7 +1622,7 @@ static int get_access_point_control_enable(char *refparam, struct dmctx *ctx, vo
|
|||
char *macfilter;
|
||||
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "macfilter", &macfilter);
|
||||
if (macfilter[0] == 0 || DM_STRCMP(macfilter, "deny") == 0 || DM_STRCMP(macfilter, "disable") == 0)
|
||||
if (macfilter[0] == 0 || DM_LSTRCMP(macfilter, "deny") == 0 || DM_LSTRCMP(macfilter, "disable") == 0)
|
||||
*value = "false";
|
||||
else
|
||||
*value = "true";
|
||||
|
|
@ -1801,11 +1805,11 @@ static void set_security_mode(struct uci_section *section, char *value, bool is_
|
|||
reset_wlan(section);
|
||||
dmuci_set_value_by_section(section, "ieee80211w", "0");
|
||||
|
||||
if (DM_STRCMP(value, "None") == 0) {
|
||||
if (DM_LSTRCMP(value, "None") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "none");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "none");
|
||||
} else if (DM_STRCMP(value, "WEP-64") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WEP-64") == 0) {
|
||||
char key[16], buf[11];
|
||||
int i;
|
||||
|
||||
|
|
@ -1818,7 +1822,7 @@ static void set_security_mode(struct uci_section *section, char *value, bool is_
|
|||
dmuci_set_value_by_section(section, "key", "1");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "none");
|
||||
} else if (DM_STRCMP(value, "WEP-128") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WEP-128") == 0) {
|
||||
char key[16], buf[27];
|
||||
int i;
|
||||
|
||||
|
|
@ -1831,19 +1835,19 @@ static void set_security_mode(struct uci_section *section, char *value, bool is_
|
|||
dmuci_set_value_by_section(section, "key", "1");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "none");
|
||||
} else if (DM_STRCMP(value, "WPA-Personal") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA-Personal") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "psk");
|
||||
dmuci_set_value_by_section(section, "key", wpa_key);
|
||||
dmuci_set_value_by_section(section, "wpa_group_rekey", "3600");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "psk");
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "key", wpa_key);
|
||||
} else if (DM_STRCMP(value, "WPA-Enterprise") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA-Enterprise") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "wpa");
|
||||
dmuci_set_value_by_section(section, "auth_port", "1812");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "wpa");
|
||||
} else if (DM_STRCMP(value, "WPA2-Personal") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA2-Personal") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "psk2");
|
||||
dmuci_set_value_by_section(section, "key", wpa_key);
|
||||
dmuci_set_value_by_section(section, "wpa_group_rekey", "3600");
|
||||
|
|
@ -1852,13 +1856,13 @@ static void set_security_mode(struct uci_section *section, char *value, bool is_
|
|||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "psk2");
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "key", wpa_key);
|
||||
} else if (DM_STRCMP(value, "WPA2-Enterprise") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA2-Enterprise") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "wpa2");
|
||||
dmuci_set_value_by_section(section, "auth_port", "1812");
|
||||
dmuci_set_value_by_section(section, "ieee80211w", "1");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "wpa2");
|
||||
} else if (DM_STRCMP(value, "WPA-WPA2-Personal") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA-WPA2-Personal") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "psk-mixed");
|
||||
dmuci_set_value_by_section(section, "key", wpa_key);
|
||||
dmuci_set_value_by_section(section, "wpa_group_rekey", "3600");
|
||||
|
|
@ -1866,24 +1870,24 @@ static void set_security_mode(struct uci_section *section, char *value, bool is_
|
|||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "psk-mixed");
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "key", wpa_key);
|
||||
} else if (DM_STRCMP(value, "WPA-WPA2-Enterprise") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA-WPA2-Enterprise") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "wpa-mixed");
|
||||
dmuci_set_value_by_section(section, "auth_port", "1812");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "wpa-mixed");
|
||||
} else if (DM_STRCMP(value, "WPA3-Personal") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA3-Personal") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "sae");
|
||||
dmuci_set_value_by_section(section, "key", wpa_key);
|
||||
dmuci_set_value_by_section(section, "ieee80211w", "2");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "sae");
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "key", wpa_key);
|
||||
} else if (DM_STRCMP(value, "WPA3-Enterprise") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA3-Enterprise") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "wpa3");
|
||||
dmuci_set_value_by_section(section, "auth_port", "1812");
|
||||
|
||||
if (map_ssid_s) dmuci_set_value_by_section(map_ssid_s, "encryption", "wpa");
|
||||
} else if (DM_STRCMP(value, "WPA3-Personal-Transition") == 0) {
|
||||
} else if (DM_LSTRCMP(value, "WPA3-Personal-Transition") == 0) {
|
||||
dmuci_set_value_by_section(section, "encryption", "sae-mixed");
|
||||
dmuci_set_value_by_section(section, "key", wpa_key);
|
||||
dmuci_set_value_by_section(section, "ieee80211w", "1");
|
||||
|
|
@ -1936,7 +1940,7 @@ static int set_access_point_security_wepkey(char *refparam, struct dmctx *ctx, v
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "wep")) {
|
||||
if (DM_LSTRSTR(encryption, "wep")) {
|
||||
char *key_index = NULL, buf[16];
|
||||
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "key", &key_index);
|
||||
|
|
@ -1960,7 +1964,7 @@ static int set_access_point_security_shared_key(char *refparam, struct dmctx *ct
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "psk")) {
|
||||
if (DM_LSTRSTR(encryption, "psk")) {
|
||||
dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->config_section, "key", value);
|
||||
|
||||
// mapcontroller config: Update the corresponding fronthaul ssid section if exist
|
||||
|
|
@ -1984,7 +1988,7 @@ static int set_access_point_security_passphrase(char *refparam, struct dmctx *ct
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "psk"))
|
||||
if (DM_LSTRSTR(encryption, "psk"))
|
||||
set_access_point_security_shared_key(refparam, ctx, data, instance, value, action);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2009,7 +2013,7 @@ static int set_access_point_security_rekey_interval(char *refparam, struct dmctx
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "encryption", &encryption);
|
||||
if (!DM_STRSTR(encryption, "wep") && DM_STRCMP(encryption, "none") != 0)
|
||||
if (!DM_LSTRSTR(encryption, "wep") && DM_LSTRCMP(encryption, "none") != 0)
|
||||
dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->config_section, "wpa_group_rekey", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2029,7 +2033,7 @@ static int set_WiFiAccessPointSecurity_SAEPassphrase(char *refparam, struct dmct
|
|||
break;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "sae")) {
|
||||
if (DM_LSTRSTR(encryption, "sae")) {
|
||||
dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->config_section, "key", value);
|
||||
|
||||
// mapcontroller config: Update the corresponding fronthaul ssid section if exist
|
||||
|
|
@ -2059,7 +2063,7 @@ static int set_access_point_security_radius_ip_address(char *refparam, struct dm
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "wpa"))
|
||||
if (DM_LSTRSTR(encryption, "wpa"))
|
||||
dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->config_section, "auth_server", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2084,7 +2088,7 @@ static int set_access_point_security_radius_server_port(char *refparam, struct d
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "wpa"))
|
||||
if (DM_LSTRSTR(encryption, "wpa"))
|
||||
dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->config_section, "auth_port", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2102,7 +2106,7 @@ static int set_access_point_security_radius_secret(char *refparam, struct dmctx
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "wpa"))
|
||||
if (DM_LSTRSTR(encryption, "wpa"))
|
||||
dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->config_section, "auth_secret", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2129,13 +2133,13 @@ static void get_cipher(char *encryption, bool *aes, bool *sae, bool *tkip)
|
|||
|
||||
for (token = strtok_r(encryption, "+", &saveptr); token; token = strtok_r(NULL, "+", &saveptr)) {
|
||||
|
||||
if (DM_STRCMP(token, "aes") == 0)
|
||||
if (DM_LSTRCMP(token, "aes") == 0)
|
||||
*aes = true;
|
||||
|
||||
if (DM_STRCMP(token, "sae") == 0)
|
||||
if (DM_LSTRCMP(token, "sae") == 0)
|
||||
*sae = true;
|
||||
|
||||
if (DM_STRCMP(token, "tkip") == 0)
|
||||
if (DM_LSTRCMP(token, "tkip") == 0)
|
||||
*tkip = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2162,23 +2166,23 @@ static int validate_mfp_config(struct uci_section *section, const char *value)
|
|||
/*Here we get which cipher is true*/
|
||||
get_cipher(encryption, &aes, &sae, &tkip);
|
||||
|
||||
if ((DM_STRCMP(mode, "WPA3-Personal")) == 0) {
|
||||
if ((sae == true || aes == true) && (tkip == false) && (DM_STRCMP(value, "Required") == 0))
|
||||
if ((DM_LSTRCMP(mode, "WPA3-Personal")) == 0) {
|
||||
if ((sae == true || aes == true) && (tkip == false) && (DM_LSTRCMP(value, "Required") == 0))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
} else if (DM_STRCMP(mode, "WPA2-Personal") == 0) {
|
||||
if ((aes == true) && (tkip == false) && (DM_STRCMP(value, "Optional") == 0))
|
||||
} else if (DM_LSTRCMP(mode, "WPA2-Personal") == 0) {
|
||||
if ((aes == true) && (tkip == false) && (DM_LSTRCMP(value, "Optional") == 0))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
|
||||
} else if (DM_STRCMP(mode, "WPA3-Personal-Transition") == 0) {
|
||||
if ((sae == true || aes == true) && (tkip == false) && (DM_STRCMP(value, "Optional") == 0))
|
||||
} else if (DM_LSTRCMP(mode, "WPA3-Personal-Transition") == 0) {
|
||||
if ((sae == true || aes == true) && (tkip == false) && (DM_LSTRCMP(value, "Optional") == 0))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
} else if (DM_STRCMP(value, "Disabled") == 0)
|
||||
} else if (DM_LSTRCMP(value, "Disabled") == 0)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
|
|
@ -2199,11 +2203,11 @@ static int set_WiFiAccessPointSecurity_MFPConfig(char *refparam, struct dmctx *c
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Disabled") == 0)
|
||||
if (DM_LSTRCMP(value, "Disabled") == 0)
|
||||
buf[0] = '0';
|
||||
else if (DM_STRCMP(value, "Optional") == 0)
|
||||
else if (DM_LSTRCMP(value, "Optional") == 0)
|
||||
buf[0] = '1';
|
||||
else if (DM_STRCMP(value, "Required") == 0)
|
||||
else if (DM_LSTRCMP(value, "Required") == 0)
|
||||
buf[0] = '2';
|
||||
buf[1] = 0;
|
||||
dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->config_section, "ieee80211w", buf);
|
||||
|
|
@ -2251,17 +2255,17 @@ static int get_wps_config_methods_enabled(struct uci_section *section, char **va
|
|||
dmuci_get_value_by_section_string(section, "wps_label", &label);
|
||||
dmuci_get_value_by_section_string(section, "wps_pin", &pin);
|
||||
|
||||
if (*pushbut && DM_STRCMP(pushbut, "1") == 0)
|
||||
if (*pushbut && DM_LSTRCMP(pushbut, "1") == 0)
|
||||
DM_STRNCPY(buf, "PushButton", sizeof(buf));
|
||||
|
||||
if (*label && DM_STRCMP(label, "1") == 0) {
|
||||
if (*label && DM_LSTRCMP(label, "1") == 0) {
|
||||
if (*buf)
|
||||
strcat(buf, ",");
|
||||
|
||||
strcat(buf, "Label");
|
||||
}
|
||||
|
||||
if (*pin && DM_STRCMP(pin, "1") == 0) {
|
||||
if (*pin && DM_LSTRCMP(pin, "1") == 0) {
|
||||
if (*buf)
|
||||
strcat(buf, ",");
|
||||
|
||||
|
|
@ -2280,13 +2284,13 @@ static void set_wps_config_methods_enabled(struct uci_section *section, char *va
|
|||
char *wps_list = dmstrdup(value);
|
||||
for (token = strtok_r(wps_list, ",", &saveptr); token; token = strtok_r(NULL, ",", &saveptr)) {
|
||||
|
||||
if (DM_STRCMP(token, "PushButton") == 0)
|
||||
if (DM_LSTRCMP(token, "PushButton") == 0)
|
||||
pushbut = true;
|
||||
|
||||
if (DM_STRCMP(token, "Label") == 0)
|
||||
if (DM_LSTRCMP(token, "Label") == 0)
|
||||
label = true;
|
||||
|
||||
if (DM_STRCMP(token, "PIN") == 0)
|
||||
if (DM_LSTRCMP(token, "PIN") == 0)
|
||||
pin = true;
|
||||
}
|
||||
dmfree(wps_list);
|
||||
|
|
@ -2603,7 +2607,7 @@ static int set_WiFiEndPointProfileSecurity_WEPKey(char *refparam, struct dmctx *
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((struct uci_section*)data, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "wep")) {
|
||||
if (DM_LSTRSTR(encryption, "wep")) {
|
||||
char *key_index = NULL, buf[16];
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section*)data, "key", &key_index);
|
||||
|
|
@ -2626,7 +2630,7 @@ static int set_WiFiEndPointProfileSecurity_PreSharedKey(char *refparam, struct d
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((struct uci_section*)data, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "psk"))
|
||||
if (DM_LSTRSTR(encryption, "psk"))
|
||||
dmuci_set_value_by_section((struct uci_section*)data, "key", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2644,7 +2648,7 @@ static int set_WiFiEndPointProfileSecurity_KeyPassphrase(char *refparam, struct
|
|||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((struct uci_section*)data, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "psk"))
|
||||
if (DM_LSTRSTR(encryption, "psk"))
|
||||
set_WiFiEndPointProfileSecurity_PreSharedKey(refparam, ctx, data, instance, value, action);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2663,7 +2667,7 @@ static int set_WiFiEndPointProfileSecurity_SAEPassphrase(char *refparam, struct
|
|||
break;
|
||||
case VALUESET:
|
||||
dmuci_get_value_by_section_string((struct uci_section*)data, "encryption", &encryption);
|
||||
if (DM_STRSTR(encryption, "sae"))
|
||||
if (DM_LSTRSTR(encryption, "sae"))
|
||||
dmuci_set_value_by_section((struct uci_section*)data, "key", value);
|
||||
break;
|
||||
}
|
||||
|
|
@ -2676,9 +2680,9 @@ static int get_WiFiEndPointProfileSecurity_MFPConfig(char *refparam, struct dmct
|
|||
dmuci_get_value_by_section_string((struct uci_section*)data, "ieee80211w", value);
|
||||
if(*value[0] == 0 || *value[0] == '0')
|
||||
*value = "Disabled";
|
||||
else if (DM_STRCMP(*value, "1") == 0)
|
||||
else if (DM_LSTRCMP(*value, "1") == 0)
|
||||
*value = "Optional";
|
||||
else if (DM_STRCMP(*value, "2") == 0)
|
||||
else if (DM_LSTRCMP(*value, "2") == 0)
|
||||
*value = "Required";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2691,11 +2695,11 @@ static int set_WiFiEndPointProfileSecurity_MFPConfig(char *refparam, struct dmct
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Disabled") == 0)
|
||||
if (DM_LSTRCMP(value, "Disabled") == 0)
|
||||
dmuci_set_value_by_section((struct uci_section*)data, "ieee80211w", "0");
|
||||
else if (DM_STRCMP(value, "Optional") == 0)
|
||||
else if (DM_LSTRCMP(value, "Optional") == 0)
|
||||
dmuci_set_value_by_section((struct uci_section*)data, "ieee80211w", "1");
|
||||
else if (DM_STRCMP(value, "Required") == 0)
|
||||
else if (DM_LSTRCMP(value, "Required") == 0)
|
||||
dmuci_set_value_by_section((struct uci_section*)data, "ieee80211w", "2");
|
||||
break;
|
||||
}
|
||||
|
|
@ -2948,7 +2952,7 @@ static int set_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, st
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Requested") == 0) {
|
||||
if (DM_LSTRCMP(value, "Requested") == 0) {
|
||||
uci_foreach_sections("wireless", "wifi-device", ss)
|
||||
wifi_start_scan(section_name(ss));
|
||||
|
||||
|
|
@ -3290,16 +3294,16 @@ static int get_access_point_associative_device_statistics_retrans_count(char *re
|
|||
/*#Device.WiFi.AccessPoint.{i}.Status!UBUS:wifi.ap.@Name/status//status*/
|
||||
static int get_wifi_access_point_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
json_object *res = NULL;
|
||||
char object[32], *status = NULL, *iface;
|
||||
|
||||
dmuci_get_value_by_section_string((((struct wifi_ssid_args *)data)->sections)->config_section, "device", &iface);
|
||||
snprintf(object, sizeof(object), "wifi.ap.%s", iface);
|
||||
dmubus_call(object, "status", UBUS_ARGS{0}, 0, &res);
|
||||
DM_ASSERT(res, status = "Error_Misconfigured");
|
||||
DM_ASSERT(res, *value = "Error_Misconfigured");
|
||||
status = dmjson_get_value(res, 1, "status");
|
||||
|
||||
if (DM_STRCMP(status, "running") == 0 || DM_STRCMP(status, "up") == 0)
|
||||
if (DM_LSTRCMP(status, "running") == 0 || DM_LSTRCMP(status, "up") == 0)
|
||||
*value = "Enabled";
|
||||
else
|
||||
*value = "Disabled";
|
||||
|
|
@ -3363,7 +3367,7 @@ static int set_radio_frequency(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section((((struct wifi_radio_args *)data)->sections)->config_section, "hwmode", (!DM_STRCMP(value, "5GHz") ? "11a" :"11g"));
|
||||
dmuci_set_value_by_section((((struct wifi_radio_args *)data)->sections)->config_section, "hwmode", (!DM_LSTRCMP(value, "5GHz") ? "11a" :"11g"));
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -3507,8 +3511,8 @@ static int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void
|
|||
dmubus_call(object, "status", UBUS_ARGS{0}, 0, &res);
|
||||
DM_ASSERT(res, *value = "n,ax");
|
||||
char *standard = dmjson_get_value(res, 1, "standard");
|
||||
if (DM_STRSTR(standard, "802.11")) {
|
||||
DM_STRNCPY(standard_list, standard + DM_STRLEN("802.11"), sizeof(standard_list));
|
||||
if (DM_LSTRSTR(standard, "802.11")) {
|
||||
DM_STRNCPY(standard_list, standard + strlen("802.11"), sizeof(standard_list));
|
||||
replace_char(standard_list, '/', ',');
|
||||
}
|
||||
|
||||
|
|
@ -3545,30 +3549,30 @@ static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
if (curr_htmode && *curr_htmode) {
|
||||
sscanf(curr_htmode, "%*[A-Z]%d", &freq);
|
||||
freq = !DM_STRCMP(curr_htmode, "NOHT") ? 20 : freq;
|
||||
freq = !DM_LSTRCMP(curr_htmode, "NOHT") ? 20 : freq;
|
||||
}
|
||||
|
||||
band = get_radio_option_nocache(section_name((((struct wifi_radio_args *)data)->sections)->config_section), "band");
|
||||
|
||||
if (DM_STRCMP(band, "5GHz") == 0) {
|
||||
if (DM_STRSTR(value, "ax"))
|
||||
if (DM_LSTRCMP(band, "5GHz") == 0) {
|
||||
if (DM_LSTRSTR(value, "ax"))
|
||||
snprintf(htmode, sizeof(htmode), "HE%d", freq);
|
||||
else if (DM_STRSTR(value, "ac"))
|
||||
else if (DM_LSTRSTR(value, "ac"))
|
||||
snprintf(htmode, sizeof(htmode), "VHT%d", freq);
|
||||
else if (DM_STRSTR(value, "n"))
|
||||
else if (DM_LSTRSTR(value, "n"))
|
||||
snprintf(htmode, sizeof(htmode), "HT%d", (freq != 20 && freq != 40) ? 20 : freq);
|
||||
else
|
||||
snprintf(htmode, sizeof(htmode), "NOHT");
|
||||
|
||||
snprintf(hwmode, sizeof(hwmode), "11a");
|
||||
} else {
|
||||
if (DM_STRSTR(value, "ax")) {
|
||||
if (DM_LSTRSTR(value, "ax")) {
|
||||
snprintf(htmode, sizeof(htmode), "HE%d", freq);
|
||||
snprintf(hwmode, sizeof(hwmode), "11g");
|
||||
} else if (DM_STRSTR(value, "n")) {
|
||||
} else if (DM_LSTRSTR(value, "n")) {
|
||||
snprintf(htmode, sizeof(htmode), "HT%d", (freq != 20 && freq != 40) ? 20 : freq);
|
||||
snprintf(hwmode, sizeof(hwmode), "11g");
|
||||
} else if (DM_STRSTR(value, "g")) {
|
||||
} else if (DM_LSTRSTR(value, "g")) {
|
||||
snprintf(htmode, sizeof(htmode), "NOHT");
|
||||
snprintf(hwmode, sizeof(hwmode), "11g");
|
||||
} else {
|
||||
|
|
@ -3602,7 +3606,7 @@ static int get_access_point_total_associations(char *refparam, struct dmctx *ctx
|
|||
static int get_WiFiDataElementsNetwork_option(const char *option, char **value)
|
||||
{
|
||||
int i = 0;
|
||||
json_object *res, *data_arr = NULL, *data_obj = NULL, *net_obj = NULL;
|
||||
json_object *res = NULL, *data_arr = NULL, *data_obj = NULL, *net_obj = NULL;
|
||||
|
||||
dmubus_call("wifi.dataelements.collector", "dump", UBUS_ARGS{0}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
|
|
@ -3656,7 +3660,7 @@ static int get_WiFiDataElementsNetworkSSID_Band(char *refparam, struct dmctx *ct
|
|||
char *band = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "band", &band);
|
||||
*value = (!DM_STRCMP(band, "2")) ? "2.4" : "5";
|
||||
*value = (!DM_LSTRCMP(band, "2")) ? "2.4" : "5";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -5284,6 +5288,10 @@ static int operate_WiFi_NeighboringWiFiDiagnostic(char *refparam, struct dmctx *
|
|||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("wifi", "status", UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(res) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
json_object *radios = NULL, *arrobj = NULL;
|
||||
int i = 0;
|
||||
|
|
|
|||
2
dmtree/vendor/iopsys/tr181/ethernet.c
vendored
2
dmtree/vendor/iopsys/tr181/ethernet.c
vendored
|
|
@ -15,7 +15,7 @@
|
|||
static int get_EthernetVLANTermination_MACVLAN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "type", value);
|
||||
*value = (DM_STRCMP(*value, "macvlan") == 0) ? "1" : "0";
|
||||
*value = (DM_LSTRCMP(*value, "macvlan") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
76
dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c
vendored
76
dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c
vendored
|
|
@ -44,7 +44,7 @@ static void sync_mcast_dmmap_iface_sec(struct uci_list *proxy_iface, char *s_mod
|
|||
|
||||
uci_foreach_element(proxy_iface, e) {
|
||||
char *p_ifname = dmstrdup(e->name);
|
||||
if (DM_STRSTR(p_ifname, "br-") != NULL)
|
||||
if (DM_LSTRSTR(p_ifname, "br-") != NULL)
|
||||
DM_STRNCPY(key, p_ifname, sizeof(key));
|
||||
else
|
||||
get_mcast_iface_key(p_ifname, key, sizeof(key));
|
||||
|
|
@ -103,7 +103,7 @@ void get_mcast_bridge_port_linker(struct dmctx *ctx, char *device_name, char **v
|
|||
char *mg = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(bridge_port_s, "management", &mg);
|
||||
if (mg && DM_STRCMP(mg, "1") == 0) {
|
||||
if (mg && DM_LSTRCMP(mg, "1") == 0) {
|
||||
char *device, linker[512] = "";
|
||||
|
||||
dmuci_get_value_by_section_string(bridge_port_s, "port", &device);
|
||||
|
|
@ -206,7 +206,7 @@ void synchronize_specific_config_sections_with_dmmap_mcast_filter(char *package,
|
|||
dmuci_get_value_by_section_string(dmmap_sect, "ipaddr", &f_ip);
|
||||
dmuci_get_value_by_section_string(dmmap_sect, "enable", &f_enable);
|
||||
|
||||
if ((f_ip[0] == '\0') || (DM_STRCMP(f_enable, "0") == 0))
|
||||
if ((f_ip[0] == '\0') || (DM_LSTRCMP(f_enable, "0") == 0))
|
||||
add_dmmap_config_dup_list(dup_list, s, dmmap_sect);
|
||||
}
|
||||
}
|
||||
|
|
@ -223,7 +223,7 @@ void synchronize_specific_config_sections_with_dmmap_mcast_filter(char *package,
|
|||
|
||||
static int get_br_key_from_lower_layer(char *lower_layer, char *key, size_t s_key)
|
||||
{
|
||||
char *p = DM_STRSTR(lower_layer, "Port");
|
||||
char *p = DM_LSTRSTR(lower_layer, "Port");
|
||||
|
||||
if (!p)
|
||||
return -1;
|
||||
|
|
@ -246,7 +246,7 @@ static int get_br_key_from_lower_layer(char *lower_layer, char *key, size_t s_ke
|
|||
int get_mcast_snooping_interface_val(char *value, char *ifname, size_t s_ifname)
|
||||
{
|
||||
/* Check if the value is valid or not. */
|
||||
if (DM_STRNCMP(value, "Device.Bridging.Bridge.", 23) != 0)
|
||||
if (DM_LSTRNCMP(value, "Device.Bridging.Bridge.", 23) != 0)
|
||||
return -1;
|
||||
|
||||
char key[10] = {0};
|
||||
|
|
@ -275,7 +275,7 @@ int get_mcast_snooping_interface_val(char *value, char *ifname, size_t s_ifname)
|
|||
|
||||
char *type, *name;
|
||||
dmuci_get_value_by_section_string(device_s, "type", &type);
|
||||
if (*type == '\0' || DM_STRCMP(type, "bridge") != 0)
|
||||
if (*type == '\0' || DM_LSTRCMP(type, "bridge") != 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(device_s, "name", &name);
|
||||
|
|
@ -540,6 +540,10 @@ static int browse_igmp_cgrp_inst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
char *inst = NULL;
|
||||
|
||||
dmubus_call("mcast", "stats", UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(res) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
int i = 0, id = 0;
|
||||
|
||||
|
|
@ -651,6 +655,10 @@ static int get_igmp_cgrps_no_of_entries(char *refparam, struct dmctx *ctx, void
|
|||
json_object *res = NULL, *jobj = NULL, *arrobj = NULL, *group_obj = NULL;
|
||||
|
||||
dmubus_call("mcast", "stats", UBUS_ARGS{0}, 0, &res);
|
||||
/* value of 'res' is being changed inside dmubus_call by pointer reference,
|
||||
* which cppcheck can't track and throws warning as if(res) is always false.
|
||||
* so suppressed the warning */
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (res) {
|
||||
int i = 0;
|
||||
|
||||
|
|
@ -666,7 +674,7 @@ static int get_igmp_cgrps_no_of_entries(char *refparam, struct dmctx *ctx, void
|
|||
int get_mcasts_filter_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *f_sec = NULL;
|
||||
char *f_inst, *f_enable;
|
||||
char *f_inst, *f_enable = NULL;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter",
|
||||
"section_name", section_name((struct uci_section *)data), f_sec) {
|
||||
|
|
@ -677,7 +685,7 @@ int get_mcasts_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
|
|||
}
|
||||
}
|
||||
|
||||
if (DM_STRCMP(f_enable, "1") == 0) {
|
||||
if (DM_LSTRCMP(f_enable, "1") == 0) {
|
||||
*value = "true";
|
||||
} else {
|
||||
*value = "false";
|
||||
|
|
@ -800,7 +808,7 @@ static int get_igmp_version(char *refparam, struct dmctx *ctx, void *data, char
|
|||
{
|
||||
char *val;
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "version", &val);
|
||||
*value = (DM_STRCMP(val, "3") == 0) ? "V3" : "V2";
|
||||
*value = (DM_LSTRCMP(val, "3") == 0) ? "V3" : "V2";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -808,11 +816,11 @@ static int set_igmp_version(char *refparam, struct dmctx *ctx, void *data, char
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if ((DM_STRCMP("V2", value) != 0) && (DM_STRCMP("V3", value) != 0))
|
||||
if ((DM_LSTRCMP(value, "V2") != 0) && (DM_LSTRCMP(value, "V3") != 0))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "version", (DM_STRCMP(value, "V2") == 0) ? "2" : "3");
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "version", (DM_LSTRCMP(value, "V2") == 0) ? "2" : "3");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -824,9 +832,9 @@ int get_mcast_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char
|
|||
char *val;
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "snooping_mode", &val);
|
||||
|
||||
if (DM_STRCMP(val, "1") == 0)
|
||||
if (DM_LSTRCMP(val, "1") == 0)
|
||||
*value = "Standard";
|
||||
else if (DM_STRCMP(val, "2") == 0)
|
||||
else if (DM_LSTRCMP(val, "2") == 0)
|
||||
*value = "Blocking";
|
||||
else
|
||||
*value = "Disabled";
|
||||
|
|
@ -840,15 +848,15 @@ int set_mcast_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if ((DM_STRCMP("Standard", value) != 0)
|
||||
&& (DM_STRCMP("Blocking", value) != 0)
|
||||
&& (DM_STRCMP("Disabled", value) != 0))
|
||||
if ((DM_LSTRCMP(value, "Standard") != 0)
|
||||
&& (DM_LSTRCMP(value, "Blocking") != 0)
|
||||
&& (DM_LSTRCMP(value, "Disabled") != 0))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Standard") == 0)
|
||||
if (DM_LSTRCMP(value, "Standard") == 0)
|
||||
DM_STRNCPY(val, "1", sizeof(val));
|
||||
else if (DM_STRCMP(value, "Blocking") == 0)
|
||||
else if (DM_LSTRCMP(value, "Blocking") == 0)
|
||||
DM_STRNCPY(val, "2", sizeof(val));
|
||||
else
|
||||
DM_STRNCPY(val, "0", sizeof(val));
|
||||
|
|
@ -967,7 +975,7 @@ int get_mcast_snooping_interface(char *refparam, struct dmctx *ctx, void *data,
|
|||
if ((tok == NULL) || (end == NULL))
|
||||
return 0;
|
||||
|
||||
if (DM_STRCMP(tok, "br") != 0)
|
||||
if (DM_LSTRCMP(tok, "br") != 0)
|
||||
return 0;
|
||||
|
||||
DM_STRNCPY(sec_name, end, sizeof(sec_name));
|
||||
|
|
@ -1016,7 +1024,7 @@ static void get_igmpp_iface_del_key_val(char *key, size_t key_size, char *if_nam
|
|||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *ifval;
|
||||
if (DM_STRSTR(if_name, "br-") != NULL) {
|
||||
if (DM_LSTRSTR(if_name, "br-") != NULL) {
|
||||
DM_STRNCPY(key, if_name, key_size);
|
||||
} else {
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
|
|
@ -1030,7 +1038,7 @@ static void get_igmpp_iface_del_key_val(char *key, size_t key_size, char *if_nam
|
|||
}
|
||||
static void del_igmpp_iface_val(char *upstream, void *data, char *pch)
|
||||
{
|
||||
if (DM_STRCMP(upstream, "1") == 0) {
|
||||
if (DM_LSTRCMP(upstream, "1") == 0) {
|
||||
dmuci_del_list_value_by_section((struct uci_section *)data,
|
||||
"upstream_interface", pch);
|
||||
} else {
|
||||
|
|
@ -1216,7 +1224,7 @@ int get_mcastp_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
|
|||
}
|
||||
}
|
||||
|
||||
if (f_enable && DM_STRCMP(f_enable, "1") == 0) {
|
||||
if (f_enable && DM_LSTRCMP(f_enable, "1") == 0) {
|
||||
*value = "true";
|
||||
} else {
|
||||
*value = "false";
|
||||
|
|
@ -1758,7 +1766,7 @@ static int set_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
|
|||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "type", &if_type);
|
||||
if (if_type && DM_STRCMP(if_type, "bridge") == 0) {
|
||||
if (if_type && DM_LSTRCMP(if_type, "bridge") == 0) {
|
||||
dmasprintf(&interface_linker, "br-%s", linker);
|
||||
is_br = true;
|
||||
} else {
|
||||
|
|
@ -1800,13 +1808,13 @@ static int get_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
|
|||
}
|
||||
|
||||
// Check if this is bridge type interface
|
||||
if (DM_STRSTR(igmpp_ifname, "br-")) {
|
||||
if (DM_LSTRSTR(igmpp_ifname, "br-")) {
|
||||
// Interface is bridge type, convert to network uci file section name
|
||||
char val[16] = {0};
|
||||
DM_STRNCPY(val, igmpp_ifname, sizeof(val));
|
||||
char *token, *end;
|
||||
token = strtok_r(val, "-", &end);
|
||||
if (DM_STRCMP(token, "br") == 0) {
|
||||
if (DM_LSTRCMP(token, "br") == 0) {
|
||||
DM_STRNCPY(sec_name, end, sizeof(sec_name));
|
||||
} else {
|
||||
goto end;
|
||||
|
|
@ -1865,7 +1873,7 @@ static int set_igmpp_interface_upstream(char *refparam, struct dmctx *ctx, void
|
|||
char key[1024];
|
||||
char *ifval;
|
||||
dmuci_get_value_by_section_string(d_sec, "ifname", &ifname);
|
||||
if (DM_STRSTR(ifname, "br-") != NULL) {
|
||||
if (DM_LSTRSTR(ifname, "br-") != NULL) {
|
||||
DM_STRNCPY(key, ifname, sizeof(key));
|
||||
} else {
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
|
|
@ -1906,7 +1914,7 @@ int get_mcastp_interface_upstream(char *refparam, struct dmctx *ctx, void *data,
|
|||
}
|
||||
}
|
||||
|
||||
*value = (up && DM_STRCMP(up, "1") == 0) ? "true" : "false";
|
||||
*value = (up && DM_LSTRCMP(up, "1") == 0) ? "true" : "false";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1924,9 +1932,9 @@ int get_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, c
|
|||
}
|
||||
}
|
||||
|
||||
if (val && DM_STRCMP(val, "1") == 0)
|
||||
if (val && DM_LSTRCMP(val, "1") == 0)
|
||||
*value = "Standard";
|
||||
else if (val && DM_STRCMP(val, "2") == 0)
|
||||
else if (val && DM_LSTRCMP(val, "2") == 0)
|
||||
*value = "Blocking";
|
||||
else
|
||||
*value = "Disabled";
|
||||
|
|
@ -1943,15 +1951,15 @@ int set_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, c
|
|||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if ((DM_STRCMP("Standard", value) != 0)
|
||||
&& (DM_STRCMP("Blocking", value) != 0)
|
||||
&& (DM_STRCMP("Disabled", value) != 0))
|
||||
if ((DM_LSTRCMP(value, "Standard") != 0)
|
||||
&& (DM_LSTRCMP(value, "Blocking") != 0)
|
||||
&& (DM_LSTRCMP(value, "Disabled") != 0))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (DM_STRCMP(value, "Standard") == 0)
|
||||
if (DM_LSTRCMP(value, "Standard") == 0)
|
||||
strcpy(val, "1");
|
||||
else if (DM_STRCMP(value, "Blocking") == 0)
|
||||
else if (DM_LSTRCMP(value, "Blocking") == 0)
|
||||
strcpy(val, "2");
|
||||
else
|
||||
strcpy(val, "0");
|
||||
|
|
|
|||
16
dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c
vendored
16
dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c
vendored
|
|
@ -169,7 +169,7 @@ static int get_mld_version(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
{
|
||||
char *val;
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "version", &val);
|
||||
*value = (DM_STRCMP(val, "1") == 0) ? "V1" : "V2";
|
||||
*value = (DM_LSTRCMP(val, "1") == 0) ? "V1" : "V2";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -177,11 +177,11 @@ static int set_mld_version(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if ((DM_STRCMP("V2", value) != 0) && (DM_STRCMP("V1", value) != 0))
|
||||
if ((DM_LSTRCMP(value, "V2") != 0) && (DM_LSTRCMP(value, "V1") != 0))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "version", (DM_STRCMP(value, "V2") == 0) ? "2" : "1");
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "version", (DM_LSTRCMP(value, "V2") == 0) ? "2" : "1");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ static int del_mldp_interface_obj(char *refparam, struct dmctx *ctx, void *data,
|
|||
}
|
||||
|
||||
if (found) {
|
||||
if (upstream && DM_STRCMP(upstream, "1") == 0)
|
||||
if (upstream && DM_LSTRCMP(upstream, "1") == 0)
|
||||
dmuci_del_list_value_by_section((struct uci_section *)data, "upstream_interface", if_name);
|
||||
else
|
||||
dmuci_del_list_value_by_section((struct uci_section *)data, "downstream_interface", if_name);
|
||||
|
|
@ -237,7 +237,7 @@ static int del_mldp_interface_obj(char *refparam, struct dmctx *ctx, void *data,
|
|||
dmuci_get_value_by_section_string(mldp_s, "upstream", &upstream);
|
||||
|
||||
if (if_name[0] != '\0') {
|
||||
if (DM_STRCMP(upstream, "1") == 0)
|
||||
if (DM_LSTRCMP(upstream, "1") == 0)
|
||||
dmuci_del_list_value_by_section((struct uci_section *)data, "upstream_interface", if_name);
|
||||
else
|
||||
dmuci_del_list_value_by_section((struct uci_section *)data, "downstream_interface", if_name);
|
||||
|
|
@ -464,7 +464,7 @@ static int set_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat
|
|||
continue;
|
||||
}
|
||||
dmuci_get_value_by_section_string(s, "type", &if_type);
|
||||
if (DM_STRCMP(if_type, "bridge") == 0)
|
||||
if (DM_LSTRCMP(if_type, "bridge") == 0)
|
||||
dmasprintf(&interface_linker, "br-%s", linker);
|
||||
else
|
||||
dmuci_get_value_by_section_string(s, "device", &interface_linker);
|
||||
|
|
@ -519,13 +519,13 @@ static int get_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat
|
|||
}
|
||||
|
||||
// Check if this is bridge type interface
|
||||
if (DM_STRSTR(mldp_ifname, "br-")) {
|
||||
if (DM_LSTRSTR(mldp_ifname, "br-")) {
|
||||
// Interface is bridge type, convert to network uci file section name
|
||||
char val[16] = {0};
|
||||
DM_STRNCPY(val, mldp_ifname, sizeof(val));
|
||||
char *tok, *end;
|
||||
tok = strtok_r(val, "-", &end);
|
||||
if (DM_STRCMP(tok, "br") == 0) {
|
||||
if (DM_LSTRCMP(tok, "br") == 0) {
|
||||
DM_STRNCPY(sec_name, end, sizeof(sec_name));
|
||||
} else {
|
||||
goto end;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,14 @@ do { \
|
|||
#define DM_STRNCMP(S1, S2, LEN) ((S1 != NULL && S2 != NULL && LEN > 0) ? strncmp(S1, S2, LEN) : -1)
|
||||
#define DM_STRCASECMP(S1, S2) ((S1 != NULL && S2 != NULL) ? strcasecmp(S1, S2) : -1)
|
||||
|
||||
/* below macros are only useful when the second argument is a string literal.
|
||||
* these macros are introduced to autofix the cppcheck warnings for null check
|
||||
* against string literal
|
||||
*/
|
||||
#define DM_LSTRSTR(STR, MATCH) ((STR != NULL) ? strstr(STR, MATCH) : NULL)
|
||||
#define DM_LSTRCMP(S1, S2) ((S1 != NULL) ? strcmp(S1, S2) : -1)
|
||||
#define DM_LSTRNCMP(S1, S2, LEN) ((S1 != NULL && LEN > 0) ? strncmp(S1, S2, LEN) : -1)
|
||||
|
||||
#define UBUS_ARGS (struct ubus_arg[])
|
||||
#define RANGE_ARGS (struct range_args[])
|
||||
#define LIST_KEY (const char *[])
|
||||
|
|
|
|||
|
|
@ -915,6 +915,10 @@ void add_list_parameter(struct dmctx *ctx, char *param_name, char *param_data, c
|
|||
struct list_head *ilist = NULL;
|
||||
|
||||
list_for_each(ilist, &ctx->list_parameter) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
dm_parameter = list_entry(ilist, struct dm_parameter, list);
|
||||
int cmp = DM_STRCMP(dm_parameter->name, param_name);
|
||||
if (cmp == 0) {
|
||||
|
|
@ -942,6 +946,10 @@ void free_all_list_parameter(struct dmctx *ctx)
|
|||
{
|
||||
struct dm_parameter *dm_parameter = NULL;
|
||||
while (ctx->list_parameter.next != &ctx->list_parameter) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
dm_parameter = list_entry(ctx->list_parameter.next, struct dm_parameter, list);
|
||||
api_del_list_parameter(dm_parameter);
|
||||
}
|
||||
|
|
@ -968,6 +976,10 @@ void free_all_set_list_tmp(struct dmctx *ctx)
|
|||
{
|
||||
struct set_tmp *set_tmp = NULL;
|
||||
while (ctx->set_list_tmp.next != &ctx->set_list_tmp) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
set_tmp = list_entry(ctx->set_list_tmp.next, struct set_tmp, list);
|
||||
del_set_list_tmp(set_tmp);
|
||||
}
|
||||
|
|
@ -995,6 +1007,10 @@ void free_all_list_fault_param(struct dmctx *ctx)
|
|||
{
|
||||
struct param_fault *param_fault = NULL;
|
||||
while (ctx->list_fault_param.next != &ctx->list_fault_param) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
param_fault = list_entry(ctx->list_fault_param.next, struct param_fault, list);
|
||||
bbf_api_del_list_fault_param(param_fault);
|
||||
}
|
||||
|
|
@ -1729,6 +1745,12 @@ static int get_linker_check_obj(DMOBJECT_ARGS)
|
|||
|
||||
get_linker(node->current_object, dmctx, data, instance, &link_val);
|
||||
|
||||
if (dmctx == NULL)
|
||||
return FAULT_9005;
|
||||
|
||||
if (dmctx->linker == NULL)
|
||||
return FAULT_9005;
|
||||
|
||||
if (dmctx->linker[0] == '\0')
|
||||
return FAULT_9005;
|
||||
|
||||
|
|
|
|||
|
|
@ -251,6 +251,10 @@ void free_dmmap_config_dup_list(struct list_head *dup_list)
|
|||
{
|
||||
struct dmmap_dup *dmmap_config = NULL;
|
||||
while (dup_list->next != dup_list) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
dmmap_config = list_entry(dup_list->next, struct dmmap_dup, list);
|
||||
dmmap_config_dup_delete(dmmap_config);
|
||||
}
|
||||
|
|
@ -736,10 +740,7 @@ char **strsplit_by_str(const char str[], char *delim)
|
|||
}
|
||||
|
||||
if (tokens_used == tokens_alloc) {
|
||||
if (strparse == NULL)
|
||||
tokens_alloc++;
|
||||
else
|
||||
tokens_alloc += 2;
|
||||
tokens_alloc += 2;
|
||||
tokens = dmrealloc(tokens, tokens_alloc * sizeof(char*));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,10 @@ struct list_head *mem_list, void *n, size_t size
|
|||
{
|
||||
struct dmmem *m = NULL;
|
||||
if (n != NULL) {
|
||||
/* container_of() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
m = container_of(n, struct dmmem, mem);
|
||||
list_del(&m->list);
|
||||
}
|
||||
|
|
@ -84,6 +88,10 @@ inline void dmfree(void *m)
|
|||
{
|
||||
if (m == NULL) return;
|
||||
struct dmmem *rm;
|
||||
/* container_of() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
rm = container_of(m, struct dmmem, mem);
|
||||
list_del(&rm->list);
|
||||
free(rm);
|
||||
|
|
@ -93,6 +101,10 @@ inline void __dmcleanmem(struct list_head *mem_list)
|
|||
{
|
||||
struct dmmem *dmm;
|
||||
while (mem_list->next != mem_list) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
dmm = list_entry(mem_list->next, struct dmmem, list);
|
||||
#ifdef WITH_MEMTRACK
|
||||
fprintf(stderr, "Allocated memory in {%s, %s(), line %d} is not freed\n", dmm->file, dmm->func, dmm->line);
|
||||
|
|
|
|||
|
|
@ -220,6 +220,10 @@ static void dmubus_receive_event(struct ubus_context *ctx, struct ubus_event_han
|
|||
if (!msg || !ev)
|
||||
return;
|
||||
|
||||
/* container_of() is an external macro and which cppcheck can't track
|
||||
* so throws warning of null pointer dereferencing for second argument
|
||||
* suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
data = container_of(ev, struct dmubus_event_data, ev);
|
||||
if (validate_blob_message(data->ev_msg, msg) == true) {
|
||||
uloop_end();
|
||||
|
|
|
|||
|
|
@ -117,6 +117,10 @@ void free_all_list_package_change(struct list_head *clist)
|
|||
{
|
||||
struct package_change *pc;
|
||||
while (clist->next != clist) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
pc = list_entry(clist->next, struct package_change, list);
|
||||
list_del(&pc->list);
|
||||
free(pc->package);//TODO !!!!! Do not use dmfree here
|
||||
|
|
@ -331,7 +335,10 @@ int dmuci_export(const char *output_path)
|
|||
char **configs = NULL;
|
||||
char **p;
|
||||
|
||||
if ((uci_list_configs(uci_ctx, &configs) != UCI_OK) || !configs)
|
||||
if (uci_list_configs(uci_ctx, &configs) != UCI_OK)
|
||||
return -1;
|
||||
|
||||
if (!configs)
|
||||
return -1;
|
||||
|
||||
for (p = configs; *p; p++)
|
||||
|
|
@ -360,7 +367,10 @@ int dmuci_commit(void)
|
|||
char **configs = NULL;
|
||||
char **p;
|
||||
|
||||
if ((uci_list_configs(uci_ctx, &configs) != UCI_OK) || !configs)
|
||||
if (uci_list_configs(uci_ctx, &configs) != UCI_OK)
|
||||
return -1;
|
||||
|
||||
if (!configs)
|
||||
return -1;
|
||||
|
||||
for (p = configs; *p; p++)
|
||||
|
|
@ -391,18 +401,30 @@ int dmuci_save(void)
|
|||
char **p;
|
||||
int rc = 0;
|
||||
|
||||
if ((uci_list_configs(uci_ctx, &configs) != UCI_OK) || !configs) {
|
||||
if (uci_list_configs(uci_ctx, &configs) != UCI_OK) {
|
||||
rc = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!configs) {
|
||||
rc = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
for (p = configs; *p; p++)
|
||||
dmuci_save_package(*p);
|
||||
|
||||
if (uci_ctx_bbfdm) {
|
||||
if ((uci_list_configs(uci_ctx_bbfdm, &bbfdm_configs) != UCI_OK) || !bbfdm_configs) {
|
||||
if (uci_list_configs(uci_ctx_bbfdm, &bbfdm_configs) != UCI_OK) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!bbfdm_configs) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (p = bbfdm_configs; *p; p++)
|
||||
dmuci_save_package_bbfdm(*p);
|
||||
|
||||
|
|
@ -434,7 +456,10 @@ int dmuci_revert(void)
|
|||
char **configs = NULL;
|
||||
char **p;
|
||||
|
||||
if ((uci_list_configs(uci_ctx, &configs) != UCI_OK) || !configs)
|
||||
if (uci_list_configs(uci_ctx, &configs) != UCI_OK)
|
||||
return -1;
|
||||
|
||||
if (!configs)
|
||||
return -1;
|
||||
|
||||
for (p = configs; *p; p++)
|
||||
|
|
@ -450,7 +475,10 @@ int dmuci_change_packages(struct list_head *clist)
|
|||
char **configs = NULL;
|
||||
char **p;
|
||||
|
||||
if ((uci_list_configs(uci_ctx, &configs) != UCI_OK) || !configs)
|
||||
if (uci_list_configs(uci_ctx, &configs) != UCI_OK)
|
||||
return -1;
|
||||
|
||||
if (!configs)
|
||||
return -1;
|
||||
|
||||
for (p = configs; *p; p++) {
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ static int get_protocol(const char *val)
|
|||
{
|
||||
int type;
|
||||
|
||||
if (DM_STRCMP("cwmp", val) == 0)
|
||||
if (DM_LSTRCMP(val, "cwmp") == 0)
|
||||
type = BBFDM_CWMP;
|
||||
else if (DM_STRCMP("usp", val) == 0)
|
||||
else if (DM_LSTRCMP(val, "usp") == 0)
|
||||
type = BBFDM_USP;
|
||||
else
|
||||
type = BBFDM_BOTH;
|
||||
|
|
@ -306,7 +306,7 @@ static int handle_add_del_req(struct ubus_context *ctx, const char *ubus_name, s
|
|||
set_bbfdatamodel_type(proto);
|
||||
dm_ctx_init_entry(&bbf_ctx, tEntryObj, 0);
|
||||
|
||||
if (DM_STRCMP(method, "add_object") == 0) {
|
||||
if (DM_LSTRCMP(method, "add_object") == 0) {
|
||||
fault = dm_entry_param_method(&bbf_ctx, CMD_ADD_OBJECT, path, pkey, NULL);
|
||||
} else {
|
||||
fault = dm_entry_param_method(&bbf_ctx, CMD_DEL_OBJECT, path, pkey, NULL);
|
||||
|
|
@ -320,7 +320,7 @@ static int handle_add_del_req(struct ubus_context *ctx, const char *ubus_name, s
|
|||
blobmsg_add_u32(&bb, "fault", fault);
|
||||
blobmsg_add_u8(&bb, "status", 0);
|
||||
} else {
|
||||
if (DM_STRCMP(method, "add_object") == 0) {
|
||||
if (DM_LSTRCMP(method, "add_object") == 0) {
|
||||
if (bbf_ctx.addobj_instance) {
|
||||
blobmsg_add_u8(&bb, "status", 1);
|
||||
bb_add_string(&bb, "instance", bbf_ctx.addobj_instance);
|
||||
|
|
@ -538,6 +538,13 @@ static int libbbf_ubus_operate(struct ubus_context *ctx, struct ubus_object *obj
|
|||
snprintf(path, PATH_MAX, "%s", (char *)blobmsg_data(tb[LIBBBF_UBUS_OPERATE_PATH]));
|
||||
|
||||
len = DM_STRLEN(path);
|
||||
if (len == 0) {
|
||||
if (input)
|
||||
free(input);
|
||||
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (path[len - 1] == '.') {
|
||||
printf("path can't end with (.)\n\r");
|
||||
if (input)
|
||||
|
|
@ -628,6 +635,10 @@ static int libbbf_ubus_add_del_handler(struct ubus_context *ctx, struct ubus_obj
|
|||
snprintf(path, PATH_MAX, "%s", (char *)blobmsg_data(tb[LIBBBF_UBUS_ADD_DEL_PATH]));
|
||||
|
||||
plen = DM_STRLEN(path);
|
||||
if (plen == 0) {
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (path[plen - 1] != '.') {
|
||||
if (plen > PATH_MAX - 2) {
|
||||
printf("path too long(%d) can't append (.)\n\r", plen);
|
||||
|
|
@ -673,6 +684,10 @@ static int libbbf_ubus_set_handler(struct ubus_context *ctx, struct ubus_object
|
|||
snprintf(value, PATH_MAX, "%s", (char *)blobmsg_data(tb[LIBBBF_UBUS_SET_VALUE]));
|
||||
|
||||
int plen = DM_STRLEN(path);
|
||||
if (plen == 0) {
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (path[plen - 1] == '.') {
|
||||
printf("path can't end with (.)\n\r");
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
|
|
@ -703,6 +718,10 @@ static int libbbf_ubus_set_handler(struct ubus_context *ctx, struct ubus_object
|
|||
}
|
||||
|
||||
while (bbf_ctx.list_fault_param.next != &bbf_ctx.list_fault_param) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
struct param_fault *p = list_entry(bbf_ctx.list_fault_param.next, struct param_fault, list);
|
||||
table = blobmsg_open_table(&bb, NULL);
|
||||
bb_add_string(&bb, "path", p->name);
|
||||
|
|
@ -723,6 +742,10 @@ static int libbbf_ubus_set_handler(struct ubus_context *ctx, struct ubus_object
|
|||
array = blobmsg_open_array(&bb, "parameters");
|
||||
|
||||
while (bbf_ctx.list_fault_param.next != &bbf_ctx.list_fault_param) {
|
||||
/* list_entry() is an external macro and which cppcheck can't track so
|
||||
* throws warning of null pointer dereferencing for second argument.
|
||||
* Suppressed the warning */
|
||||
// cppcheck-suppress nullPointer
|
||||
struct param_fault *p = list_entry(bbf_ctx.list_fault_param.next, struct param_fault, list);
|
||||
table = blobmsg_open_table(&bb, NULL);
|
||||
bb_add_string(&bb, "path", p->name);
|
||||
|
|
@ -763,7 +786,7 @@ static int libbbf_ubus_transaction_handler(struct ubus_context *ctx, struct ubus
|
|||
memset(&bb, 0, sizeof(struct blob_buf));
|
||||
blob_buf_init(&bb, 0);
|
||||
|
||||
if (DM_STRCMP(method, "transaction_start") == 0) {
|
||||
if (DM_LSTRCMP(method, "transaction_start") == 0) {
|
||||
if (!g_dynamicdm_transaction_start) {
|
||||
g_dynamicdm_transaction_start = true;
|
||||
blobmsg_add_u8(&bb, "status", true);
|
||||
|
|
@ -771,7 +794,7 @@ static int libbbf_ubus_transaction_handler(struct ubus_context *ctx, struct ubus
|
|||
printf("Transaction already in process\n");
|
||||
blobmsg_add_u8(&bb, "status", false);
|
||||
}
|
||||
} else if(DM_STRCMP(method, "transaction_abort") == 0) {
|
||||
} else if(DM_LSTRCMP(method, "transaction_abort") == 0) {
|
||||
if (g_dynamicdm_transaction_start) {
|
||||
g_dynamicdm_transaction_start = false;
|
||||
dm_ctx_init_entry(&bbf_ctx, tEntryObj, 0);
|
||||
|
|
@ -782,7 +805,7 @@ static int libbbf_ubus_transaction_handler(struct ubus_context *ctx, struct ubus
|
|||
printf("Transaction still not started\n\r");
|
||||
blobmsg_add_u8(&bb, "status", false);
|
||||
}
|
||||
} else if (DM_STRCMP(method, "transaction_commit") == 0) {
|
||||
} else if (DM_LSTRCMP(method, "transaction_commit") == 0) {
|
||||
if (g_dynamicdm_transaction_start) {
|
||||
g_dynamicdm_transaction_start = false;
|
||||
dm_ctx_init_entry(&bbf_ctx, tEntryObj, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue