Commit e52da6fe authored by Jonathan Beck's avatar Jonathan Beck

make it compile

parent 6ac4ceb4
...@@ -75,7 +75,7 @@ int iphone_afc_new_client ( iphone_device_t device, int src_port, int dst_port, ...@@ -75,7 +75,7 @@ int iphone_afc_new_client ( iphone_device_t device, int src_port, int dst_port,
// Allocate a packet // Allocate a packet
client_loc->afc_packet = (AFCPacket*)malloc(sizeof(AFCPacket)); client_loc->afc_packet = (AFCPacket*)malloc(sizeof(AFCPacket));
if (!client_loc->afc_packet) { if (!client_loc->afc_packet) {
mux_close_connection(client_loc->connection); iphone_mux_free_client(client_loc->connection);
free(client_loc); free(client_loc);
return IPHONE_E_UNKNOWN_ERROR; return IPHONE_E_UNKNOWN_ERROR;
} }
...@@ -157,7 +157,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int ...@@ -157,7 +157,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
return -1; return -1;
} }
memcpy(buffer+sizeof(AFCPacket), data, offset); memcpy(buffer+sizeof(AFCPacket), data, offset);
bytes = mux_send(client->connection, buffer, client->afc_packet->this_length); bytes = iphone_mux_send(client->connection, buffer, client->afc_packet->this_length);
free(buffer); free(buffer);
if (bytes <= 0) { if (bytes <= 0) {
return bytes; return bytes;
...@@ -170,7 +170,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int ...@@ -170,7 +170,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
fwrite(data+offset, 1, length-offset, stdout); fwrite(data+offset, 1, length-offset, stdout);
} }
bytes = mux_send(client->connection, data+offset, length-offset); bytes = iphone_mux_send(client->connection, data+offset, length-offset);
return bytes; return bytes;
} else { } else {
if (debug) fprintf(stderr, "dispatch_AFC_packet doin things the old way\n"); if (debug) fprintf(stderr, "dispatch_AFC_packet doin things the old way\n");
...@@ -181,7 +181,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int ...@@ -181,7 +181,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
if (length > 0) { memcpy(buffer+sizeof(AFCPacket), data, length); buffer[sizeof(AFCPacket)+length] = '\0'; } if (length > 0) { memcpy(buffer+sizeof(AFCPacket), data, length); buffer[sizeof(AFCPacket)+length] = '\0'; }
if (debug) fwrite(buffer, 1, client->afc_packet->this_length, stdout); if (debug) fwrite(buffer, 1, client->afc_packet->this_length, stdout);
if (debug) fprintf(stderr, "\n"); if (debug) fprintf(stderr, "\n");
bytes = mux_send(client->connection, buffer, client->afc_packet->this_length); bytes = iphone_mux_send(client->connection, buffer, client->afc_packet->this_length);
if (buffer) { if (buffer) {
free(buffer); free(buffer);
...@@ -210,7 +210,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) { ...@@ -210,7 +210,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) {
int bytes = 0, recv_len = 0, current_count=0; int bytes = 0, recv_len = 0, current_count=0;
int retval = 0; int retval = 0;
bytes = mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4); bytes = iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4);
if (bytes <= 0) { if (bytes <= 0) {
free(buffer); free(buffer);
fprintf(stderr, "Just didn't get enough.\n"); fprintf(stderr, "Just didn't get enough.\n");
...@@ -263,7 +263,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) { ...@@ -263,7 +263,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) {
buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE); buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE);
final_buffer = (char*)malloc(sizeof(char) * recv_len); final_buffer = (char*)malloc(sizeof(char) * recv_len);
while(current_count < recv_len){ while(current_count < recv_len){
bytes = mux_recv(client->connection, buffer, recv_len-current_count); bytes = iphone_mux_recv(client->connection, buffer, recv_len-current_count);
if (debug) fprintf(stderr, "receive_AFC_data: still collecting packets\n"); if (debug) fprintf(stderr, "receive_AFC_data: still collecting packets\n");
if (bytes < 0) if (bytes < 0)
{ {
...@@ -603,7 +603,7 @@ int iphone_afc_get_file_attr ( iphone_afc_client_t client, const char *filename, ...@@ -603,7 +603,7 @@ int iphone_afc_get_file_attr ( iphone_afc_client_t client, const char *filename,
stbuf->st_uid = getuid(); stbuf->st_uid = getuid();
stbuf->st_gid = getgid(); stbuf->st_gid = getgid();
afc_close_file(client,file); iphone_afc_close_file(client,file);
} }
} }
......
...@@ -49,8 +49,9 @@ int debug = 0; ...@@ -49,8 +49,9 @@ int debug = 0;
static int ifuse_getattr(const char *path, struct stat *stbuf) { static int ifuse_getattr(const char *path, struct stat *stbuf) {
int res = 0; int res = 0;
AFCFile *file;
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
res = iphone_afc_get_file_attr(afc, path, stbuf);
return res; return res;
} }
...@@ -59,9 +60,9 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, ...@@ -59,9 +60,9 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi) { off_t offset, struct fuse_file_info *fi) {
int i; int i;
char **dirs; char **dirs;
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
dirs = afc_get_dir_list(afc, path); dirs = iphone_afc_get_dir_list(afc, path);
if(!dirs) if(!dirs)
return -ENOENT; return -ENOENT;
...@@ -77,10 +78,10 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, ...@@ -77,10 +78,10 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
static int ifuse_create(const char *path, mode_t mode, struct fuse_file_info *fi) { static int ifuse_create(const char *path, mode_t mode, struct fuse_file_info *fi) {
// exactly the same as open but using a different mode // exactly the same as open but using a different mode
AFCFile *file; iphone_afc_file_t file;
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
file = afc_open_file(afc, path, AFC_FILE_WRITE); iphone_afc_open_file(afc, path, AFC_FILE_WRITE, &file);
fh_index++; fh_index++;
fi->fh = fh_index; fi->fh = fh_index;
g_hash_table_insert(file_handles, &fh_index, file); g_hash_table_insert(file_handles, &fh_index, file);
...@@ -88,8 +89,8 @@ static int ifuse_create(const char *path, mode_t mode, struct fuse_file_info *fi ...@@ -88,8 +89,8 @@ static int ifuse_create(const char *path, mode_t mode, struct fuse_file_info *fi
} }
static int ifuse_open(const char *path, struct fuse_file_info *fi) { static int ifuse_open(const char *path, struct fuse_file_info *fi) {
AFCFile *file; iphone_afc_file_t file;
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
uint32 mode = 0; uint32 mode = 0;
if ((fi->flags & 3) == O_RDWR || (fi->flags & 3) == O_WRONLY) { if ((fi->flags & 3) == O_RDWR || (fi->flags & 3) == O_WRONLY) {
...@@ -100,7 +101,7 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi) { ...@@ -100,7 +101,7 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi) {
mode = AFC_FILE_READ; mode = AFC_FILE_READ;
} }
file = afc_open_file(afc, path, mode); iphone_afc_open_file(afc, path, mode, &file);
fh_index++; fh_index++;
fi->fh = fh_index; fi->fh = fh_index;
...@@ -112,8 +113,8 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi) { ...@@ -112,8 +113,8 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi) {
static int ifuse_read(const char *path, char *buf, size_t size, off_t offset, static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi) { struct fuse_file_info *fi) {
int bytes; int bytes;
AFCFile *file; iphone_afc_file_t file;
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
if (size == 0) if (size == 0)
return 0; return 0;
...@@ -123,23 +124,23 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset, ...@@ -123,23 +124,23 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
return -ENOENT; return -ENOENT;
} }
bytes = afc_seek_file(afc, file, offset); bytes = iphone_afc_seek_file(afc, file, offset);
bytes = afc_read_file(afc, file, buf, size); bytes = iphone_afc_read_file(afc, file, buf, size);
return bytes; return bytes;
} }
static int ifuse_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { static int ifuse_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
int bytes = 0; int bytes = 0;
AFCFile *file = NULL; iphone_afc_file_t file = NULL;
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
if (size == 0) return 0; if (size == 0) return 0;
file = g_hash_table_lookup(file_handles, &(fi->fh)); file = g_hash_table_lookup(file_handles, &(fi->fh));
if (!file) return -ENOENT; if (!file) return -ENOENT;
bytes = afc_seek_file(afc, file, offset); bytes = iphone_afc_seek_file(afc, file, offset);
bytes = afc_write_file(afc, file, buf, size); bytes = iphone_afc_write_file(afc, file, buf, size);
return bytes; return bytes;
} }
...@@ -148,16 +149,15 @@ static int ifuse_fsync(const char *path, int datasync, struct fuse_file_info *fi ...@@ -148,16 +149,15 @@ static int ifuse_fsync(const char *path, int datasync, struct fuse_file_info *fi
} }
static int ifuse_release(const char *path, struct fuse_file_info *fi){ static int ifuse_release(const char *path, struct fuse_file_info *fi){
AFCFile *file; iphone_afc_file_t file;
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
file = g_hash_table_lookup(file_handles, &(fi->fh)); file = g_hash_table_lookup(file_handles, &(fi->fh));
if (!file){ if (!file){
return -ENOENT; return -ENOENT;
} }
afc_close_file(afc, file); iphone_afc_close_file(afc, file);
free(file);
g_hash_table_remove(file_handles, &(fi->fh)); g_hash_table_remove(file_handles, &(fi->fh));
return 0; return 0;
...@@ -165,49 +165,44 @@ static int ifuse_release(const char *path, struct fuse_file_info *fi){ ...@@ -165,49 +165,44 @@ static int ifuse_release(const char *path, struct fuse_file_info *fi){
void *ifuse_init(struct fuse_conn_info *conn) { void *ifuse_init(struct fuse_conn_info *conn) {
int port = 0; int port = 0;
AFClient *afc = NULL; iphone_afc_client_t afc = NULL;
conn->async_read = 0; conn->async_read = 0;
file_handles = g_hash_table_new(g_int_hash, g_int_equal); file_handles = g_hash_table_new(g_int_hash, g_int_equal);
phone = get_iPhone(); iphone_get_device(&phone);
if (!phone){ if (!phone){
fprintf(stderr, "No iPhone found, is it connected?\n"); fprintf(stderr, "No iPhone found, is it connected?\n");
return NULL; return NULL;
} }
lockdownd_client *control = new_lockdownd_client(phone);
if (!lockdownd_hello(control)) {
fprintf(stderr, "Something went wrong in the lockdownd client.\n");
return NULL;
}
if (!lockdownd_init(phone, &control)) { if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) {
free_iPhone(phone); iphone_free_device(phone);
fprintf(stderr, "Something went wrong in the lockdownd client.\n"); fprintf(stderr, "Something went wrong in the lockdownd client.\n");
return NULL; return NULL;
} }
port = lockdownd_start_service(control, "com.apple.afc"); port = iphone_lckd_start_service(control, "com.apple.afc");
if (!port) { if (!port) {
lockdownd_close(control); iphone_lckd_free_client(control);
free_iPhone(phone); iphone_free_device(phone);
fprintf(stderr, "Something went wrong when starting AFC."); fprintf(stderr, "Something went wrong when starting AFC.");
return NULL; return NULL;
} }
afc = afc_connect(phone, 3432, port); iphone_afc_new_client(phone, 3432, port, &afc);
return afc; return afc;
} }
void ifuse_cleanup(void *data) { void ifuse_cleanup(void *data) {
AFClient *afc = (AFClient *)data; iphone_afc_client_t afc = (iphone_afc_client_t )data;
afc_disconnect(afc); iphone_afc_free_client(afc);
lockdownd_close(control); iphone_lckd_free_client(control);
free_iPhone(phone); iphone_free_device(phone);
} }
int ifuse_flush(const char *path, struct fuse_file_info *fi) { int ifuse_flush(const char *path, struct fuse_file_info *fi) {
...@@ -215,8 +210,8 @@ int ifuse_flush(const char *path, struct fuse_file_info *fi) { ...@@ -215,8 +210,8 @@ int ifuse_flush(const char *path, struct fuse_file_info *fi) {
} }
int ifuse_statfs(const char *path, struct statvfs *stats) { int ifuse_statfs(const char *path, struct statvfs *stats) {
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
char **info_raw = afc_get_devinfo(afc); char **info_raw = iphone_afc_get_devinfo(afc);
uint32 totalspace = 0, freespace = 0, blocksize = 0, i = 0; uint32 totalspace = 0, freespace = 0, blocksize = 0, i = 0;
if (!info_raw) return -ENOENT; if (!info_raw) return -ENOENT;
...@@ -243,38 +238,39 @@ int ifuse_statfs(const char *path, struct statvfs *stats) { ...@@ -243,38 +238,39 @@ int ifuse_statfs(const char *path, struct statvfs *stats) {
int ifuse_truncate(const char *path, off_t size) { int ifuse_truncate(const char *path, off_t size) {
int result = 0; int result = 0;
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
AFCFile *tfile = afc_open_file(afc, path, AFC_FILE_READ); iphone_afc_file_t tfile = NULL;
iphone_afc_open_file(afc, path, AFC_FILE_READ, &tfile);
if (!tfile) return -1; if (!tfile) return -1;
result = afc_truncate_file(afc, tfile, size); result = iphone_afc_truncate_file(afc, tfile, size);
afc_close_file(afc, tfile); iphone_afc_close_file(afc, tfile);
return result; return result;
} }
int ifuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) { int ifuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) {
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
AFCFile *file = g_hash_table_lookup(file_handles, &fi->fh); iphone_afc_file_t file = g_hash_table_lookup(file_handles, &fi->fh);
if (!file) return -ENOENT; if (!file) return -ENOENT;
return afc_truncate_file(afc, file, size); return iphone_afc_truncate_file(afc, file, size);
} }
int ifuse_unlink(const char *path) { int ifuse_unlink(const char *path) {
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
if (afc_delete_file(afc, path)) return 0; if (iphone_afc_delete_file(afc, path)) return 0;
else return -1; else return -1;
} }
int ifuse_rename(const char *from, const char *to) { int ifuse_rename(const char *from, const char *to) {
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
if (afc_rename_file(afc, from, to)) return 0; if (iphone_afc_rename_file(afc, from, to)) return 0;
else return -1; else return -1;
} }
int ifuse_mkdir(const char *dir, mode_t ignored) { int ifuse_mkdir(const char *dir, mode_t ignored) {
AFClient *afc = fuse_get_context()->private_data; iphone_afc_client_t afc = fuse_get_context()->private_data;
if (afc_mkdir(afc, dir)) return 0; if (iphone_afc_mkdir(afc, dir)) return 0;
else return -1; else return -1;
} }
......
...@@ -76,7 +76,7 @@ int iphone_get_device ( iphone_device_t *device ){ ...@@ -76,7 +76,7 @@ int iphone_get_device ( iphone_device_t *device ){
// Check to see if we are connected // Check to see if we are connected
if (!phone->device || !phone->__device) { if (!phone->device || !phone->__device) {
free_iPhone(phone); iphone_free_device(phone);
if (debug) fprintf(stderr, "get_iPhone(): iPhone not found\n"); if (debug) fprintf(stderr, "get_iPhone(): iPhone not found\n");
return IPHONE_E_NO_DEVICE; return IPHONE_E_NO_DEVICE;
} }
...@@ -99,7 +99,7 @@ int iphone_get_device ( iphone_device_t *device ){ ...@@ -99,7 +99,7 @@ int iphone_get_device ( iphone_device_t *device ){
// Check for bad response // Check for bad response
if (bytes < 20) { if (bytes < 20) {
free(version); free(version);
free_iPhone(phone); iphone_free_device(phone);
if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n"); if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n");
if (debug && bytes < 0) fprintf(stderr, "get_iPhone(): libusb error message %d: %s (%s)\n", if (debug && bytes < 0) fprintf(stderr, "get_iPhone(): libusb error message %d: %s (%s)\n",
bytes, usb_strerror(), strerror(-bytes)); bytes, usb_strerror(), strerror(-bytes));
...@@ -115,7 +115,7 @@ int iphone_get_device ( iphone_device_t *device ){ ...@@ -115,7 +115,7 @@ int iphone_get_device ( iphone_device_t *device ){
return IPHONE_E_SUCCESS; return IPHONE_E_SUCCESS;
} else { } else {
// Bad header // Bad header
free_iPhone(phone); iphone_free_device(phone);
free(version); free(version);
if (debug) fprintf(stderr, "get_iPhone(): Received a bad header/invalid version number."); if (debug) fprintf(stderr, "get_iPhone(): Received a bad header/invalid version number.");
return IPHONE_E_BAD_HEADER; return IPHONE_E_BAD_HEADER;
...@@ -123,7 +123,7 @@ int iphone_get_device ( iphone_device_t *device ){ ...@@ -123,7 +123,7 @@ int iphone_get_device ( iphone_device_t *device ){
// If it got to this point it's gotta be bad // If it got to this point it's gotta be bad
if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n"); if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n");
free_iPhone(phone); iphone_free_device(phone);
free(version); free(version);
return IPHONE_E_UNKNOWN_ERROR; // 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
} }
......
...@@ -97,7 +97,7 @@ iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone) { ...@@ -97,7 +97,7 @@ iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone) {
void iphone_lckd_free_client( iphone_lckd_client_t client ) { void iphone_lckd_free_client( iphone_lckd_client_t client ) {
if (!client) return; if (!client) return;
if (client->connection) { if (client->connection) {
mux_close_connection(client->connection); iphone_mux_free_client(client->connection);
} }
if (client->ssl_session) gnutls_deinit(*client->ssl_session); if (client->ssl_session) gnutls_deinit(*client->ssl_session);
...@@ -118,12 +118,12 @@ int iphone_lckd_recv ( iphone_lckd_client_t client, char **dump_data ) { ...@@ -118,12 +118,12 @@ int iphone_lckd_recv ( iphone_lckd_client_t client, char **dump_data ) {
char *receive; char *receive;
uint32 datalen = 0, bytes = 0; uint32 datalen = 0, bytes = 0;
if (!client->in_SSL) bytes = mux_recv(client->connection, (char *)&datalen, sizeof(datalen)); if (!client->in_SSL) bytes = iphone_mux_recv(client->connection, (char *)&datalen, sizeof(datalen));
else bytes = gnutls_record_recv(*client->ssl_session, &datalen, sizeof(datalen)); else bytes = gnutls_record_recv(*client->ssl_session, &datalen, sizeof(datalen));
datalen = ntohl(datalen); datalen = ntohl(datalen);
receive = (char*)malloc(sizeof(char) * datalen); receive = (char*)malloc(sizeof(char) * datalen);
if (!client->in_SSL) bytes = mux_recv(client->connection, receive, datalen); if (!client->in_SSL) bytes = iphone_mux_recv(client->connection, receive, datalen);
else bytes = gnutls_record_recv(*client->ssl_session, receive, datalen); else bytes = gnutls_record_recv(*client->ssl_session, receive, datalen);
*dump_data = receive; *dump_data = receive;
return bytes; return bytes;
...@@ -157,7 +157,7 @@ int iphone_lckd_send ( iphone_lckd_client_t client, char *raw_data, uint32_t len ...@@ -157,7 +157,7 @@ int iphone_lckd_send ( iphone_lckd_client_t client, char *raw_data, uint32_t len
packet = NULL; packet = NULL;
} }
if (!client->in_SSL) bytes = mux_send(client->connection, real_query, ntohl(length)+sizeof(length)); if (!client->in_SSL) bytes = iphone_mux_send(client->connection, real_query, ntohl(length)+sizeof(length));
else gnutls_record_send(*client->ssl_session, real_query, ntohl(length)+sizeof(length)); else gnutls_record_send(*client->ssl_session, real_query, ntohl(length)+sizeof(length));
if (debug) printf("lockdownd_send(): sent it!\n"); if (debug) printf("lockdownd_send(): sent it!\n");
free(real_query); free(real_query);
...@@ -186,11 +186,11 @@ int lockdownd_hello(iphone_lckd_client_t control) { ...@@ -186,11 +186,11 @@ int lockdownd_hello(iphone_lckd_client_t control) {
uint32 length; uint32 length;
xmlDocDumpMemory(plist, (xmlChar **)&XML_content, &length); xmlDocDumpMemory(plist, (xmlChar **)&XML_content, &length);
bytes = lockdownd_send(control, XML_content, length); bytes = iphone_lckd_send(control, XML_content, length);
xmlFree(XML_content); xmlFree(XML_content);
xmlFreeDoc(plist); plist = NULL; xmlFreeDoc(plist); plist = NULL;
bytes = lockdownd_recv(control, &XML_content); bytes = iphone_lckd_recv(control, &XML_content);
plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0); plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0);
if (!plist) return 0; if (!plist) return 0;
...@@ -240,13 +240,13 @@ int lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, cha ...@@ -240,13 +240,13 @@ int lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, cha
xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length); xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length);
/* send to iPhone */ /* send to iPhone */
bytes = lockdownd_send(control, XML_content, length); bytes = iphone_lckd_send(control, XML_content, length);
xmlFree(XML_content); xmlFree(XML_content);
xmlFreeDoc(plist); plist = NULL; xmlFreeDoc(plist); plist = NULL;
/* Now get iPhone's answer */ /* Now get iPhone's answer */
bytes = lockdownd_recv(control, &XML_content); bytes = iphone_lckd_recv(control, &XML_content);
plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0); plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0);
if (!plist) return 0; if (!plist) return 0;
...@@ -407,13 +407,13 @@ int lockdownd_pair_device(iphone_lckd_client_t control, char *uid, char *host_id ...@@ -407,13 +407,13 @@ int lockdownd_pair_device(iphone_lckd_client_t control, char *uid, char *host_id
printf("XML Pairing request : %s\n",XML_content); printf("XML Pairing request : %s\n",XML_content);
/* send to iPhone */ /* send to iPhone */
bytes = lockdownd_send(control, XML_content, length); bytes = iphone_lckd_send(control, XML_content, length);
xmlFree(XML_content); xmlFree(XML_content);
xmlFreeDoc(plist); plist = NULL; xmlFreeDoc(plist); plist = NULL;
/* Now get iPhone's answer */ /* Now get iPhone's answer */
bytes = lockdownd_recv(control, &XML_content); bytes = iphone_lckd_recv(control, &XML_content);
if (debug) { if (debug) {
printf("lockdown_pair_device: iPhone's response to our pair request:\n"); printf("lockdown_pair_device: iPhone's response to our pair request:\n");
...@@ -621,13 +621,13 @@ int lockdownd_start_SSL_session(iphone_lckd_client_t control, const char *HostID ...@@ -621,13 +621,13 @@ int lockdownd_start_SSL_session(iphone_lckd_client_t control, const char *HostID
} }
xmlDocDumpMemory(plist, (xmlChar **)&what2send, &len); xmlDocDumpMemory(plist, (xmlChar **)&what2send, &len);
bytes = lockdownd_send(control, what2send, len); bytes = iphone_lckd_send(control, what2send, len);
xmlFree(what2send); xmlFree(what2send);
xmlFreeDoc(plist); xmlFreeDoc(plist);
if (bytes > 0) { if (bytes > 0) {
len = lockdownd_recv(control, &what2send); len = iphone_lckd_recv(control, &what2send);
plist = xmlReadMemory(what2send, len, NULL, NULL, 0); plist = xmlReadMemory(what2send, len, NULL, NULL, 0);
dict = xmlDocGetRootElement(plist); dict = xmlDocGetRootElement(plist);
for (dict = dict->children; dict; dict = dict->next) { for (dict = dict->children; dict; dict = dict->next) {
...@@ -721,7 +721,7 @@ ssize_t lockdownd_secuwrite(gnutls_transport_ptr_t transport, char *buffer, size ...@@ -721,7 +721,7 @@ ssize_t lockdownd_secuwrite(gnutls_transport_ptr_t transport, char *buffer, size
control = (iphone_lckd_client_t)transport; control = (iphone_lckd_client_t)transport;
if (debug) printf("lockdownd_secuwrite() called\n"); if (debug) printf("lockdownd_secuwrite() called\n");
if (debug) printf("pre-send\nlength = %zi\n", length); if (debug) printf("pre-send\nlength = %zi\n", length);
bytes = mux_send(control->connection, buffer, length); bytes = iphone_mux_send(control->connection, buffer, length);
if (debug) printf("post-send\nsent %i bytes\n", bytes); if (debug) printf("post-send\nsent %i bytes\n", bytes);
if (debug) { if (debug) {
FILE *my_ssl_packet = fopen("sslpacketwrite.out", "w+"); FILE *my_ssl_packet = fopen("sslpacketwrite.out", "w+");
...@@ -779,7 +779,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_ ...@@ -779,7 +779,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_
char *recv_buffer = (char*)malloc(sizeof(char) * (length * 1000)); // ensuring nothing stupid happens char *recv_buffer = (char*)malloc(sizeof(char) * (length * 1000)); // ensuring nothing stupid happens
if (debug) printf("pre-read\nclient wants %zi bytes\n", length); if (debug) printf("pre-read\nclient wants %zi bytes\n", length);
bytes = mux_recv(control->connection, recv_buffer, (length * 1000)); bytes = iphone_mux_recv(control->connection, recv_buffer, (length * 1000));
if (debug) printf("post-read\nwe got %i bytes\n", bytes); if (debug) printf("post-read\nwe got %i bytes\n", bytes);
if (debug && bytes < 0) { if (debug && bytes < 0) {
printf("lockdownd_securead(): uh oh\n"); printf("lockdownd_securead(): uh oh\n");
...@@ -838,10 +838,10 @@ int iphone_lckd_start_service ( iphone_lckd_client_t client, const char *service ...@@ -838,10 +838,10 @@ int iphone_lckd_start_service ( iphone_lckd_client_t client, const char *service
xmlDocDumpMemory(plist, (xmlChar **)&XML_query, &length); xmlDocDumpMemory(plist, (xmlChar **)&XML_query, &length);
lockdownd_send(client, XML_query, length); iphone_lckd_send(client, XML_query, length);
free(XML_query); free(XML_query);
length = lockdownd_recv(client, &XML_query); length = iphone_lckd_recv(client, &XML_query);
xmlFreeDoc(plist); xmlFreeDoc(plist);
......
...@@ -176,7 +176,7 @@ void iphone_mux_free_client ( iphone_umux_client_t client ) { ...@@ -176,7 +176,7 @@ void iphone_mux_free_client ( iphone_umux_client_t client ) {
bytes = usb_bulk_write(client->phone->device, BULKOUT, (char*)client->header, sizeof(usbmux_tcp_header), 800); bytes = usb_bulk_write(client->phone->device, BULKOUT, (char*)client->header, sizeof(usbmux_tcp_header), 800);
if(debug && bytes < 0) if(debug && bytes < 0)
printf("mux_close_connection(): when writing, libusb gave me the error: %s\n", usb_strerror()); printf("iphone_muxèfree_client(): when writing, libusb gave me the error: %s\n", usb_strerror());
bytes = usb_bulk_read(client->phone->device, BULKIN, (char*)client->header, sizeof(usbmux_tcp_header), 800); bytes = usb_bulk_read(client->phone->device, BULKIN, (char*)client->header, sizeof(usbmux_tcp_header), 800);
if(debug && bytes < 0) if(debug && bytes < 0)
...@@ -332,7 +332,7 @@ int iphone_mux_recv ( iphone_umux_client_t client, char *data, uint32_t datalen ...@@ -332,7 +332,7 @@ int iphone_mux_recv ( iphone_umux_client_t client, char *data, uint32_t datalen
// Free our buffer and continue. // Free our buffer and continue.
free(buffer); free(buffer);
buffer = NULL; buffer = NULL;
return mux_recv(client, data, datalen); // recurse back in to try again return iphone_mux_recv(client, data, datalen); // recurse back in to try again
} }
// The packet was absolutely meant for us if it hits this point. // The packet was absolutely meant for us if it hits this point.
......
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