1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 04:09:01 +00:00

Consolidate raw socket acquisition.

This commit is contained in:
dmiller
2025-06-30 19:24:32 +00:00
parent fc71b7544d
commit 67a796844f
16 changed files with 162 additions and 207 deletions

View File

@@ -105,7 +105,6 @@ NpingOps::NpingOps() {
sendpref_set=false;
send_eth=false;
send_eth_set=false;
delay=0;
delay_set=false;
@@ -620,10 +619,10 @@ bool NpingOps::issetPacketCount(){
* PACKET_SEND_ETH, PACKET_SEND_IP_WEAK, PACKET_SEND_IP_STRONG, PACKET_SEND_IP
* @return OP_SUCCESS on success and OP_FAILURE in case of error. */
int NpingOps::setSendPreference(int v){
if( v!=PACKET_SEND_NOPREF && v!=PACKET_SEND_ETH_WEAK &&
v!=PACKET_SEND_ETH_STRONG && v!=PACKET_SEND_ETH &&
v!=PACKET_SEND_IP_WEAK && v!=PACKET_SEND_IP_STRONG &&
v!=PACKET_SEND_IP ){
// Validate: no extra bits set
if( (v & ~(PACKET_SEND_ETH | PACKET_SEND_IP))
// Validate: both ETH and IP cannot be STRONG
|| ((v & PACKET_SEND_ETH_STRONG) && (v & PACKET_SEND_IP_STRONG))) {
nping_fatal(QT_3,"setSendPreference(): Invalid value supplied\n");
return OP_FAILURE;
}else{
@@ -648,51 +647,31 @@ bool NpingOps::issetSendPreference(){
/* Returns true if send preference is Ethernet */
bool NpingOps::sendPreferenceEthernet(){
if ( this->getSendPreference()==PACKET_SEND_ETH_WEAK )
return true;
else if (this->getSendPreference()==PACKET_SEND_ETH_STRONG)
return true;
else if (this->getSendPreference()==PACKET_SEND_ETH )
return true;
else
return false;
return (this->sendpref & PACKET_SEND_ETH);
} /* End of sendPreferenceEthernet() */
/* Returns true if send preference is Ethernet */
bool NpingOps::sendPreferenceIP(){
if ( this->getSendPreference()==PACKET_SEND_IP_WEAK )
return true;
else if (this->getSendPreference()==PACKET_SEND_IP_STRONG)
return true;
else if (this->getSendPreference()==PACKET_SEND_IP )
return true;
else
return false;
return (this->sendpref & PACKET_SEND_IP);
} /* End of sendPreferenceIP() */
/** Sets SendEth.
* @return OP_SUCCESS on success and OP_FAILURE in case of error. */
int NpingOps::setSendEth(bool val){
this->send_eth=val;
this->send_eth_set=true;
this->sendpref = PACKET_SEND_ETH;
this->sendpref_set = true;
return OP_SUCCESS;
} /* End of setSendEth() */
/** Returns value of attribute send_eth */
bool NpingOps::sendEth(){
return this->send_eth;
return (this->sendpref & PACKET_SEND_ETH_STRONG);
} /* End of getSendEth() */
/* Returns true if option has been set */
bool NpingOps::issetSendEth(){
return this->send_eth_set;
} /* End of issetSendEth() */
/** Sets inter-probe delay. Supplied parameter is assumed to be in milliseconds
* and must be a long integer greater than zero.
* @warning timeout is assumed to be in milliseconds. Use tval2msecs() from