]>
Commit | Line | Data |
---|---|---|
5cb5a6ff LP |
1 | /*-*- Mode: C; c-basic-offset: 8 -*-*/ |
2 | ||
3 | #ifndef foosockethfoo | |
4 | #define foosockethfoo | |
5 | ||
6 | typedef struct Socket Socket; | |
7 | ||
acbb0225 | 8 | #include "manager.h" |
87f0e418 | 9 | #include "unit.h" |
542563ba | 10 | #include "socket-util.h" |
5cb5a6ff LP |
11 | |
12 | typedef enum SocketState { | |
13 | SOCKET_DEAD, | |
14 | SOCKET_START_PRE, | |
15 | SOCKET_START_POST, | |
16 | SOCKET_LISTENING, | |
17 | SOCKET_RUNNING, | |
18 | SOCKET_STOP_PRE, | |
034c6ed7 LP |
19 | SOCKET_STOP_PRE_SIGTERM, |
20 | SOCKET_STOP_PRE_SIGKILL, | |
5cb5a6ff | 21 | SOCKET_STOP_POST, |
034c6ed7 LP |
22 | SOCKET_STOP_POST_SIGTERM, |
23 | SOCKET_STOP_POST_SIGKILL, | |
5cb5a6ff LP |
24 | SOCKET_MAINTAINANCE, |
25 | _SOCKET_STATE_MAX | |
26 | } SocketState; | |
27 | ||
28 | typedef enum SocketExecCommand { | |
29 | SOCKET_EXEC_START_PRE, | |
30 | SOCKET_EXEC_START_POST, | |
31 | SOCKET_EXEC_STOP_PRE, | |
32 | SOCKET_EXEC_STOP_POST, | |
33 | _SOCKET_EXEC_MAX | |
34 | } SocketExecCommand; | |
35 | ||
542563ba LP |
36 | typedef enum SocketType { |
37 | SOCKET_SOCKET, | |
38 | SOCKET_FIFO | |
39 | } SocketType; | |
40 | ||
41 | typedef struct SocketPort SocketPort; | |
42 | ||
43 | struct SocketPort { | |
44 | SocketType type; | |
45 | ||
46 | SocketAddress address; | |
47 | char *path; | |
48 | ||
49 | int fd; | |
acbb0225 | 50 | Watch fd_watch; |
542563ba | 51 | |
034c6ed7 | 52 | LIST_FIELDS(SocketPort, port); |
542563ba LP |
53 | }; |
54 | ||
5cb5a6ff LP |
55 | struct Socket { |
56 | Meta meta; | |
57 | ||
542563ba LP |
58 | LIST_HEAD(SocketPort, ports); |
59 | ||
60 | /* Only for INET6 sockets: issue IPV6_V6ONLY sockopt */ | |
61 | bool bind_ipv6_only; | |
62 | unsigned backlog; | |
5cb5a6ff | 63 | |
034c6ed7 LP |
64 | usec_t timeout_usec; |
65 | ||
5cb5a6ff LP |
66 | ExecCommand* exec_command[_SOCKET_EXEC_MAX]; |
67 | ExecContext exec_context; | |
68 | ||
034c6ed7 LP |
69 | Service *service; |
70 | ||
71 | SocketState state; | |
72 | ||
73 | ExecCommand* control_command; | |
5cb5a6ff LP |
74 | pid_t control_pid; |
75 | ||
acbb0225 LP |
76 | char *bind_to_device; |
77 | ||
034c6ed7 | 78 | bool failure; |
acbb0225 | 79 | Watch timer_watch; |
5cb5a6ff LP |
80 | }; |
81 | ||
44d8db9e LP |
82 | /* Called from the service code when collecting fds */ |
83 | int socket_collect_fds(Socket *s, int **fds, unsigned *n_fds); | |
84 | ||
87f0e418 | 85 | extern const UnitVTable socket_vtable; |
5cb5a6ff LP |
86 | |
87 | #endif |