mirror of
https://github.com/nmap/nmap.git
synced 2026-01-01 20:39:02 +00:00
Consistently renamed nsi_XXX calls into nsock_iod_XXX
This is part of the effort to make nsock expose only nsock_ prefixed symbols and simplify the API.
This commit is contained in:
@@ -116,8 +116,8 @@ typedef struct npool *nsock_pool;
|
||||
* multiple event calls, but only one at a time. Also the event calls must be in
|
||||
* a "reasonable" order. For example, you might start with nsock_connect_tcp()
|
||||
* followed by a bunch of nsock_read* and nsock_write* calls. Then you either
|
||||
* destroy the iod for good with nsi_delete() and allocate a new one via nsi_new
|
||||
* for your next connection. */
|
||||
* destroy the iod for good with nsock_iod_delete() and allocate a new one via
|
||||
* nsock_iod_new for your next connection. */
|
||||
typedef struct niod *nsock_iod;
|
||||
|
||||
/* An event is created when you do various calls (for reading, writing,
|
||||
@@ -202,15 +202,14 @@ void nsock_loop_quit(nsock_pool nsp);
|
||||
* if the status is NSOCK_LOOP_ERROR was returned by nsock_loop() */
|
||||
int nsock_pool_get_errorcode(nsock_pool nsp);
|
||||
|
||||
nsock_ssl nsi_getssl(nsock_iod nsockiod);
|
||||
nsock_ssl nsock_iod_get_ssl(nsock_iod nsockiod);
|
||||
|
||||
/* Note that nsi_get1_ssl_session will increment the usage count of the
|
||||
* SSL_SESSION, since nsock does a free when the nsi is destroyed. It's up to
|
||||
* any calling function/etc to do a SSL_SESSION_free() on it.
|
||||
* nsi_get0_ssl_session doesn't increment, and is for informational purposes
|
||||
* only. */
|
||||
nsock_ssl_session nsi_get1_ssl_session(nsock_iod nsockiod);
|
||||
nsock_ssl_session nsi_get0_ssl_session(nsock_iod nsockiod);
|
||||
/* Note that nsock_iod_get_ssl_session will increment the usage count of the
|
||||
* SSL_SESSION if inc_ref is not zero, since nsock does a free when the IOD
|
||||
* is destroyed. It's up to any calling function/etc to do a SSL_SESSION_free()
|
||||
* on it. Passing in inc_ref=0 doesn't increment, and is for informational
|
||||
* purposes only. */
|
||||
nsock_ssl_session nsock_iod_get_ssl_session(nsock_iod nsockiod, int inc_ref);
|
||||
|
||||
/* Sometimes it is useful to store a pointer to information inside the NSP so
|
||||
* you can retrieve it during a callback. */
|
||||
@@ -371,23 +370,23 @@ char *nse_readbuf(nsock_event nse, int *nbytes);
|
||||
nsock_iod nse_iod(nsock_event nse);
|
||||
|
||||
/* nsock_iod is like a "file descriptor" for the nsock library. You use it to
|
||||
* request events. And here is how you create an nsock_iod. nsi_new returns
|
||||
* NULL if the iod cannot be allocated. Pass NULL as userdata if you don't want
|
||||
* to immediately associate any user data with the iod. */
|
||||
nsock_iod nsi_new(nsock_pool nsockp, void *userdata);
|
||||
* request events. And here is how you create an nsock_iod. nsock_iod_new
|
||||
* returns NULL if the iod cannot be allocated. Pass NULL as udata if you
|
||||
* don't want to immediately associate any user data with the IOD. */
|
||||
nsock_iod nsock_iod_new(nsock_pool nsockp, void *udata);
|
||||
|
||||
/* This version allows you to associate an existing sd with the msi so that you
|
||||
* can read/write it using the nsock infrastructure. For example, you may want
|
||||
* to watch for data from STDIN_FILENO at the same time as you read/write
|
||||
* various sockets. STDIN_FILENO is a special case, however. Any other sd is
|
||||
* dup()ed, so you may close or otherwise manipulate your copy. The duped copy
|
||||
* will be destroyed when the nsi is destroyed */
|
||||
nsock_iod nsi_new2(nsock_pool nsockp, int sd, void *userdata);
|
||||
* will be destroyed when the IOD is destroyed */
|
||||
nsock_iod nsock_iod_new2(nsock_pool nsockp, int sd, void *udata);
|
||||
|
||||
/* If msiod_new returned success, you must free the iod when you are done with
|
||||
* it to conserve memory (and in some cases, sockets). After this call,
|
||||
/* If nsock_iod_new returned success, you must free the iod when you are done
|
||||
* with it to conserve memory (and in some cases, sockets). After this call,
|
||||
* nsockiod may no longer be used -- you need to create a new one with
|
||||
* nsi_new(). pending_response tells what to do with any events that are
|
||||
* nsock_iod_new(). pending_response tells what to do with any events that are
|
||||
* pending on this nsock_iod. This can be NSOCK_PENDING_NOTIFY (send a KILL
|
||||
* notification to each event), NSOCK_PENDING_SILENT (do not send notification
|
||||
* to the killed events), or NSOCK_PENDING_ERROR (print an error message and
|
||||
@@ -398,15 +397,15 @@ enum nsock_del_mode {
|
||||
NSOCK_PENDING_ERROR,
|
||||
};
|
||||
|
||||
void nsi_delete(nsock_iod nsockiod, enum nsock_del_mode pending_response);
|
||||
void nsock_iod_delete(nsock_iod iod, enum nsock_del_mode pending_response);
|
||||
|
||||
/* Sometimes it is useful to store a pointer to information inside
|
||||
* the nsiod so you can retrieve it during a callback. */
|
||||
void nsi_setud(nsock_iod nsiod, void *data);
|
||||
void nsock_iod_set_udata(nsock_iod iod, void *udata);
|
||||
|
||||
/* And the function above wouldn't make much sense if we didn't have a way to
|
||||
* retrieve that data ... */
|
||||
void *nsi_getud(nsock_iod nsiod);
|
||||
void *nsock_iod_get_udata(nsock_iod iod);
|
||||
|
||||
/* I didn't want to do this. Its an ugly hack, but I suspect it will be
|
||||
* necessary. I certainly can't reproduce in nsock EVERYTHING you might want
|
||||
@@ -415,33 +414,33 @@ void *nsi_getud(nsock_iod nsiod);
|
||||
* "reasonable" things with it, like setting socket receive buffers. But don't
|
||||
* create havok by closing the descriptor! If the descriptor you get back is
|
||||
* -1, the iod does not currently possess a valid descriptor */
|
||||
int nsi_getsd(nsock_iod nsiod);
|
||||
int nsock_iod_get_sd(nsock_iod iod);
|
||||
|
||||
/* Returns the ID of an nsock_iod . This ID is always unique amongst ids for a
|
||||
* given nspool (unless you blow through billions of them). */
|
||||
unsigned long nsi_id(nsock_iod nsockiod);
|
||||
unsigned long nsock_iod_id(nsock_iod iod);
|
||||
|
||||
/* Returns Packets received in bytes */
|
||||
unsigned long nsi_get_read_count(nsock_iod nsockiod);
|
||||
unsigned long nsock_iod_get_read_count(nsock_iod iod);
|
||||
|
||||
/* Returns Packets sent in bytes */
|
||||
unsigned long nsi_get_write_count(nsock_iod nsockiod);
|
||||
unsigned long nsock_iod_get_write_count(nsock_iod iod);
|
||||
|
||||
/* Returns 1 if an NSI is communicating via SSL, 0 otherwise */
|
||||
int nsi_checkssl(nsock_iod nsockiod);
|
||||
int nsock_iod_check_ssl(nsock_iod iod);
|
||||
|
||||
/* Returns the remote peer port (or -1 if unavailable). Note the return value
|
||||
* is a whole int so that -1 can be distinguished from 65535. Port is returned
|
||||
* in host byte order. */
|
||||
int nsi_peerport(nsock_iod nsiod);
|
||||
int nsock_iod_get_peerport(nsock_iod iod);
|
||||
|
||||
/* Sets the local address to bind to before connect() */
|
||||
int nsi_set_localaddr(nsock_iod nsi, struct sockaddr_storage *ss, size_t sslen);
|
||||
int nsock_iod_set_localaddr(nsock_iod iod, struct sockaddr_storage *ss, size_t sslen);
|
||||
|
||||
/* Sets IPv4 options to apply before connect(). It makes a copy of the options,
|
||||
* so you can free() yours if necessary. This copy is freed when the iod is
|
||||
* destroyed */
|
||||
int nsi_set_ipoptions(nsock_iod nsi, void *ipopts, size_t ipoptslen);
|
||||
int nsock_iod_set_ipoptions(nsock_iod iod, void *ipopts, size_t ipoptslen);
|
||||
|
||||
/* Returns that host/port/protocol information for the last communication (or
|
||||
* comm. attempt) this nsi has been involved with. By "involved" with I mean
|
||||
@@ -455,11 +454,13 @@ int nsi_set_ipoptions(nsock_iod nsi, void *ipopts, size_t ipoptslen);
|
||||
* address space. The sockaddr members should actually be sockaddr_storage,
|
||||
* sockaddr_in6, or sockaddr_in with the socklen of them set appropriately (eg
|
||||
* sizeof(sockaddr_storage) if that is what you are passing). */
|
||||
int nsi_getlastcommunicationinfo(nsock_iod ms_iod, int *protocol, int *af, struct sockaddr *local, struct sockaddr *remote, size_t socklen);
|
||||
int nsock_iod_get_communication_info(nsock_iod iod, int *protocol, int *af,
|
||||
struct sockaddr *local,
|
||||
struct sockaddr *remote, size_t socklen);
|
||||
|
||||
/* Set the hostname of the remote host, for when that matters. This is currently
|
||||
* only used for Server Name Indication in SSL connections. */
|
||||
int nsi_set_hostname(nsock_iod nsi, const char *hostname);
|
||||
int nsock_iod_set_hostname(nsock_iod iod, const char *hostname);
|
||||
|
||||
/* EVENT CREATION FUNCTIONS
|
||||
* ---
|
||||
@@ -661,11 +662,12 @@ void nse_readpcap(nsock_event nsee, const unsigned char **l2_data,
|
||||
size_t *l2_len, const unsigned char **l3_data, size_t *l3_len,
|
||||
size_t *packet_len, struct timeval *ts);
|
||||
|
||||
/* Well. Just pcap-style datalink. Like DLT_EN10MB or DLT_SLIP. Check in pcap(3) manpage. */
|
||||
int nsi_pcap_linktype(nsock_iod nsiod);
|
||||
/* Well. Just pcap-style datalink.
|
||||
* Like DLT_EN10MB or DLT_SLIP. Check in pcap(3) manpage. */
|
||||
int nsock_iod_linktype(nsock_iod iod);
|
||||
|
||||
/* Is this nsiod a pcap descriptor? */
|
||||
int nsi_is_pcap(nsock_iod nsiod);
|
||||
int nsock_iod_is_pcap(nsock_iod iod);
|
||||
|
||||
#endif /* HAVE_PCAP */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user