chiark / gitweb /
service/socket: show main/control pids in dump
[elogind.git] / socket.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #ifndef foosockethfoo
4 #define foosockethfoo
5
6 /***
7   This file is part of systemd.
8
9   Copyright 2010 Lennart Poettering
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2 of the License, or
14   (at your option) any later version.
15
16   systemd is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   General Public License for more details.
20
21   You should have received a copy of the GNU General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 typedef struct Socket Socket;
26
27 #include "manager.h"
28 #include "unit.h"
29 #include "socket-util.h"
30
31 typedef enum SocketState {
32         SOCKET_DEAD,
33         SOCKET_START_PRE,
34         SOCKET_START_POST,
35         SOCKET_LISTENING,
36         SOCKET_RUNNING,
37         SOCKET_STOP_PRE,
38         SOCKET_STOP_PRE_SIGTERM,
39         SOCKET_STOP_PRE_SIGKILL,
40         SOCKET_STOP_POST,
41         SOCKET_STOP_POST_SIGTERM,
42         SOCKET_STOP_POST_SIGKILL,
43         SOCKET_MAINTAINANCE,
44         _SOCKET_STATE_MAX
45 } SocketState;
46
47 typedef enum SocketExecCommand {
48         SOCKET_EXEC_START_PRE,
49         SOCKET_EXEC_START_POST,
50         SOCKET_EXEC_STOP_PRE,
51         SOCKET_EXEC_STOP_POST,
52         _SOCKET_EXEC_MAX
53 } SocketExecCommand;
54
55 typedef enum SocketType {
56         SOCKET_SOCKET,
57         SOCKET_FIFO
58 } SocketType;
59
60 typedef struct SocketPort SocketPort;
61
62 struct SocketPort {
63         SocketType type;
64
65         SocketAddress address;
66         char *path;
67
68         int fd;
69         Watch fd_watch;
70
71         LIST_FIELDS(SocketPort, port);
72 };
73
74 struct Socket {
75         Meta meta;
76
77         LIST_HEAD(SocketPort, ports);
78
79         /* Only for INET6 sockets: issue IPV6_V6ONLY sockopt */
80         bool bind_ipv6_only;
81         unsigned backlog;
82
83         usec_t timeout_usec;
84
85         ExecCommand* exec_command[_SOCKET_EXEC_MAX];
86         ExecContext exec_context;
87
88         Service *service;
89
90         SocketState state;
91
92         KillMode kill_mode;
93
94         ExecCommand* control_command;
95         pid_t control_pid;
96
97         char *bind_to_device;
98         mode_t directory_mode;
99         mode_t socket_mode;
100
101         bool failure;
102         Watch timer_watch;
103 };
104
105 /* Called from the service code when collecting fds */
106 int socket_collect_fds(Socket *s, int **fds, unsigned *n_fds);
107
108 /* Called from the service when it shut down */
109 void socket_notify_service_dead(Socket *s);
110
111 extern const UnitVTable socket_vtable;
112
113 #endif