aboutsummaryrefslogtreecommitdiff
path: root/lib/include/initsock.h
blob: a68748170e31a6632addae40a3f3a8dbe719e113 (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
60
61
/* SPDX-License-Identifier: ISC */
#ifndef INITSOCK_H
#define INITSOCK_H

#include <stdint.h>

#include "config.h"
#include "service.h"

#define INIT_SOCK_PATH SOCKDIR "/init.sock"

typedef enum {
	EIR_STATUS = 0x00,
	EIR_START = 0x01,
	EIR_STOP = 0x02,
} E_INIT_REQUEST;

typedef enum {
	ESS_NONE = 0x00,
	ESS_RUNNING = 0x01,
	ESS_ENQUEUED = 0x02,
	ESS_DONE = 0x03,
	ESS_FAILED = 0x04
} E_SERVICE_STATE;

typedef struct {
	uint8_t rq;
	uint8_t padd[3];

	union {
		struct {
			uint8_t filter;
			uint8_t padd[3];
		} status;

		struct {
			uint32_t id;
		} startstop;
	} arg;
} init_request_t;

typedef struct {
	E_SERVICE_STATE state;
	int exit_status;
	int id;
	char *filename;
	char *service_name;
} init_status_response_t;

int init_socket_create(void);

int init_socket_open(const char *tmppath);

int init_socket_send_request(int fd, E_INIT_REQUEST rq, ...);

int init_socket_send_status(int fd, const void *dest_addr, size_t addrlen,
			    E_SERVICE_STATE state, service_t *svc);

int init_socket_recv_status(int fd, init_status_response_t *resp);

#endif /* INITSOCK_H */