projects
/
openwrt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rpcd: iwinfo plugin fixes
[openwrt.git]
/
tools
/
firmware-utils
/
src
/
asustrx.c
diff --git
a/tools/firmware-utils/src/asustrx.c
b/tools/firmware-utils/src/asustrx.c
index
20fd1ed
..
67f2680
100644
(file)
--- a/
tools/firmware-utils/src/asustrx.c
+++ b/
tools/firmware-utils/src/asustrx.c
@@
-48,6
+48,7
@@
struct asustrx_tail {
char *in_path = NULL;
char *out_path = NULL;
char *productid = NULL;
char *in_path = NULL;
char *out_path = NULL;
char *productid = NULL;
+uint8_t version[4] = { };
static const uint32_t crc32_tbl[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
static const uint32_t crc32_tbl[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
@@
-119,7
+120,7
@@
static const uint32_t crc32_tbl[] = {
static void parse_options(int argc, char **argv) {
int c;
static void parse_options(int argc, char **argv) {
int c;
- while ((c = getopt(argc, argv, "i:o:p:")) != -1) {
+ while ((c = getopt(argc, argv, "i:o:p:
v:
")) != -1) {
switch (c) {
case 'i':
in_path = optarg;
switch (c) {
case 'i':
in_path = optarg;
@@
-130,6
+131,10
@@
static void parse_options(int argc, char **argv) {
case 'p':
productid = optarg;
break;
case 'p':
productid = optarg;
break;
+ case 'v':
+ if (sscanf(optarg, "%hu.%hu.%hu.%hu", &version[0], &version[1], &version[2], &version[3]) != 4)
+ fprintf(stderr, "Version %s doesn't match suppored 4-digits format\n", optarg);
+ break;
}
}
}
}
}
}
@@
-137,8
+142,9
@@
static void parse_options(int argc, char **argv) {
static void usage() {
printf("Usage:\n");
printf("\t-i file\t\t\t\tinput TRX file\n");
static void usage() {
printf("Usage:\n");
printf("\t-i file\t\t\t\tinput TRX file\n");
- printf("\t-o
offse
t\t\t\toutput Asus TRX file\n");
+ printf("\t-o
file\
t\t\t\toutput Asus TRX file\n");
printf("\t-p productid\t\t\tproduct (device) ID\n");
printf("\t-p productid\t\t\tproduct (device) ID\n");
+ printf("\t-v version\t\t\tfirmware version formatted with 4 digits like: 1.2.3.4\n");
}
int main(int argc, char **argv) {
}
int main(int argc, char **argv) {
@@
-161,6
+167,10
@@
int main(int argc, char **argv) {
}
/* Fill Asus tail */
}
/* Fill Asus tail */
+ tail.version[0] = version[0];
+ tail.version[1] = version[1];
+ tail.version[2] = version[2];
+ tail.version[3] = version[3];
strncpy(tail.productid, productid, sizeof(tail.productid));
/* Open files */
strncpy(tail.productid, productid, sizeof(tail.productid));
/* Open files */
@@
-187,7
+197,7
@@
int main(int argc, char **argv) {
}
for (i = 0; i < bytes; i++) {
if (buf[i]) {
}
for (i = 0; i < bytes; i++) {
if (buf[i]) {
- fprintf(stderr, "Input TRX doesn't have last 64 B empty %s\n");
+ fprintf(stderr, "Input TRX doesn't have last 64 B empty %s\n"
, out_path
);
err = -ENOSPC;
goto err;
}
err = -ENOSPC;
goto err;
}
@@
-207,7
+217,7
@@
int main(int argc, char **argv) {
bytes = sizeof(tail);
fseek(out, -bytes, SEEK_CUR);
if (fwrite(&tail, 1, bytes, out) != bytes) {
bytes = sizeof(tail);
fseek(out, -bytes, SEEK_CUR);
if (fwrite(&tail, 1, bytes, out) != bytes) {
- fprintf(stderr, "Couldn't write %zu B to %s\n", bytes);
+ fprintf(stderr, "Couldn't write %zu B to %s\n", bytes
, out_path
);
err = -EIO;
goto err;
}
err = -EIO;
goto err;
}
@@
-232,7
+242,7
@@
int main(int argc, char **argv) {
hdr.crc32 = cpu_to_le32(crc32);
rewind(out);
if (fwrite(&hdr, 1, bytes, out) != bytes) {
hdr.crc32 = cpu_to_le32(crc32);
rewind(out);
if (fwrite(&hdr, 1, bytes, out) != bytes) {
- fprintf(stderr, "Couldn't write %zu B to %s\n", bytes);
+ fprintf(stderr, "Couldn't write %zu B to %s\n", bytes
, out_path
);
err = -EIO;
goto err;
}
err = -EIO;
goto err;
}