xref: /aosp_15_r20/prebuilts/android-emulator/linux-x86_64/lib/control_socket.proto (revision d870e0501505f2fc9999364ffe386a6b6151adc1)
1// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14syntax = "proto2";
15
16package android.emulation.control;
17
18option java_package = "com.android.emulator.control";
19
20// Used to communicate the socket state between a waterfall service running
21// inside the emulator (guest) and a domain socket running on the host
22// (emulator)
23//
24// The host does not have the abiliy to open direct connections, but can accept
25// incoming connections.
26//
27// The protocol is as follows:
28//
29// - The first message on a channel from guest -> host is always a
30// "SocketControl" message.
31// - A channel that is identified with fd=0 is called the control channel.
32//   Only SocketControl messages are exchanged on this channel.
33//
34// For channel 0:
35//    - If the hosts sends an open message:
36//           - The guest should respond with a new connection, With the first
37//           message
38//             an identity message with the requested fd
39//    - If the hosts sends a close message:
40//           - The guest can close the connection with the given fd, no new
41//           messages will be send on the
42//             channel. (Be aware of out of order delivery, there still might be
43//             some leftover bytes)
44//    - If the guests sends a close message:
45//           - The host can close the connection with the given fd, no new
46//           messages will be send on the
47//             channel. (Be aware of out of order delivery, there still might be
48//             some leftover bytes)
49//
50// For a new connection the host usually will read the socket control message,
51// and pass on the remaining bytes to whomever wants to consume them.
52message SocketControl {
53    enum Sort {
54        identity = 0;  // Indicates the identify of the channel on which this
55                       // message is sent.
56        open = 1;      // Request the client to open up a connection with the
57                       // requested id.
58        close = 2;     // Indicate that the channel with the given fd is to be
59                    // closed. More specifically No new data will be placed on
60                    // the wire after the sending of this message.
61    }
62
63    required Sort sort = 1;   // 1 Byte
64    required fixed32 fd = 2;  // 4 Bytes
65}
66