xref: /openbmc/qemu/qapi/sockets.json (revision cad9aa6fbdccd95e56e10cfa57c354a20a333717)
1# -*- Mode: Python -*-
2# vim: filetype=python
3
4##
5# *****************
6# Socket data types
7# *****************
8##
9
10##
11# @NetworkAddressFamily:
12#
13# The network address family
14#
15# @ipv4: IPV4 family
16#
17# @ipv6: IPV6 family
18#
19# @unix: unix socket
20#
21# @vsock: vsock family (since 2.8)
22#
23# @unknown: otherwise
24#
25# Since: 2.1
26##
27{ 'enum': 'NetworkAddressFamily',
28  'data': [ 'ipv4', 'ipv6', 'unix', 'vsock', 'unknown' ] }
29
30##
31# @InetSocketAddressBase:
32#
33# @host: host part of the address
34#
35# @port: port part of the address
36##
37{ 'struct': 'InetSocketAddressBase',
38  'data': {
39    'host': 'str',
40    'port': 'str' } }
41
42##
43# @InetSocketAddress:
44#
45# Captures a socket address or address range in the Internet
46# namespace.
47#
48# @numeric: true if the host/port are guaranteed to be numeric, false
49#     if name resolution should be attempted.  Defaults to false.
50#     (Since 2.9)
51#
52# @to: If present, this is range of possible addresses, with port
53#     between @port and @to.
54#
55# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and
56#     IPv6
57#
58# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and
59#     IPv6
60#
61# @keep-alive: enable keep-alive when connecting to/listening on this socket.
62#     (Since 4.2, not supported for listening sockets until 10.1)
63#
64# @keep-alive-count: number of keep-alive packets sent before the connection is
65#     closed.  Only supported for TCP sockets on systems where TCP_KEEPCNT
66#     socket option is defined (this includes Linux, Windows, macOS, FreeBSD,
67#     but not OpenBSD).  When set to 0, system setting is used.  (Since 10.1)
68#
69# @keep-alive-idle: time in seconds the connection needs to be idle before
70#     sending a keepalive packet.  Only supported for TCP sockets on systems
71#     where TCP_KEEPIDLE socket option is defined (this includes Linux,
72#     Windows, macOS, FreeBSD, but not OpenBSD).  When set to 0, system setting
73#     is used.  (Since 10.1)
74#
75# @keep-alive-interval: time in seconds between keep-alive packets.  Only
76#     supported for TCP sockets on systems where TCP_KEEPINTVL is defined (this
77#     includes Linux, Windows, macOS, FreeBSD, but not OpenBSD).  When set to
78#     0, system setting is used.  (Since 10.1)
79#
80# @mptcp: enable multi-path TCP.  (Since 6.1)
81#
82# Since: 1.3
83##
84{ 'struct': 'InetSocketAddress',
85  'base': 'InetSocketAddressBase',
86  'data': {
87    '*numeric':  'bool',
88    '*to': 'uint16',
89    '*ipv4': 'bool',
90    '*ipv6': 'bool',
91    '*keep-alive': 'bool',
92    '*keep-alive-count': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPCNT' },
93    '*keep-alive-idle': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPIDLE' },
94    '*keep-alive-interval': { 'type': 'uint32', 'if': 'HAVE_TCP_KEEPINTVL' },
95    '*mptcp': { 'type': 'bool', 'if': 'HAVE_IPPROTO_MPTCP' } } }
96
97##
98# @UnixSocketAddress:
99#
100# Captures a socket address in the local ("Unix socket") namespace.
101#
102# @path: filesystem path to use
103#
104# @abstract: if true, this is a Linux abstract socket address.  @path
105#     will be prefixed by a null byte, and optionally padded with null
106#     bytes.  Defaults to false.  (Since 5.1)
107#
108# @tight: if false, pad an abstract socket address with enough null
109#     bytes to make it fill struct sockaddr_un member sun_path.
110#     Defaults to true.  (Since 5.1)
111#
112# Since: 1.3
113##
114{ 'struct': 'UnixSocketAddress',
115  'data': {
116    'path': 'str',
117    '*abstract': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
118    '*tight': { 'type': 'bool', 'if': 'CONFIG_LINUX' } } }
119
120##
121# @VsockSocketAddress:
122#
123# Captures a socket address in the vsock namespace.
124#
125# @cid: unique host identifier
126#
127# @port: port
128#
129# .. note:: String types are used to allow for possible future
130#    hostname or service resolution support.
131#
132# Since: 2.8
133##
134{ 'struct': 'VsockSocketAddress',
135  'data': {
136    'cid': 'str',
137    'port': 'str' } }
138
139##
140# @FdSocketAddress:
141#
142# A file descriptor name or number.
143#
144# @str: decimal is for file descriptor number, otherwise it's a file
145#     descriptor name.  Named file descriptors are permitted in
146#     monitor commands, in combination with the `getfd` command.
147#     Decimal file descriptors are permitted at startup or other
148#     contexts where no monitor context is active.
149#
150# Since: 1.2
151##
152{ 'struct': 'FdSocketAddress',
153  'data': {
154    'str': 'str' } }
155
156##
157# @InetSocketAddressWrapper:
158#
159# @data: internet domain socket address
160#
161# Since: 1.3
162##
163{ 'struct': 'InetSocketAddressWrapper',
164  'data': { 'data': 'InetSocketAddress' } }
165
166##
167# @UnixSocketAddressWrapper:
168#
169# @data: UNIX domain socket address
170#
171# Since: 1.3
172##
173{ 'struct': 'UnixSocketAddressWrapper',
174  'data': { 'data': 'UnixSocketAddress' } }
175
176##
177# @VsockSocketAddressWrapper:
178#
179# @data: VSOCK domain socket address
180#
181# Since: 2.8
182##
183{ 'struct': 'VsockSocketAddressWrapper',
184  'data': { 'data': 'VsockSocketAddress' } }
185
186##
187# @FdSocketAddressWrapper:
188#
189# @data: file descriptor name or number
190#
191# Since: 1.3
192##
193{ 'struct': 'FdSocketAddressWrapper',
194  'data': { 'data': 'FdSocketAddress' } }
195
196##
197# @SocketAddressLegacy:
198#
199# Captures the address of a socket, which could also be a named file
200# descriptor
201#
202# @type: Transport type
203#
204# Since: 1.3
205##
206{ 'union': 'SocketAddressLegacy',
207  'base': { 'type': 'SocketAddressType' },
208  'discriminator': 'type',
209  'data': {
210    'inet': 'InetSocketAddressWrapper',
211    'unix': 'UnixSocketAddressWrapper',
212    'vsock': 'VsockSocketAddressWrapper',
213    'fd': 'FdSocketAddressWrapper' } }
214# Note: This type is deprecated in favor of `SocketAddress`.  The
215# difference between `SocketAddressLegacy` and `SocketAddress` is that the
216# latter has fewer ``{}`` on the wire.
217
218##
219# @SocketAddressType:
220#
221# Available `SocketAddress` types
222#
223# @inet: Internet address
224#
225# @unix: Unix domain socket
226#
227# @vsock: VMCI address
228#
229# @fd: Socket file descriptor
230#
231# Since: 2.9
232##
233{ 'enum': 'SocketAddressType',
234  'data': [ 'inet', 'unix', 'vsock', 'fd' ] }
235
236##
237# @SocketAddress:
238#
239# Captures the address of a socket, which could also be a socket file
240# descriptor
241#
242# @type: Transport type
243#
244# Since: 2.9
245##
246{ 'union': 'SocketAddress',
247  'base': { 'type': 'SocketAddressType' },
248  'discriminator': 'type',
249  'data': { 'inet': 'InetSocketAddress',
250            'unix': 'UnixSocketAddress',
251            'vsock': 'VsockSocketAddress',
252            'fd': 'FdSocketAddress' } }
253