summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/restore.c103
-rw-r--r--src/tss.c67
-rw-r--r--src/tss.h2
3 files changed, 92 insertions, 80 deletions
diff --git a/src/restore.c b/src/restore.c
index c43b7d6..f222d8a 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -1921,6 +1921,7 @@ plist_t restore_get_savage_firmware_data(restored_client_t restore, struct idevi
plist_free(request);
return NULL;
}
+ debug("DEBUG: %s: using %s\n", __func__, comp_name);
info("Sending Savage TSS request...\n");
response = tss_request_send(request, client->tss_url);
@@ -1985,78 +1986,8 @@ plist_t restore_get_yonkers_firmware_data(restored_client_t restore, struct idev
plist_t request = NULL;
plist_t response = NULL;
plist_t node = NULL;
- uint8_t isprod = 1;
- uint64_t fabrevision = (uint64_t)-1;
int ret;
- node = plist_dict_get_item(p_info, "Yonkers,ProductionMode");
- if (node && (plist_get_node_type(node) == PLIST_BOOLEAN)) {
- plist_get_bool_val(node, &isprod);
- }
-
- node = plist_dict_get_item(p_info, "Yonkers,FabRevision");
- if (node && (plist_get_node_type(node) == PLIST_UINT)) {
- plist_get_uint_val(node, &fabrevision);
- }
-
- plist_t manifest_node = plist_dict_get_item(build_identity, "Manifest");
- if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
- error("ERROR: Unable to find manifest node\n");
- return NULL;
- }
- plist_dict_iter iter = NULL;
- plist_dict_new_iter(manifest_node, &iter);
- while (1) {
- plist_dict_next_item(manifest_node, iter, &comp_name, &node);
- if (comp_name == NULL) {
- node = NULL;
- break;
- }
- if (strncmp(comp_name, "Yonkers,", 8) == 0) {
- int target_node = 1;
- plist_t sub_node;
- if ((sub_node = plist_dict_get_item(node, "EPRO")) != NULL && plist_get_node_type(sub_node) == PLIST_BOOLEAN) {
- uint8_t b = 0;
- plist_get_bool_val(sub_node, &b);
- target_node &= ((isprod) ? b : !b);
- }
- if ((sub_node = plist_dict_get_item(node, "FabRevision")) != NULL && plist_get_node_type(sub_node) == PLIST_UINT) {
- uint64_t v = 0;
- plist_get_uint_val(sub_node, &v);
- target_node &= (v == fabrevision);
- }
- if (target_node) {
- comp_node = node;
- break;
- }
- }
- free(comp_name);
- comp_name = NULL;
- }
- free(iter);
- node = NULL;
-
- if (comp_name == NULL) {
- error("ERROR: No Yonkers node for %s/%lu\n", (isprod) ? "Production" : "Development", (unsigned long)fabrevision);
- return NULL;
- }
- debug("DEBUG: %s: using %s\n", __func__, comp_name);
-
- if (build_identity_get_component_path(build_identity, comp_name, &comp_path) < 0) {
- error("ERROR: Unable get path for '%s' component\n", comp_name);
- free(comp_name);
- return NULL;
- }
-
- ret = extract_component(client->ipsw, comp_path, &component_data, &component_size);
- free(comp_path);
- comp_path = NULL;
- if (ret < 0) {
- error("ERROR: Unable to extract '%s' component\n", comp_name);
- free(comp_name);
- return NULL;
- }
-
/* create Yonkers request */
request = tss_request_new(NULL);
if (request == NULL) {
@@ -2075,18 +2006,16 @@ plist_t restore_get_yonkers_firmware_data(restored_client_t restore, struct idev
plist_dict_merge(&parameters, p_info);
/* add required tags for Yonkers TSS request */
- tss_request_add_yonkers_tags(request, parameters, NULL);
+ tss_request_add_yonkers_tags(request, parameters, NULL, &comp_name);
plist_free(parameters);
- if (comp_node != NULL) {
- plist_t comp_dict = plist_copy(comp_node);
- plist_dict_remove_item(comp_dict, "Info");
- plist_dict_set_item(request, comp_name, comp_dict);
+ if (!comp_name) {
+ error("ERROR: Could not determine Yonkers firmware component\n");
+ plist_free(request);
+ return NULL;
}
-
- free(comp_name);
- comp_name = NULL;
+ debug("DEBUG: %s: using %s\n", __func__, comp_name);
info("Sending Yonkers TSS request...\n");
response = tss_request_send(request, client->tss_url);
@@ -2103,6 +2032,24 @@ plist_t restore_get_yonkers_firmware_data(restored_client_t restore, struct idev
error("ERROR: No 'Yonkers,Ticket' in TSS response, this might not work\n");
}
+ if (build_identity_get_component_path(build_identity, comp_name, &comp_path) < 0) {
+ error("ERROR: Unable get path for '%s' component\n", comp_name);
+ free(comp_name);
+ return NULL;
+ }
+
+ /* now get actual component data */
+ ret = extract_component(client->ipsw, comp_path, &component_data, &component_size);
+ free(comp_path);
+ comp_path = NULL;
+ if (ret < 0) {
+ error("ERROR: Unable to extract '%s' component\n", comp_name);
+ free(comp_name);
+ return NULL;
+ }
+ free(comp_name);
+ comp_name = NULL;
+
plist_t firmware_data = plist_new_dict();
plist_dict_set_item(firmware_data, "YonkersFirmware", plist_new_data((char *)component_data, (uint64_t)component_size));
plist_dict_set_item(response, "FirmwareData", firmware_data);
diff --git a/src/tss.c b/src/tss.c
index 80d2935..ca4a7bc 100644
--- a/src/tss.c
+++ b/src/tss.c
@@ -969,7 +969,7 @@ int tss_request_add_savage_tags(plist_t request, plist_t parameters, plist_t ove
return 0;
}
-int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t overrides)
+int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name)
{
plist_t node = NULL;
@@ -1006,6 +1006,71 @@ int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t ov
}
}
+ char *comp_name = NULL;
+ plist_t comp_node = NULL;
+ uint8_t isprod = 1;
+ uint64_t fabrevision = (uint64_t)-1;
+
+ node = plist_dict_get_item(parameters, "Yonkers,ProductionMode");
+ if (node && (plist_get_node_type(node) == PLIST_BOOLEAN)) {
+ plist_get_bool_val(node, &isprod);
+ }
+
+ node = plist_dict_get_item(parameters, "Yonkers,FabRevision");
+ if (node && (plist_get_node_type(node) == PLIST_UINT)) {
+ plist_get_uint_val(node, &fabrevision);
+ }
+
+ plist_dict_iter iter = NULL;
+ plist_dict_new_iter(manifest_node, &iter);
+ while (iter) {
+ node = NULL;
+ comp_name = NULL;
+ plist_dict_next_item(manifest_node, iter, &comp_name, &node);
+ if (comp_name == NULL) {
+ node = NULL;
+ break;
+ }
+ if (strncmp(comp_name, "Yonkers,", 8) == 0) {
+ int target_node = 1;
+ plist_t sub_node;
+ if ((sub_node = plist_dict_get_item(node, "EPRO")) != NULL && plist_get_node_type(sub_node) == PLIST_BOOLEAN) {
+ uint8_t b = 0;
+ plist_get_bool_val(sub_node, &b);
+ target_node &= ((isprod) ? b : !b);
+ }
+ if ((sub_node = plist_dict_get_item(node, "FabRevision")) != NULL && plist_get_node_type(sub_node) == PLIST_UINT) {
+ uint64_t v = 0;
+ plist_get_uint_val(sub_node, &v);
+ target_node &= (v == fabrevision);
+ }
+ if (target_node) {
+ comp_node = node;
+ break;
+ }
+ }
+ free(comp_name);
+ }
+ free(iter);
+
+ if (comp_name == NULL) {
+ error("ERROR: No Yonkers node for %s/%lu\n", (isprod) ? "Production" : "Development", (unsigned long)fabrevision);
+ return -1;
+ }
+
+ /* add Yonkers,SysTopPatch* */
+ if (comp_node != NULL) {
+ plist_t comp_dict = plist_copy(comp_node);
+ plist_dict_remove_item(comp_dict, "Info");
+ plist_dict_set_item(request, comp_name, comp_dict);
+ }
+
+ if (component_name) {
+ *component_name = comp_name;
+ } else {
+ free(comp_name);
+ }
+
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);
diff --git a/src/tss.h b/src/tss.h
index 7911283..7a8c21a 100644
--- a/src/tss.h
+++ b/src/tss.h
@@ -41,7 +41,7 @@ int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrid
int tss_request_add_baseband_tags(plist_t request, plist_t parameters, plist_t overrides);
int tss_request_add_se_tags(plist_t request, plist_t parameters, plist_t overrides);
int tss_request_add_savage_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name);
-int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t overrides);
+int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name);
int tss_request_add_ap_img4_tags(plist_t request, plist_t parameters);
int tss_request_add_ap_img3_tags(plist_t request, plist_t parameters);