blob: 36a0e4019a0af2f92445e0763ec8b328bec28937 [file] [log] [blame]
JP Abgrall408fa572011-03-16 15:57:42 -07001/*
2 * Copyright (C) 2011 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
17#ifndef __TRANSPORT_H
18#define __TRANSPORT_H
19
Dan Albertcc731cc2015-02-24 21:26:58 -080020#include <stdbool.h>
Dan Alberte9fca142015-02-18 18:03:26 -080021#include <sys/types.h>
22
Dan Albert76649012015-02-24 15:51:19 -080023#include "adb.h"
24
Dan Albert630b9af2014-11-24 23:34:35 -080025#ifdef __cplusplus
26extern "C" {
27#endif
28
Dan Albertcc731cc2015-02-24 21:26:58 -080029#if ADB_TRACE
30void dump_hex(const unsigned char* ptr, size_t len);
31#endif
Dan Albert630b9af2014-11-24 23:34:35 -080032
Dan Albert76649012015-02-24 15:51:19 -080033/*
34 * Obtain a transport from the available transports.
35 * If state is != CS_ANY, only transports in that state are considered.
36 * If serial is non-NULL then only the device with that serial will be chosen.
37 * If no suitable transport is found, error is set.
38 */
39atransport* acquire_one_transport(int state, transport_type ttype,
Dan Albertbac34742015-02-25 17:51:28 -080040 const char* serial, const char** error_out);
Dan Albert76649012015-02-24 15:51:19 -080041void add_transport_disconnect(atransport* t, adisconnect* dis);
42void remove_transport_disconnect(atransport* t, adisconnect* dis);
43void kick_transport(atransport* t);
44void run_transport_disconnects(atransport* t);
45void update_transports(void);
46
47/* transports are ref-counted
48** get_device_transport does an acquire on your behalf before returning
49*/
50void init_transport_registration(void);
51int list_transports(char* buf, size_t bufsize, int long_listing);
52atransport* find_transport(const char* serial);
53
54void register_usb_transport(usb_handle* h, const char* serial,
55 const char* devpath, unsigned writeable);
56
57/* cause new transports to be init'd and added to the list */
58int register_socket_transport(int s, const char* serial, int port, int local);
59
60/* this should only be used for transports with connection_state == CS_NOPERM */
61void unregister_usb_transport(usb_handle* usb);
62
63/* these should only be used for the "adb disconnect" command */
64void unregister_transport(atransport* t);
65void unregister_all_tcp_transports();
66
67int check_header(apacket* p);
68int check_data(apacket* p);
69
70/* for MacOS X cleanup */
71void close_usb_devices();
72
73void send_packet(apacket* p, atransport* t);
74
75asocket* create_device_tracker(void);
76
Dan Albert630b9af2014-11-24 23:34:35 -080077#ifdef __cplusplus
78}
79#endif
80
JP Abgrall408fa572011-03-16 15:57:42 -070081#endif /* __TRANSPORT_H */