Show default values of some command-line options
This commit is contained in:
parent
4506659b69
commit
4fa516602c
3 changed files with 30 additions and 23 deletions
29
main.c
29
main.c
|
@ -23,27 +23,24 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "nmrpd.h"
|
#include "nmrpd.h"
|
||||||
|
|
||||||
#define NMRP_UL_TIMEOUT_S 30 * 60
|
|
||||||
#define NMRP_RX_TIMEOUT_MS 10000
|
|
||||||
|
|
||||||
void usage(FILE *fp)
|
void usage(FILE *fp)
|
||||||
{
|
{
|
||||||
fprintf(fp,
|
fprintf(fp,
|
||||||
"Usage: nmrpflash [OPTIONS...]\n"
|
"Usage: nmrpflash [OPTIONS...]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options (-i, and -f or -c are mandatory):\n"
|
"Options (-i, and -f or -c are mandatory):\n"
|
||||||
" -a <ipaddr> IP address to assign to target device\n"
|
" -a <ipaddr> IP address to assign to target device [%s]\n"
|
||||||
" -A <ipaddr> IP address to assign to selected interface\n"
|
" -A <ipaddr> IP address to assign to selected interface [%s]\n"
|
||||||
" -B Blind mode (don't wait for response packets)\n"
|
" -B Blind mode (don't wait for response packets)\n"
|
||||||
" -c <command> Command to run before (or instead of) TFTP upload\n"
|
" -c <command> Command to run before (or instead of) TFTP upload\n"
|
||||||
" -f <firmware> Firmware file\n"
|
" -f <firmware> Firmware file\n"
|
||||||
" -F <filename> Remote filename to use during TFTP upload\n"
|
" -F <filename> Remote filename to use during TFTP upload\n"
|
||||||
" -i <interface> Network interface directly connected to device\n"
|
" -i <interface> Network interface directly connected to device\n"
|
||||||
" -m <mac> MAC address of target device (xx:xx:xx:xx:xx:xx)\n"
|
" -m <mac> MAC address of target device (xx:xx:xx:xx:xx:xx)\n"
|
||||||
" -M <netmask> Subnet mask to assign to target device\n"
|
" -M <netmask> Subnet mask to assign to target device [%s]\n"
|
||||||
" -t <timeout> Timeout (in milliseconds) for NMRP packets\n"
|
" -t <timeout> Timeout (in milliseconds) for NMRP packets [%d ms]\n"
|
||||||
" -T <timeout> Time (seconds) to wait after successfull TFTP upload\n"
|
" -T <timeout> Time (seconds) to wait after successfull TFTP upload [%d s]\n"
|
||||||
" -p <port> Port to use for TFTP upload\n"
|
" -p <port> Port to use for TFTP upload [%d]\n"
|
||||||
#ifdef NMRPFLASH_SET_REGION
|
#ifdef NMRPFLASH_SET_REGION
|
||||||
" -R <region> Set device region (NA, WW, GR, PR, RU, BZ, IN, KO, JP)\n"
|
" -R <region> Set device region (NA, WW, GR, PR, RU, BZ, IN, KO, JP)\n"
|
||||||
#endif
|
#endif
|
||||||
|
@ -77,6 +74,12 @@ void usage(FILE *fp)
|
||||||
"nmrpflash is free software, licensed under the GNU GPLv3.\n"
|
"nmrpflash is free software, licensed under the GNU GPLv3.\n"
|
||||||
"Source code at https://github.com/jclehner/nmrpflash\n"
|
"Source code at https://github.com/jclehner/nmrpflash\n"
|
||||||
"\n",
|
"\n",
|
||||||
|
NMRP_DEFAULT_IP_REMOTE,
|
||||||
|
NMRP_DEFAULT_IP_LOCAL,
|
||||||
|
NMRP_DEFAULT_SUBNET,
|
||||||
|
NMRP_DEFAULT_RX_TIMEOUT_MS,
|
||||||
|
NMRP_DEFAULT_UL_TIMEOUT_S,
|
||||||
|
NMRP_DEFAULT_TFTP_PORT,
|
||||||
NMRPFLASH_VERSION
|
NMRPFLASH_VERSION
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -135,18 +138,18 @@ int main(int argc, char **argv)
|
||||||
int c, val, max;
|
int c, val, max;
|
||||||
bool list = false, have_dest_mac = false;
|
bool list = false, have_dest_mac = false;
|
||||||
struct nmrpd_args args = {
|
struct nmrpd_args args = {
|
||||||
.rx_timeout = (NMRP_RX_TIMEOUT_MS),
|
.rx_timeout = NMRP_DEFAULT_RX_TIMEOUT_MS,
|
||||||
.ul_timeout = (NMRP_UL_TIMEOUT_S) * 1000,
|
.ul_timeout = NMRP_DEFAULT_UL_TIMEOUT_S * 1000,
|
||||||
.tftpcmd = NULL,
|
.tftpcmd = NULL,
|
||||||
.file_local = NULL,
|
.file_local = NULL,
|
||||||
.file_remote = NULL,
|
.file_remote = NULL,
|
||||||
.ipaddr_intf = NULL,
|
.ipaddr_intf = NULL,
|
||||||
.ipaddr = NULL,
|
.ipaddr = NULL,
|
||||||
.ipmask = "255.255.255.0",
|
.ipmask = NMRP_DEFAULT_SUBNET,
|
||||||
.intf = NULL,
|
.intf = NULL,
|
||||||
.mac = "ff:ff:ff:ff:ff:ff",
|
.mac = "ff:ff:ff:ff:ff:ff",
|
||||||
.op = NMRP_UPLOAD_FW,
|
.op = NMRP_UPLOAD_FW,
|
||||||
.port = 69,
|
.port = NMRP_DEFAULT_TFTP_PORT,
|
||||||
.region = NULL,
|
.region = NULL,
|
||||||
.blind = false,
|
.blind = false,
|
||||||
.offset = 0,
|
.offset = 0,
|
||||||
|
|
12
nmrp.c
12
nmrp.c
|
@ -386,18 +386,10 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
|
|
||||||
if (!args->ipaddr) {
|
if (!args->ipaddr) {
|
||||||
autoip = true;
|
autoip = true;
|
||||||
/* A random IP address. The MAC of the first device that was
|
args->ipaddr = NMRP_DEFAULT_IP_REMOTE;
|
||||||
* used to test this utility starts with a4:2b:8c, so we use
|
|
||||||
* 164 (0xa4) and 183 (0x2b + 0x8c).
|
|
||||||
*
|
|
||||||
* These addresses should not cause collisions on most networks,
|
|
||||||
* and if they do, the user is probably "poweruser" enough to
|
|
||||||
* be able to use the -a and -A options.
|
|
||||||
*/
|
|
||||||
args->ipaddr = "10.164.183.252";
|
|
||||||
|
|
||||||
if (!args->ipaddr_intf) {
|
if (!args->ipaddr_intf) {
|
||||||
args->ipaddr_intf = "10.164.183.253";
|
args->ipaddr_intf = NMRP_DEFAULT_IP_LOCAL;
|
||||||
}
|
}
|
||||||
} else if (args->ipaddr_intf) {
|
} else if (args->ipaddr_intf) {
|
||||||
autoip = true;
|
autoip = true;
|
||||||
|
|
12
nmrpd.h
12
nmrpd.h
|
@ -72,6 +72,18 @@
|
||||||
|
|
||||||
#define NMRPFLASH_SET_REGION
|
#define NMRPFLASH_SET_REGION
|
||||||
|
|
||||||
|
#define NMRP_DEFAULT_UL_TIMEOUT_S (30 * 60)
|
||||||
|
#define NMRP_DEFAULT_RX_TIMEOUT_MS (10000)
|
||||||
|
/*
|
||||||
|
* These addresses should not cause collisions on most networks,
|
||||||
|
* and if they do, the user is probably "poweruser" enough to
|
||||||
|
* be able to use the -a and -A options.
|
||||||
|
*/
|
||||||
|
#define NMRP_DEFAULT_IP_LOCAL "10.164.183.252"
|
||||||
|
#define NMRP_DEFAULT_IP_REMOTE "10.164.183.253"
|
||||||
|
#define NMRP_DEFAULT_SUBNET "255.255.255.0"
|
||||||
|
#define NMRP_DEFAULT_TFTP_PORT 69
|
||||||
|
|
||||||
struct eth_hdr {
|
struct eth_hdr {
|
||||||
uint8_t ether_dhost[6];
|
uint8_t ether_dhost[6];
|
||||||
uint8_t ether_shost[6];
|
uint8_t ether_shost[6];
|
||||||
|
|
Loading…
Add table
Reference in a new issue