4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
8 * Cherepanov Vitaliy <v.cherepanov@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
23 * - Samsung RnD Institute Russia
27 #include "da_protocol.h"
28 #include "da_protocol_check.h"
33 //application checking functions
34 int check_app_type(uint32_t app_type)
36 if ((app_type >= APP_INFO_TYPE_MIN) &&
37 (app_type <= APP_INFO_TYPE_MAX)) {
40 LOGE("wrong value\n");
45 int check_app_id(uint32_t app_type, char *app_id)
53 case APP_TYPE_RUNNING:
54 strtol(app_id, &p, 10);
55 if ((*app_id != 0) && (*p == 0))
58 LOGE("wrong app id for APP_RUNNING\n");
61 res = (strlen(app_id) == 0);
63 LOGE("wrong app id for APP_COMMON\n");
66 LOGE("wrong app type\n");
73 int check_exec_path(char *path)
78 if (!(res = (stat (path, &buffer) == 0)))
79 LOGE("wrong exec path <%s>\n", path);
84 //config checking functions
85 int check_conf_features(uint64_t feature0, uint64_t feature1)
89 feature0 &= ~(uint64_t)FL_ALL_FEATURES;
92 LOGE("wrong features0 0x%016llX mask %016llX\n", feature0, (uint64_t)FL_ALL_FEATURES);
96 feature1 &= ~(uint64_t)0;
99 LOGE("wrong features1 0x%016llX mask %016llX\n", feature1, (uint64_t)0);
107 int check_conf_systrace_period(uint32_t system_trace_period)
110 if ((system_trace_period < CONF_SYSTRACE_PERIOD_MIN) ||
111 (system_trace_period > CONF_SYSTRACE_PERIOD_MAX))
113 LOGE("wrong system trace period value %lu (0x%08X)\n",
114 system_trace_period, system_trace_period);
121 int check_conf_datamsg_period(uint32_t data_message_period)
124 if ((data_message_period < CONF_DATA_MSG_PERIOD_MIN) ||
125 (data_message_period > CONF_DATA_MSG_PERIOD_MAX))
127 LOGE("wrong data message period value %lu (0x%08X)\n",
128 data_message_period, data_message_period);
135 //User space check functions
136 int check_us_app_count(uint32_t app_count)
139 if ((app_count < US_APP_COUNT_MIN) ||
140 (app_count > US_APP_COUNT_MAX))
142 LOGE("wrong user space app count %lu (0x%08X)\n", app_count, app_count);
148 //User space app inst check function
149 int check_us_app_inst_func_count(uint32_t func_count)
152 if ((func_count < US_APP_INST_FUNC_MIN) ||
153 (func_count > US_APP_INST_FUNC_MAX))
155 LOGE("wrong US app inst func count %lu (0x%08X)\n",
156 func_count, func_count);
163 static char *args_avail = US_FUNC_ARGS;
164 int check_us_inst_func_args(char *args)
167 for (p = args; *p != 0; p++)
168 if (strchr(args_avail, (int)*p) == NULL){
169 LOGE("wrong args <%s> char <%c> <0x%02X>\n", args, (int)*p, (char)*p);
175 int check_lib_inst_count(uint32_t lib_count)
178 if ((lib_count < US_APP_INST_LIB_MIN) ||
179 (lib_count > US_APP_INST_LIB_MAX))
181 LOGE("wrong US app inst lib count %lu (0x%08X)\n",
182 lib_count, lib_count);
189 int check_conf(struct conf_t *conf)
191 //Check features value
192 if (!check_conf_features(conf->use_features0, conf->use_features1)) {
193 LOGE("check features fail\n");
197 if (!check_conf_systrace_period(conf->system_trace_period)) {
198 LOGE("system trace period error\n");
202 if (!check_conf_datamsg_period(conf->data_message_period)) {
203 LOGE("data message period error\n");