summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AFC.c14
-rw-r--r--src/ifuse.c106
-rw-r--r--src/iphone.c8
-rw-r--r--src/lockdown.c32
-rw-r--r--src/usbmux.c4
5 files changed, 80 insertions, 84 deletions
diff --git a/src/AFC.c b/src/AFC.c
index 64a26b0..5866915 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -75,7 +75,7 @@ int iphone_afc_new_client ( iphone_device_t device, int src_port, int dst_port,
75 // Allocate a packet 75 // Allocate a packet
76 client_loc->afc_packet = (AFCPacket*)malloc(sizeof(AFCPacket)); 76 client_loc->afc_packet = (AFCPacket*)malloc(sizeof(AFCPacket));
77 if (!client_loc->afc_packet) { 77 if (!client_loc->afc_packet) {
78 mux_close_connection(client_loc->connection); 78 iphone_mux_free_client(client_loc->connection);
79 free(client_loc); 79 free(client_loc);
80 return IPHONE_E_UNKNOWN_ERROR; 80 return IPHONE_E_UNKNOWN_ERROR;
81 } 81 }
@@ -157,7 +157,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
157 return -1; 157 return -1;
158 } 158 }
159 memcpy(buffer+sizeof(AFCPacket), data, offset); 159 memcpy(buffer+sizeof(AFCPacket), data, offset);
160 bytes = mux_send(client->connection, buffer, client->afc_packet->this_length); 160 bytes = iphone_mux_send(client->connection, buffer, client->afc_packet->this_length);
161 free(buffer); 161 free(buffer);
162 if (bytes <= 0) { 162 if (bytes <= 0) {
163 return bytes; 163 return bytes;
@@ -170,7 +170,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
170 fwrite(data+offset, 1, length-offset, stdout); 170 fwrite(data+offset, 1, length-offset, stdout);
171 } 171 }
172 172
173 bytes = mux_send(client->connection, data+offset, length-offset); 173 bytes = iphone_mux_send(client->connection, data+offset, length-offset);
174 return bytes; 174 return bytes;
175 } else { 175 } else {
176 if (debug) fprintf(stderr, "dispatch_AFC_packet doin things the old way\n"); 176 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 if (length > 0) { memcpy(buffer+sizeof(AFCPacket), data, length); buffer[sizeof(AFCPacket)+length] = '\0'; } 181 if (length > 0) { memcpy(buffer+sizeof(AFCPacket), data, length); buffer[sizeof(AFCPacket)+length] = '\0'; }
182 if (debug) fwrite(buffer, 1, client->afc_packet->this_length, stdout); 182 if (debug) fwrite(buffer, 1, client->afc_packet->this_length, stdout);
183 if (debug) fprintf(stderr, "\n"); 183 if (debug) fprintf(stderr, "\n");
184 bytes = mux_send(client->connection, buffer, client->afc_packet->this_length); 184 bytes = iphone_mux_send(client->connection, buffer, client->afc_packet->this_length);
185 185
186 if (buffer) { 186 if (buffer) {
187 free(buffer); 187 free(buffer);
@@ -210,7 +210,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) {
210 int bytes = 0, recv_len = 0, current_count=0; 210 int bytes = 0, recv_len = 0, current_count=0;
211 int retval = 0; 211 int retval = 0;
212 212
213 bytes = mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4); 213 bytes = iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4);
214 if (bytes <= 0) { 214 if (bytes <= 0) {
215 free(buffer); 215 free(buffer);
216 fprintf(stderr, "Just didn't get enough.\n"); 216 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 buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE); 263 buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE);
264 final_buffer = (char*)malloc(sizeof(char) * recv_len); 264 final_buffer = (char*)malloc(sizeof(char) * recv_len);
265 while(current_count < recv_len){ 265 while(current_count < recv_len){
266 bytes = mux_recv(client->connection, buffer, recv_len-current_count); 266 bytes = iphone_mux_recv(client->connection, buffer, recv_len-current_count);
267 if (debug) fprintf(stderr, "receive_AFC_data: still collecting packets\n"); 267 if (debug) fprintf(stderr, "receive_AFC_data: still collecting packets\n");
268 if (bytes < 0) 268 if (bytes < 0)
269 { 269 {
@@ -603,7 +603,7 @@ int iphone_afc_get_file_attr ( iphone_afc_client_t client, const char *filename,
603 stbuf->st_uid = getuid(); 603 stbuf->st_uid = getuid();
604 stbuf->st_gid = getgid(); 604 stbuf->st_gid = getgid();
605 605
606 afc_close_file(client,file); 606 iphone_afc_close_file(client,file);
607 } 607 }
608} 608}
609 609
diff --git a/src/ifuse.c b/src/ifuse.c
index cc2072f..1c184a2 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -49,8 +49,9 @@ int debug = 0;
49 49
50static int ifuse_getattr(const char *path, struct stat *stbuf) { 50static int ifuse_getattr(const char *path, struct stat *stbuf) {
51 int res = 0; 51 int res = 0;
52 AFCFile *file; 52
53 AFClient *afc = fuse_get_context()->private_data; 53 iphone_afc_client_t afc = fuse_get_context()->private_data;
54 res = iphone_afc_get_file_attr(afc, path, stbuf);
54 55
55 return res; 56 return res;
56} 57}
@@ -59,9 +60,9 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
59 off_t offset, struct fuse_file_info *fi) { 60 off_t offset, struct fuse_file_info *fi) {
60 int i; 61 int i;
61 char **dirs; 62 char **dirs;
62 AFClient *afc = fuse_get_context()->private_data; 63 iphone_afc_client_t afc = fuse_get_context()->private_data;
63 64
64 dirs = afc_get_dir_list(afc, path); 65 dirs = iphone_afc_get_dir_list(afc, path);
65 66
66 if(!dirs) 67 if(!dirs)
67 return -ENOENT; 68 return -ENOENT;
@@ -77,10 +78,10 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
77 78
78static int ifuse_create(const char *path, mode_t mode, struct fuse_file_info *fi) { 79static int ifuse_create(const char *path, mode_t mode, struct fuse_file_info *fi) {
79 // exactly the same as open but using a different mode 80 // exactly the same as open but using a different mode
80 AFCFile *file; 81 iphone_afc_file_t file;
81 AFClient *afc = fuse_get_context()->private_data; 82 iphone_afc_client_t afc = fuse_get_context()->private_data;
82 83
83 file = afc_open_file(afc, path, AFC_FILE_WRITE); 84 iphone_afc_open_file(afc, path, AFC_FILE_WRITE, &file);
84 fh_index++; 85 fh_index++;
85 fi->fh = fh_index; 86 fi->fh = fh_index;
86 g_hash_table_insert(file_handles, &fh_index, file); 87 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} 89}
89 90
90static int ifuse_open(const char *path, struct fuse_file_info *fi) { 91static int ifuse_open(const char *path, struct fuse_file_info *fi) {
91 AFCFile *file; 92 iphone_afc_file_t file;
92 AFClient *afc = fuse_get_context()->private_data; 93 iphone_afc_client_t afc = fuse_get_context()->private_data;
93 uint32 mode = 0; 94 uint32 mode = 0;
94 95
95 if ((fi->flags & 3) == O_RDWR || (fi->flags & 3) == O_WRONLY) { 96 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 mode = AFC_FILE_READ; 101 mode = AFC_FILE_READ;
101 } 102 }
102 103
103 file = afc_open_file(afc, path, mode); 104 iphone_afc_open_file(afc, path, mode, &file);
104 105
105 fh_index++; 106 fh_index++;
106 fi->fh = fh_index; 107 fi->fh = fh_index;
@@ -112,8 +113,8 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi) {
112static int ifuse_read(const char *path, char *buf, size_t size, off_t offset, 113static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
113 struct fuse_file_info *fi) { 114 struct fuse_file_info *fi) {
114 int bytes; 115 int bytes;
115 AFCFile *file; 116 iphone_afc_file_t file;
116 AFClient *afc = fuse_get_context()->private_data; 117 iphone_afc_client_t afc = fuse_get_context()->private_data;
117 118
118 if (size == 0) 119 if (size == 0)
119 return 0; 120 return 0;
@@ -123,23 +124,23 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
123 return -ENOENT; 124 return -ENOENT;
124 } 125 }
125 126
126 bytes = afc_seek_file(afc, file, offset); 127 bytes = iphone_afc_seek_file(afc, file, offset);
127 bytes = afc_read_file(afc, file, buf, size); 128 bytes = iphone_afc_read_file(afc, file, buf, size);
128 return bytes; 129 return bytes;
129} 130}
130 131
131static int ifuse_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { 132static int ifuse_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
132 int bytes = 0; 133 int bytes = 0;
133 AFCFile *file = NULL; 134 iphone_afc_file_t file = NULL;
134 AFClient *afc = fuse_get_context()->private_data; 135 iphone_afc_client_t afc = fuse_get_context()->private_data;
135 136
136 if (size == 0) return 0; 137 if (size == 0) return 0;
137 138
138 file = g_hash_table_lookup(file_handles, &(fi->fh)); 139 file = g_hash_table_lookup(file_handles, &(fi->fh));
139 if (!file) return -ENOENT; 140 if (!file) return -ENOENT;
140 141
141 bytes = afc_seek_file(afc, file, offset); 142 bytes = iphone_afc_seek_file(afc, file, offset);
142 bytes = afc_write_file(afc, file, buf, size); 143 bytes = iphone_afc_write_file(afc, file, buf, size);
143 return bytes; 144 return bytes;
144} 145}
145 146
@@ -148,16 +149,15 @@ static int ifuse_fsync(const char *path, int datasync, struct fuse_file_info *fi
148} 149}
149 150
150static int ifuse_release(const char *path, struct fuse_file_info *fi){ 151static int ifuse_release(const char *path, struct fuse_file_info *fi){
151 AFCFile *file; 152 iphone_afc_file_t file;
152 AFClient *afc = fuse_get_context()->private_data; 153 iphone_afc_client_t afc = fuse_get_context()->private_data;
153 154
154 file = g_hash_table_lookup(file_handles, &(fi->fh)); 155 file = g_hash_table_lookup(file_handles, &(fi->fh));
155 if (!file){ 156 if (!file){
156 return -ENOENT; 157 return -ENOENT;
157 } 158 }
158 afc_close_file(afc, file); 159 iphone_afc_close_file(afc, file);
159 160
160 free(file);
161 g_hash_table_remove(file_handles, &(fi->fh)); 161 g_hash_table_remove(file_handles, &(fi->fh));
162 162
163 return 0; 163 return 0;
@@ -165,49 +165,44 @@ static int ifuse_release(const char *path, struct fuse_file_info *fi){
165 165
166void *ifuse_init(struct fuse_conn_info *conn) { 166void *ifuse_init(struct fuse_conn_info *conn) {
167 int port = 0; 167 int port = 0;
168 AFClient *afc = NULL; 168 iphone_afc_client_t afc = NULL;
169 169
170 conn->async_read = 0; 170 conn->async_read = 0;
171 171
172 file_handles = g_hash_table_new(g_int_hash, g_int_equal); 172 file_handles = g_hash_table_new(g_int_hash, g_int_equal);
173 173
174 phone = get_iPhone(); 174 iphone_get_device(&phone);
175 if (!phone){ 175 if (!phone){
176 fprintf(stderr, "No iPhone found, is it connected?\n"); 176 fprintf(stderr, "No iPhone found, is it connected?\n");
177 return NULL;
178 }
179
180 lockdownd_client *control = new_lockdownd_client(phone);
181 if (!lockdownd_hello(control)) {
182 fprintf(stderr, "Something went wrong in the lockdownd client.\n");
183 return NULL; 177 return NULL;
184 } 178 }
179
185 180
186 if (!lockdownd_init(phone, &control)) { 181 if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) {
187 free_iPhone(phone); 182 iphone_free_device(phone);
188 fprintf(stderr, "Something went wrong in the lockdownd client.\n"); 183 fprintf(stderr, "Something went wrong in the lockdownd client.\n");
189 return NULL; 184 return NULL;
190 } 185 }
191 186
192 port = lockdownd_start_service(control, "com.apple.afc"); 187 port = iphone_lckd_start_service(control, "com.apple.afc");
193 if (!port) { 188 if (!port) {
194 lockdownd_close(control); 189 iphone_lckd_free_client(control);
195 free_iPhone(phone); 190 iphone_free_device(phone);
196 fprintf(stderr, "Something went wrong when starting AFC."); 191 fprintf(stderr, "Something went wrong when starting AFC.");
197 return NULL; 192 return NULL;
198 } 193 }
199 194
200 afc = afc_connect(phone, 3432, port); 195 iphone_afc_new_client(phone, 3432, port, &afc);
201 196
202 return afc; 197 return afc;
203} 198}
204 199
205void ifuse_cleanup(void *data) { 200void ifuse_cleanup(void *data) {
206 AFClient *afc = (AFClient *)data; 201 iphone_afc_client_t afc = (iphone_afc_client_t )data;
207 202
208 afc_disconnect(afc); 203 iphone_afc_free_client(afc);
209 lockdownd_close(control); 204 iphone_lckd_free_client(control);
210 free_iPhone(phone); 205 iphone_free_device(phone);
211} 206}
212 207
213int ifuse_flush(const char *path, struct fuse_file_info *fi) { 208int 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} 210}
216 211
217int ifuse_statfs(const char *path, struct statvfs *stats) { 212int ifuse_statfs(const char *path, struct statvfs *stats) {
218 AFClient *afc = fuse_get_context()->private_data; 213 iphone_afc_client_t afc = fuse_get_context()->private_data;
219 char **info_raw = afc_get_devinfo(afc); 214 char **info_raw = iphone_afc_get_devinfo(afc);
220 uint32 totalspace = 0, freespace = 0, blocksize = 0, i = 0; 215 uint32 totalspace = 0, freespace = 0, blocksize = 0, i = 0;
221 216
222 if (!info_raw) return -ENOENT; 217 if (!info_raw) return -ENOENT;
@@ -243,38 +238,39 @@ int ifuse_statfs(const char *path, struct statvfs *stats) {
243 238
244int ifuse_truncate(const char *path, off_t size) { 239int ifuse_truncate(const char *path, off_t size) {
245 int result = 0; 240 int result = 0;
246 AFClient *afc = fuse_get_context()->private_data; 241 iphone_afc_client_t afc = fuse_get_context()->private_data;
247 AFCFile *tfile = afc_open_file(afc, path, AFC_FILE_READ); 242 iphone_afc_file_t tfile = NULL;
243 iphone_afc_open_file(afc, path, AFC_FILE_READ, &tfile);
248 if (!tfile) return -1; 244 if (!tfile) return -1;
249 245
250 result = afc_truncate_file(afc, tfile, size); 246 result = iphone_afc_truncate_file(afc, tfile, size);
251 afc_close_file(afc, tfile); 247 iphone_afc_close_file(afc, tfile);
252 return result; 248 return result;
253} 249}
254 250
255int ifuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) { 251int ifuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) {
256 AFClient *afc = fuse_get_context()->private_data; 252 iphone_afc_client_t afc = fuse_get_context()->private_data;
257 AFCFile *file = g_hash_table_lookup(file_handles, &fi->fh); 253 iphone_afc_file_t file = g_hash_table_lookup(file_handles, &fi->fh);
258 if (!file) return -ENOENT; 254 if (!file) return -ENOENT;
259 255
260 return afc_truncate_file(afc, file, size); 256 return iphone_afc_truncate_file(afc, file, size);
261} 257}
262 258
263int ifuse_unlink(const char *path) { 259int ifuse_unlink(const char *path) {
264 AFClient *afc = fuse_get_context()->private_data; 260 iphone_afc_client_t afc = fuse_get_context()->private_data;
265 if (afc_delete_file(afc, path)) return 0; 261 if (iphone_afc_delete_file(afc, path)) return 0;
266 else return -1; 262 else return -1;
267} 263}
268 264
269int ifuse_rename(const char *from, const char *to) { 265int ifuse_rename(const char *from, const char *to) {
270 AFClient *afc = fuse_get_context()->private_data; 266 iphone_afc_client_t afc = fuse_get_context()->private_data;
271 if (afc_rename_file(afc, from, to)) return 0; 267 if (iphone_afc_rename_file(afc, from, to)) return 0;
272 else return -1; 268 else return -1;
273} 269}
274 270
275int ifuse_mkdir(const char *dir, mode_t ignored) { 271int ifuse_mkdir(const char *dir, mode_t ignored) {
276 AFClient *afc = fuse_get_context()->private_data; 272 iphone_afc_client_t afc = fuse_get_context()->private_data;
277 if (afc_mkdir(afc, dir)) return 0; 273 if (iphone_afc_mkdir(afc, dir)) return 0;
278 else return -1; 274 else return -1;
279} 275}
280 276
diff --git a/src/iphone.c b/src/iphone.c
index 9027e35..3d179de 100644
--- a/src/iphone.c
+++ b/src/iphone.c
@@ -76,7 +76,7 @@ int iphone_get_device ( iphone_device_t *device ){
76 76
77 // Check to see if we are connected 77 // Check to see if we are connected
78 if (!phone->device || !phone->__device) { 78 if (!phone->device || !phone->__device) {
79 free_iPhone(phone); 79 iphone_free_device(phone);
80 if (debug) fprintf(stderr, "get_iPhone(): iPhone not found\n"); 80 if (debug) fprintf(stderr, "get_iPhone(): iPhone not found\n");
81 return IPHONE_E_NO_DEVICE; 81 return IPHONE_E_NO_DEVICE;
82 } 82 }
@@ -99,7 +99,7 @@ int iphone_get_device ( iphone_device_t *device ){
99 // Check for bad response 99 // Check for bad response
100 if (bytes < 20) { 100 if (bytes < 20) {
101 free(version); 101 free(version);
102 free_iPhone(phone); 102 iphone_free_device(phone);
103 if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n"); 103 if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n");
104 if (debug && bytes < 0) fprintf(stderr, "get_iPhone(): libusb error message %d: %s (%s)\n", 104 if (debug && bytes < 0) fprintf(stderr, "get_iPhone(): libusb error message %d: %s (%s)\n",
105 bytes, usb_strerror(), strerror(-bytes)); 105 bytes, usb_strerror(), strerror(-bytes));
@@ -115,7 +115,7 @@ int iphone_get_device ( iphone_device_t *device ){
115 return IPHONE_E_SUCCESS; 115 return IPHONE_E_SUCCESS;
116 } else { 116 } else {
117 // Bad header 117 // Bad header
118 free_iPhone(phone); 118 iphone_free_device(phone);
119 free(version); 119 free(version);
120 if (debug) fprintf(stderr, "get_iPhone(): Received a bad header/invalid version number."); 120 if (debug) fprintf(stderr, "get_iPhone(): Received a bad header/invalid version number.");
121 return IPHONE_E_BAD_HEADER; 121 return IPHONE_E_BAD_HEADER;
@@ -123,7 +123,7 @@ int iphone_get_device ( iphone_device_t *device ){
123 123
124 // If it got to this point it's gotta be bad 124 // If it got to this point it's gotta be bad
125 if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n"); 125 if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n");
126 free_iPhone(phone); 126 iphone_free_device(phone);
127 free(version); 127 free(version);
128 return IPHONE_E_UNKNOWN_ERROR; // if it got to this point it's gotta be bad 128 return IPHONE_E_UNKNOWN_ERROR; // if it got to this point it's gotta be bad
129} 129}
diff --git a/src/lockdown.c b/src/lockdown.c
index 4950a9e..d30d6e0 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -97,7 +97,7 @@ iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone) {
97void iphone_lckd_free_client( iphone_lckd_client_t client ) { 97void iphone_lckd_free_client( iphone_lckd_client_t client ) {
98 if (!client) return; 98 if (!client) return;
99 if (client->connection) { 99 if (client->connection) {
100 mux_close_connection(client->connection); 100 iphone_mux_free_client(client->connection);
101 } 101 }
102 102
103 if (client->ssl_session) gnutls_deinit(*client->ssl_session); 103 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 char *receive; 118 char *receive;
119 uint32 datalen = 0, bytes = 0; 119 uint32 datalen = 0, bytes = 0;
120 120
121 if (!client->in_SSL) bytes = mux_recv(client->connection, (char *)&datalen, sizeof(datalen)); 121 if (!client->in_SSL) bytes = iphone_mux_recv(client->connection, (char *)&datalen, sizeof(datalen));
122 else bytes = gnutls_record_recv(*client->ssl_session, &datalen, sizeof(datalen)); 122 else bytes = gnutls_record_recv(*client->ssl_session, &datalen, sizeof(datalen));
123 datalen = ntohl(datalen); 123 datalen = ntohl(datalen);
124 124
125 receive = (char*)malloc(sizeof(char) * datalen); 125 receive = (char*)malloc(sizeof(char) * datalen);
126 if (!client->in_SSL) bytes = mux_recv(client->connection, receive, datalen); 126 if (!client->in_SSL) bytes = iphone_mux_recv(client->connection, receive, datalen);
127 else bytes = gnutls_record_recv(*client->ssl_session, receive, datalen); 127 else bytes = gnutls_record_recv(*client->ssl_session, receive, datalen);
128 *dump_data = receive; 128 *dump_data = receive;
129 return bytes; 129 return bytes;
@@ -157,7 +157,7 @@ int iphone_lckd_send ( iphone_lckd_client_t client, char *raw_data, uint32_t len
157 packet = NULL; 157 packet = NULL;
158 } 158 }
159 159
160 if (!client->in_SSL) bytes = mux_send(client->connection, real_query, ntohl(length)+sizeof(length)); 160 if (!client->in_SSL) bytes = iphone_mux_send(client->connection, real_query, ntohl(length)+sizeof(length));
161 else gnutls_record_send(*client->ssl_session, real_query, ntohl(length)+sizeof(length)); 161 else gnutls_record_send(*client->ssl_session, real_query, ntohl(length)+sizeof(length));
162 if (debug) printf("lockdownd_send(): sent it!\n"); 162 if (debug) printf("lockdownd_send(): sent it!\n");
163 free(real_query); 163 free(real_query);
@@ -186,11 +186,11 @@ int lockdownd_hello(iphone_lckd_client_t control) {
186 uint32 length; 186 uint32 length;
187 187
188 xmlDocDumpMemory(plist, (xmlChar **)&XML_content, &length); 188 xmlDocDumpMemory(plist, (xmlChar **)&XML_content, &length);
189 bytes = lockdownd_send(control, XML_content, length); 189 bytes = iphone_lckd_send(control, XML_content, length);
190 190
191 xmlFree(XML_content); 191 xmlFree(XML_content);
192 xmlFreeDoc(plist); plist = NULL; 192 xmlFreeDoc(plist); plist = NULL;
193 bytes = lockdownd_recv(control, &XML_content); 193 bytes = iphone_lckd_recv(control, &XML_content);
194 194
195 plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0); 195 plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0);
196 if (!plist) return 0; 196 if (!plist) return 0;
@@ -240,13 +240,13 @@ int lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, cha
240 xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length); 240 xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length);
241 241
242 /* send to iPhone */ 242 /* send to iPhone */
243 bytes = lockdownd_send(control, XML_content, length); 243 bytes = iphone_lckd_send(control, XML_content, length);
244 244
245 xmlFree(XML_content); 245 xmlFree(XML_content);
246 xmlFreeDoc(plist); plist = NULL; 246 xmlFreeDoc(plist); plist = NULL;
247 247
248 /* Now get iPhone's answer */ 248 /* Now get iPhone's answer */
249 bytes = lockdownd_recv(control, &XML_content); 249 bytes = iphone_lckd_recv(control, &XML_content);
250 250
251 plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0); 251 plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0);
252 if (!plist) return 0; 252 if (!plist) return 0;
@@ -407,13 +407,13 @@ int lockdownd_pair_device(iphone_lckd_client_t control, char *uid, char *host_id
407 printf("XML Pairing request : %s\n",XML_content); 407 printf("XML Pairing request : %s\n",XML_content);
408 408
409 /* send to iPhone */ 409 /* send to iPhone */
410 bytes = lockdownd_send(control, XML_content, length); 410 bytes = iphone_lckd_send(control, XML_content, length);
411 411
412 xmlFree(XML_content); 412 xmlFree(XML_content);
413 xmlFreeDoc(plist); plist = NULL; 413 xmlFreeDoc(plist); plist = NULL;
414 414
415 /* Now get iPhone's answer */ 415 /* Now get iPhone's answer */
416 bytes = lockdownd_recv(control, &XML_content); 416 bytes = iphone_lckd_recv(control, &XML_content);
417 417
418 if (debug) { 418 if (debug) {
419 printf("lockdown_pair_device: iPhone's response to our pair request:\n"); 419 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 } 621 }
622 622
623 xmlDocDumpMemory(plist, (xmlChar **)&what2send, &len); 623 xmlDocDumpMemory(plist, (xmlChar **)&what2send, &len);
624 bytes = lockdownd_send(control, what2send, len); 624 bytes = iphone_lckd_send(control, what2send, len);
625 625
626 xmlFree(what2send); 626 xmlFree(what2send);
627 xmlFreeDoc(plist); 627 xmlFreeDoc(plist);
628 628
629 if (bytes > 0) { 629 if (bytes > 0) {
630 len = lockdownd_recv(control, &what2send); 630 len = iphone_lckd_recv(control, &what2send);
631 plist = xmlReadMemory(what2send, len, NULL, NULL, 0); 631 plist = xmlReadMemory(what2send, len, NULL, NULL, 0);
632 dict = xmlDocGetRootElement(plist); 632 dict = xmlDocGetRootElement(plist);
633 for (dict = dict->children; dict; dict = dict->next) { 633 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 control = (iphone_lckd_client_t)transport; 721 control = (iphone_lckd_client_t)transport;
722 if (debug) printf("lockdownd_secuwrite() called\n"); 722 if (debug) printf("lockdownd_secuwrite() called\n");
723 if (debug) printf("pre-send\nlength = %zi\n", length); 723 if (debug) printf("pre-send\nlength = %zi\n", length);
724 bytes = mux_send(control->connection, buffer, length); 724 bytes = iphone_mux_send(control->connection, buffer, length);
725 if (debug) printf("post-send\nsent %i bytes\n", bytes); 725 if (debug) printf("post-send\nsent %i bytes\n", bytes);
726 if (debug) { 726 if (debug) {
727 FILE *my_ssl_packet = fopen("sslpacketwrite.out", "w+"); 727 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 char *recv_buffer = (char*)malloc(sizeof(char) * (length * 1000)); // ensuring nothing stupid happens 779 char *recv_buffer = (char*)malloc(sizeof(char) * (length * 1000)); // ensuring nothing stupid happens
780 780
781 if (debug) printf("pre-read\nclient wants %zi bytes\n", length); 781 if (debug) printf("pre-read\nclient wants %zi bytes\n", length);
782 bytes = mux_recv(control->connection, recv_buffer, (length * 1000)); 782 bytes = iphone_mux_recv(control->connection, recv_buffer, (length * 1000));
783 if (debug) printf("post-read\nwe got %i bytes\n", bytes); 783 if (debug) printf("post-read\nwe got %i bytes\n", bytes);
784 if (debug && bytes < 0) { 784 if (debug && bytes < 0) {
785 printf("lockdownd_securead(): uh oh\n"); 785 printf("lockdownd_securead(): uh oh\n");
@@ -838,10 +838,10 @@ int iphone_lckd_start_service ( iphone_lckd_client_t client, const char *service
838 838
839 xmlDocDumpMemory(plist, (xmlChar **)&XML_query, &length); 839 xmlDocDumpMemory(plist, (xmlChar **)&XML_query, &length);
840 840
841 lockdownd_send(client, XML_query, length); 841 iphone_lckd_send(client, XML_query, length);
842 free(XML_query); 842 free(XML_query);
843 843
844 length = lockdownd_recv(client, &XML_query); 844 length = iphone_lckd_recv(client, &XML_query);
845 845
846 xmlFreeDoc(plist); 846 xmlFreeDoc(plist);
847 847
diff --git a/src/usbmux.c b/src/usbmux.c
index 48cb963..5e3f441 100644
--- a/src/usbmux.c
+++ b/src/usbmux.c
@@ -176,7 +176,7 @@ void iphone_mux_free_client ( iphone_umux_client_t client ) {
176 176
177 bytes = usb_bulk_write(client->phone->device, BULKOUT, (char*)client->header, sizeof(usbmux_tcp_header), 800); 177 bytes = usb_bulk_write(client->phone->device, BULKOUT, (char*)client->header, sizeof(usbmux_tcp_header), 800);
178 if(debug && bytes < 0) 178 if(debug && bytes < 0)
179 printf("mux_close_connection(): when writing, libusb gave me the error: %s\n", usb_strerror()); 179 printf("iphone_muxèfree_client(): when writing, libusb gave me the error: %s\n", usb_strerror());
180 180
181 bytes = usb_bulk_read(client->phone->device, BULKIN, (char*)client->header, sizeof(usbmux_tcp_header), 800); 181 bytes = usb_bulk_read(client->phone->device, BULKIN, (char*)client->header, sizeof(usbmux_tcp_header), 800);
182 if(debug && bytes < 0) 182 if(debug && bytes < 0)
@@ -332,7 +332,7 @@ int iphone_mux_recv ( iphone_umux_client_t client, char *data, uint32_t datalen
332 // Free our buffer and continue. 332 // Free our buffer and continue.
333 free(buffer); 333 free(buffer);
334 buffer = NULL; 334 buffer = NULL;
335 return mux_recv(client, data, datalen); // recurse back in to try again 335 return iphone_mux_recv(client, data, datalen); // recurse back in to try again
336 } 336 }
337 337
338 // The packet was absolutely meant for us if it hits this point. 338 // The packet was absolutely meant for us if it hits this point.