Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7664901a authored by Dan Albert's avatar Dan Albert
Browse files

Move transport declarations into transport.h.

There are a few cloexec issues in here as an added bonus.

Change-Id: I1699d719d733f47878bdba0454230cf5ab6a60b6
parent 5329d3fd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "adb.h"
#include "adb_auth.h"
#include "adb_listeners.h"
#include "transport.h"

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

+8 −46
Original line number Diff line number Diff line
@@ -18,10 +18,10 @@
#define __ADB_H

#include <limits.h>
#include <sys/types.h>

#include "adb_trace.h"
#include "fdevent.h"
#include "transport.h"  /* readx(), writex() */

#ifdef __cplusplus
extern "C" {
@@ -37,12 +37,15 @@ extern "C" {
#define A_WRTE 0x45545257
#define A_AUTH 0x48545541

#define A_VERSION 0x01000000        // ADB protocol version
// ADB protocol version.
#define A_VERSION 0x01000000

#define ADB_VERSION_MAJOR 1         // Used for help/version information
#define ADB_VERSION_MINOR 0         // Used for help/version information
// Used for help/version information.
#define ADB_VERSION_MAJOR 1
#define ADB_VERSION_MINOR 0

#define ADB_SERVER_VERSION    32    // Increment this when we want to force users to start a new adb server
// Increment this when we want to force users to start a new adb server.
#define ADB_SERVER_VERSION 32

typedef struct amessage amessage;
typedef struct apacket apacket;
@@ -263,33 +266,11 @@ void fatal(const char *fmt, ...);
void fatal_errno(const char *fmt, ...);

void handle_packet(apacket *p, atransport *t);
void send_packet(apacket *p, atransport *t);

void get_my_path(char *s, size_t maxLen);
int launch_server(int server_port);
int adb_main(int is_daemon, int server_port);


/* transports are ref-counted
** get_device_transport does an acquire on your behalf before returning
*/
void init_transport_registration(void);
int  list_transports(char *buf, size_t  bufsize, int long_listing);
void update_transports(void);

asocket*  create_device_tracker(void);

/* Obtain a transport from the available transports.
** If state is != CS_ANY, only transports in that state are considered.
** If serial is non-NULL then only the device with that serial will be chosen.
** If no suitable transport is found, error is set.
*/
atransport *acquire_one_transport(int state, transport_type ttype, const char* serial, char **error_out);
void   add_transport_disconnect( atransport*  t, adisconnect*  dis );
void   remove_transport_disconnect( atransport*  t, adisconnect*  dis );
void   run_transport_disconnects( atransport*  t );
void   kick_transport( atransport*  t );

/* initialize a transport object's func pointers and state */
#if ADB_HOST
int get_available_local_transport_index();
@@ -297,22 +278,6 @@ int get_available_local_transport_index();
int  init_socket_transport(atransport *t, int s, int port, int local);
void init_usb_transport(atransport *t, usb_handle *usb, int state);

/* for MacOS X cleanup */
void close_usb_devices();

/* cause new transports to be init'd and added to the list */
int register_socket_transport(int s, const char *serial, int port, int local);

/* these should only be used for the "adb disconnect" command */
void unregister_transport(atransport *t);
void unregister_all_tcp_transports();

void register_usb_transport(usb_handle *h, const char *serial, const char *devpath, unsigned writeable);

/* this should only be used for transports with connection_state == CS_NOPERM */
void unregister_usb_transport(usb_handle *usb);

atransport *find_transport(const char *serial);
#if ADB_HOST
atransport* find_emulator_transport_by_adb_port(int adb_port);
#endif
@@ -343,9 +308,6 @@ void set_verity_enabled_state_service(int fd, void* cookie);
apacket *get_apacket(void);
void put_apacket(apacket *p);

int check_header(apacket *p);
int check_data(apacket *p);

// Define it if you want to dump packets.
#define DEBUG_PACKETS 0

+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#include "adb.h"
#include "adb_auth.h"
#include "transport.h"
#include "sysdeps.h"

int auth_enabled = 0;
+5 −3
Original line number Diff line number Diff line
@@ -14,18 +14,20 @@
 * limitations under the License.
 */

#include <resolv.h>
#include <stdio.h>
#include <string.h>
#include <resolv.h>
#include <cutils/list.h>
#include <cutils/sockets.h>

#include "sysdeps.h"

#include "adb.h"
#include "adb_auth.h"
#include "cutils/list.h"
#include "cutils/sockets.h"
#include "fdevent.h"
#include "mincrypt/rsa.h"
#include "mincrypt/sha.h"
#include "transport.h"

#define TRACE_TAG TRACE_AUTH

+22 −5
Original line number Diff line number Diff line
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <zipfile/zipfile.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>

#include "sysdeps.h"

#define  TRACE_TAG  TRACE_ADB
#include "adb_client.h"
#include "transport.h"
#include "zipfile/zipfile.h"

static transport_type __adb_transport = kTransportAny;
static const char* __adb_serial = NULL;
Loading