1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-10 17:59:04 +00:00

Implementation of UNIX-domain sockets for Nsock.

Implementation of UNIX-domain sockets functionality
for Nsock. Also some minor necessary changes to
existing Nsock functions, to work properly with
UNIX-domain sockets.
This commit is contained in:
david
2012-11-12 20:44:37 +00:00
parent c5f632382f
commit f01e3800fb
11 changed files with 221 additions and 48 deletions

View File

@@ -76,10 +76,14 @@ nsock_event_id nsock_sendto(nsock_pool ms_pool, nsock_iod ms_iod, nsock_ev_handl
nse = msevent_new(nsp, NSE_TYPE_WRITE, nsi, timeout_msecs, handler, userdata);
assert(nse);
if (sin->sin_family == AF_INET) {
if (saddr->sa_family == AF_INET) {
sin->sin_port = htons(port);
#if HAVE_SYS_UN_H
} else if (saddr->sa_family == AF_INET6) {
#else
} else {
assert(sin->sin_family == AF_INET6);
#endif
assert(saddr->sa_family == AF_INET6);
#if HAVE_IPV6
sin6->sin6_port = htons(port);
#else
@@ -107,9 +111,9 @@ nsock_event_id nsock_sendto(nsock_pool ms_pool, nsock_iod ms_iod, nsock_ev_handl
} else {
displaystr[0] = '\0';
}
nsock_trace(nsp, "Sendto request for %d bytes to IOD #%li EID %li [%s:%hu]%s",
nsock_trace(nsp, "Sendto request for %d bytes to IOD #%li EID %li [%s]%s",
datalen, nsi->id, nse->id,
inet_ntop_ez(&nse->writeinfo.dest, nse->writeinfo.destlen), port,
get_hostaddr_string(&nse->writeinfo.dest, nse->writeinfo.destlen, port),
displaystr);
}
@@ -147,8 +151,9 @@ nsock_event_id nsock_write(nsock_pool ms_pool, nsock_iod ms_iod,
replacenonprintable(displaystr + 2, datalen, '.');
} else displaystr[0] = '\0';
if (nsi->peerlen > 0)
nsock_trace(nsp, "Write request for %d bytes to IOD #%li EID %li [%s:%d]%s", datalen, nsi->id,
nse->id, inet_ntop_ez(&nsi->peer, nsi->peerlen), nsi_peerport(nsi), displaystr);
nsock_trace(nsp, "Write request for %d bytes to IOD #%li EID %li [%s]%s", datalen, nsi->id,
nse->id, get_hostaddr_string(&nsi->peer, nsi->peerlen, (unsigned short)nsi_peerport(nsi)),
displaystr);
else
nsock_trace(nsp, "Write request for %d bytes to IOD #%li EID %li (peer unspecified)%s", datalen,
nsi->id, nse->id, displaystr);
@@ -220,8 +225,9 @@ nsock_event_id nsock_printf(nsock_pool ms_pool, nsock_iod ms_iod,
displaystr[0] = '\0';
}
if (nsi->peerlen > 0)
nsock_trace(nsp, "Write request for %d bytes to IOD #%li EID %li [%s:%d]%s", strlength, nsi->id,
nse->id, inet_ntop_ez(&nsi->peer, nsi->peerlen), nsi_peerport(nsi), displaystr);
nsock_trace(nsp, "Write request for %d bytes to IOD #%li EID %li [%s]%s", strlength, nsi->id,
nse->id, get_hostaddr_string(&nsi->peer, nsi->peerlen, (unsigned short)nsi_peerport(nsi)),
displaystr);
else
nsock_trace(nsp, "Write request for %d bytes to IOD #%li EID %li (peer unspecified)%s", strlength,
nsi->id, nse->id, displaystr);