" -T <timeout> Time (seconds) to wait after successfull TFTP upload\n"
" -p <port> Port to use for TFTP upload\n"
#ifdef NMRPFLASH_SET_REGION
- " -R <region> Set device region\n"
+ " -R <region> Set device region (NA, WW, GR, PR, RU, BZ, IN, KO, JP)\n"
#endif
#ifdef NMRPFLASH_TFTP_TEST
" -U Test TFTP upload\n"
.mac = "ff:ff:ff:ff:ff:ff",
.op = NMRP_UPLOAD_FW,
.port = 69,
- .force_root = 1
+ .region = NULL,
};
#ifdef NMRPFLASH_WINDOWS
WSADATA wsa;
case 'M':
args.ipmask = optarg;
break;
- case 'p':
#ifdef NMRPFLASH_SET_REGION
case 'R':
+ args.region = optarg;
+ break;
#endif
+ case 'p':
case 'T':
case 't':
if (c == 'p') {
max = 0xffff;
- } else if (c == 'R') {
- max = 0x0009;
}
val = atoi(optarg);
args.rx_timeout = val;
} else if (c == 'T') {
args.ul_timeout = val * 1000;
- } else if (c == 'R') {
- args.region = val;
}
break;
#undef CASE_CODE
}
+static uint16_t to_region_code(const char *region)
+{
+#define REGION_CODE(r, c) if (!strcasecmp(region, r)) return c
+ REGION_CODE("NA", 0x0001);
+ REGION_CODE("WW", 0x0002);
+ REGION_CODE("GR", 0x0003);
+ REGION_CODE("PR", 0x0004);
+ REGION_CODE("RU", 0x0005);
+ REGION_CODE("BZ", 0x0006);
+ REGION_CODE("IN", 0x0007);
+ REGION_CODE("KO", 0x0008);
+ REGION_CODE("JP", 0x0009);
+#undef REGION_CODE
+ return 0;
+}
+
static void msg_dump(struct nmrp_msg *msg, int dump_opts)
{
struct nmrp_opt *opt;
}
}
+ if (args->region) {
+ region = htons(to_region_code(args->region));
+ if (!region) {
+ fprintf(stderr, "Invalid region code '%s'.\n", args->region);
+ return 1;
+ }
+ } else {
+ region = 0;
+ }
+
status = 1;
sock = ethsock_create(args->intf, ETH_P_NMRP);
msg_opt_add(&tx.msg, NMRP_O_FW_UP, NULL, 0);
#ifdef NMRPFLASH_SET_REGION
- if (args->region) {
- region = htons(args->region);
+ if (region) {
msg_opt_add(&tx.msg, NMRP_O_DEV_REGION, ®ion, 2);
}
#endif