summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-08-21 21:34:59 +0200
committerGravatar Jonathan Beck2008-08-21 21:34:59 +0200
commit6b706ced7bea4223cce3b83f25268130226a9756 (patch)
tree3ffbeaafaa6f120ab138709df5bd0c4b998d005f /src
parentbb496ff039679ad44d2a9dbfb4224b2fcd54c7e2 (diff)
downloadlibimobiledevice-6b706ced7bea4223cce3b83f25268130226a9756.tar.gz
libimobiledevice-6b706ced7bea4223cce3b83f25268130226a9756.tar.bz2
add get_device_uid function
Conflicts:
Diffstat (limited to 'src')
-rw-r--r--src/lockdown.c35
-rw-r--r--src/lockdown.h1
-rw-r--r--src/main.c6
3 files changed, 37 insertions, 5 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index def62ea..6ba7e18 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -214,13 +214,16 @@ int lockdownd_hello(lockdownd_client *control) {
free_dictionary(dictionary);
return 0;
}
-/** Askes for the device's public key. Part of the lockdownd handshake.
+
+/** Generic function to handle simple (key, value) requests.
*
- * @note You most likely want lockdownd_init unless you are doing something special.
+ * @param control an initialized lockdownd client.
+ * @param key the key to request
+ * @param value a pointer to the requested value
*
* @return 1 on success and 0 on failure.
*/
-int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key)
+int lockdownd_generic_get_value(lockdownd_client *control, char *req_key, char **value)
{
xmlDocPtr plist = new_plist();
xmlNode *dict = NULL;
@@ -232,7 +235,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
/* Setup DevicePublicKey request plist */
dict = add_child_to_plist(plist, "dict", "\n", NULL, 0);
- key = add_key_str_dict_element(plist, dict, "Key", "DevicePublicKey", 1);
+ key = add_key_str_dict_element(plist, dict, "Key", req_key, 1);
key = add_key_str_dict_element(plist, dict, "Request", "GetValue", 1);
xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length);
@@ -264,7 +267,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
success = 1;
}
if (!strcmp(dictionary[i], "Value")) {
- *public_key = strdup(dictionary[i+1]);
+ *value = strdup(dictionary[i+1]);
}
}
@@ -275,6 +278,28 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
return success;
}
+/** Askes for the device's unique id. Part of the lockdownd handshake.
+ *
+ * @note You most likely want lockdownd_init unless you are doing something special.
+ *
+ * @return 1 on success and 0 on failure.
+ */
+int lockdownd_get_device_uid(lockdownd_client *control, char **uid)
+{
+ return lockdownd_generic_get_value(control, "UniqueDeviceID", uid);
+}
+
+/** Askes for the device's public key. Part of the lockdownd handshake.
+ *
+ * @note You most likely want lockdownd_init unless you are doing something special.
+ *
+ * @return 1 on success and 0 on failure.
+ */
+int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key)
+{
+ return lockdownd_generic_get_value(control, "DevicePublicKey", public_key);
+}
+
/** Completes the entire lockdownd handshake.
*
* @param phone The iPhone
diff --git a/src/lockdown.h b/src/lockdown.h
index 6b27900..df70bbd 100644
--- a/src/lockdown.h
+++ b/src/lockdown.h
@@ -41,6 +41,7 @@ char *lockdownd_generate_hostid();
lockdownd_client *new_lockdownd_client(iPhone *phone);
int lockdownd_hello(lockdownd_client *control);
+int lockdownd_get_device_uid(lockdownd_client *control, char **uid);
int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key);
int lockdownd_gen_pair_cert(char *public_key_b64, char **device_cert_b64, char **host_cert_b64, char **root_cert_b64);
int lockdownd_pair_device(lockdownd_client *control, char *public_key, char *host_id);
diff --git a/src/main.c b/src/main.c
index 42600c3..78c62f7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -57,6 +57,12 @@ int main(int argc, char *argv[]) {
return -1;
}
+ char *uid = NULL;
+ if (lockdownd_get_device_uid(control, &uid)) {
+ printf("DeviceUniqueID : %s\n", uid);
+ free(uid);
+ }
+
port = lockdownd_start_service(control, "com.apple.afc");
if (port) {