1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-20 14:39:02 +00:00

Enforce nsock naming scheme.

convert nsp_* calls into nsock_pool_*. Separate words with underscores
where appropriate.
This commit is contained in:
henri
2015-06-27 08:21:16 +00:00
parent ab161bbb0b
commit 0348359f60
18 changed files with 93 additions and 93 deletions

View File

@@ -165,7 +165,7 @@ FPNetworkControl::FPNetworkControl() {
FPNetworkControl::~FPNetworkControl() { FPNetworkControl::~FPNetworkControl() {
if (this->nsock_init) { if (this->nsock_init) {
nsock_event_cancel(this->nsp, this->pcap_ev_id, 0); nsock_event_cancel(this->nsp, this->pcap_ev_id, 0);
nsp_delete(this->nsp); nsock_pool_delete(this->nsp);
this->nsock_init = false; this->nsock_init = false;
} }
} }
@@ -184,23 +184,23 @@ void FPNetworkControl::init(const char *ifname, devtype iftype) {
} }
if (this->nsock_init) { if (this->nsock_init) {
nsock_event_cancel(this->nsp, this->pcap_ev_id, 0); nsock_event_cancel(this->nsp, this->pcap_ev_id, 0);
nsp_delete(this->nsp); nsock_pool_delete(this->nsp);
} }
/* Create a new nsock pool */ /* Create a new nsock pool */
if ((this->nsp = nsp_new(NULL)) == NULL) if ((this->nsp = nsock_pool_new(NULL)) == NULL)
fatal("Unable to obtain an Nsock pool"); fatal("Unable to obtain an Nsock pool");
nsock_set_log_function(this->nsp, nmap_nsock_stderr_logger); nsock_set_log_function(this->nsp, nmap_nsock_stderr_logger);
nmap_adjust_loglevel(this->nsp, o.packetTrace()); nmap_adjust_loglevel(this->nsp, o.packetTrace());
nsp_setdevice(nsp, o.device); nsock_pool_set_device(nsp, o.device);
if (o.proxy_chain) if (o.proxy_chain)
nsp_set_proxychain(this->nsp, o.proxy_chain); nsock_pool_set_proxychain(this->nsp, o.proxy_chain);
/* Allow broadcast addresses */ /* Allow broadcast addresses */
nsp_setbroadcast(this->nsp, 1); nsock_pool_set_broadcast(this->nsp, 1);
/* Allocate an NSI for packet capture */ /* Allocate an NSI for packet capture */
this->pcap_nsi = nsi_new(this->nsp, NULL); this->pcap_nsi = nsi_new(this->nsp, NULL);
@@ -411,7 +411,7 @@ int FPNetworkControl::setup_sniffer(const char *iface, const char *bpf_filter) {
fatal("Error opening capture device %s\n", pcapdev); fatal("Error opening capture device %s\n", pcapdev);
/* Store the pcap NSI inside the pool so we can retrieve it inside a callback */ /* Store the pcap NSI inside the pool so we can retrieve it inside a callback */
nsp_setud(this->nsp, (void *)&(this->pcap_nsi)); nsock_pool_set_udata(this->nsp, (void *)&(this->pcap_nsi));
return OP_SUCCESS; return OP_SUCCESS;
} }
@@ -440,8 +440,8 @@ int FPNetworkControl::scheduleProbe(FPProbe *pkt, int in_msecs_time) {
* The reason for that is because C++ does not allow to use class methods as callback * The reason for that is because C++ does not allow to use class methods as callback
* functions, so this is a small hack to make that happen. */ * functions, so this is a small hack to make that happen. */
void FPNetworkControl::probe_transmission_handler(nsock_pool nsp, nsock_event nse, void *arg) { void FPNetworkControl::probe_transmission_handler(nsock_pool nsp, nsock_event nse, void *arg) {
assert(nsp_getud(nsp) != NULL); assert(nsock_pool_get_udata(nsp) != NULL);
nsock_iod nsi_pcap = *((nsock_iod *)nsp_getud(nsp)); nsock_iod nsi_pcap = *((nsock_iod *)nsock_pool_get_udata(nsp));
enum nse_status status = nse_status(nse); enum nse_status status = nse_status(nse);
enum nse_type type = nse_type(nse); enum nse_type type = nse_type(nse);
FPProbe *myprobe = (FPProbe *)arg; FPProbe *myprobe = (FPProbe *)arg;

View File

@@ -873,7 +873,7 @@ int ncat_connect(void)
nsock_set_default_engine("select"); nsock_set_default_engine("select");
/* Create an nsock pool */ /* Create an nsock pool */
if ((mypool = nsp_new(NULL)) == NULL) if ((mypool = nsock_pool_new(NULL)) == NULL)
bye("Failed to create nsock_pool."); bye("Failed to create nsock_pool.");
if (o.debug >= 6) if (o.debug >= 6)
@@ -886,10 +886,10 @@ int ncat_connect(void)
nsock_set_loglevel(mypool, NSOCK_LOG_ERROR); nsock_set_loglevel(mypool, NSOCK_LOG_ERROR);
/* Allow connections to broadcast addresses. */ /* Allow connections to broadcast addresses. */
nsp_setbroadcast(mypool, 1); nsock_pool_set_broadcast(mypool, 1);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
set_ssl_ctx_options((SSL_CTX *) nsp_ssl_init(mypool)); set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool));
#endif #endif
if (!o.proxytype) { if (!o.proxytype) {
@@ -1055,7 +1055,7 @@ int ncat_connect(void)
} }
#endif #endif
nsp_delete(mypool); nsock_pool_delete(mypool);
return rc == NSOCK_LOOP_ERROR ? 1 : 0; return rc == NSOCK_LOOP_ERROR ? 1 : 0;
} }

View File

@@ -1213,16 +1213,16 @@ static void nmap_mass_rdns_core(Target **targets, int num_targets) {
// And finally, do it! // And finally, do it!
if ((dnspool = nsp_new(NULL)) == NULL) if ((dnspool = nsock_pool_new(NULL)) == NULL)
fatal("Unable to create nsock pool in %s()", __func__); fatal("Unable to create nsock pool in %s()", __func__);
nsock_set_log_function(dnspool, nmap_nsock_stderr_logger); nsock_set_log_function(dnspool, nmap_nsock_stderr_logger);
nmap_adjust_loglevel(dnspool, o.packetTrace()); nmap_adjust_loglevel(dnspool, o.packetTrace());
nsp_setdevice(dnspool, o.device); nsock_pool_set_device(dnspool, o.device);
if (o.proxy_chain) if (o.proxy_chain)
nsp_set_proxychain(dnspool, o.proxy_chain); nsock_pool_set_proxychain(dnspool, o.proxy_chain);
connect_dns_servers(); connect_dns_servers();
@@ -1251,7 +1251,7 @@ static void nmap_mass_rdns_core(Target **targets, int num_targets) {
close_dns_servers(); close_dns_servers();
nsp_delete(dnspool); nsock_pool_delete(dnspool);
if (cname_reqs.size() && o.debugging) if (cname_reqs.size() && o.debugging)
log_write(LOG_STDOUT, "Performing system-dns for %d domain names that use CNAMEs\n", (int) cname_reqs.size()); log_write(LOG_STDOUT, "Performing system-dns for %d domain names that use CNAMEs\n", (int) cname_reqs.size());

View File

@@ -1445,7 +1445,7 @@ int EchoServer::start() {
int rc; int rc;
/* Create a new nsock pool */ /* Create a new nsock pool */
if ((nsp = nsp_new(NULL)) == NULL) if ((nsp = nsock_pool_new(NULL)) == NULL)
nping_fatal(QT_3, "Failed to create new pool. QUITTING.\n"); nping_fatal(QT_3, "Failed to create new pool. QUITTING.\n");
/* Set nsock trace level */ /* Set nsock trace level */

View File

@@ -152,12 +152,12 @@ int ProbeMode::init_nsock(){
struct timeval now; struct timeval now;
if( nsock_init==false ){ if( nsock_init==false ){
/* Create a new nsock pool */ /* Create a new nsock pool */
if ((nsp = nsp_new(NULL)) == NULL) if ((nsp = nsock_pool_new(NULL)) == NULL)
nping_fatal(QT_3, "Failed to create new pool. QUITTING.\n"); nping_fatal(QT_3, "Failed to create new pool. QUITTING.\n");
nsp_setdevice(nsp, o.getDevice()); nsock_pool_set_device(nsp, o.getDevice());
/* Allow broadcast addresses */ /* Allow broadcast addresses */
nsp_setbroadcast(nsp, 1); nsock_pool_set_broadcast(nsp, 1);
/* Set nsock trace level */ /* Set nsock trace level */
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
@@ -175,7 +175,7 @@ int ProbeMode::init_nsock(){
/** Cleans up the internal nsock pool and any other internal data that /** Cleans up the internal nsock pool and any other internal data that
* needs to be taken care of before destroying the object. */ * needs to be taken care of before destroying the object. */
int ProbeMode::cleanup(){ int ProbeMode::cleanup(){
nsp_delete(this->nsp); nsock_pool_delete(this->nsp);
return OP_SUCCESS; return OP_SUCCESS;
} /* End of cleanup() */ } /* End of cleanup() */

View File

@@ -70,26 +70,26 @@ static int gc_pool (lua_State *L)
{ {
nsock_pool *nsp = (nsock_pool *) lua_touserdata(L, 1); nsock_pool *nsp = (nsock_pool *) lua_touserdata(L, 1);
assert(*nsp != NULL); assert(*nsp != NULL);
nsp_delete(*nsp); nsock_pool_delete(*nsp);
*nsp = NULL; *nsp = NULL;
return 0; return 0;
} }
static nsock_pool new_pool (lua_State *L) static nsock_pool new_pool (lua_State *L)
{ {
nsock_pool nsp = nsp_new(NULL); nsock_pool nsp = nsock_pool_new(NULL);
nsock_pool *nspp; nsock_pool *nspp;
/* configure logging */ /* configure logging */
nsock_set_log_function(nsp, nmap_nsock_stderr_logger); nsock_set_log_function(nsp, nmap_nsock_stderr_logger);
nmap_adjust_loglevel(nsp, o.scriptTrace()); nmap_adjust_loglevel(nsp, o.scriptTrace());
nsp_setdevice(nsp, o.device); nsock_pool_set_device(nsp, o.device);
if (o.proxy_chain) if (o.proxy_chain)
nsp_set_proxychain(nsp, o.proxy_chain); nsock_pool_set_proxychain(nsp, o.proxy_chain);
nsp_setbroadcast(nsp, true); nsock_pool_set_broadcast(nsp, true);
nspp = (nsock_pool *) lua_newuserdata(L, sizeof(nsock_pool)); nspp = (nsock_pool *) lua_newuserdata(L, sizeof(nsock_pool));
*nspp = nsp; *nspp = nsp;
@@ -1110,7 +1110,7 @@ LUALIB_API int luaopen_nsock (lua_State *L)
#if HAVE_OPENSSL #if HAVE_OPENSSL
/* Value speed over security in SSL connections. */ /* Value speed over security in SSL connections. */
nsp_ssl_init_max_speed(nsp); nsock_pool_ssl_init_max_speed(nsp);
#endif #endif
luaL_newlibtable(L, l_nsock); luaL_newlibtable(L, l_nsock);

View File

@@ -200,7 +200,7 @@ void nsock_loop_quit(nsock_pool nsp);
/* This next function returns the errno style error code -- which is only valid /* This next function returns the errno style error code -- which is only valid
* if the status is NSOCK_LOOP_ERROR was returned by nsock_loop() */ * if the status is NSOCK_LOOP_ERROR was returned by nsock_loop() */
int nsp_geterrorcode(nsock_pool nsp); int nsock_pool_get_errorcode(nsock_pool nsp);
nsock_ssl nsi_getssl(nsock_iod nsockiod); nsock_ssl nsi_getssl(nsock_iod nsockiod);
@@ -214,34 +214,34 @@ nsock_ssl_session nsi_get0_ssl_session(nsock_iod nsockiod);
/* Sometimes it is useful to store a pointer to information inside the NSP so /* Sometimes it is useful to store a pointer to information inside the NSP so
* you can retrieve it during a callback. */ * you can retrieve it during a callback. */
void nsp_setud(nsock_pool nsp, void *data); void nsock_pool_set_udata(nsock_pool nsp, void *data);
/* And the function above wouldn't make much sense if we didn't have a way to /* And the function above wouldn't make much sense if we didn't have a way to
* retrieve that data ... */ * retrieve that data ... */
void *nsp_getud(nsock_pool nsp); void *nsock_pool_get_udata(nsock_pool nsp);
/* Turns on or off broadcast support on new sockets. Default is off (0, false) /* Turns on or off broadcast support on new sockets. Default is off (0, false)
* set in nsp_new(). Any non-zero (true) value sets SO_BROADCAST on all new * set in nsock_pool_new(). Any non-zero (true) value sets SO_BROADCAST on all
* sockets (value of optval will be used directly in the setsockopt() call). */ * new sockets (value of optval will be used directly in the setsockopt() call). */
void nsp_setbroadcast(nsock_pool nsp, int optval); void nsock_pool_set_broadcast(nsock_pool nsp, int optval);
/* Sets the name of the interface for new sockets to bind to. */ /* Sets the name of the interface for new sockets to bind to. */
void nsp_setdevice(nsock_pool nsp, const char *device); void nsock_pool_set_device(nsock_pool nsp, const char *device);
/* Initializes an Nsock pool to create SSL connections. This sets an internal /* Initializes an Nsock pool to create SSL connections. This sets an internal
* SSL_CTX, which is like a template that sets options for all connections that * SSL_CTX, which is like a template that sets options for all connections that
* are made from it. Returns the SSL_CTX so you can set your own options. */ * are made from it. Returns the SSL_CTX so you can set your own options. */
nsock_ssl_ctx nsp_ssl_init(nsock_pool ms_pool); nsock_ssl_ctx nsock_pool_ssl_init(nsock_pool ms_pool);
/* Initializes an Nsock pool to create SSL connections that emphasize speed over /* Initializes an Nsock pool to create SSL connections that emphasize speed over
* security. Insecure ciphers are used when they are faster and no certificate * security. Insecure ciphers are used when they are faster and no certificate
* verification is done. Returns the SSL_CTX so you can set your own options. */ * verification is done. Returns the SSL_CTX so you can set your own options. */
nsock_ssl_ctx nsp_ssl_init_max_speed(nsock_pool ms_pool); nsock_ssl_ctx nsock_pool_ssl_init_max_speed(nsock_pool ms_pool);
/* Enforce use of a given IO engine. /* Enforce use of a given IO engine.
* The engine parameter is a zero-terminated string that will be * The engine parameter is a zero-terminated string that will be
* strup()'ed by the library. No validity check is performed by this function, * strup()'ed by the library. No validity check is performed by this function,
* beware nsp_new() will fatal() if an invalid/unavailable engine name was * beware nsock_pool_new() will fatal() if an invalid/unavailable engine name was
* supplied before. * supplied before.
* Pass NULL to reset to default (use most efficient engine available). * Pass NULL to reset to default (use most efficient engine available).
* *
@@ -255,13 +255,13 @@ const char *nsock_list_engines(void);
* returns an nsock_pool event aggregator. In the case of error, NULL will be * returns an nsock_pool event aggregator. In the case of error, NULL will be
* returned. If you do not wish to immediately associate any userdata, pass in * returned. If you do not wish to immediately associate any userdata, pass in
* NULL. */ * NULL. */
nsock_pool nsp_new(void *userdata); nsock_pool nsock_pool_new(void *udata);
/* If nsp_new returned success, you must free the nsp when you are done with it /* If nsock_pool_new returned success, you must free the nsp when you are done with it
* to conserve memory (and in some cases, sockets). After this call, nsp may no * to conserve memory (and in some cases, sockets). After this call, nsp may no
* longer be used. Any pending events are sent an NSE_STATUS_KILL callback and * longer be used. Any pending events are sent an NSE_STATUS_KILL callback and
* all outstanding iods are deleted. */ * all outstanding iods are deleted. */
void nsp_delete(nsock_pool nsp); void nsock_pool_delete(nsock_pool nsp);
/* Logging subsystem: set custom logging function. /* Logging subsystem: set custom logging function.
* (See nsock_logger_t type definition). */ * (See nsock_logger_t type definition). */
@@ -273,8 +273,8 @@ void nsock_set_loglevel(nsock_pool nsp, nsock_loglevel_t loglevel);
/* Parse a proxy chain description string and build a nsock_proxychain object /* Parse a proxy chain description string and build a nsock_proxychain object
* accordingly. If the optional nsock_pool parameter is passed in, it gets * accordingly. If the optional nsock_pool parameter is passed in, it gets
* associated to the chain object. The alternative is to pass nsp=NULL and call * associated to the chain object. The alternative is to pass nsp=NULL and call
* nsp_set_proxychain() manually. Whatever is done, the chain object has to be * nsock_pool_set_proxychain() manually. Whatever is done, the chain object has
* deleted by the caller, using proxychain_delete(). */ * to be deleted by the caller, using proxychain_delete(). */
int nsock_proxychain_new(const char *proxystr, nsock_proxychain *chain, nsock_pool nspool); int nsock_proxychain_new(const char *proxystr, nsock_proxychain *chain, nsock_pool nspool);
/* If nsock_proxychain_new() returned success, caller has to free the chain /* If nsock_proxychain_new() returned success, caller has to free the chain
@@ -284,7 +284,7 @@ void nsock_proxychain_delete(nsock_proxychain chain);
/* Assign a previously created proxychain object to a nsock pool. After this, /* Assign a previously created proxychain object to a nsock pool. After this,
* new connections requests will be issued through the chain of proxies (if * new connections requests will be issued through the chain of proxies (if
* possible). */ * possible). */
int nsp_set_proxychain(nsock_pool nspool, nsock_proxychain chain); int nsock_pool_set_proxychain(nsock_pool nspool, nsock_proxychain chain);
/* nsock_event handles a single event. Its ID is generally returned when the /* nsock_event handles a single event. Its ID is generally returned when the
* event is created, and the event itself is included in callbacks * event is created, and the event itself is included in callbacks

View File

@@ -288,7 +288,7 @@ nsock_event_id nsock_connect_unixsock_stream(nsock_pool nsp, nsock_iod nsiod, ns
get_unixsock_path(ss), nsi->id, nse->id); get_unixsock_path(ss), nsi->id, nse->id);
nsock_connect_internal(ms, nse, SOCK_STREAM, 0, ss, sslen, 0); nsock_connect_internal(ms, nse, SOCK_STREAM, 0, ss, sslen, 0);
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
@@ -314,7 +314,7 @@ nsock_event_id nsock_connect_unixsock_datagram(nsock_pool nsp, nsock_iod nsiod,
get_unixsock_path(ss), nsi->id, nse->id); get_unixsock_path(ss), nsi->id, nse->id);
nsock_connect_internal(ms, nse, SOCK_DGRAM, 0, ss, sslen, 0); nsock_connect_internal(ms, nse, SOCK_DGRAM, 0, ss, sslen, 0);
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
} }
@@ -343,7 +343,7 @@ nsock_event_id nsock_connect_tcp(nsock_pool nsp, nsock_iod ms_iod, nsock_ev_hand
/* Do the actual connect() */ /* Do the actual connect() */
nsock_connect_internal(ms, nse, SOCK_STREAM, IPPROTO_TCP, ss, sslen, port); nsock_connect_internal(ms, nse, SOCK_STREAM, IPPROTO_TCP, ss, sslen, port);
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
} }
@@ -371,7 +371,7 @@ nsock_event_id nsock_connect_sctp(nsock_pool nsp, nsock_iod ms_iod, nsock_ev_han
/* Do the actual connect() */ /* Do the actual connect() */
nsock_connect_internal(ms, nse, SOCK_STREAM, IPPROTO_SCTP, ss, sslen, port); nsock_connect_internal(ms, nse, SOCK_STREAM, IPPROTO_SCTP, ss, sslen, port);
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
} }
@@ -397,7 +397,7 @@ nsock_event_id nsock_connect_ssl(nsock_pool nsp, nsock_iod nsiod, nsock_ev_handl
struct nevent *nse; struct nevent *nse;
if (!ms->sslctx) if (!ms->sslctx)
nsp_ssl_init(ms); nsock_pool_ssl_init(ms);
assert(nsi->state == NSIOD_STATE_INITIAL || nsi->state == NSIOD_STATE_UNKNOWN); assert(nsi->state == NSIOD_STATE_INITIAL || nsi->state == NSIOD_STATE_UNKNOWN);
@@ -413,7 +413,7 @@ nsock_event_id nsock_connect_ssl(nsock_pool nsp, nsock_iod nsiod, nsock_ev_handl
/* Do the actual connect() */ /* Do the actual connect() */
nsock_connect_internal(ms, nse, SOCK_STREAM, proto, ss, sslen, port); nsock_connect_internal(ms, nse, SOCK_STREAM, proto, ss, sslen, port);
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
@@ -435,7 +435,7 @@ nsock_event_id nsock_reconnect_ssl(nsock_pool nsp, nsock_iod nsiod, nsock_ev_han
struct nevent *nse; struct nevent *nse;
if (!ms->sslctx) if (!ms->sslctx)
nsp_ssl_init(ms); nsock_pool_ssl_init(ms);
nse = event_new(ms, NSE_TYPE_CONNECT_SSL, nsi, timeout_msecs, handler, userdata); nse = event_new(ms, NSE_TYPE_CONNECT_SSL, nsi, timeout_msecs, handler, userdata);
assert(nse); assert(nse);
@@ -449,7 +449,7 @@ nsock_event_id nsock_reconnect_ssl(nsock_pool nsp, nsock_iod nsiod, nsock_ev_han
/* Do the actual connect() */ /* Do the actual connect() */
nse->event_done = 0; nse->event_done = 0;
nse->status = NSE_STATUS_SUCCESS; nse->status = NSE_STATUS_SUCCESS;
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
@@ -486,7 +486,7 @@ nsock_event_id nsock_connect_udp(nsock_pool nsp, nsock_iod nsiod, nsock_ev_handl
inet_ntop_ez(ss, sslen), port, nsi->id, nse->id); inet_ntop_ez(ss, sslen), port, nsi->id, nse->id);
nsock_connect_internal(ms, nse, SOCK_DGRAM, IPPROTO_UDP, ss, sslen, port); nsock_connect_internal(ms, nse, SOCK_DGRAM, IPPROTO_UDP, ss, sslen, port);
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
} }

View File

@@ -416,7 +416,7 @@ void handle_connect_result(struct npool *ms, struct nevent *nse, enum nse_status
/* At this point the TCP connection is done, whether successful or not. /* At this point the TCP connection is done, whether successful or not.
* Therefore decrease the read/write listen counts that were incremented in * Therefore decrease the read/write listen counts that were incremented in
* nsp_add_event. In the SSL case, we may increase one of the counts depending * nsock_pool_add_event. In the SSL case, we may increase one of the counts depending
* on whether SSL_connect returns an error of SSL_ERROR_WANT_READ or * on whether SSL_connect returns an error of SSL_ERROR_WANT_READ or
* SSL_ERROR_WANT_WRITE. In that case we will re-enter this function, but we * SSL_ERROR_WANT_WRITE. In that case we will re-enter this function, but we
* don't want to execute this block again. */ * don't want to execute this block again. */
@@ -477,7 +477,7 @@ void handle_connect_result(struct npool *ms, struct nevent *nse, enum nse_status
/* SSLv3-only and TLSv1-only servers can't be connected to when the /* SSLv3-only and TLSv1-only servers can't be connected to when the
* SSL_OP_NO_SSLv2 option is not set, which is the case when the pool * SSL_OP_NO_SSLv2 option is not set, which is the case when the pool
* was initialized with nsp_ssl_init_max_speed. Try reconnecting with * was initialized with nsock_pool_ssl_init_max_speed. Try reconnecting with
* SSL_OP_NO_SSLv2. Never downgrade a NO_SSLv2 connection to one that * SSL_OP_NO_SSLv2. Never downgrade a NO_SSLv2 connection to one that
* might use SSLv2. */ * might use SSLv2. */
nsock_log_info(ms, "EID %li reconnecting with SSL_OP_NO_SSLv2", nse->id); nsock_log_info(ms, "EID %li reconnecting with SSL_OP_NO_SSLv2", nse->id);
@@ -1237,7 +1237,7 @@ const struct timeval *nsock_gettimeofday() {
/* Adds an event to the appropriate nsp event list, handles housekeeping such as /* Adds an event to the appropriate nsp event list, handles housekeeping such as
* adjusting the descriptor select/poll lists, registering the timeout value, * adjusting the descriptor select/poll lists, registering the timeout value,
* etc. */ * etc. */
void nsp_add_event(struct npool *nsp, struct nevent *nse) { void nsock_pool_add_event(struct npool *nsp, struct nevent *nse) {
nsock_log_debug(nsp, "NSE #%lu: Adding event (timeout in %ldms)", nsock_log_debug(nsp, "NSE #%lu: Adding event (timeout in %ldms)",
nse->id, nse->id,
(long)TIMEVAL_MSEC_SUBTRACT(nse->timeout, nsock_tod)); (long)TIMEVAL_MSEC_SUBTRACT(nse->timeout, nsock_tod));

View File

@@ -209,7 +209,7 @@ struct npool {
#endif #endif
/* Optional proxy chain (NULL is not set). Can only be set once per NSP (using /* Optional proxy chain (NULL is not set). Can only be set once per NSP (using
* nsock_proxychain_new() or nsp_set_proxychain(). */ * nsock_proxychain_new() or nsock_pool_set_proxychain(). */
struct proxy_chain *px_chain; struct proxy_chain *px_chain;
}; };
@@ -458,7 +458,7 @@ void event_delete(struct npool *nsp, struct nevent *nse);
/* Add an event to the appropriate nsp event list, handles housekeeping such as /* Add an event to the appropriate nsp event list, handles housekeeping such as
* adjusting the descriptor select/poll lists, registering the timeout value, * adjusting the descriptor select/poll lists, registering the timeout value,
* etc. */ * etc. */
void nsp_add_event(struct npool *nsp, struct nevent *nse); void nsock_pool_add_event(struct npool *nsp, struct nevent *nse);
void nsock_connect_internal(struct npool *ms, struct nevent *nse, int type, int proto, struct sockaddr_storage *ss, size_t sslen, unsigned short port); void nsock_connect_internal(struct npool *ms, struct nevent *nse, int type, int proto, struct sockaddr_storage *ss, size_t sslen, unsigned short port);

View File

@@ -370,7 +370,7 @@ nsock_event_id nsock_pcap_read_packet(nsock_pool nsp, nsock_iod nsiod,
nsock_log_info(ms, "Pcap read request from IOD #%li EID %li", nsi->id, nse->id); nsock_log_info(ms, "Pcap read request from IOD #%li EID %li", nsi->id, nse->id);
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
} }

View File

@@ -89,35 +89,35 @@ static void nsock_library_initialize(void);
/* This next function returns the errno style error code -- which is only /* This next function returns the errno style error code -- which is only
* valid if the status NSOCK_LOOP_ERROR was returned by nsock_loop() */ * valid if the status NSOCK_LOOP_ERROR was returned by nsock_loop() */
int nsp_geterrorcode(nsock_pool nsp) { int nsock_pool_get_errorcode(nsock_pool nsp) {
struct npool *mt = (struct npool *)nsp; struct npool *mt = (struct npool *)nsp;
return mt->errnum; return mt->errnum;
} }
/* Sometimes it is useful to store a pointer to information inside /* Sometimes it is useful to store a pointer to information inside
* the NSP so you can retrieve it during a callback. */ * the NSP so you can retrieve it during a callback. */
void nsp_setud(nsock_pool nsp, void *data) { void nsock_pool_set_udata(nsock_pool nsp, void *data) {
struct npool *mt = (struct npool *)nsp; struct npool *mt = (struct npool *)nsp;
mt->userdata = data; mt->userdata = data;
} }
/* And the define above wouldn't make much sense if we didn't have a way /* And the define above wouldn't make much sense if we didn't have a way
* to retrieve that data ... */ * to retrieve that data ... */
void *nsp_getud(nsock_pool nsp) { void *nsock_pool_get_udata(nsock_pool nsp) {
struct npool *mt = (struct npool *)nsp; struct npool *mt = (struct npool *)nsp;
return mt->userdata; return mt->userdata;
} }
/* Turns on or off broadcast support on new sockets. Default is off (0, false) /* Turns on or off broadcast support on new sockets. Default is off (0, false)
* set in nsp_new(). Any non-zero (true) value sets SO_BROADCAST on all new * set in nsock_pool_new(). Any non-zero (true) value sets SO_BROADCAST on all new
* sockets (value of optval will be used directly in the setsockopt() call */ * sockets (value of optval will be used directly in the setsockopt() call */
void nsp_setbroadcast(nsock_pool nsp, int optval) { void nsock_pool_set_broadcast(nsock_pool nsp, int optval) {
struct npool *mt = (struct npool *)nsp; struct npool *mt = (struct npool *)nsp;
mt->broadcast = optval; mt->broadcast = optval;
} }
/* Sets the name of the interface for new sockets to bind to. */ /* Sets the name of the interface for new sockets to bind to. */
void nsp_setdevice(nsock_pool nsp, const char *device) { void nsock_pool_set_device(nsock_pool nsp, const char *device) {
struct npool *mt = (struct npool *)nsp; struct npool *mt = (struct npool *)nsp;
mt->device = device; mt->device = device;
} }
@@ -136,7 +136,7 @@ static int expirable_cmp(gh_hnode_t *n1, gh_hnode_t *n2) {
* returns an nsock_pool event aggregator. In the case of error, NULL will be * returns an nsock_pool event aggregator. In the case of error, NULL will be
* returned. If you do not wish to immediately associate any userdata, pass in * returned. If you do not wish to immediately associate any userdata, pass in
* NULL. */ * NULL. */
nsock_pool nsp_new(void *userdata) { nsock_pool nsock_pool_new(void *userdata) {
struct npool *nsp; struct npool *nsp;
/* initialize the library in not already done */ /* initialize the library in not already done */
@@ -189,11 +189,11 @@ nsock_pool nsp_new(void *userdata) {
return (nsock_pool)nsp; return (nsock_pool)nsp;
} }
/* If nsp_new returned success, you must free the nsp when you are done with it /* If nsock_pool_new returned success, you must free the nsp when you are done with it
* to conserve memory (and in some cases, sockets). After this call, nsp may no * to conserve memory (and in some cases, sockets). After this call, nsp may no
* longer be used. Any pending events are sent an NSE_STATUS_KILL callback and * longer be used. Any pending events are sent an NSE_STATUS_KILL callback and
* all outstanding iods are deleted. */ * all outstanding iods are deleted. */
void nsp_delete(nsock_pool ms_pool) { void nsock_pool_delete(nsock_pool ms_pool) {
struct npool *nsp = (struct npool *)ms_pool; struct npool *nsp = (struct npool *)ms_pool;
struct nevent *nse; struct nevent *nse;
struct niod *nsi; struct niod *nsi;

View File

@@ -109,7 +109,7 @@ int nsock_proxychain_new(const char *proxystr, nsock_proxychain *chain, nsock_po
} }
if (nsp) { if (nsp) {
if (nsp_set_proxychain(nspool, pxc) < 0) { if (nsock_pool_set_proxychain(nspool, pxc) < 0) {
nsock_proxychain_delete(pxc); nsock_proxychain_delete(pxc);
return -1; return -1;
} }
@@ -137,7 +137,7 @@ void nsock_proxychain_delete(nsock_proxychain chain) {
} }
} }
int nsp_set_proxychain(nsock_pool nspool, nsock_proxychain chain) { int nsock_pool_set_proxychain(nsock_pool nspool, nsock_proxychain chain) {
struct npool *nsp = (struct npool *)nspool; struct npool *nsp = (struct npool *)nspool;
if (nsp && nsp->px_chain) { if (nsp && nsp->px_chain) {

View File

@@ -81,7 +81,7 @@ nsock_event_id nsock_readlines(nsock_pool nsp, nsock_iod ms_iod,
nse->readinfo.read_type = NSOCK_READLINES; nse->readinfo.read_type = NSOCK_READLINES;
nse->readinfo.num = nlines; nse->readinfo.num = nlines;
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
} }
@@ -104,7 +104,7 @@ nsock_event_id nsock_readbytes(nsock_pool nsp, nsock_iod ms_iod,
nse->readinfo.read_type = NSOCK_READBYTES; nse->readinfo.read_type = NSOCK_READBYTES;
nse->readinfo.num = nbytes; nse->readinfo.num = nbytes;
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
} }
@@ -127,7 +127,7 @@ nsock_event_id nsock_read(nsock_pool nsp, nsock_iod ms_iod,
nse->readinfo.read_type = NSOCK_READ; nse->readinfo.read_type = NSOCK_READ;
nsp_add_event(ms, nse); nsock_pool_add_event(ms, nse);
return nse->id; return nse->id;
} }

View File

@@ -80,8 +80,8 @@
extern struct timeval nsock_tod; extern struct timeval nsock_tod;
/* Create an SSL_CTX and do initialization that is common to nsp_ssl_init and /* Create an SSL_CTX and do initialization that is common to nsock_pool_ssl_init and
* nsp_ssl_init_max_speed. */ * nsock_pool_ssl_init_max_speed. */
static SSL_CTX *ssl_init_common() { static SSL_CTX *ssl_init_common() {
SSL_CTX *ctx; SSL_CTX *ctx;
@@ -109,7 +109,7 @@ static SSL_CTX *ssl_init_common() {
* are made from it. The connections made from this context will use only secure * are made from it. The connections made from this context will use only secure
* ciphers but no server certificate verification is done. Returns the SSL_CTX * ciphers but no server certificate verification is done. Returns the SSL_CTX
* so you can set your own options. */ * so you can set your own options. */
nsock_ssl_ctx nsp_ssl_init(nsock_pool ms_pool) { nsock_ssl_ctx nsock_pool_ssl_init(nsock_pool ms_pool) {
struct npool *ms = (struct npool *)ms_pool; struct npool *ms = (struct npool *)ms_pool;
char rndbuf[128]; char rndbuf[128];
@@ -123,7 +123,7 @@ nsock_ssl_ctx nsp_ssl_init(nsock_pool ms_pool) {
get_random_bytes(rndbuf, sizeof(rndbuf)); get_random_bytes(rndbuf, sizeof(rndbuf));
RAND_add(rndbuf, sizeof(rndbuf), 0); RAND_add(rndbuf, sizeof(rndbuf), 0);
if (!RAND_status()) if (!RAND_status())
fatal("nsp_ssl_init: Failed to seed OpenSSL PRNG (RAND_status returned false)."); fatal("nsock_pool_ssl_init: Failed to seed OpenSSL PRNG (RAND_status returned false).");
/* By default, do no server certificate verification. To enable it, do /* By default, do no server certificate verification. To enable it, do
* something like: * something like:
@@ -151,7 +151,7 @@ nsock_ssl_ctx nsp_ssl_init(nsock_pool ms_pool) {
/* Initializes an Nsock pool to create SSL connections that emphasize speed over /* Initializes an Nsock pool to create SSL connections that emphasize speed over
* security. Insecure ciphers are used when they are faster and no certificate * security. Insecure ciphers are used when they are faster and no certificate
* verification is done. Returns the SSL_CTX so you can set your own options. */ * verification is done. Returns the SSL_CTX so you can set your own options. */
nsock_ssl_ctx nsp_ssl_init_max_speed(nsock_pool ms_pool) { nsock_ssl_ctx nsock_pool_ssl_init_max_speed(nsock_pool ms_pool) {
struct npool *ms = (struct npool *)ms_pool; struct npool *ms = (struct npool *)ms_pool;
char rndbuf[128]; char rndbuf[128];
@@ -201,11 +201,11 @@ int nsi_ssl_post_connect_verify(const nsock_iod nsockiod) {
#else /* NOT HAVE_OPENSSL */ #else /* NOT HAVE_OPENSSL */
nsock_ssl_ctx nsp_ssl_init(nsock_pool ms_pool) { nsock_ssl_ctx nsock_pool_ssl_init(nsock_pool ms_pool) {
fatal("%s called with no OpenSSL support", __func__); fatal("%s called with no OpenSSL support", __func__);
} }
nsock_ssl_ctx nsp_ssl_init_max_speed(nsock_pool ms_pool) { nsock_ssl_ctx nsock_pool_ssl_init_max_speed(nsock_pool ms_pool) {
fatal("%s called with no OpenSSL support", __func__); fatal("%s called with no OpenSSL support", __func__);
} }

View File

@@ -73,7 +73,7 @@ nsock_event_id nsock_timer_create(nsock_pool ms_pool, nsock_ev_handler handler,
nsock_log_info(nsp, "Timer created - %dms from now. EID %li", timeout_msecs, nsock_log_info(nsp, "Timer created - %dms from now. EID %li", timeout_msecs,
nse->id); nse->id);
nsp_add_event(nsp, nse); nsock_pool_add_event(nsp, nse);
return nse->id; return nse->id;
} }

View File

@@ -117,7 +117,7 @@ nsock_event_id nsock_sendto(nsock_pool ms_pool, nsock_iod ms_iod, nsock_ev_handl
fs_cat(&nse->iobuf, data, datalen); fs_cat(&nse->iobuf, data, datalen);
nsp_add_event(nsp, nse); nsock_pool_add_event(nsp, nse);
return nse->id; return nse->id;
} }
@@ -155,7 +155,7 @@ nsock_event_id nsock_write(nsock_pool ms_pool, nsock_iod ms_iod,
fs_cat(&nse->iobuf, data, datalen); fs_cat(&nse->iobuf, data, datalen);
nsp_add_event(nsp, nse); nsock_pool_add_event(nsp, nse);
return nse->id; return nse->id;
} }
@@ -224,7 +224,7 @@ nsock_event_id nsock_printf(nsock_pool ms_pool, nsock_iod ms_iod,
if (buf2 != buf) if (buf2 != buf)
free(buf2); free(buf2);
nsp_add_event(nsp, nse); nsock_pool_add_event(nsp, nse);
return nse->id; return nse->id;
} }

View File

@@ -2272,7 +2272,7 @@ static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *m
enum nse_type type = nse_type(nse); enum nse_type type = nse_type(nse);
ServiceNFO *svc = (ServiceNFO *) mydata; ServiceNFO *svc = (ServiceNFO *) mydata;
ServiceProbe *probe = svc->currentProbe(); ServiceProbe *probe = svc->currentProbe();
ServiceGroup *SG = (ServiceGroup *) nsp_getud(nsp); ServiceGroup *SG = (ServiceGroup *) nsock_pool_get_udata(nsp);
assert(type == NSE_TYPE_CONNECT || type == NSE_TYPE_CONNECT_SSL); assert(type == NSE_TYPE_CONNECT || type == NSE_TYPE_CONNECT_SSL);
@@ -2341,7 +2341,7 @@ static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *myd
ServiceGroup *SG; ServiceGroup *SG;
int err; int err;
SG = (ServiceGroup *) nsp_getud(nsp); SG = (ServiceGroup *) nsock_pool_get_udata(nsp);
nsi = nse_iod(nse); nsi = nse_iod(nse);
// Check if a status message was requested // Check if a status message was requested
@@ -2390,7 +2390,7 @@ static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *myda
enum nse_type type = nse_type(nse); enum nse_type type = nse_type(nse);
ServiceNFO *svc = (ServiceNFO *) mydata; ServiceNFO *svc = (ServiceNFO *) mydata;
ServiceProbe *probe = svc->currentProbe(); ServiceProbe *probe = svc->currentProbe();
ServiceGroup *SG = (ServiceGroup *) nsp_getud(nsp); ServiceGroup *SG = (ServiceGroup *) nsock_pool_get_udata(nsp);
const u8 *readstr; const u8 *readstr;
int readstrlen; int readstrlen;
const struct MatchDetails *MD; const struct MatchDetails *MD;
@@ -2752,21 +2752,21 @@ int service_scan(std::vector<Target *> &Targets) {
// Lets create a nsock pool for managing all the concurrent probes // Lets create a nsock pool for managing all the concurrent probes
// Store the servicegroup in there for availability in callbacks // Store the servicegroup in there for availability in callbacks
if ((nsp = nsp_new(SG)) == NULL) { if ((nsp = nsock_pool_new(SG)) == NULL) {
fatal("%s() failed to create new nsock pool.", __func__); fatal("%s() failed to create new nsock pool.", __func__);
} }
nsock_set_log_function(nsp, nmap_nsock_stderr_logger); nsock_set_log_function(nsp, nmap_nsock_stderr_logger);
nmap_adjust_loglevel(nsp, o.versionTrace()); nmap_adjust_loglevel(nsp, o.versionTrace());
nsp_setdevice(nsp, o.device); nsock_pool_set_device(nsp, o.device);
if (o.proxy_chain) { if (o.proxy_chain) {
nsp_set_proxychain(nsp, o.proxy_chain); nsock_pool_set_proxychain(nsp, o.proxy_chain);
} }
#if HAVE_OPENSSL #if HAVE_OPENSSL
/* We don't care about connection security in version detection. */ /* We don't care about connection security in version detection. */
nsp_ssl_init_max_speed(nsp); nsock_pool_ssl_init_max_speed(nsp);
#endif #endif
launchSomeServiceProbes(nsp, SG); launchSomeServiceProbes(nsp, SG);
@@ -2778,11 +2778,11 @@ int service_scan(std::vector<Target *> &Targets) {
// OK! Lets start our main loop! // OK! Lets start our main loop!
looprc = nsock_loop(nsp, timeout); looprc = nsock_loop(nsp, timeout);
if (looprc == NSOCK_LOOP_ERROR) { if (looprc == NSOCK_LOOP_ERROR) {
int err = nsp_geterrorcode(nsp); int err = nsock_pool_get_errorcode(nsp);
fatal("Unexpected nsock_loop error. Error code %d (%s)", err, socket_strerror(err)); fatal("Unexpected nsock_loop error. Error code %d (%s)", err, socket_strerror(err));
} }
nsp_delete(nsp); nsock_pool_delete(nsp);
if (o.verbose) { if (o.verbose) {
char additional_info[128]; char additional_info[128];