mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 06:01:28 +00:00
Got rid of (unnecessary) spaces in blank lines in *.cc and *.h files.
sed -i 's/^\s*$//'
This commit is contained in:
@@ -183,7 +183,7 @@ void *cp_alloc(int sz) {
|
||||
|
||||
if ((modulus = sz % ALIGN_ON))
|
||||
sz += ALIGN_ON - modulus;
|
||||
|
||||
|
||||
if ((nextchar - charpool[currentcharpool]) + sz <= currentcharpoolsz) {
|
||||
p = nextchar;
|
||||
nextchar += sz;
|
||||
@@ -193,7 +193,7 @@ void *cp_alloc(int sz) {
|
||||
cp_grow();
|
||||
|
||||
return cp_alloc(sz);
|
||||
|
||||
|
||||
}
|
||||
|
||||
char *cp_strdup(const char *src) {
|
||||
|
||||
@@ -67,7 +67,7 @@ struct ip
|
||||
/*
|
||||
* Non DIX types. Won't clash for 1500 types.
|
||||
*/
|
||||
|
||||
|
||||
#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
|
||||
#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
|
||||
#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
|
||||
@@ -292,7 +292,7 @@ struct ip_timestamp {
|
||||
#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
|
||||
#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
|
||||
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
|
||||
|
||||
|
||||
|
||||
#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
|
||||
#define ICMP_ROUTERADVERT 9 /* router advertisement */
|
||||
|
||||
@@ -188,7 +188,7 @@ static int tty_getchar()
|
||||
fd_set set;
|
||||
struct timeval tv;
|
||||
#endif
|
||||
|
||||
|
||||
if (tty_fd && tcgetpgrp(tty_fd) == getpgrp()) {
|
||||
|
||||
// This is so that when the terminal has been disconnected, it will be
|
||||
|
||||
@@ -189,7 +189,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
||||
{"arp-reply", no_argument, 0, 0},
|
||||
{"rarp-request", no_argument, 0, 0},
|
||||
{"rarp-reply", no_argument, 0, 0},
|
||||
|
||||
|
||||
/* TCP/UDP */
|
||||
{"source-port", required_argument, 0, 'g'},
|
||||
{"dest-port", required_argument, 0, 'p'},
|
||||
@@ -300,7 +300,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
||||
{"nsock-engine", required_argument, 0, 0},
|
||||
{"no-capture", no_argument, 0, 'N'},
|
||||
{"hide-sent", no_argument, 0, 'H'},
|
||||
|
||||
|
||||
/* Output */
|
||||
{"verbose", optional_argument, 0, 'v'},
|
||||
{"reduce-verbosity", optional_argument, 0, 'q'},
|
||||
@@ -352,7 +352,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
||||
} else if (optcmp(long_options[option_index].name, "traceroute") == 0 ||
|
||||
optcmp(long_options[option_index].name, "tr") == 0) {
|
||||
o.enableTraceroute();
|
||||
|
||||
|
||||
/* Now shortcuts that we support but that are not actual modes */
|
||||
} else if (optcmp(long_options[option_index].name, "arp-request") == 0) {
|
||||
if( o.issetMode() && o.getMode()!=ARP)
|
||||
@@ -517,7 +517,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
||||
nping_fatal(QT_3, "Invalid TCP flag supplied (%c). If you want to specify flags using a number you must add prefix \"0x\"", optarg[f]);
|
||||
else
|
||||
nping_fatal(QT_3, "Invalid TCP flag supplied: %c", optarg[f]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -833,7 +833,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
||||
nping_fatal(QT_3,"IPv6 Flow Label must be a number between 0 and 1048575");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* PACKET PAYLOAD OPTIONS ***************************************************/
|
||||
/* Hexadecimal payload specification */
|
||||
} else if (optcmp(long_options[option_index].name, "data") == 0 ){
|
||||
@@ -977,7 +977,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
||||
case '4': /* IPv4 */
|
||||
o.setIPVersion(IP_VERSION_4);
|
||||
break; /* case '4': */
|
||||
|
||||
|
||||
case '6': /* IPv6 */
|
||||
o.setIPVersion(IP_VERSION_6);
|
||||
break; /* case '6': */
|
||||
@@ -1049,7 +1049,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
||||
printUsage();
|
||||
exit(1);
|
||||
break; /* case 'h': */
|
||||
|
||||
|
||||
case 'h': /* Help */
|
||||
printUsage();
|
||||
exit(0);
|
||||
@@ -1138,7 +1138,7 @@ int ArgParser::parseArguments(int argc, char *argv[]) {
|
||||
o.increaseVerbosity();
|
||||
}
|
||||
break; /* case 'v': */
|
||||
|
||||
|
||||
case 'q': /* Reduce verbosity */
|
||||
if (optarg){
|
||||
if (isdigit(optarg[0])){
|
||||
@@ -1835,12 +1835,12 @@ int ArgParser::atoEtherType(char *opt, u16 *type){
|
||||
|
||||
|
||||
int ArgParser::parseICMPTimestamp(char *optarg, u32 *dst){
|
||||
|
||||
|
||||
long diff=0;
|
||||
|
||||
if(optarg==NULL || dst==NULL)
|
||||
nping_fatal(QT_3, "parseICMPTimestamp(): NULL pointer supplied.");
|
||||
|
||||
|
||||
if( meansRandom(optarg) ){
|
||||
while( (*dst=get_random_u32()) == 0);
|
||||
}
|
||||
@@ -1875,6 +1875,6 @@ long diff=0;
|
||||
else
|
||||
*dst=diff;
|
||||
}
|
||||
|
||||
|
||||
return OP_SUCCESS;
|
||||
} /* End of parseICMPTimestamp() */
|
||||
|
||||
@@ -284,7 +284,7 @@ u8 *Crypto::deriveKey(const u8 *from, size_t fromlen, size_t *final_len){
|
||||
nping_print(DBG_4, "%s()", __func__);
|
||||
if(from==NULL || fromlen==0)
|
||||
return NULL;
|
||||
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
if( o.doCrypto() ){
|
||||
static u8 hash[MAX(SHA256_HASH_LEN, EVP_MAX_MD_SIZE)];
|
||||
|
||||
@@ -224,7 +224,7 @@ int EchoClient::nep_connect(NpingTarget *target, u16 port){
|
||||
struct sockaddr_in *s4=(struct sockaddr_in *)&ss;
|
||||
struct sockaddr_in6 *s6=(struct sockaddr_in6 *)&ss;
|
||||
enum nsock_loopstatus loopstatus;
|
||||
|
||||
|
||||
if(target==NULL)
|
||||
nping_fatal(QT_3, "nep_connect(): NULL parameter supplied.");
|
||||
else
|
||||
@@ -279,7 +279,7 @@ int EchoClient::nep_handshake(){
|
||||
nping_print(DBG_4, "%s()", __func__);
|
||||
enum nsock_loopstatus loopstatus;
|
||||
EchoHeader h;
|
||||
|
||||
|
||||
/* Receive NEP_HANDSHAKE_SERVER message */
|
||||
nsock_readbytes(this->nsp, this->nsi, recv_hs_server_handler, ECHO_READ_TIMEOUT, NULL, NEP_HANDSHAKE_SERVER_LEN);
|
||||
loopstatus=nsock_loop(this->nsp, ECHO_READ_TIMEOUT-1);
|
||||
@@ -313,7 +313,7 @@ int EchoClient::nep_handshake(){
|
||||
loopstatus=nsock_loop(this->nsp, ECHO_READ_TIMEOUT-1);
|
||||
if(loopstatus!=NSOCK_LOOP_QUIT)
|
||||
return OP_FAILURE;
|
||||
|
||||
|
||||
nping_print(DBG_1, "===NEP Handshake completed successfully===");
|
||||
return OP_SUCCESS;
|
||||
} /* End of nep_handshake() */
|
||||
@@ -735,7 +735,7 @@ int EchoClient::generate_packet_spec(EchoHeader *h){
|
||||
h->setTimestamp();
|
||||
h->setIPVersion( o.getIPVersion()==AF_INET6 ? 0x06: 0x04 );
|
||||
h->setPacketCount( (o.getPacketCount()>0xFFFF) ? 0xFFFF : o.getPacketCount() );
|
||||
|
||||
|
||||
/** Insert packet field specifiers */
|
||||
if(o.ipv6()){ /* AF_INET6 */
|
||||
/* Traffic class */
|
||||
@@ -858,7 +858,7 @@ int EchoClient::nep_echoed_packet_handler(nsock_pool nsp, nsock_event nse, void
|
||||
}
|
||||
return OP_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/* Read the remaining data */
|
||||
if( (recvbuff=(u8 *)nse_readbuf(nse, &recvbytes))==NULL ){
|
||||
nping_print(DBG_4,"nep_echoed_packet_handler(): nse_readbuf failed!\n");
|
||||
|
||||
@@ -150,7 +150,7 @@ class EchoClient {
|
||||
ProbeMode probe;
|
||||
u8 lasthdr[MAX_NEP_PACKET_LENGTH];
|
||||
size_t readbytes;
|
||||
|
||||
|
||||
/* Methods */
|
||||
int nep_connect(NpingTarget *target, u16 port);
|
||||
int nep_handshake();
|
||||
|
||||
@@ -476,7 +476,7 @@ int EchoHeader::setClientNonce(u8 *nonce){
|
||||
case TYPE_NEP_HANDSHAKE_FINAL:
|
||||
memcpy(this->data_hsfinal->client_nonce , nonce, NONCE_LEN);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return OP_FAILURE;
|
||||
break;
|
||||
@@ -594,7 +594,7 @@ u8 EchoHeader::getIPVersion(){
|
||||
case TYPE_NEP_PACKET_SPEC:
|
||||
return this->data_pspec->ip_version;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return 0xAB;
|
||||
break;
|
||||
|
||||
@@ -192,7 +192,7 @@
|
||||
#define DLT_NODATALINKHEADERINCLUDED 0x0000
|
||||
|
||||
/* GENERAL FORMAT:
|
||||
|
||||
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
@@ -325,21 +325,21 @@ class EchoHeader : public ApplicationLayerElement {
|
||||
|
||||
int setVersion(u8 val);
|
||||
u8 getVersion();
|
||||
|
||||
|
||||
int setMessageType(u8 val);
|
||||
u8 getMessageType();
|
||||
|
||||
|
||||
int setTotalLength(u16 val);
|
||||
int setTotalLength();
|
||||
u16 getTotalLength();
|
||||
|
||||
int setSequenceNumber(u32 val);
|
||||
u32 getSequenceNumber();
|
||||
|
||||
|
||||
int setTimestamp(u32 val);
|
||||
int setTimestamp();
|
||||
u32 getTimestamp();
|
||||
|
||||
|
||||
int setReserved(u32 val);
|
||||
u32 getReserved();
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
|
||||
extern NpingOps o;
|
||||
extern EchoServer es;
|
||||
|
||||
|
||||
EchoServer::EchoServer() {
|
||||
this->reset();
|
||||
} /* End of EchoServer constructor */
|
||||
@@ -265,7 +265,7 @@ int EchoServer::nep_listen_socket(){
|
||||
* this port in a previous execution, not long ago. */
|
||||
if( setsockopt(master_sd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int))!=0 )
|
||||
nping_warning(QT_3, "Failed to set SO_REUSEADDR on master socket.");
|
||||
|
||||
|
||||
memset(&server_addr6, 0, sizeof(struct sockaddr_in6));
|
||||
server_addr6.sin6_addr = (o.spoofSource()) ? o.getIPv6SourceAddress() : in6addr_any;
|
||||
server_addr6.sin6_family = AF_INET6;
|
||||
@@ -297,7 +297,7 @@ int EchoServer::nep_listen_socket(){
|
||||
/* Obtain a regular TCP socket for IPv4 */
|
||||
if( (master_sd=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))<0 )
|
||||
nping_fatal(QT_3, "Could not obtain AF_INET/SOCK_STREAM/IPPROTO_TCP socket");
|
||||
|
||||
|
||||
/* Set SO_REUSEADDR on socket so the bind does not fail if we had used
|
||||
* this port in a previous execution, not long ago. */
|
||||
if( setsockopt(master_sd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int))!=0 )
|
||||
@@ -311,7 +311,7 @@ int EchoServer::nep_listen_socket(){
|
||||
#ifdef HAVE_SOCKADDR_IN_SIN_LEN
|
||||
server_addr4.sin_len = sizeof(struct sockaddr_in);
|
||||
#endif
|
||||
|
||||
|
||||
/* Bind to local address and the specified port */
|
||||
if( bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){
|
||||
nping_warning(QT_3, "Failed to bind to source address %s. Trying to bind to port %d...", IPtoa(server_addr4.sin_addr), port);
|
||||
@@ -584,7 +584,7 @@ clientid_t EchoServer::nep_match_headers(IPv4Header *ip4, IPv6Header *ip6, TCPHe
|
||||
minimum_score=MIN_ACCEPTABLE_SCORE_ICMP;
|
||||
else
|
||||
minimum_score=10000;
|
||||
|
||||
|
||||
/* Check if we managed to match packet and client */
|
||||
if (candidate>=0 && candidate_score>=minimum_score){
|
||||
nping_print(DBG_2, "%s() Packet matched successfully with client #%d", __func__, candidate);
|
||||
@@ -733,7 +733,7 @@ clientid_t EchoServer::nep_match_packet(const u8 *pkt, size_t pktlen){
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return CLIENT_NOT_FOUND;
|
||||
break;
|
||||
@@ -1062,7 +1062,7 @@ int EchoServer::nep_packetspec_handler(nsock_pool nsp, nsock_event nse, void *pa
|
||||
/* At this point, we consider the NEP session fully established and therefore
|
||||
* we update the count of served clients */
|
||||
o.stats.addEchoClientServed();
|
||||
|
||||
|
||||
return OP_SUCCESS;
|
||||
} /* End of nep_packetspec_handler() */
|
||||
|
||||
@@ -1165,7 +1165,7 @@ int EchoServer::parse_hs_client(u8 *pkt, size_t pktlen, NEPContext *ctx){
|
||||
nping_print(DBG_3,"Session Key MAC_S2C:"); print_hexdump(DBG_3,ctx->getMacKeyS2C(), MAC_KEY_LEN);
|
||||
nping_print(DBG_3,"Session Key CIPHER_C2S:"); print_hexdump(DBG_3,ctx->getCipherKeyC2S(), MAC_KEY_LEN);
|
||||
nping_print(DBG_3,"Session Key CIPHER_S2C:"); print_hexdump(DBG_3,ctx->getCipherKeyS2C(), MAC_KEY_LEN);
|
||||
|
||||
|
||||
|
||||
/* Decrypt the encrypted part of the message before validating the MAC */
|
||||
if((next_iv=h.decrypt(ctx->getCipherKeyC2S(), CIPHER_KEY_LEN, ctx->getClientNonce(), TYPE_NEP_HANDSHAKE_CLIENT))==NULL){
|
||||
@@ -1366,7 +1366,7 @@ int EchoServer::generate_ready(EchoHeader *h, NEPContext *ctx){
|
||||
if( (next_iv=h->encrypt(ctx->getCipherKeyS2C(), CIPHER_KEY_LEN, ctx->getNextEncryptionIV()))==NULL )
|
||||
return OP_FAILURE;
|
||||
ctx->setNextEncryptionIV(next_iv);
|
||||
|
||||
|
||||
return OP_SUCCESS;
|
||||
} /* End of generate_ready() */
|
||||
|
||||
@@ -1392,7 +1392,7 @@ int EchoServer::generate_echo(EchoHeader *h, const u8 *pkt, size_t pktlen, NEPCo
|
||||
}else{
|
||||
/* Determine where the application data starts */
|
||||
int offset=PacketParser::payload_offset(pkt, pktlen, false);
|
||||
|
||||
|
||||
/* If the packet does not have application data, don't touch it */
|
||||
if(offset==0){
|
||||
nping_print(DBG_3, "No payload found. Echoing the whole packet\n");
|
||||
@@ -1459,7 +1459,7 @@ int EchoServer::start() {
|
||||
/* Create new IOD for pcap */
|
||||
if ((pcap_nsi = nsi_new(nsp, NULL)) == NULL)
|
||||
nping_fatal(QT_3, "Failed to create new nsock_iod. QUITTING.\n");
|
||||
|
||||
|
||||
/* Open pcap */
|
||||
nping_print(DBG_2,"Opening pcap device %s", o.getDevice());
|
||||
Strncpy(pcapdev, o.getDevice(), sizeof(pcapdev));
|
||||
|
||||
@@ -158,7 +158,7 @@ class EchoServer {
|
||||
int generate_hs_final(EchoHeader *h, NEPContext *ctx);
|
||||
int generate_ready(EchoHeader *h, NEPContext *ctx);
|
||||
int generate_echo(EchoHeader *h, const u8 *pkt, size_t pktlen, NEPContext *ctx);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
EchoServer();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* NEPContext.cc -- *
|
||||
* *
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* NEPContext.cc -- *
|
||||
* *
|
||||
@@ -202,7 +202,7 @@ class NEPContext {
|
||||
struct sockaddr_storage clnt_addr;
|
||||
|
||||
u8 *generateKey(int key_type, size_t *final_len);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
NEPContext();
|
||||
@@ -260,7 +260,7 @@ class NEPContext {
|
||||
u8 *getCipherKeyS2C();
|
||||
u8 *getCipherKeyS2C(size_t *final_len);
|
||||
int generateCipherKeyS2C();
|
||||
|
||||
|
||||
int generateClientNonce();
|
||||
int generateServerNonce();
|
||||
int setClientNonce(u8 *buff);
|
||||
|
||||
@@ -360,7 +360,7 @@ NpingOps::NpingOps() {
|
||||
|
||||
memset(echo_passphrase, 0, sizeof(echo_passphrase));
|
||||
echo_passphrase_set=false;
|
||||
|
||||
|
||||
memset(&last_sent_pkt_time, 0, sizeof(struct timeval));
|
||||
|
||||
delayed_rcvd_str=NULL;
|
||||
@@ -2357,7 +2357,7 @@ if (this->havePcap()==false){
|
||||
else
|
||||
this->setPacketCount( DEFAULT_PACKET_COUNT );
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( !this->issetDelay() )
|
||||
this->setDelay( DEFAULT_DELAY );
|
||||
|
||||
@@ -188,7 +188,7 @@ class NpingOps {
|
||||
bool mode_set;
|
||||
bool traceroute; /* Is traceroute mode enabled? */
|
||||
bool traceroute_set;
|
||||
|
||||
|
||||
/* Output */
|
||||
int vb; /* Current Verbosity level */
|
||||
bool vb_set;
|
||||
@@ -220,7 +220,7 @@ class NpingOps {
|
||||
/* Privileges */
|
||||
bool isr00t; /* True if current user has root privs */
|
||||
bool isr00t_set;
|
||||
|
||||
|
||||
/* Payloads */
|
||||
int payload_type; /* Type of payload (RAND,HEX,FILE) */
|
||||
bool payload_type_set;
|
||||
@@ -228,11 +228,11 @@ class NpingOps {
|
||||
bool payload_buff_set;
|
||||
int payload_len; /* Length of payload */
|
||||
bool payload_len_set;
|
||||
|
||||
|
||||
/* Roles */
|
||||
int role; /* Nping's role: normal|client|server. */
|
||||
bool role_set;
|
||||
|
||||
|
||||
/* IPv4 */
|
||||
u8 ttl; /* IPv4 TTL / IPv6 Hop limit */
|
||||
bool ttl_set;
|
||||
@@ -254,7 +254,7 @@ class NpingOps {
|
||||
bool ipv4_src_address_set;
|
||||
char *ip_options; /* IP Options */
|
||||
bool ip_options_set;
|
||||
|
||||
|
||||
/* IPv6 */
|
||||
u8 ipv6_tclass; /* Traffic Class */
|
||||
bool ipv6_tclass_set;
|
||||
@@ -262,7 +262,7 @@ class NpingOps {
|
||||
bool ipv6_flowlabel_set;
|
||||
struct in6_addr ipv6_src_address; /**< Source IPv6 address */
|
||||
bool ipv6_src_address_set;
|
||||
|
||||
|
||||
/* TCP / UDP */
|
||||
u16 *target_ports; /* Will point to an array of ports */
|
||||
int tportcount; /* Total number of target ports */
|
||||
@@ -279,7 +279,7 @@ class NpingOps {
|
||||
bool tcpwin_set;
|
||||
bool badsum; /* Generate invalid TCP/UDP checksums? */
|
||||
bool badsum_set;
|
||||
|
||||
|
||||
/* ICMP */
|
||||
u8 icmp_type; /* ICMP Type */
|
||||
bool icmp_type_set;
|
||||
@@ -308,7 +308,7 @@ class NpingOps {
|
||||
u32 icmp_advert_entry_pref[MAX_ICMP_ADVERT_ENTRIES];
|
||||
int icmp_advert_entry_count;
|
||||
bool icmp_advert_entry_set;
|
||||
|
||||
|
||||
/* Ethernet */
|
||||
u8 src_mac[6]; /* Source MAC address */
|
||||
bool src_mac_set;
|
||||
@@ -316,7 +316,7 @@ class NpingOps {
|
||||
bool dst_mac_set;
|
||||
u16 eth_type; /* EtherType field of the Ethernet frame */
|
||||
bool eth_type_set;
|
||||
|
||||
|
||||
/* ARP/RARP */
|
||||
u16 arp_htype; /* ARP Hardware type */
|
||||
bool arp_htype_set;
|
||||
@@ -336,7 +336,7 @@ class NpingOps {
|
||||
bool arp_spa_set;
|
||||
struct in_addr arp_tpa; /* ARP Target protocol address */
|
||||
bool arp_tpa_set;
|
||||
|
||||
|
||||
/* Echo mode */
|
||||
u16 echo_port; /* Echo port to listen or connect to */
|
||||
bool echo_port_set;
|
||||
@@ -407,7 +407,7 @@ class NpingOps {
|
||||
bool issetSendPreference();
|
||||
bool sendPreferenceEthernet();
|
||||
bool sendPreferenceIP();
|
||||
|
||||
|
||||
int setSendEth(bool val);
|
||||
bool sendEth();
|
||||
bool issetSendEth();
|
||||
|
||||
@@ -239,7 +239,7 @@ int NpingTarget::getTargetSockAddr(struct sockaddr_storage *ss, size_t *ss_len)
|
||||
memcpy(ss, &targetsock, targetsocklen);
|
||||
*ss_len = targetsocklen;
|
||||
return 0;
|
||||
|
||||
|
||||
} /* End of getTargetSockAddr() */
|
||||
|
||||
|
||||
@@ -952,7 +952,7 @@ int NpingTarget::setProbeRecvTCP(u16 sport, u16 dport){
|
||||
/* Update stats info */
|
||||
diff= TIMEVAL_SUBTRACT(this->sentprobes[i].recv, this->sentprobes[i].sent);
|
||||
this->updateRTTs(diff);
|
||||
|
||||
|
||||
return OP_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,16 +163,16 @@ class NpingTarget {
|
||||
|
||||
struct sockaddr_storage nexthopsock; /**< Next Hop address */
|
||||
size_t nexthopsocklen;
|
||||
|
||||
|
||||
char targetipstring[INET6_ADDRSTRLEN];
|
||||
bool targetipstring_set;
|
||||
|
||||
u8 MACaddress[6]; /**< Target MAC Address */
|
||||
bool MACaddress_set;
|
||||
|
||||
|
||||
u8 SrcMACaddress[6]; /**< Source MAC Address */
|
||||
bool SrcMACaddress_set;
|
||||
|
||||
|
||||
u8 NextHopMACaddress[6]; /**< Next Hop MAC Address */
|
||||
bool NextHopMACaddress_set;
|
||||
|
||||
@@ -190,13 +190,13 @@ class NpingTarget {
|
||||
void Initialize();
|
||||
void FreeInternal();
|
||||
void generateIPString();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
NpingTarget();
|
||||
~NpingTarget();
|
||||
void Recycle();
|
||||
|
||||
|
||||
/* Target IP address */
|
||||
int getTargetSockAddr(struct sockaddr_storage *ss, size_t *ss_len);
|
||||
int setTargetSockAddr(struct sockaddr_storage *ss, size_t ss_len);
|
||||
@@ -205,7 +205,7 @@ class NpingTarget {
|
||||
struct in6_addr getIPv6Address();
|
||||
const struct in6_addr *getIPv6Address_aux();
|
||||
u8 *getIPv6Address_u8();
|
||||
|
||||
|
||||
/* Source address used to reach the target */
|
||||
int getSourceSockAddr(struct sockaddr_storage *ss, size_t *ss_len);
|
||||
int setSourceSockAddr(struct sockaddr_storage *ss, size_t ss_len);
|
||||
@@ -219,7 +219,7 @@ class NpingTarget {
|
||||
struct in6_addr getIPv6SourceAddress();
|
||||
const struct in6_addr *getIPv6SourceAddress_aux();
|
||||
u8 *getIPv6SourceAddress_u8();
|
||||
|
||||
|
||||
/* Info about host proximity */
|
||||
void setDirectlyConnected(bool connected);
|
||||
bool isDirectlyConnected();
|
||||
@@ -236,7 +236,7 @@ class NpingTarget {
|
||||
const u8 *getMACAddress();
|
||||
bool determineNextHopMACAddress();
|
||||
bool determineTargetMACAddress();
|
||||
|
||||
|
||||
/* Source MAC address */
|
||||
int setSrcMACAddress(const u8 *addy);
|
||||
const u8 *getSrcMACAddress();
|
||||
@@ -247,7 +247,7 @@ class NpingTarget {
|
||||
const char *getDeviceFullName();
|
||||
int setDeviceType(devtype type);
|
||||
devtype getDeviceType();
|
||||
|
||||
|
||||
/* Resolved Host name */
|
||||
const char *getResolvedHostName();
|
||||
void setResolvedHostName(char *name);
|
||||
|
||||
@@ -279,7 +279,7 @@ int NpingTargets::processSpecs(){
|
||||
size_t slen=0;
|
||||
bool result=false;
|
||||
struct route_nfo rnfo;
|
||||
|
||||
|
||||
memset(&ss, 0, sizeof(struct sockaddr_storage));
|
||||
memset(buff, 0, MAX_NPING_HOSTNAME_LEN+1);
|
||||
|
||||
@@ -332,7 +332,7 @@ int NpingTargets::processSpecs(){
|
||||
if( o.spoofSource() ){
|
||||
mytarget->setSpoofedSourceSockAddr( o.getSourceSockAddr(), sizeof(struct sockaddr_storage));
|
||||
}
|
||||
|
||||
|
||||
/* Network interface */
|
||||
mytarget->setDeviceNames( rnfo.ii.devname, rnfo.ii.devfullname );
|
||||
mytarget->setDeviceType( rnfo.ii.device_type );
|
||||
@@ -359,7 +359,7 @@ int NpingTargets::processSpecs(){
|
||||
s6->sin6_family=AF_INET6;
|
||||
mytarget->setSourceSockAddr(&ss, sizeof(struct sockaddr_storage));
|
||||
}
|
||||
|
||||
|
||||
/* Insert current target into targets array */
|
||||
this->Targets.push_back(mytarget);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
* Nmap, and also available from https://svn.nmap.org/nmap/COPYING *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PacketDiff.h"
|
||||
#include "nping.h"
|
||||
|
||||
|
||||
@@ -124,11 +124,11 @@
|
||||
#define __PACKETDIFF_H__ 1
|
||||
|
||||
#include "nping.h"
|
||||
|
||||
|
||||
class PacketDiff {
|
||||
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/* Misc */
|
||||
|
||||
@@ -700,7 +700,7 @@ int ProbeMode::createIPv6(IPv6Header *i, PacketElement *next_element, const char
|
||||
i->setNextHeader(next_proto);
|
||||
i->setPayloadLength();
|
||||
i->setDestinationAddress( target->getIPv6Address_u8() );
|
||||
|
||||
|
||||
/* Hop Limit */
|
||||
if ( o.issetTraceroute() ){
|
||||
i->setHopLimit( o.getCurrentRound() );
|
||||
@@ -1689,7 +1689,7 @@ void ProbeMode::probe_nping_event_handler(nsock_pool nsp, nsock_event nse, void
|
||||
|
||||
/* Read a packet */
|
||||
nse_readpcap(nse, &link, &linklen, &packet, &packetlen, NULL, &pcaptime);
|
||||
|
||||
|
||||
/* If we are on a Ethernet network, extract the next packet protocol
|
||||
* from the Ethernet frame. */
|
||||
if( nsi_pcap_linktype(nsi) == DLT_EN10MB ){
|
||||
@@ -1726,7 +1726,7 @@ void ProbeMode::probe_nping_event_handler(nsock_pool nsp, nsock_event nse, void
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Packet is IP */
|
||||
if(ip){
|
||||
getPacketStrInfo("IP",(const u8*)packet, packetlen, buffer, 512);
|
||||
|
||||
@@ -162,7 +162,7 @@ class ProbeMode {
|
||||
|
||||
nsock_pool nsp; /**< Internal Nsock pool */
|
||||
bool nsock_init; /**< True if nsock pool has been initialized */
|
||||
|
||||
|
||||
public:
|
||||
|
||||
ProbeMode();
|
||||
@@ -172,7 +172,7 @@ class ProbeMode {
|
||||
int start();
|
||||
int cleanup();
|
||||
nsock_pool getNsockPool();
|
||||
|
||||
|
||||
static int createIPv4(IPv4Header *i, PacketElement *next_element, const char *next_proto, NpingTarget *target);
|
||||
static int createIPv6(IPv6Header *i, PacketElement *next_element, const char *next_proto, NpingTarget *target);
|
||||
static int doIPv6ThroughSocket(int rawfd);
|
||||
|
||||
@@ -833,7 +833,7 @@ if( !addr || !dev )
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
|
||||
} /* End of devname2ipaddr() */
|
||||
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ int main(int argc, char *argv[] ){
|
||||
o.displayNpingDoneMsg();
|
||||
o.cleanup();
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
} /* End of main() */
|
||||
|
||||
|
||||
@@ -432,7 +432,7 @@
|
||||
#define PAYLOAD_ECHO_BYTES_IN_DOUBT 40
|
||||
|
||||
#define NSOCK_INFINITE -1
|
||||
|
||||
|
||||
/* Prototypes for nping.cc shared functions */
|
||||
char *getBPFFilterString();
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ int nping_fatal(int level, const char *str, ...) {
|
||||
return OP_SUCCESS;
|
||||
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
||||
return OP_SUCCESS;
|
||||
|
||||
|
||||
|
||||
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
||||
vfprintf(stderr, str, list);
|
||||
@@ -189,7 +189,7 @@ int nping_warning(int level, const char *str, ...) {
|
||||
|
||||
int current_vb_level= o.getVerbosity();
|
||||
int current_dbg_level= o.getDebugging();
|
||||
|
||||
|
||||
/* Determine if caller requested that we don't print a newline character */
|
||||
if ( level & NO_NEWLINE ){
|
||||
level ^= NO_NEWLINE; /* Unset the flag restoring the original level */
|
||||
@@ -201,7 +201,7 @@ int nping_warning(int level, const char *str, ...) {
|
||||
return OP_SUCCESS;
|
||||
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
||||
return OP_SUCCESS;
|
||||
|
||||
|
||||
/* Otherwise, print the info to stderr*/
|
||||
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
||||
vfprintf(stderr, str, list); /* Print to stderr */
|
||||
@@ -230,7 +230,7 @@ int nping_print(int level, const char *str, ...){
|
||||
|
||||
int current_vb_level= o.getVerbosity();
|
||||
int current_dbg_level= o.getDebugging();
|
||||
|
||||
|
||||
/* Determine if caller requested that we don't print a newline character */
|
||||
if ( level & NO_NEWLINE ){
|
||||
level ^= NO_NEWLINE; /* Unset the flag restoring the original level */
|
||||
@@ -242,7 +242,7 @@ int nping_print(int level, const char *str, ...){
|
||||
return OP_SUCCESS;
|
||||
if( level>=DBG_0 && level<=DBG_9 && level>current_dbg_level )
|
||||
return OP_SUCCESS;
|
||||
|
||||
|
||||
/* Otherwise, print the info to stderr*/
|
||||
if ( (level>=QT_3 && level<=VB_4) || (level>=DBG_1 && level<=DBG_9) ){
|
||||
vfprintf(stdout, str, list); /* Print to stderr */
|
||||
|
||||
@@ -193,7 +193,7 @@ class NpingTimer {
|
||||
double elapsed(struct timeval *now=NULL);
|
||||
bool is_started();
|
||||
bool is_stopped();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
bool timeval_set(const struct timeval *tv);
|
||||
@@ -236,7 +236,7 @@ class NpingStats {
|
||||
|
||||
int startRxClock();
|
||||
int stopRxClock();
|
||||
|
||||
|
||||
int startRuntime();
|
||||
int stopRuntime();
|
||||
|
||||
|
||||
@@ -596,7 +596,7 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
||||
|
||||
if( ss==NULL || sslen==NULL || host==NULL)
|
||||
nping_fatal(QT_3, "resolveCached(): NULL values supplied");
|
||||
|
||||
|
||||
/* First we check if we have the host already cached */
|
||||
for(int i=0; i<MAX_CACHED_HOSTS && i<cached_count; i++){
|
||||
if( !strcasecmp( archive[i].hostname , host ) ){ /* Cache hit */
|
||||
@@ -613,18 +613,18 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
||||
nping_print(DBG_4, "resolveCached(): Cache miss %d for %s\n", misses, host);
|
||||
|
||||
if( (result=resolve(host, 0, ss, sslen, pf)) == 0 ){
|
||||
|
||||
|
||||
/* Increment count */
|
||||
if( cached_count < MAX_CACHED_HOSTS )
|
||||
cached_count++;
|
||||
|
||||
|
||||
/* Store info */
|
||||
memset(&(archive[current_index]), 0, sizeof(cached_host_t) );
|
||||
strncpy(archive[current_index].hostname, host, MAX_CACHED_HOSTNAME_LEN);
|
||||
archive[current_index].sslen = *sslen;
|
||||
memcpy(&(archive[current_index].ss), ss, *sslen);
|
||||
|
||||
|
||||
|
||||
/* I run some tests to see what is the best approach when the cache
|
||||
* is full. The thing is that in Nping, we are likely to call
|
||||
* this function over and over with specifying the same hosts. Deleting
|
||||
@@ -635,9 +635,9 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
||||
if( current_index < MAX_CACHED_HOSTS-1 )
|
||||
current_index++;
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///* Watch out for the overflow. If cache is full, */
|
||||
//if( cached_count == MAX_CACHED_HOSTS ){
|
||||
//if( way%2==1 ){
|
||||
@@ -660,7 +660,7 @@ int resolveCached(char *host, struct sockaddr_storage *ss, size_t *sslen, int pf
|
||||
//else
|
||||
//current_index++;
|
||||
//return OP_SUCCESS;
|
||||
|
||||
|
||||
}else{
|
||||
nping_warning(QT_2, "Error resolving %s\n",host);
|
||||
return OP_FAILURE;
|
||||
@@ -699,7 +699,7 @@ struct hostent *gethostbynameCached(char *host){
|
||||
nping_print(DBG_4, "gethostbynameCached(): Cache miss %d for %s", misses, host);
|
||||
|
||||
if( (result=gethostbyname(host) ) != NULL ){
|
||||
|
||||
|
||||
/* Increment cache entry count */
|
||||
if( cached_count < MAX_CACHED_HOSTS )
|
||||
cached_count++;
|
||||
@@ -709,7 +709,7 @@ struct hostent *gethostbynameCached(char *host){
|
||||
* one in its place */
|
||||
if ( current_index==MAX_CACHED_HOSTS-1 && archive[current_index].h != NULL )
|
||||
hostentfree( archive[current_index].h );
|
||||
|
||||
|
||||
/* Store the hostent entry in the cache */
|
||||
memset(&(archive[current_index]), 0, sizeof(gethostbynamecached_t) );
|
||||
strncpy(archive[current_index].hostname, host, MAX_CACHED_HOSTNAME_LEN);
|
||||
@@ -723,7 +723,7 @@ struct hostent *gethostbynameCached(char *host){
|
||||
else{
|
||||
return archive[current_index].h;
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
return NULL;
|
||||
}
|
||||
@@ -961,7 +961,7 @@ int tcppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
||||
struct sockaddr_in6 *d6=(struct sockaddr_in6 *)dst;
|
||||
char srcipstring[128];
|
||||
char dstipstring[128];
|
||||
|
||||
|
||||
assert(packet);
|
||||
assert(dstbuff);
|
||||
assert(len>=20);
|
||||
@@ -972,7 +972,7 @@ int tcppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
||||
if( detail!=LOW_DETAIL && detail!=MEDIUM_DETAIL && detail!=HIGH_DETAIL)
|
||||
detail=LOW_DETAIL;
|
||||
|
||||
|
||||
|
||||
/* Determine target IP address */
|
||||
if(src!=NULL){
|
||||
if( s4->sin_family==AF_INET ){
|
||||
@@ -1059,7 +1059,7 @@ int tcppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
||||
strncpy((char*)dstbuff, protoinfo, dstlen);
|
||||
|
||||
return OP_SUCCESS;
|
||||
|
||||
|
||||
} /* End of tcppackethdrinfo() */
|
||||
|
||||
|
||||
@@ -1076,7 +1076,7 @@ int udppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
||||
struct sockaddr_in6 *d6=(struct sockaddr_in6 *)dst;
|
||||
char srcipstring[128];
|
||||
char dstipstring[128];
|
||||
|
||||
|
||||
assert(packet);
|
||||
assert(dstbuff);
|
||||
assert(len>=8);
|
||||
@@ -1087,7 +1087,7 @@ int udppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
||||
if( detail!=LOW_DETAIL && detail!=MEDIUM_DETAIL && detail!=HIGH_DETAIL)
|
||||
detail=LOW_DETAIL;
|
||||
|
||||
|
||||
|
||||
/* Determine target IP address */
|
||||
if(src!=NULL){
|
||||
if( s4->sin_family==AF_INET ){
|
||||
@@ -1131,7 +1131,7 @@ int udppackethdrinfo(const u8 *packet, size_t len, u8 *dstbuff, size_t dstlen,
|
||||
strncpy((char*)dstbuff, protoinfo, dstlen);
|
||||
|
||||
return OP_SUCCESS;
|
||||
|
||||
|
||||
} /* End of udppackethdrinfo() */
|
||||
|
||||
|
||||
@@ -1352,7 +1352,7 @@ u8 *getTCPheaderLocation(u8 *pkt, size_t pktLen){
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
|
||||
} /* End of getTCPHeaderLocation() */
|
||||
|
||||
|
||||
@@ -1395,7 +1395,7 @@ u16 *getSrcPortFromIPPacket(u8 *pkt, size_t pktLen){
|
||||
if((header=getTCPheaderLocation(pkt, pktLen))==NULL){
|
||||
if ((header=getUDPheaderLocation(pkt, pktLen))==NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
}
|
||||
pnt=(u16*)&(header[0]);
|
||||
port= ntohs(*pnt);
|
||||
@@ -1458,24 +1458,24 @@ int obtainRawSocket(){
|
||||
|
||||
if( o.ipv6() ){
|
||||
switch( o.getMode() ){
|
||||
|
||||
|
||||
case TCP:
|
||||
protocol = IPPROTO_TCP;
|
||||
break;
|
||||
|
||||
|
||||
case UDP:
|
||||
protocol = IPPROTO_UDP;
|
||||
break;
|
||||
|
||||
|
||||
case ICMP:
|
||||
protocol = IPPROTO_ICMPV6;
|
||||
break;
|
||||
|
||||
|
||||
case ARP:
|
||||
nping_warning(QT_2,"Warning: createRawSocket() should not be called in ARP mode.");
|
||||
return 0;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
nping_fatal(QT_3, "createRawSocket(): NpingOps::getMode() does not return a valid mode. Please report this bug.");
|
||||
break;
|
||||
@@ -1541,7 +1541,7 @@ int getinterfaces_inet6_linux(if6_t *ifbuf, int max_ifaces){
|
||||
|
||||
if(ifbuf==NULL || max_ifaces<=0)
|
||||
nping_fatal(QT_3,"getinterfaces_inet6_linux() NULL values supplied");
|
||||
|
||||
|
||||
/* TODO: Do we fatal() or should we just error and return OP_FAILURE? */
|
||||
if ( !file_is_readable(PATH_PROC_IFINET6) )
|
||||
nping_fatal(QT_3, "Couldn't get IPv6 interface information. File %s does not exist or you don't have read permissions.", PATH_PROC_IFINET6);
|
||||
@@ -1677,7 +1677,7 @@ int getinterfaces_inet6_linux(if6_t *ifbuf, int max_ifaces){
|
||||
printf(" %02x", dev_flags);
|
||||
printf(" %8s\n", devname);
|
||||
*/
|
||||
|
||||
|
||||
} /* End of loop */
|
||||
|
||||
/* Cleanup */
|
||||
@@ -1735,7 +1735,7 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
||||
|
||||
if(rtbuf==NULL || max_routes<=0)
|
||||
nping_fatal(QT_3,"getroutes_inet6_linux() NULL values supplied");
|
||||
|
||||
|
||||
/* TODO: Do we fatal() or should we just error and return OP_FAILURE? */
|
||||
if ( !file_is_readable(PATH_PROC_IPV6ROUTE) )
|
||||
nping_fatal(QT_3, "Couldn't get IPv6 route information. File %s does not exist or you don't have read permissions.", PATH_PROC_IPV6ROUTE);
|
||||
@@ -1757,7 +1757,7 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
||||
* TODO: Can interfaces with format eth0:1 appear on /proc/net/ipv6_route?
|
||||
* If they can, then we need to change the code to skip the last : */
|
||||
removecolon(buffer);
|
||||
|
||||
|
||||
/* 1. Check it has the correct length. */
|
||||
size_t min_len=0;
|
||||
min_len += 3*32; /* Three IPv6 addresses in hex */
|
||||
@@ -1908,12 +1908,12 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
||||
*
|
||||
for(i=0; i<16; i++)
|
||||
printf("%02x", rtbuf[parsed_routes].dst_net.s6_addr[i]);
|
||||
|
||||
|
||||
printf(" %02x ", rtbuf[parsed_routes].dst_prefix);
|
||||
|
||||
for(i=0; i<16; i++)
|
||||
printf("%02x", rtbuf[parsed_routes].src_net.s6_addr[i]);
|
||||
|
||||
|
||||
printf(" %02x ", rtbuf[parsed_routes].src_prefix);
|
||||
|
||||
for(i=0; i<16; i++)
|
||||
@@ -1926,7 +1926,7 @@ int getroutes_inet6_linux(route6_t *rtbuf, int max_routes){
|
||||
printf(" %8s\n", rtbuf[parsed_routes].devname);
|
||||
*/
|
||||
parsed_routes++;
|
||||
|
||||
|
||||
} /* End of loop */
|
||||
|
||||
/* Cleanup */
|
||||
@@ -1958,7 +1958,7 @@ route6_t *route_dst_ipv6_linux(const struct sockaddr_storage *const dst){
|
||||
u8 zero_addr[16]; /* Just to compare route to addr "::" */
|
||||
memset(zero_addr, 0, 16);
|
||||
dstsin6=(struct sockaddr_in6 *)dst;
|
||||
|
||||
|
||||
if(dst==NULL) return NULL;
|
||||
if(dstsin6->sin6_family!=AF_INET6) return NULL;
|
||||
|
||||
|
||||
@@ -399,6 +399,6 @@ LUALIB_API int luaopen_pcrelib(lua_State *L)
|
||||
lua_pop(L, 1);
|
||||
|
||||
luaL_newlib(L, pcrelib);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ int l_get_ssl_certificate(lua_State *L)
|
||||
static int l_ssl_cert_index(lua_State *L)
|
||||
{
|
||||
struct cert_userdata *udata;
|
||||
|
||||
|
||||
udata = (struct cert_userdata *) luaL_checkudata(L, 1, "SSL_CERT");
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, udata->attributes_table);
|
||||
/* The key. */
|
||||
@@ -505,7 +505,7 @@ static int l_ssl_cert_index(lua_State *L)
|
||||
static int l_ssl_cert_gc(lua_State *L)
|
||||
{
|
||||
struct cert_userdata *udata;
|
||||
|
||||
|
||||
udata = (struct cert_userdata *) luaL_checkudata(L, 1, "SSL_CERT");
|
||||
X509_free(udata->cert);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, udata->attributes_table);
|
||||
|
||||
@@ -238,7 +238,7 @@ class OFProbe {
|
||||
class HostOsScanStats {
|
||||
|
||||
friend class HostOsScan;
|
||||
|
||||
|
||||
public:
|
||||
HostOsScanStats(Target *t);
|
||||
~HostOsScanStats();
|
||||
@@ -528,7 +528,7 @@ class OSScan {
|
||||
int chunk_and_do_scan(std::vector<Target *> &Targets, int family);
|
||||
int os_scan_ipv4(std::vector<Target *> &Targets);
|
||||
int os_scan_ipv6(std::vector<Target *> &Targets);
|
||||
|
||||
|
||||
public:
|
||||
OSScan();
|
||||
~OSScan();
|
||||
|
||||
@@ -500,7 +500,7 @@ void print_state_summary(PortList *Ports, unsigned short type) {
|
||||
|
||||
states = state_summary_size(reason_head);
|
||||
currentr = reason_head;
|
||||
|
||||
|
||||
while(currentr != NULL) {
|
||||
if(states == 1 && (!first_time))
|
||||
separator = " and ";
|
||||
|
||||
@@ -162,7 +162,7 @@ static int nmap_protocols_init() {
|
||||
o.loaded_data_files["nmap-protocols"] = filename;
|
||||
|
||||
memset(protocol_table, 0, sizeof(protocol_table));
|
||||
|
||||
|
||||
while(fgets(line, sizeof(line), fp)) {
|
||||
lineno++;
|
||||
p = line;
|
||||
|
||||
12
services.cc
12
services.cc
@@ -234,7 +234,7 @@ static int nmap_services_init() {
|
||||
continue;
|
||||
|
||||
res = sscanf(line, "%127s %hu/%15s %31s", servicename, &portno, proto, ratio_str);
|
||||
|
||||
|
||||
if (res == 3) {
|
||||
ratio = 0;
|
||||
} else if (res == 4) {
|
||||
@@ -245,13 +245,13 @@ static int nmap_services_init() {
|
||||
|
||||
if (ratio_n < 0 || ratio_d < 0)
|
||||
fatal("%s:%d contains an invalid negative value", filename, lineno);
|
||||
|
||||
|
||||
if (ratio_n > ratio_d)
|
||||
fatal("%s:%d has a ratio %g. All ratios must be < 1", filename, lineno, (double)ratio_n/ratio_d);
|
||||
|
||||
|
||||
if (ratio_d == 0)
|
||||
fatal("%s:%d has a ratio denominator of 0 causing a division by 0 error", filename, lineno);
|
||||
|
||||
|
||||
ratio = (double)ratio_n / ratio_d;
|
||||
ratio_format = 1;
|
||||
} else if (strncmp(ratio_str, "0.", 2) == 0) {
|
||||
@@ -325,7 +325,7 @@ void free_services() {
|
||||
services_initialized = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Adds ports whose names match mask and one or more protocols
|
||||
* specified by range_type to porttbl. Increases the respective
|
||||
* protocol counts in ports.
|
||||
@@ -338,7 +338,7 @@ int addportsfromservmask(char *mask, u8 *porttbl, int range_type) {
|
||||
|
||||
if (!services_initialized && nmap_services_init() == -1)
|
||||
fatal("%s: Couldn't get port numbers", __func__);
|
||||
|
||||
|
||||
for (i = service_table.begin(); i != service_table.end(); i++) {
|
||||
service_node& current = i->second;
|
||||
if (wildtest(mask, current.s_name)) {
|
||||
|
||||
Reference in New Issue
Block a user