c884be964e0d3ad072d7245f191f8b966f1c2f7a
[staging/basesystem.git] / service / system / task_manager / server / include / tskm_comm.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 // Communication module header file
18 #ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_
19 #define TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_
20
21 #include <sys/types.h>
22 #include "system_service/tskm_local_type.h"
23
24 #define TSKM_SOCKET_NAME      "/tmp/tskm_sock"  // Sockets for Primary Library
25
26 #define TSKM_COMM_CONNECT_MAX   (32)
27
28 typedef struct {
29   pid_t pid;
30   int connFd;
31 } TSKM_SRV_CONNENT_t;
32
33 typedef struct {
34   uint32_t num;
35   TSKM_SRV_CONNENT_t conn[TSKM_COMM_CONNECT_MAX];
36 } TSKM_SRV_CONNENT_LIST_t;
37
38 typedef struct {
39   int sockFd;
40   const char *sockName;
41   TSKM_SRV_CONNENT_LIST_t connList;
42 } TSKM_SRV_SOCK_CTX_t;
43
44 TSKM_ERR_t tskm_srvSockCreate(const char* sockName,
45                               TSKM_SRV_SOCK_CTX_t* p_sock);
46 TSKM_SRV_CONNENT_t* tskm_srvSockConnect(TSKM_SRV_SOCK_CTX_t* p_sock);
47 void tskm_srvSockDisconnect(TSKM_SRV_SOCK_CTX_t* p_sock,
48                             TSKM_SRV_CONNENT_t *p_conn);
49 void tskm_srvSockDestory(TSKM_SRV_SOCK_CTX_t* p_sock);
50 int tskm_cliSockConnect(const char* sockName);
51 int tskm_sockRcv(int fd, TSKM_EVENT_INFO_t* p_ev);
52 int tskm_sockSend(int fd, TSKM_EVENT_INFO_t* p_ev);
53 void tskm_sockDestory(int fd);
54
55 int tskm_comm_procInit(void);
56 int tskm_comm_setSvcWatchState(uint32_t id, BOOL bIsRun, uint32_t timeout);
57
58 #endif  // TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_
59