mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Consolidate raw socket acquisition.
This commit is contained in:
parent
fc71b7544d
commit
67a796844f
16 changed files with 162 additions and 207 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -97,14 +97,6 @@
|
|||
#define FLAG_SYN 6
|
||||
#define FLAG_FIN 7
|
||||
|
||||
#define PACKET_SEND_NOPREF 1 /* These have been taken from NmapOps.h */
|
||||
#define PACKET_SEND_ETH_WEAK 2
|
||||
#define PACKET_SEND_ETH_STRONG 4
|
||||
#define PACKET_SEND_ETH 6
|
||||
#define PACKET_SEND_IP_WEAK 8
|
||||
#define PACKET_SEND_IP_STRONG 16
|
||||
#define PACKET_SEND_IP 24
|
||||
|
||||
#define IP_VERSION_4 0x04
|
||||
#define IP_VERSION_6 0x06
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue