summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matt Colyer2008-08-14 09:27:21 -0700
committerGravatar Matt Colyer2008-08-14 09:27:21 -0700
commita641dd49bb60355c1abf87949722d0bfa63defff (patch)
tree035b759f9eb74ab04a47f446d03d62ba0222e8db
parent540aaf87f97eb7ff5561046f20a79d70f7a745d3 (diff)
downloadlibimobiledevice-a641dd49bb60355c1abf87949722d0bfa63defff.tar.gz
libimobiledevice-a641dd49bb60355c1abf87949722d0bfa63defff.tar.bz2
Fixed documentation in usbmux.c.
-rw-r--r--src/usbmux.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/usbmux.c b/src/usbmux.c
index d2ef49f..511bb01 100644
--- a/src/usbmux.c
+++ b/src/usbmux.c
@@ -32,6 +32,13 @@ extern int debug;
32static usbmux_connection **connlist = NULL; 32static usbmux_connection **connlist = NULL;
33static int connections = 0; 33static int connections = 0;
34 34
35/** Creates a USBMux packet for the given set of ports.
36 *
37 * @param s_port The source port for the connection.
38 * @param d_port The destination port for the connection.
39 *
40 * @return A USBMux packet
41 */
35usbmux_tcp_header *new_mux_packet(uint16 s_port, uint16 d_port) { 42usbmux_tcp_header *new_mux_packet(uint16 s_port, uint16 d_port) {
36 usbmux_tcp_header *conn = (usbmux_tcp_header*)malloc(sizeof(usbmux_tcp_header)); 43 usbmux_tcp_header *conn = (usbmux_tcp_header*)malloc(sizeof(usbmux_tcp_header));
37 conn->type = htonl(6); 44 conn->type = htonl(6);
@@ -47,6 +54,10 @@ usbmux_tcp_header *new_mux_packet(uint16 s_port, uint16 d_port) {
47 return conn; 54 return conn;
48} 55}
49 56
57/** Creates a USBMux header containing version information
58 *
59 * @return A USBMux header
60 */
50usbmux_version_header *version_header() { 61usbmux_version_header *version_header() {
51 usbmux_version_header *version = (usbmux_version_header*)malloc(sizeof(usbmux_version_header)); 62 usbmux_version_header *version = (usbmux_version_header*)malloc(sizeof(usbmux_version_header));
52 version->type = 0; 63 version->type = 0;
@@ -97,16 +108,14 @@ void add_connection(usbmux_connection *connection) {
97 connections++; 108 connections++;
98} 109}
99 110
100/** This is a higher-level USBMuxTCP-type function. 111/** 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 * 112 *
103 * @param phone The iPhone to initialize a connection on. 113 * @param phone The iPhone to initialize a connection on.
104 * @param s_port The source port 114 * @param s_port The source port
105 * @param d_port The destination port -- 0xf27e for lockdownd. 115 * @param d_port The destination port -- 0xf27e for lockdownd.
116 *
106 * @return A mux TCP header for the connection which is used for tracking and data transfer. 117 * @return A mux TCP header for the connection which is used for tracking and data transfer.
107 *
108 */ 118 */
109
110usbmux_connection *mux_connect(iPhone *phone, uint16 s_port, uint16 d_port) { 119usbmux_connection *mux_connect(iPhone *phone, uint16 s_port, uint16 d_port) {
111 if (!phone || !s_port || !d_port) return NULL; 120 if (!phone || !s_port || !d_port) return NULL;
112 int bytes = 0; 121 int bytes = 0;
@@ -144,14 +153,11 @@ usbmux_connection *mux_connect(iPhone *phone, uint16 s_port, uint16 d_port) {
144 return NULL; 153 return NULL;
145} 154}
146 155
147/** 156/** Cleans up the given USBMux connection.
148 * This is a higher-level USBmuxTCP-type function. 157 * @note Once a connection is closed it may not be used again.
149 * 158 *
150 * @param phone The iPhone to close a connection with.
151 * @param connection The connection to close. 159 * @param connection The connection to close.
152 * @return Doesn't return anything; WILL FREE THE CONNECTION'S MEMORY!!!
153 */ 160 */
154
155void mux_close_connection(usbmux_connection *connection) { 161void mux_close_connection(usbmux_connection *connection) {
156 if (!connection || !connection->phone) return; 162 if (!connection || !connection->phone) return;
157 163
@@ -171,13 +177,12 @@ void mux_close_connection(usbmux_connection *connection) {
171 delete_connection(connection); 177 delete_connection(connection);
172} 178}
173 179
174/* 180/** Sends the given data over the selected connection.
175 * This is a higher-level USBMuxTCP-like function.
176 * 181 *
177 * @param phone The iPhone to send to.
178 * @param connection The connection we're sending data on. 182 * @param connection The connection we're sending data on.
179 * @param data A pointer to the data to send. 183 * @param data A pointer to the data to send.
180 * @param datalen How much data we're sending. 184 * @param datalen How much data we're sending.
185 *
181 * @return The number of bytes sent, minus the header (28), or -1 on error. 186 * @return The number of bytes sent, minus the header (28), or -1 on error.
182 */ 187 */
183int mux_send(usbmux_connection *connection, const char *data, uint32 datalen) { 188int mux_send(usbmux_connection *connection, const char *data, uint32 datalen) {
@@ -231,16 +236,14 @@ int mux_send(usbmux_connection *connection, const char *data, uint32 datalen) {
231 return bytes; // or something 236 return bytes; // or something
232} 237}
233 238
234/** 239/** This is a higher-level USBMuxTCP-like function
235 * This is a higher-level USBMuxTCP-like function
236 * 240 *
237 * @param phone The phone to receive data from.
238 * @param connection The connection to receive data on. 241 * @param connection The connection to receive data on.
239 * @param data Where to put the data we receive. 242 * @param data Where to put the data we receive.
240 * @param datalen How much data to read. 243 * @param datalen How much data to read.
241 * @returns How many bytes were read, or -1 if something bad happens. 244 *
245 * @return How many bytes were read, or -1 if something bad happens.
242 */ 246 */
243
244int mux_recv(usbmux_connection *connection, char *data, uint32 datalen) { 247int mux_recv(usbmux_connection *connection, char *data, uint32 datalen) {
245 /* 248 /*
246 * Order of operation: 249 * Order of operation: