summaryrefslogtreecommitdiffstats
path: root/task_manager/server/include/tskm_comm.h
blob: c884be964e0d3ad072d7245f191f8b966f1c2f7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Communication module header file
#ifndef TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_
#define TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_

#include <sys/types.h>
#include "system_service/tskm_local_type.h"

#define TSKM_SOCKET_NAME      "/tmp/tskm_sock"  // Sockets for Primary Library

#define TSKM_COMM_CONNECT_MAX   (32)

typedef struct {
  pid_t pid;
  int connFd;
} TSKM_SRV_CONNENT_t;

typedef struct {
  uint32_t num;
  TSKM_SRV_CONNENT_t conn[TSKM_COMM_CONNECT_MAX];
} TSKM_SRV_CONNENT_LIST_t;

typedef struct {
  int sockFd;
  const char *sockName;
  TSKM_SRV_CONNENT_LIST_t connList;
} TSKM_SRV_SOCK_CTX_t;

TSKM_ERR_t tskm_srvSockCreate(const char* sockName,
                              TSKM_SRV_SOCK_CTX_t* p_sock);
TSKM_SRV_CONNENT_t* tskm_srvSockConnect(TSKM_SRV_SOCK_CTX_t* p_sock);
void tskm_srvSockDisconnect(TSKM_SRV_SOCK_CTX_t* p_sock,
                            TSKM_SRV_CONNENT_t *p_conn);
void tskm_srvSockDestory(TSKM_SRV_SOCK_CTX_t* p_sock);
int tskm_cliSockConnect(const char* sockName);
int tskm_sockRcv(int fd, TSKM_EVENT_INFO_t* p_ev);
int tskm_sockSend(int fd, TSKM_EVENT_INFO_t* p_ev);
void tskm_sockDestory(int fd);

int tskm_comm_procInit(void);
int tskm_comm_setSvcWatchState(uint32_t id, BOOL bIsRun, uint32_t timeout);

#endif  // TASK_MANAGER_SERVER_INCLUDE_TSKM_COMM_H_