summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libimobiledevice/lockdown.h19
-rw-r--r--src/lockdown.c37
2 files changed, 47 insertions, 9 deletions
diff --git a/include/libimobiledevice/lockdown.h b/include/libimobiledevice/lockdown.h
index 46792a6..0e48eef 100644
--- a/include/libimobiledevice/lockdown.h
+++ b/include/libimobiledevice/lockdown.h
@@ -295,6 +295,25 @@ lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist);
295 */ 295 */
296lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); 296lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
297 297
298 /**
299 * Pairs the device using the supplied pair record and passing the given options.
300 *
301 * @param client The lockdown client
302 * @param pair_record The pair record to use for pairing. If NULL is passed, then
303 * the pair records from the current machine are used. New records will be
304 * generated automatically when pairing is done for the first time.
305 * @param options The pairing options to pass. Can be NULL for no options.
306 * @param response If non-NULL a pointer to lockdownd's response dictionary is returned.
307 * The caller is responsible to free the response dictionary with plist_free().
308 *
309 * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL,
310 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
311 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
312 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
313 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
314 */
315lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response);
316
298/** 317/**
299 * Validates if the device is paired with the given HostID. If successful the 318 * Validates if the device is paired with the given HostID. If successful the
300 * specified host will become trusted host of the device indicated by the 319 * specified host will become trusted host of the device indicated by the
diff --git a/src/lockdown.c b/src/lockdown.c
index 026d1d1..85124bd 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -848,6 +848,8 @@ leave:
848 * the pair records from the current machine are used. New records will be 848 * the pair records from the current machine are used. New records will be
849 * generated automatically when pairing is done for the first time. 849 * generated automatically when pairing is done for the first time.
850 * @param verb This is either "Pair", "ValidatePair" or "Unpair". 850 * @param verb This is either "Pair", "ValidatePair" or "Unpair".
851 * @param options The pairing options to pass.
852 * @param response If non-NULL a pointer to lockdownd's response dictionary is returned.
851 * 853 *
852 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, 854 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
853 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong, 855 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
@@ -855,7 +857,7 @@ leave:
855 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, 857 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
856 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id 858 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
857 */ 859 */
858static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record, const char *verb) 860static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record, const char *verb, plist_t options, plist_t *result)
859{ 861{
860 if (!client) 862 if (!client)
861 return LOCKDOWN_E_INVALID_ARG; 863 return LOCKDOWN_E_INVALID_ARG;
@@ -915,9 +917,9 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_
915 plist_dict_set_item(dict, "Request", plist_new_string(verb)); 917 plist_dict_set_item(dict, "Request", plist_new_string(verb));
916 plist_dict_set_item(dict, "ProtocolVersion", plist_new_string(LOCKDOWN_PROTOCOL_VERSION)); 918 plist_dict_set_item(dict, "ProtocolVersion", plist_new_string(LOCKDOWN_PROTOCOL_VERSION));
917 919
918 plist_t options = plist_new_dict(); 920 if (options) {
919 plist_dict_set_item(options, "ExtendedPairingErrors", plist_new_bool(1)); 921 plist_dict_set_item(dict, "PairingOptions", plist_copy(options));
920 plist_dict_set_item(dict, "PairingOptions", options); 922 }
921 923
922 /* send to device */ 924 /* send to device */
923 ret = lockdownd_send(client, dict); 925 ret = lockdownd_send(client, dict);
@@ -1010,25 +1012,42 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_
1010 wifi_node = NULL; 1012 wifi_node = NULL;
1011 } 1013 }
1012 1014
1013 plist_free(dict); 1015 if (result) {
1014 dict = NULL; 1016 *result = dict;
1017 } else {
1018 plist_free(dict);
1019 dict = NULL;
1020 }
1015 1021
1016 return ret; 1022 return ret;
1017} 1023}
1018 1024
1019LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 1025LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1020{ 1026{
1021 return lockdownd_do_pair(client, pair_record, "Pair"); 1027
1028 plist_t options = plist_new_dict();
1029 plist_dict_set_item(options, "ExtendedPairingErrors", plist_new_bool(1));
1030
1031 lockdownd_error_t ret = lockdownd_do_pair(client, pair_record, "Pair", options, NULL);
1032
1033 plist_free(options);
1034
1035 return ret;
1036}
1037
1038LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response)
1039{
1040 return lockdownd_do_pair(client, pair_record, "Pair", options, response);
1022} 1041}
1023 1042
1024LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 1043LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1025{ 1044{
1026 return lockdownd_do_pair(client, pair_record, "ValidatePair"); 1045 return lockdownd_do_pair(client, pair_record, "ValidatePair", NULL, NULL);
1027} 1046}
1028 1047
1029LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 1048LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1030{ 1049{
1031 return lockdownd_do_pair(client, pair_record, "Unpair"); 1050 return lockdownd_do_pair(client, pair_record, "Unpair", NULL, NULL);
1032} 1051}
1033 1052
1034LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client) 1053LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)