From: Vitaliy Cherepanov Date: Fri, 9 Aug 2013 13:06:54 +0000 (+0400) Subject: [IMPROVE] message config check add X-Git-Tag: Tizen_SDK_2.3~210 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5648cb29b512d81025a86fd4b1cd115ae7e6daec;p=platform%2Fcore%2Fsystem%2Fswap-manager.git [IMPROVE] message config check add --- diff --git a/daemon/da_protocol.c b/daemon/da_protocol.c index 9406327..3f35b48 100644 --- a/daemon/da_protocol.c +++ b/daemon/da_protocol.c @@ -290,7 +290,7 @@ static int parse_conf(struct msg_buf_t *msg, struct conf_t *conf) parse_deb("parse_conf\n"); if (!parse_int64(msg, &conf->use_features0)) { - LOGE("use features0 parsing error\n"); + LOGE("use features0 error\n"); return 0; } @@ -299,13 +299,23 @@ static int parse_conf(struct msg_buf_t *msg, struct conf_t *conf) return 0; } - if (!parse_int32( msg, &conf->system_trace_period)) { - LOGE("system trace period parsing error\n"); + //Check features value + if (!check_conf_features(conf->use_features0, conf->use_features1)) { + LOGE("check features fail\n"); return 0; } - if (!parse_int32( msg, &conf->data_message_period)) { - LOGE("data message period parsing error\n"); + if (!parse_int32( msg, &conf->system_trace_period) || + !check_conf_systrace_period(conf->system_trace_period)) + { + LOGE("system trace period error\n"); + return 0; + } + + if (!parse_int32( msg, &conf->data_message_period) || + !check_conf_datamsg_period(conf->data_message_period)) + { + LOGE("data message period error\n"); return 0; } //print_conf(conf); diff --git a/daemon/da_protocol.h b/daemon/da_protocol.h index b8855d2..d3f00cd 100644 --- a/daemon/da_protocol.h +++ b/daemon/da_protocol.h @@ -104,34 +104,42 @@ enum ErrorCode{ }; enum feature_code{ - FL_RESERVED0 = 0x0000001, - FL_RESERVED1 = 0x0000002, - FL_FUNCTION_PROFILING = 0x0000004, //On/Off the UserSpaceInst - FL_MEMORY_ALLCATION_PROBING = 0x0000008, //memory allocation API (glibc) - FL_FILE_API_PROBING = 0x0000010, //file API (glibc, OSP) - FL_THREAD_API_PROBING = 0x0000020, //thread API (glibc, OSP) - FL_OSP_UI_API_PROBING = 0x0000040, //UI API (OSP) - FL_SCREENSHOT = 0x0000080, //Screenshot - FL_USER_EVENT = 0x0000100, //events of Touch, Gesture, Orientation, Key - FL_RECORDING = 0x0000200, //recording the user event - FL_SYSTCALL_FILE = 0x0000400, //File operation syscalls tracing - FL_SYSTCALL_IPC = 0x0000800, //IPC syscall tracing - FL_SYSTCALL_PROCESS = 0x0001000, //Process syscalls tracing - FL_SYSTCALL_SIGNAL = 0x0002000, //Signal syscalls tracing - FL_SYSTCALL_NETWORK = 0x0004000, //Network syscalls tracing - FL_SYSTCALL_DESC = 0x0008000, //Descriptor syscalls tracing - FL_CONTEXT_SWITCH = 0x0010000, //Context switch tracing - FL_NETWORK_API_PROBING = 0x0020000, //network API (glibc, OSP, libsoap, openssl) - FL_OPENGL_API_PROBING = 0x0040000, //openGL API - FL_CPU = 0x0100000, //CPU core load, frequency - FL_PROCESSES = 0x0200000, //Process load - FL_MEMORY = 0x0400000, //Process size(VSS, PSS. RSS), heap usage(application, library), physical memory in use - FL_DISK = 0x0800000, - FL_NETWORK = 0x1000000, - FL_DEVICE = 0x2000000, - FL_ENERGY = 0x4000000, - FL_RESERVED2 = 0x8000000 + FL_RESERVED1 = 0x00000001, + FL_RESERVED2 = 0x00000002, + FL_FUNCTION_PROFILING = 0x00000004, //On/Off the UserSpaceInst + FL_MEMORY_ALLCATION_PROBING = 0x00000008, //memory allocation API (glibc) + FL_FILE_API_PROBING = 0x00000010, //file API (glibc, OSP) + FL_THREAD_API_PROBING = 0x00000020, //thread API (glibc, OSP) + FL_OSP_UI_API_PROBING = 0x00000040, //UI API (OSP) + FL_SCREENSHOT = 0x00000080, //Screenshot + FL_USER_EVENT = 0x00000100, //events of Touch, Gesture, Orientation, Key + FL_RECORDING = 0x00000200, //recording the user event + FL_SYSTCALL_FILE = 0x00000400, //File operation syscalls tracing + FL_SYSTCALL_IPC = 0x00000800, //IPC syscall tracing + FL_SYSTCALL_PROCESS = 0x00001000, //Process syscalls tracing + FL_SYSTCALL_SIGNAL = 0x00002000, //Signal syscalls tracing + FL_SYSTCALL_NETWORK = 0x00004000, //Network syscalls tracing + FL_SYSTCALL_DESC = 0x00008000, //Descriptor syscalls tracing + FL_CONTEXT_SWITCH = 0x00010000, //Context switch tracing + FL_NETWORK_API_PROBING = 0x00020000, //network API (glibc, OSP, libsoap, openssl) + FL_OPENGL_API_PROBING = 0x00040000, //openGL API + FL_RESERVED3 = 0x00080000, + FL_CPU = 0x00100000, //CPU core load, frequency + FL_PROCESSES = 0x00200000, //Process load + FL_MEMORY = 0x00400000, //Process size(VSS, PSS. RSS), heap usage(application, library), physical memory in use + FL_DISK = 0x00800000, + FL_NETWORK = 0x01000000, + FL_DEVICE = 0x02000000, + FL_ENERGY = 0x04000000, + FL_RESERVED4 = 0x08000000, + + FL_ALL_FEATURES = 0xFFFFFFFF & + (~FL_RESERVED1) & + (~FL_RESERVED2) & + (~FL_RESERVED3) & + (~FL_RESERVED4) }; + #define IS_OPT_SET_IN(OPT, reg) (reg & (OPT)) #define IS_OPT_SET(OPT) IS_OPT_SET_IN((OPT), prof_session.conf.use_features0) #define IS_SYSTEM_INFO_NEEDED() ( \ diff --git a/daemon/da_protocol_check.c b/daemon/da_protocol_check.c index c0604bd..48eda05 100644 --- a/daemon/da_protocol_check.c +++ b/daemon/da_protocol_check.c @@ -29,6 +29,7 @@ #include +//application checking functions int check_app_type(uint32_t app_type) { if ((app_type >= APP_INFO_TYPE_MIN) && @@ -68,3 +69,51 @@ int check_app_id (uint32_t app_type, char *app_id) return res; } +//config checking functions +int check_conf_features (uint64_t feature0, uint64_t feature1) +{ + int res = 1; + + feature0 &= ~(uint64_t)FL_ALL_FEATURES; + + if (feature0 != 0) { + LOGE("wrong features0 0x%016llX mask %016llX\n", feature0, (uint64_t)FL_ALL_FEATURES); + res = 0; + } + + feature1 &= ~(uint64_t)0; + + if (feature1 != 0) { + LOGE("wrong features1 0x%016llX mask %016llX\n", feature1, (uint64_t)0); + res = 0; + } + + return res; +} + + +int check_conf_systrace_period(uint32_t system_trace_period) +{ + int res = 1; + if ((system_trace_periodCONF_SYSTRACE_PERIOD_MAX)) + { + LOGE("wrong system trace period value %lu\n", system_trace_period); + res = 0; + } + + return res; +} + +int check_conf_datamsg_period(uint32_t data_message_period) +{ + int res = 1; + if ((data_message_periodCONF_DATA_MSG_PERIOD_MAX)) + { + LOGE("wrong data message period value %lu\n", data_message_period); + res = 0; + } + + return res; +} diff --git a/daemon/da_protocol_check.h b/daemon/da_protocol_check.h index 984a329..bc9c277 100644 --- a/daemon/da_protocol_check.h +++ b/daemon/da_protocol_check.h @@ -31,5 +31,11 @@ #define APP_INFO_TYPE_MIN 0x0001 #define APP_INFO_TYPE_MAX 0x0003 +#define CONF_SYSTRACE_PERIOD_MIN 10 +#define CONF_SYSTRACE_PERIOD_MAX 1000 + +#define CONF_DATA_MSG_PERIOD_MIN 10 +#define CONF_DATA_MSG_PERIOD_MAX 1000 int check_app_type(uint32_t app_type); int check_app_id (uint32_t app_type, char *app_id); +int check_conf_features (uint64_t feature0, uint64_t feature1);