2019-03-15 11:23:40 +01:00
|
|
|
/* SPDX-License-Identifier: ISC */
|
|
|
|
#ifndef INITSOCK_H
|
|
|
|
#define INITSOCK_H
|
|
|
|
|
2019-03-25 22:54:38 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-03-15 11:23:40 +01:00
|
|
|
#include "config.h"
|
2019-03-18 14:00:20 +01:00
|
|
|
#include "service.h"
|
2019-03-15 11:23:40 +01:00
|
|
|
|
|
|
|
#define INIT_SOCK_PATH SOCKDIR "/init.sock"
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
EIR_STATUS = 0x00,
|
2019-03-28 14:15:39 +01:00
|
|
|
EIR_START = 0x01,
|
|
|
|
EIR_STOP = 0x02,
|
2019-03-15 11:23:40 +01:00
|
|
|
} E_INIT_REQUEST;
|
|
|
|
|
2019-03-18 14:00:20 +01:00
|
|
|
typedef enum {
|
|
|
|
ESS_NONE = 0x00,
|
|
|
|
ESS_RUNNING = 0x01,
|
|
|
|
ESS_ENQUEUED = 0x02,
|
2019-03-18 18:38:27 +01:00
|
|
|
ESS_DONE = 0x03,
|
|
|
|
ESS_FAILED = 0x04
|
2019-03-18 14:00:20 +01:00
|
|
|
} E_SERVICE_STATE;
|
|
|
|
|
2019-03-15 11:23:40 +01:00
|
|
|
typedef struct {
|
2019-03-25 22:54:38 +01:00
|
|
|
uint8_t rq;
|
2019-03-27 17:48:13 +01:00
|
|
|
uint8_t padd[3];
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint8_t filter;
|
|
|
|
uint8_t padd[3];
|
|
|
|
} status;
|
2019-03-28 14:15:39 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t id;
|
|
|
|
} startstop;
|
2019-03-27 17:48:13 +01:00
|
|
|
} arg;
|
2019-03-15 11:23:40 +01:00
|
|
|
} init_request_t;
|
|
|
|
|
2019-03-29 11:02:22 +01:00
|
|
|
typedef struct {
|
|
|
|
uint8_t state;
|
|
|
|
uint8_t exit_status;
|
|
|
|
uint8_t padd[2];
|
|
|
|
int32_t id;
|
|
|
|
} init_response_status_t;
|
|
|
|
|
2019-03-18 14:00:20 +01:00
|
|
|
typedef struct {
|
|
|
|
E_SERVICE_STATE state;
|
|
|
|
int exit_status;
|
2019-03-28 13:57:19 +01:00
|
|
|
int id;
|
2019-03-18 14:00:20 +01:00
|
|
|
char *filename;
|
|
|
|
char *service_name;
|
2019-03-29 10:40:59 +01:00
|
|
|
} init_status_t;
|
2019-03-18 14:00:20 +01:00
|
|
|
|
2019-03-15 11:23:40 +01:00
|
|
|
int init_socket_open(const char *tmppath);
|
|
|
|
|
2019-03-27 17:48:13 +01:00
|
|
|
int init_socket_send_request(int fd, E_INIT_REQUEST rq, ...);
|
2019-03-15 11:23:40 +01:00
|
|
|
|
2019-03-29 10:40:59 +01:00
|
|
|
int init_socket_recv_status(int fd, init_status_t *resp);
|
|
|
|
|
|
|
|
void free_init_status(init_status_t *resp);
|
2019-03-18 14:00:20 +01:00
|
|
|
|
2019-03-15 11:23:40 +01:00
|
|
|
#endif /* INITSOCK_H */
|