blob: 0aa774a7d61dc0277228d84ea14af9cf509385b5 [file] [log] [blame]
Dan Albert020292b2015-02-18 18:03:26 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Josh Gao65d18e22020-04-22 20:57:26 -070017#pragma once
Dan Albert020292b2015-02-18 18:03:26 -080018
19#include "adb.h"
20
Elliott Hughes88b4c852015-04-30 17:32:03 -070021#include <string>
22
David Pursell19d0c232016-04-07 11:25:48 -070023#include <android-base/macros.h>
24
Dan Albert020292b2015-02-18 18:03:26 -080025// error/status codes for install_listener.
Elliott Hughes3aec2ba2015-05-05 13:10:43 -070026enum InstallStatus {
Dan Albert020292b2015-02-18 18:03:26 -080027 INSTALL_STATUS_OK = 0,
28 INSTALL_STATUS_INTERNAL_ERROR = -1,
29 INSTALL_STATUS_CANNOT_BIND = -2,
30 INSTALL_STATUS_CANNOT_REBIND = -3,
Elliott Hughesa585cbd2015-04-20 08:09:20 -070031 INSTALL_STATUS_LISTENER_NOT_FOUND = -4,
Elliott Hughesfe7ff812015-04-17 09:47:42 -070032};
Dan Albert020292b2015-02-18 18:03:26 -080033
Daniel Colascione232c39c2019-11-13 17:51:19 -080034inline constexpr int INSTALL_LISTENER_NO_REBIND = 1 << 0;
35inline constexpr int INSTALL_LISTENER_DISABLED = 1 << 1;
36
David Pursell19d0c232016-04-07 11:25:48 -070037InstallStatus install_listener(const std::string& local_name, const char* connect_to,
Daniel Colascione232c39c2019-11-13 17:51:19 -080038 atransport* transport, int flags, int* resolved_tcp_port,
Spencer Low753d4852015-07-30 23:07:55 -070039 std::string* error);
Dan Albert020292b2015-02-18 18:03:26 -080040
Elliott Hughes88b4c852015-04-30 17:32:03 -070041std::string format_listeners();
Dan Albert020292b2015-02-18 18:03:26 -080042
Elliott Hughes3aec2ba2015-05-05 13:10:43 -070043InstallStatus remove_listener(const char* local_name, atransport* transport);
Dan Albert020292b2015-02-18 18:03:26 -080044void remove_all_listeners(void);
45
Josh Gao65d18e22020-04-22 20:57:26 -070046#if ADB_HOST
47void enable_server_sockets();
Josh Gao165460f2017-05-09 13:43:35 -070048void close_smartsockets();
Josh Gao65d18e22020-04-22 20:57:26 -070049#endif