summaryrefslogtreecommitdiffstats
path: root/src/usbmux.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usbmux.c')
-rw-r--r--src/usbmux.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/usbmux.c b/src/usbmux.c
index c5b7535..235a1f2 100644
--- a/src/usbmux.c
+++ b/src/usbmux.c
@@ -60,12 +60,11 @@ usbmux_version_header *version_header() {
60 60
61// Maintenance functions. 61// Maintenance functions.
62 62
63/* delete_connection(connection) 63/** Removes a connection from the list of connections made.
64 * connection: the connection to delete from the tracking list.
65 * Removes a connection from the list of connections made.
66 * The list of connections is necessary for buffering. 64 * The list of connections is necessary for buffering.
65 *
66 * @param connection The connection to delete from the tracking list.
67 */ 67 */
68
69void delete_connection(usbmux_connection *connection) { 68void delete_connection(usbmux_connection *connection) {
70 usbmux_connection **newlist = (usbmux_connection**)malloc(sizeof(usbmux_connection*) * (connections - 1)); 69 usbmux_connection **newlist = (usbmux_connection**)malloc(sizeof(usbmux_connection*) * (connections - 1));
71 int i = 0, j = 0; 70 int i = 0, j = 0;
@@ -85,10 +84,10 @@ void delete_connection(usbmux_connection *connection) {
85 free(connection); 84 free(connection);
86} 85}
87 86
88/* add_connection(connection) 87/** Adds a connection to the list of connections made.
89 * connection: the connection to add to the global list of connections.
90 * Adds a connection to the list of connections made.
91 * The connection list is necessary for buffering. 88 * The connection list is necessary for buffering.
89 *
90 * @param connection The connection to add to the global list of connections.
92 */ 91 */
93 92
94void add_connection(usbmux_connection *connection) { 93void add_connection(usbmux_connection *connection) {
@@ -98,14 +97,14 @@ void add_connection(usbmux_connection *connection) {
98 connections++; 97 connections++;
99} 98}
100 99
101/* mux_connect(phone, s_port, d_port) 100/** This is a higher-level USBMuxTCP-type function.
102 * This is a higher-level USBMuxTCP-type function.
103 * phone: the iPhone to initialize a connection on.
104 * s_port: the source port
105 * d_port: the destination port -- 0xf27e for lockdownd.
106 * Initializes a connection on phone, with source port s_port and destination port d_port 101 * Initializes a connection on phone, with source port s_port and destination port d_port
102 *
103 * @param phone The iPhone to initialize a connection on.
104 * @param s_port The source port
105 * @param d_port The destination port -- 0xf27e for lockdownd.
106 * @return A mux TCP header for the connection which is used for tracking and data transfer.
107 * 107 *
108 * Returns a mux TCP header for the connection which is used for tracking and data transfer.
109 */ 108 */
110 109
111usbmux_connection *mux_connect(iPhone *phone, uint16 s_port, uint16 d_port) { 110usbmux_connection *mux_connect(iPhone *phone, uint16 s_port, uint16 d_port) {
@@ -146,12 +145,12 @@ usbmux_connection *mux_connect(iPhone *phone, uint16 s_port, uint16 d_port) {
146 return NULL; 145 return NULL;
147} 146}
148 147
149/* mux_close_connection(phone, connection) 148/**
150 * This is a higher-level USBmuxTCP-type function. 149 * This is a higher-level USBmuxTCP-type function.
151 * phone: the iPhone to close a connection with.
152 * connection: the connection to close.
153 * 150 *
154 * Doesn't return anything; WILL FREE THE CONNECTION'S MEMORY!!! 151 * @param phone The iPhone to close a connection with.
152 * @param connection The connection to close.
153 * @return Doesn't return anything; WILL FREE THE CONNECTION'S MEMORY!!!
155 */ 154 */
156 155
157void mux_close_connection(usbmux_connection *connection) { 156void mux_close_connection(usbmux_connection *connection) {
@@ -173,14 +172,14 @@ void mux_close_connection(usbmux_connection *connection) {
173 delete_connection(connection); 172 delete_connection(connection);
174} 173}
175 174
176/* mux_send(phone, connection, data, datalen) 175/*
177 * This is a higher-level USBMuxTCP-like function. 176 * This is a higher-level USBMuxTCP-like function.
178 * phone: the iPhone to send to.
179 * connection: the connection we're sending data on.
180 * data: a pointer to the data to send.
181 * datalen: how much data we're sending.
182 * 177 *
183 * Returns number of bytes sent, minus the header (28), or -1 on error. 178 * @param phone The iPhone to send to.
179 * @param connection The connection we're sending data on.
180 * @param data A pointer to the data to send.
181 * @param datalen How much data we're sending.
182 * @return The number of bytes sent, minus the header (28), or -1 on error.
184 */ 183 */
185int mux_send(usbmux_connection *connection, const char *data, uint32 datalen) { 184int mux_send(usbmux_connection *connection, const char *data, uint32 datalen) {
186 if (!connection->phone || !connection || !data || datalen == 0) return -1; 185 if (!connection->phone || !connection || !data || datalen == 0) return -1;
@@ -233,14 +232,14 @@ int mux_send(usbmux_connection *connection, const char *data, uint32 datalen) {
233 return bytes; // or something 232 return bytes; // or something
234} 233}
235 234
236/* mux_recv(phone, connection, data, datalen) 235/**
237 * This is a higher-level USBMuxTCP-like function 236 * This is a higher-level USBMuxTCP-like function
238 * phone: the phone to receive data from. 237 *
239 * connection: the connection to receive data on. 238 * @param phone The phone to receive data from.
240 * data: where to put the data we receive. 239 * @param connection The connection to receive data on.
241 * datalen: how much data to read. 240 * @param data Where to put the data we receive.
242 * 241 * @param datalen How much data to read.
243 * Returns: how many bytes were read, or -1 if something bad happens. 242 * @returns How many bytes were read, or -1 if something bad happens.
244 */ 243 */
245 244
246int mux_recv(usbmux_connection *connection, char *data, uint32 datalen) { 245int mux_recv(usbmux_connection *connection, char *data, uint32 datalen) {