mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Simplify using a local pointer
This commit is contained in:
33
targets.cc
33
targets.cc
@@ -499,16 +499,17 @@ static void refresh_hostbatch(HostGroupState *hs, struct addrset *exclude_group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
|
Target *current_target = hs->hostbatch[0];
|
||||||
|
|
||||||
/* If there's a chance we can do ARP ping or may need the MAC address,
|
/* If there's a chance we can do ARP ping or may need the MAC address,
|
||||||
* we'll do the extra check. Some things like VPN claim devt_ethernet
|
* we'll do the extra check. Some things like VPN claim devt_ethernet
|
||||||
* but are not DLT_EN10MB. */
|
* but are not DLT_EN10MB. */
|
||||||
if (hs->hostbatch[0]->ifType() == devt_ethernet &&
|
if (current_target->ifType() == devt_ethernet &&
|
||||||
o.sendpref != PACKET_SEND_IP_STRONG) {
|
o.sendpref != PACKET_SEND_IP_STRONG) {
|
||||||
netutil_eth_t *eth = eth_open_cached(hs->hostbatch[0]->deviceName());
|
netutil_eth_t *eth = eth_open_cached(current_target->deviceName());
|
||||||
if (DLT_EN10MB == netutil_eth_datalink(eth)) {
|
if (DLT_EN10MB == netutil_eth_datalink(eth)) {
|
||||||
// Do ARP/ND if possible
|
// Do ARP/ND if possible
|
||||||
if (hs->hostbatch[0]->directlyConnected() &&
|
if (current_target->directlyConnected() &&
|
||||||
o.implicitARPPing) {
|
o.implicitARPPing) {
|
||||||
arpping(hs->hostbatch, hs->current_batch_sz);
|
arpping(hs->hostbatch, hs->current_batch_sz);
|
||||||
arpping_done = true;
|
arpping_done = true;
|
||||||
@@ -516,13 +517,14 @@ static void refresh_hostbatch(HostGroupState *hs, struct addrset *exclude_group,
|
|||||||
// If we want to do layer-2 sending, we'll need a MAC address.
|
// If we want to do layer-2 sending, we'll need a MAC address.
|
||||||
if ((o.sendpref & PACKET_SEND_ETH)) {
|
if ((o.sendpref & PACKET_SEND_ETH)) {
|
||||||
for (i=0; i < hs->current_batch_sz; i++) {
|
for (i=0; i < hs->current_batch_sz; i++) {
|
||||||
if (!(hs->hostbatch[i]->flags & HOST_DOWN) &&
|
current_target = hs->hostbatch[i];
|
||||||
!hs->hostbatch[i]->timedOut(&now)) {
|
if (!(current_target->flags & HOST_DOWN) &&
|
||||||
if (!setTargetNextHopMAC(hs->hostbatch[i])) {
|
!current_target->timedOut(&now)) {
|
||||||
|
if (!setTargetNextHopMAC(current_target)) {
|
||||||
error("%s: Failed to determine dst MAC address for target %s",
|
error("%s: Failed to determine dst MAC address for target %s",
|
||||||
__func__, hs->hostbatch[i]->NameIP());
|
__func__, current_target->NameIP());
|
||||||
hs->hostbatch[i]->flags = HOST_DOWN;
|
current_target->flags = HOST_DOWN;
|
||||||
hs->hostbatch[i]->reason.reason_id = ER_NOROUTE;
|
current_target->reason.reason_id = ER_NOROUTE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -531,15 +533,16 @@ static void refresh_hostbatch(HostGroupState *hs, struct addrset *exclude_group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Then we do the mass ping (if required - IP-level pings) */
|
/* Then we do the mass ping (if required - IP-level pings) */
|
||||||
if ((pingtype == PINGTYPE_NONE && !arpping_done) || hs->hostbatch[0]->ifType() == devt_loopback) {
|
if ((pingtype == PINGTYPE_NONE && !arpping_done) || current_target->ifType() == devt_loopback) {
|
||||||
for (i=0; i < hs->current_batch_sz; i++) {
|
for (i=0; i < hs->current_batch_sz; i++) {
|
||||||
if (!(hs->hostbatch[i]->flags & HOST_DOWN || hs->hostbatch[i]->timedOut(&now))) {
|
current_target = hs->hostbatch[i];
|
||||||
initialize_timeout_info(&hs->hostbatch[i]->to);
|
if (!(current_target->flags & HOST_DOWN || current_target->timedOut(&now))) {
|
||||||
hs->hostbatch[i]->flags |= HOST_UP; /*hostbatch[i].up = 1;*/
|
initialize_timeout_info(¤t_target->to);
|
||||||
|
current_target->flags |= HOST_UP; /*hostbatch[i].up = 1;*/
|
||||||
if (pingtype == PINGTYPE_NONE && !arpping_done)
|
if (pingtype == PINGTYPE_NONE && !arpping_done)
|
||||||
hs->hostbatch[i]->reason.reason_id = ER_USER;
|
current_target->reason.reason_id = ER_USER;
|
||||||
else
|
else
|
||||||
hs->hostbatch[i]->reason.reason_id = ER_LOCALHOST;
|
current_target->reason.reason_id = ER_LOCALHOST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!arpping_done) {
|
} else if (!arpping_done) {
|
||||||
|
|||||||
Reference in New Issue
Block a user