Add PORT env var
This commit is contained in:
parent
a88d28b32a
commit
fd02c7dfa9
4 changed files with 14 additions and 2 deletions
5
main.c
5
main.c
|
@ -68,8 +68,9 @@ void usage(FILE *fp)
|
||||||
"C:\\> nmrpflash.exe -i net0 -f firmware.bin\n"
|
"C:\\> nmrpflash.exe -i net0 -f firmware.bin\n"
|
||||||
#endif
|
#endif
|
||||||
"\n"
|
"\n"
|
||||||
"When using -c, the environment variables IP, NETMASK and MAC are\n"
|
"When using -c, the environment variables IP, PORT, NETMASK\n"
|
||||||
"set to the device IP address, subnet mask and MAC address.\n"
|
"and MAC are set to the device IP address, TFTP port, subnet\n"
|
||||||
|
"mask and MAC address, respectively.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"nmrpflash %s, Copyright (C) 2016 Joseph C. Lehner\n"
|
"nmrpflash %s, Copyright (C) 2016 Joseph C. Lehner\n"
|
||||||
"nmrpflash is free software, licensed under the GNU GPLv3.\n"
|
"nmrpflash is free software, licensed under the GNU GPLv3.\n"
|
||||||
|
|
2
nmrp.c
2
nmrp.c
|
@ -654,8 +654,10 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
if (args->tftpcmd) {
|
if (args->tftpcmd) {
|
||||||
printf("Executing '%s' ... \n", args->tftpcmd);
|
printf("Executing '%s' ... \n", args->tftpcmd);
|
||||||
setenv("IP", inet_ntoa(ipconf.addr), 1);
|
setenv("IP", inet_ntoa(ipconf.addr), 1);
|
||||||
|
setenv("PORT", lltostr(args->port, 10), 1);
|
||||||
setenv("MAC", mac_to_str(rx.eh.ether_shost), 1);
|
setenv("MAC", mac_to_str(rx.eh.ether_shost), 1);
|
||||||
setenv("NETMASK", inet_ntoa(ipconf.mask), 1);
|
setenv("NETMASK", inet_ntoa(ipconf.mask), 1);
|
||||||
|
//setenv("FILENAME", args->file_remote ? args->file_remote : "", 1);
|
||||||
status = system(args->tftpcmd);
|
status = system(args->tftpcmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
nmrpd.h
1
nmrpd.h
|
@ -131,4 +131,5 @@ int ethsock_ip_add(struct ethsock *sock, uint32_t ipaddr, uint32_t ipmask, struc
|
||||||
int ethsock_ip_del(struct ethsock *sock, struct ethsock_ip_undo **undo);
|
int ethsock_ip_del(struct ethsock *sock, struct ethsock_ip_undo **undo);
|
||||||
|
|
||||||
time_t time_monotonic();
|
time_t time_monotonic();
|
||||||
|
char *lltostr(long long ll, int base);
|
||||||
#endif
|
#endif
|
||||||
|
|
8
util.c
8
util.c
|
@ -1,3 +1,4 @@
|
||||||
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "nmrpd.h"
|
#include "nmrpd.h"
|
||||||
|
@ -27,3 +28,10 @@ time_t time_monotonic()
|
||||||
return round(GetTickCount() / 1000.0);
|
return round(GetTickCount() / 1000.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *lltostr(long long ll, int base)
|
||||||
|
{
|
||||||
|
static char buf[32];
|
||||||
|
snprintf(buf, sizeof(buf) - 1, (base == 16 ? "%llx" : (base == 8 ? "%llo" : "%lld")), ll);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue