Commit ad65cefa authored by Jonathan Beck's avatar Jonathan Beck

migrate usbmux.c.

parent 21d5d4ac
...@@ -32,18 +32,19 @@ extern "C" { ...@@ -32,18 +32,19 @@ extern "C" {
//general errors //general errors
#define IPHONE_E_SUCCESS 0 #define IPHONE_E_SUCCESS 0
#define IPHONE_E_INVALID_ARG -1 #define IPHONE_E_INVALID_ARG -1
#define IPHONE_E_NO_DEVICE -2 #define IPHONE_E_UNKNOWN_ERROR -2
#define IPHONE_E_TIMEOUT -3 #define IPHONE_E_NO_DEVICE -3
#define IPHONE_E_NOT_ENOUGH_DATA -4 #define IPHONE_E_TIMEOUT -4
#define IPHONE_E_BAD_HEADER -5 #define IPHONE_E_NOT_ENOUGH_DATA -5
#define IPHONE_E_BAD_HEADER -6
//lockdownd specific error //lockdownd specific error
#define IPHONE_E_INVALID_CONF -6 #define IPHONE_E_INVALID_CONF -7
#define IPHONE_E_PAIRING_FAILED -7 #define IPHONE_E_PAIRING_FAILED -8
#define IPHONE_E_SSL_ERROR -8 #define IPHONE_E_SSL_ERROR -9
//afc specific error //afc specific error
#define IPHONE_E_NO_SUCH_FILE -9 #define IPHONE_E_NO_SUCH_FILE -10
struct iphone_device_int; struct iphone_device_int;
typedef struct iphone_device_int *iphone_device_t; typedef struct iphone_device_int *iphone_device_t;
......
...@@ -42,7 +42,6 @@ int iphone_get_device ( iphone_device_t *device ){ ...@@ -42,7 +42,6 @@ int iphone_get_device ( iphone_device_t *device ){
struct usb_bus *bus, *busses; struct usb_bus *bus, *busses;
struct usb_device *dev; struct usb_device *dev;
iphone_device_t phone = (iphone_device_t)malloc(sizeof(struct iphone_device_int)); iphone_device_t phone = (iphone_device_t)malloc(sizeof(struct iphone_device_int));
usbmux_version_header *version = version_header();
// Initialize the struct // Initialize the struct
phone->device = NULL; phone->device = NULL;
...@@ -126,7 +125,7 @@ int iphone_get_device ( iphone_device_t *device ){ ...@@ -126,7 +125,7 @@ int iphone_get_device ( iphone_device_t *device ){
if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n"); if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n");
free_iPhone(phone); free_iPhone(phone);
free(version); free(version);
return IPHONE_E_NO_DEVICE; // if it got to this point it's gotta be bad return IPHONE_E_UNKNOWN_ERROR; // if it got to this point it's gotta be bad
} }
/** Cleans up an iPhone structure, then frees the structure itself. /** Cleans up an iPhone structure, then frees the structure itself.
......
...@@ -77,8 +77,8 @@ char *lockdownd_generate_hostid() { ...@@ -77,8 +77,8 @@ char *lockdownd_generate_hostid() {
iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone) { iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone) {
if (!phone) return NULL; if (!phone) return NULL;
iphone_lckd_client_t control = (iphone_lckd_client_t)malloc(sizeof(struct iphone_lckd_client_int)); iphone_lckd_client_t control = (iphone_lckd_client_t)malloc(sizeof(struct iphone_lckd_client_int));
control->connection = mux_connect(phone, 0x0a00, 0xf27e);
if (!control->connection) { if (IPHONE_E_SUCCESS != iphone_mux_new_client ( phone, 0x0a00, 0xf27e, &control->connection)) {
free(control); free(control);
return NULL; return NULL;
} }
...@@ -100,7 +100,7 @@ void iphone_lckd_free_client( iphone_lckd_client_t client ) { ...@@ -100,7 +100,7 @@ void iphone_lckd_free_client( iphone_lckd_client_t client ) {
mux_close_connection(client->connection); mux_close_connection(client->connection);
} }
if (client->ssl_session) gnutls_deinit(*control->ssl_session); if (client->ssl_session) gnutls_deinit(*client->ssl_session);
free(client->ssl_session); free(client->ssl_session);
free(client); free(client);
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
struct iphone_lckd_client_int { struct iphone_lckd_client_int {
usbmux_connection *connection; iphone_umux_client_t connection;
gnutls_session_t *ssl_session; gnutls_session_t *ssl_session;
int in_SSL; int in_SSL;
char *gtls_buffer_hack; char *gtls_buffer_hack;
......
This diff is collapsed.
...@@ -43,12 +43,12 @@ typedef struct { ...@@ -43,12 +43,12 @@ typedef struct {
uint16 window, nullnull, length16; uint16 window, nullnull, length16;
} usbmux_tcp_header; } usbmux_tcp_header;
typedef struct { struct iphone_umux_client_int {
usbmux_tcp_header *header; usbmux_tcp_header *header;
iphone_device_t phone; iphone_device_t phone;
char *recv_buffer; char *recv_buffer;
int r_len; int r_len;
} usbmux_connection; };
usbmux_tcp_header *new_mux_packet(uint16 s_port, uint16 d_port); usbmux_tcp_header *new_mux_packet(uint16 s_port, uint16 d_port);
...@@ -58,10 +58,5 @@ typedef struct { ...@@ -58,10 +58,5 @@ typedef struct {
usbmux_version_header *version_header(); usbmux_version_header *version_header();
usbmux_connection *mux_connect(iphone_device_t phone, uint16 s_port, uint16 d_port);
void mux_close_connection(usbmux_connection *connection);
int mux_send(usbmux_connection *connection, const char *data, uint32 datalen);
int mux_recv(usbmux_connection *connection, char *data, uint32 datalen);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment