sensord: fix the svace issue because of using non-terminated string
[platform/core/system/sensord.git] / src / shared / command_common.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef _COMMAND_COMMON_H_
21 #define _COMMAND_COMMON_H_
22
23 #include <cpacket.h>
24 #include <sensor_common.h>
25
26 #define COMMAND_CHANNEL_PATH            "/tmp/sensord_command_socket\0"
27 #define EVENT_CHANNEL_PATH                      "/tmp/sensord_event_socket\0"
28
29 #define MAX_HANDLE                      256
30 #define MAX_HANDLE_REACHED      -2
31
32 enum packet_type_t {
33         CMD_DONE = -1,
34         CMD_NONE = 0,
35         CMD_GET_ID,
36         CMD_GET_SENSOR_LIST,
37         CMD_HELLO,
38         CMD_BYEBYE,
39         CMD_START,
40         CMD_STOP,
41         CMD_REG,
42         CMD_UNREG,
43         CMD_SET_OPTION,
44         CMD_SET_WAKEUP,
45         CMD_SET_BATCH,
46         CMD_UNSET_BATCH,
47         CMD_GET_DATA,
48         CMD_SET_ATTRIBUTE_INT,
49         CMD_SET_ATTRIBUTE_STR,
50         CMD_CNT,
51 };
52
53 typedef struct {
54         char name[NAME_MAX];
55 } cmd_get_id_t;
56
57 typedef struct {
58 } cmd_get_sensor_list_t;
59
60 typedef struct {
61         int client_id;
62         sensor_id_t sensor;
63 } cmd_hello_t;
64
65 typedef struct {
66 } cmd_byebye_t;
67
68
69 typedef struct {
70         unsigned int type;
71 } cmd_get_data_t;
72
73 typedef struct {
74         long value;
75 } cmd_done_t;
76
77
78 typedef struct {
79         int client_id;
80 } cmd_get_id_done_t;
81
82 typedef struct {
83         int sensor_cnt;
84         char data[0];
85 } cmd_get_sensor_list_done_t;
86
87 typedef struct {
88         int state;
89         sensor_data_t base_data;
90 } cmd_get_data_done_t;
91
92 typedef struct {
93 } cmd_start_t;
94
95 typedef struct {
96 } cmd_stop_t;
97
98 typedef struct {
99         unsigned int event_type;
100 } cmd_reg_t;
101
102 typedef struct {
103         unsigned int event_type;
104 } cmd_unreg_t;
105
106 typedef struct {
107         unsigned int interval;
108         unsigned int latency;
109 } cmd_set_batch_t;
110
111 typedef struct {
112 } cmd_unset_batch_t;
113
114 typedef struct {
115         int option;
116 } cmd_set_option_t;
117
118 typedef struct {
119         int wakeup;
120 } cmd_set_wakeup_t;
121
122 typedef struct  {
123         int attribute;
124         int value;
125 } cmd_set_attribute_int_t;
126
127 typedef struct  {
128         int attribute;
129         int value_len;
130         char value[0];
131 } cmd_set_attribute_str_t;
132
133 #define EVENT_CHANNEL_MAGIC 0xCAFECAFE
134
135 typedef struct {
136         unsigned int magic;
137         int client_id;
138 } event_channel_ready_t;
139
140 typedef void *(*cmd_func_t)(void *data, void *cb_data);
141
142 #endif /* _COMMAND_COMMON_H_ */