Don't continue in blind mode if remote does respond
This commit is contained in:
parent
5cc29f6935
commit
5d189c61b2
1 changed files with 5 additions and 8 deletions
13
nmrp.c
13
nmrp.c
|
@ -357,7 +357,7 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
uint16_t region;
|
uint16_t region;
|
||||||
char *filename;
|
char *filename;
|
||||||
time_t beg;
|
time_t beg;
|
||||||
int i, timeout, status, ulreqs, expect, upload_ok, autoip, ka_reqs, fake;
|
int i, timeout, status, ulreqs, expect, upload_ok, autoip, ka_reqs;
|
||||||
ssize_t bytes;
|
ssize_t bytes;
|
||||||
struct ethsock *sock;
|
struct ethsock *sock;
|
||||||
struct ethsock_ip_undo *ip_undo = NULL;
|
struct ethsock_ip_undo *ip_undo = NULL;
|
||||||
|
@ -509,7 +509,6 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
upload_ok = 0;
|
upload_ok = 0;
|
||||||
fake = 0;
|
|
||||||
timeout = args->blind ? 10 : NMRP_ADVERTISE_TIMEOUT;
|
timeout = args->blind ? 10 : NMRP_ADVERTISE_TIMEOUT;
|
||||||
beg = time_monotonic();
|
beg = time_monotonic();
|
||||||
|
|
||||||
|
@ -526,6 +525,8 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
status = pkt_recv(sock, &rx);
|
status = pkt_recv(sock, &rx);
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
if (memcmp(rx.eh.ether_dhost, src, 6) == 0) {
|
if (memcmp(rx.eh.ether_dhost, src, 6) == 0) {
|
||||||
|
// don't continue in blind mode if we've received a response
|
||||||
|
args->blind = false;
|
||||||
break;
|
break;
|
||||||
} else if (verbosity) {
|
} else if (verbosity) {
|
||||||
printf("\nIgnoring bogus response: %s -> %s.\n",
|
printf("\nIgnoring bogus response: %s -> %s.\n",
|
||||||
|
@ -547,7 +548,6 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
memcpy(rx.eh.ether_shost, dest, 6);
|
memcpy(rx.eh.ether_shost, dest, 6);
|
||||||
msg_init(&rx.msg, NMRP_C_CONF_REQ);
|
msg_init(&rx.msg, NMRP_C_CONF_REQ);
|
||||||
printf("Continuing blindly.");
|
printf("Continuing blindly.");
|
||||||
fake = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -590,7 +590,7 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
msg_mkconfack(&tx.msg, ipaddr.s_addr, ipmask.s_addr, region);
|
msg_mkconfack(&tx.msg, ipaddr.s_addr, ipmask.s_addr, region);
|
||||||
expect = NMRP_C_TFTP_UL_REQ;
|
expect = NMRP_C_TFTP_UL_REQ;
|
||||||
|
|
||||||
if (!fake) {
|
if (!args->blind) {
|
||||||
printf("Received configuration request from %s.\n",
|
printf("Received configuration request from %s.\n",
|
||||||
mac_to_str(rx.eh.ether_shost));
|
mac_to_str(rx.eh.ether_shost));
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
printf("Received upload request: filename '%s'.\n", filename);
|
printf("Received upload request: filename '%s'.\n", filename);
|
||||||
} else if (!args->file_remote) {
|
} else if (!args->file_remote) {
|
||||||
args->file_remote = leafname(args->file_local);
|
args->file_remote = leafname(args->file_local);
|
||||||
if (!fake) {
|
if (!args->blind) {
|
||||||
printf("Received upload request without filename.\n");
|
printf("Received upload request without filename.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -734,12 +734,9 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
// fake response
|
// fake response
|
||||||
msg_init(&rx.msg, expect);
|
msg_init(&rx.msg, expect);
|
||||||
memcpy(rx.eh.ether_shost, tx.eh.ether_dhost, 6);
|
memcpy(rx.eh.ether_shost, tx.eh.ether_dhost, 6);
|
||||||
fake = 1;
|
|
||||||
} else {
|
} else {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fake = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ethsock_set_timeout(sock, args->rx_timeout);
|
ethsock_set_timeout(sock, args->rx_timeout);
|
||||||
|
|
Loading…
Add table
Reference in a new issue