The vendor info in the safeloader header for some images (e.g. Archer
C60 v3) starts with "fw-type:Cloud" instead of a big endian data length.
Only detection is implemented at this moment, as the full header format
is not yet understood.
Signed-off-by: Sander Vanheule <sander@svanheule.net>
* UINT32 size, followed by that number of bytes containing (text) data.
* Padded with 0xFF. Payload starts at offset 0x1014.
*
* UINT32 size, followed by that number of bytes containing (text) data.
* Padded with 0xFF. Payload starts at offset 0x1014.
*
+ * SAFELOADER_TYPE_CLOUD
+ * Standard preamble with size including preamble length, and checksum.
+ * Followed by the 'fw-type:Cloud' string and some (unknown) data.
+ * Payload starts at offset 0x1014.
+ *
* SAFELOADER_TYPE_QNEW
* Reversed order preamble, with (apparent) md5 checksum before the image
* size. The size does not include the preamble length.
* SAFELOADER_TYPE_QNEW
* Reversed order preamble, with (apparent) md5 checksum before the image
* size. The size does not include the preamble length.
enum safeloader_image_type {
SAFELOADER_TYPE_DEFAULT,
SAFELOADER_TYPE_VENDOR,
enum safeloader_image_type {
SAFELOADER_TYPE_DEFAULT,
SAFELOADER_TYPE_VENDOR,
static void safeloader_parse_image(FILE *input_file, struct safeloader_image_info *image)
{
static void safeloader_parse_image(FILE *input_file, struct safeloader_image_info *image)
{
+ static const char *HEADER_ID_CLOUD = "fw-type:Cloud";
static const char *HEADER_ID_QNEW = "?NEW";
char buf[64];
static const char *HEADER_ID_QNEW = "?NEW";
char buf[64];
if (memcmp(HEADER_ID_QNEW, &buf[0], strlen(HEADER_ID_QNEW)) == 0)
image->type = SAFELOADER_TYPE_QNEW;
if (memcmp(HEADER_ID_QNEW, &buf[0], strlen(HEADER_ID_QNEW)) == 0)
image->type = SAFELOADER_TYPE_QNEW;
+ else if (memcmp(HEADER_ID_CLOUD, &buf[0], strlen(HEADER_ID_CLOUD)) == 0)
+ image->type = SAFELOADER_TYPE_CLOUD;
else if (ntohl(*((uint32_t *) &buf[0])) <= SAFELOADER_HEADER_SIZE)
image->type = SAFELOADER_TYPE_VENDOR;
else
else if (ntohl(*((uint32_t *) &buf[0])) <= SAFELOADER_HEADER_SIZE)
image->type = SAFELOADER_TYPE_VENDOR;
else
switch (image->type) {
case SAFELOADER_TYPE_DEFAULT:
case SAFELOADER_TYPE_VENDOR:
switch (image->type) {
case SAFELOADER_TYPE_DEFAULT:
case SAFELOADER_TYPE_VENDOR:
+ case SAFELOADER_TYPE_CLOUD:
image->payload_offset = SAFELOADER_PAYLOAD_OFFSET;
break;
case SAFELOADER_TYPE_QNEW:
image->payload_offset = SAFELOADER_PAYLOAD_OFFSET;
break;
case SAFELOADER_TYPE_QNEW: