]> git.ipfire.org Git - people/ms/systemd.git/blame - socket.h
util: introduce mkdir_parents() that creates parent paths of sockets and suchlike
[people/ms/systemd.git] / socket.h
CommitLineData
5cb5a6ff
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3#ifndef foosockethfoo
4#define foosockethfoo
5
a7334b09
LP
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
5cb5a6ff
LP
25typedef struct Socket Socket;
26
acbb0225 27#include "manager.h"
87f0e418 28#include "unit.h"
542563ba 29#include "socket-util.h"
5cb5a6ff
LP
30
31typedef enum SocketState {
32 SOCKET_DEAD,
33 SOCKET_START_PRE,
34 SOCKET_START_POST,
35 SOCKET_LISTENING,
36 SOCKET_RUNNING,
37 SOCKET_STOP_PRE,
034c6ed7
LP
38 SOCKET_STOP_PRE_SIGTERM,
39 SOCKET_STOP_PRE_SIGKILL,
5cb5a6ff 40 SOCKET_STOP_POST,
034c6ed7
LP
41 SOCKET_STOP_POST_SIGTERM,
42 SOCKET_STOP_POST_SIGKILL,
5cb5a6ff
LP
43 SOCKET_MAINTAINANCE,
44 _SOCKET_STATE_MAX
45} SocketState;
46
47typedef 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
542563ba
LP
55typedef enum SocketType {
56 SOCKET_SOCKET,
57 SOCKET_FIFO
58} SocketType;
59
60typedef struct SocketPort SocketPort;
61
62struct SocketPort {
63 SocketType type;
64
65 SocketAddress address;
66 char *path;
67
68 int fd;
acbb0225 69 Watch fd_watch;
542563ba 70
034c6ed7 71 LIST_FIELDS(SocketPort, port);
542563ba
LP
72};
73
5cb5a6ff
LP
74struct Socket {
75 Meta meta;
76
542563ba
LP
77 LIST_HEAD(SocketPort, ports);
78
79 /* Only for INET6 sockets: issue IPV6_V6ONLY sockopt */
80 bool bind_ipv6_only;
81 unsigned backlog;
5cb5a6ff 82
034c6ed7
LP
83 usec_t timeout_usec;
84
5cb5a6ff
LP
85 ExecCommand* exec_command[_SOCKET_EXEC_MAX];
86 ExecContext exec_context;
87
034c6ed7
LP
88 Service *service;
89
90 SocketState state;
91
92 ExecCommand* control_command;
5cb5a6ff
LP
93 pid_t control_pid;
94
acbb0225
LP
95 char *bind_to_device;
96
034c6ed7 97 bool failure;
acbb0225 98 Watch timer_watch;
5cb5a6ff
LP
99};
100
44d8db9e
LP
101/* Called from the service code when collecting fds */
102int socket_collect_fds(Socket *s, int **fds, unsigned *n_fds);
103
ceee3d82
LP
104/* Called from the service when it shut down */
105void socket_notify_service_dead(Socket *s);
106
87f0e418 107extern const UnitVTable socket_vtable;
5cb5a6ff
LP
108
109#endif