diff options
Diffstat (limited to 'src/lockdown.c')
| -rw-r--r-- | src/lockdown.c | 35 |
1 files changed, 30 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) { | |||
| 214 | free_dictionary(dictionary); | 214 | free_dictionary(dictionary); |
| 215 | return 0; | 215 | return 0; |
| 216 | } | 216 | } |
| 217 | /** Askes for the device's public key. Part of the lockdownd handshake. | 217 | |
| 218 | /** Generic function to handle simple (key, value) requests. | ||
| 218 | * | 219 | * |
| 219 | * @note You most likely want lockdownd_init unless you are doing something special. | 220 | * @param control an initialized lockdownd client. |
| 221 | * @param key the key to request | ||
| 222 | * @param value a pointer to the requested value | ||
| 220 | * | 223 | * |
| 221 | * @return 1 on success and 0 on failure. | 224 | * @return 1 on success and 0 on failure. |
| 222 | */ | 225 | */ |
| 223 | int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key) | 226 | int lockdownd_generic_get_value(lockdownd_client *control, char *req_key, char **value) |
| 224 | { | 227 | { |
| 225 | xmlDocPtr plist = new_plist(); | 228 | xmlDocPtr plist = new_plist(); |
| 226 | xmlNode *dict = NULL; | 229 | xmlNode *dict = NULL; |
| @@ -232,7 +235,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key | |||
| 232 | 235 | ||
| 233 | /* Setup DevicePublicKey request plist */ | 236 | /* Setup DevicePublicKey request plist */ |
| 234 | dict = add_child_to_plist(plist, "dict", "\n", NULL, 0); | 237 | dict = add_child_to_plist(plist, "dict", "\n", NULL, 0); |
| 235 | key = add_key_str_dict_element(plist, dict, "Key", "DevicePublicKey", 1); | 238 | key = add_key_str_dict_element(plist, dict, "Key", req_key, 1); |
| 236 | key = add_key_str_dict_element(plist, dict, "Request", "GetValue", 1); | 239 | key = add_key_str_dict_element(plist, dict, "Request", "GetValue", 1); |
| 237 | xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length); | 240 | xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length); |
| 238 | 241 | ||
| @@ -264,7 +267,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key | |||
| 264 | success = 1; | 267 | success = 1; |
| 265 | } | 268 | } |
| 266 | if (!strcmp(dictionary[i], "Value")) { | 269 | if (!strcmp(dictionary[i], "Value")) { |
| 267 | *public_key = strdup(dictionary[i+1]); | 270 | *value = strdup(dictionary[i+1]); |
| 268 | } | 271 | } |
| 269 | } | 272 | } |
| 270 | 273 | ||
| @@ -275,6 +278,28 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key | |||
| 275 | return success; | 278 | return success; |
| 276 | } | 279 | } |
| 277 | 280 | ||
| 281 | /** Askes for the device's unique id. Part of the lockdownd handshake. | ||
| 282 | * | ||
| 283 | * @note You most likely want lockdownd_init unless you are doing something special. | ||
| 284 | * | ||
| 285 | * @return 1 on success and 0 on failure. | ||
| 286 | */ | ||
| 287 | int lockdownd_get_device_uid(lockdownd_client *control, char **uid) | ||
| 288 | { | ||
| 289 | return lockdownd_generic_get_value(control, "UniqueDeviceID", uid); | ||
| 290 | } | ||
| 291 | |||
| 292 | /** Askes for the device's public key. Part of the lockdownd handshake. | ||
| 293 | * | ||
| 294 | * @note You most likely want lockdownd_init unless you are doing something special. | ||
| 295 | * | ||
| 296 | * @return 1 on success and 0 on failure. | ||
| 297 | */ | ||
| 298 | int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key) | ||
| 299 | { | ||
| 300 | return lockdownd_generic_get_value(control, "DevicePublicKey", public_key); | ||
| 301 | } | ||
| 302 | |||
| 278 | /** Completes the entire lockdownd handshake. | 303 | /** Completes the entire lockdownd handshake. |
| 279 | * | 304 | * |
| 280 | * @param phone The iPhone | 305 | * @param phone The iPhone |
