Debian Codegraph @

modules/lsp-3rd-party/include/pw-headers/pipewire/extensions/security-context.h

raw
1 /* PipeWire */
2 /* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */
3 /* SPDX-License-Identifier: MIT */
4
5 #ifndef PIPEWIRE_EXT_SECURITY_CONTEXT_H
6 #define PIPEWIRE_EXT_SECURITY_CONTEXT_H
7
8 #include <pw-headers/spa/utils/defs.h>
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 /** \defgroup pw_security_context Security Context
15 * Security Context interface
16 */
17
18 /**
19 * \addtogroup pw_security_context
20 * \{
21 */
22 #define PW_TYPE_INTERFACE_SecurityContext PW_TYPE_INFO_INTERFACE_BASE "SecurityContext"
23
24 #define PW_SECURITY_CONTEXT_PERM_MASK PW_PERM_RWX
25
26 #define PW_VERSION_SECURITY_CONTEXT 3
27 struct pw_security_context;
28
29 #ifndef PW_API_SECURITY_CONTEXT
30 #define PW_API_SECURITY_CONTEXT static inline
31 #endif
32
33 #define PW_EXTENSION_MODULE_SECURITY_CONTEXT PIPEWIRE_MODULE_PREFIX "module-security-context"
34
35 #define PW_SECURITY_CONTEXT_EVENT_NUM 0
36
37
38 /** \ref pw_security_context events */
39 struct pw_security_context_events {
40 #define PW_VERSION_SECURITY_CONTEXT_EVENTS 0
41 uint32_t version;
42 };
43
44 #define PW_SECURITY_CONTEXT_METHOD_ADD_LISTENER 0
45 #define PW_SECURITY_CONTEXT_METHOD_CREATE 1
46 #define PW_SECURITY_CONTEXT_METHOD_NUM 2
47
48 /** \ref pw_security_context methods */
49 struct pw_security_context_methods {
50 #define PW_VERSION_SECURITY_CONTEXT_METHODS 0
51 uint32_t version;
52
53 int (*add_listener) (void *object,
54 struct spa_hook *listener,
55 const struct pw_security_context_events *events,
56 void *data);
57
58 /**
59 * Create a new security context
60 *
61 * Creates a new security context with a socket listening FD.
62 * PipeWire will accept new client connections on listen_fd.
63 *
64 * listen_fd must be ready to accept new connections when this request is
65 * sent by the client. In other words, the client must call bind(2) and
66 * listen(2) before sending the FD.
67 *
68 * close_fd is a FD closed by the client when PipeWire should stop
69 * accepting new connections on listen_fd.
70 *
71 * PipeWire must continue to accept connections on listen_fd when
72 * the client which created the security context disconnects.
73 *
74 * After sending this request, closing listen_fd and close_fd remains the
75 * only valid operation on them.
76 *
77 * \param listen_fd the fd to listen on for new connections
78 * \param close_fd the fd used to stop listening
79 * \param props extra properties. These will be copied on the client
80 * that connects through this context.
81 *
82 * Some properties to set:
83 *
84 * - pipewire.sec.engine with the engine name.
85 * - pipewire.sec.app-id with the application id, this is an opaque,
86 * engine specific id for an application
87 * - pipewire.sec.instance-id with the instance id, this is an opaque,
88 * engine specific id for a running instance of an application.
89 *
90 * See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md
91 * For a list of engine names and the properties to set.
92 *
93 * This requires X and W permissions on the security_context.
94 */
95 int (*create) (void *object,
96 int listen_fd,
97 int close_fd,
98 const struct spa_dict *props);
99 };
100
101 /** \copydoc pw_security_context_methods.add_listener
102 * \sa pw_security_context_methods.add_listener */
103 PW_API_SECURITY_CONTEXT int pw_security_context_add_listener(struct pw_security_context *object,
104 struct spa_hook *listener,
105 const struct pw_security_context_events *events,
106 void *data)
107 {
108 return spa_api_method_r(int, -ENOTSUP,
109 pw_security_context, (struct spa_interface*)object, add_listener, 0,
110 listener, events, data);
111 }
112
113 /** \copydoc pw_security_context_methods.create
114 * \sa pw_security_context_methods.create */
115 PW_API_SECURITY_CONTEXT int pw_security_context_create(struct pw_security_context *object,
116 int listen_fd, int close_fd, const struct spa_dict *props)
117 {
118 return spa_api_method_r(int, -ENOTSUP,
119 pw_security_context, (struct spa_interface*)object, create, 0,
120 listen_fd, close_fd, props);
121 }
122
123 /**
124 * \}
125 */
126
127 #ifdef __cplusplus
128 } /* extern "C" */
129 #endif
130
131 #endif /* PIPEWIRE_EXT_SECURITY_CONTEXT_H */