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

Added a --nsock-engine option to nmap, nping and ncat to enforce use of a

given nsock IO engine. [Henri]
This commit is contained in:
henri
2012-03-01 09:05:02 +00:00
parent ee9b9eb0a7
commit b1086ac340
8 changed files with 57 additions and 4 deletions

View File

@@ -1,5 +1,8 @@
# Nmap Changelog ($Id$); -*-text-*-
o Added a --nsock-engine option to nmap, nping and ncat to enforce use of a
given nsock IO engine. [Henri]
o [NSE] Added support to broadcast-listener for extracting address, native vlan
and management IP address from CDP packets. [Tom]

View File

@@ -2860,6 +2860,23 @@ worth the extra time.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--nsock-engine
epoll|select</option>
<indexterm><primary><option>--nsock-engine</option></primary></indexterm>
<indexterm><primary>Nsock IO engine</primary></indexterm>
</term>
<listitem>
<para>Enforce use of a given nsock IO multiplexing engine. Only the
<literal>select(2)</literal>-based fallback engine is guaranteed to be
available on your system. Engines are named after the name of the IO
management facility they leverage. Engines currenty implemented are
<literal>epoll</literal> and <literal>select</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-T

View File

@@ -262,6 +262,7 @@ int main(int argc, char *argv[])
{"proxy", required_argument, NULL, 0},
{"proxy-type", required_argument, NULL, 0},
{"proxy-auth", required_argument, NULL, 0},
{"nsock-engine", required_argument, NULL, 0},
#ifdef HAVE_OPENSSL
{"ssl", no_argument, &o.ssl, 1},
{"ssl-cert", required_argument, NULL, 0},
@@ -412,6 +413,10 @@ int main(int argc, char *argv[])
bye("You can't specify more than one --proxy-auth.");
o.proxy_auth = Strdup(optarg);
}
else if (strcmp(long_options[option_index].name, "nsock-engine") == 0)
{
nsock_set_default_engine(optarg);
}
else if (strcmp(long_options[option_index].name, "broker") == 0)
{
o.broker = 1;

View File

@@ -573,6 +573,8 @@ void parse_options(int argc, char **argv) {
{"source-port", required_argument, 0, 'g'},
{"randomize_hosts", no_argument, 0, 0},
{"randomize-hosts", no_argument, 0, 0},
{"nsock_engine", required_argument, 0, 0},
{"nsock-engine", required_argument, 0, 0},
{"osscan_limit", no_argument, 0, 0}, /* skip OSScan if no open ports */
{"osscan-limit", no_argument, 0, 0}, /* skip OSScan if no open ports */
{"osscan_guess", no_argument, 0, 0}, /* More guessing flexability */
@@ -793,6 +795,8 @@ void parse_options(int argc, char **argv) {
|| strcmp(long_options[option_index].name, "rH") == 0) {
o.randomize_hosts = 1;
o.ping_group_sz = PING_GROUP_SZ * 4;
} else if (optcmp(long_options[option_index].name, "nsock-engine") == 0) {
nsock_set_default_engine(optarg);
} else if (optcmp(long_options[option_index].name, "osscan-limit") == 0) {
o.osscan_limit = 1;
} else if (optcmp(long_options[option_index].name, "osscan-guess") == 0
@@ -2111,6 +2115,7 @@ void nmap_free_mem() {
free_services();
AllProbes::service_scan_free();
traceroute_hop_cache_clear();
nsock_set_default_engine(NULL);
}
/* Reads in a (normal or machine format) Nmap log file and gathers enough

View File

@@ -271,6 +271,7 @@ char errstr[256];
{"send-ip", no_argument, 0, 0},
{"bpf-filter", required_argument, 0, 0},
{"filter", required_argument, 0, 0},
{"nsock-engine", required_argument, 0, 0},
{"no-capture", no_argument, 0, 'N'},
{"hide-sent", no_argument, 0, 'H'},
@@ -954,7 +955,9 @@ char errstr[256];
o.setBPFFilterSpec( optarg );
if( o.issetDisablePacketCapture() && o.disablePacketCapture()==true )
outError(QT_2, "Warning: There is no point on specifying a BPF filter if you disable packet capture. BPF filter will be ignored.");
} else if (optcmp(long_options[option_index].name, "nsock-engine") == 0){
nsock_set_default_engine(optarg);
/* Output Options */
} else if (optcmp(long_options[option_index].name, "quiet") == 0 ){
o.setVerbosity(-4);

View File

@@ -193,6 +193,14 @@ nsock_ssl_ctx nsp_ssl_init(nsock_pool ms_pool);
* 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);
/* Enforce use of a given IO engine.
* The engine parameter is a zero-terminated string that will be
* 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
* supplied before.
* Pass NULL to reset to default (use most efficient engine available). */
void nsock_set_default_engine(char *engine);
/* And here is how you create an nsock_pool. This allocates, initializes, and
* 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

View File

@@ -83,8 +83,10 @@ static struct io_engine *available_engines[] = {
NULL
};
static char *engine_hint;
struct io_engine *get_io_engine(const char *engine_hint) {
struct io_engine *get_io_engine(void) {
struct io_engine *engine = NULL;
int i;
@@ -105,3 +107,13 @@ struct io_engine *get_io_engine(const char *engine_hint) {
return engine;
}
void nsock_set_default_engine(char *engine) {
if (engine_hint)
free(engine_hint);
if (engine)
engine_hint = strdup(engine);
else
engine_hint = NULL;
}

View File

@@ -81,7 +81,7 @@ static int nsocklib_initialized = 0;
/* defined in nsock_engines.h */
struct io_engine *get_io_engine(const char *engine_hint);
struct io_engine *get_io_engine(void);
/* ---- INTERNAL FUNCTIONS PROTOTYPES ---- */
static void nsock_library_initialize(void);
@@ -170,7 +170,7 @@ nsock_pool nsp_new(void *userdata) {
nsp->userdata = userdata;
nsp->engine = get_io_engine(NULL);
nsp->engine = get_io_engine();
nsp->engine->init(nsp);
/* initialize IO events lists */