1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-21 15:09:02 +00:00

Improve indentation and comments in init_socket.

This commit is contained in:
david
2010-08-11 14:39:42 +00:00
parent c78dcce4d3
commit 852ad9440d

View File

@@ -2951,32 +2951,27 @@ static void ultrascan_port_probe_update(UltraScanInfo *USI, HostScanStats *hss,
/* We set the socket lingering so we will RST connection instead of wasting /* Set the socket lingering so we will RST connections instead of wasting
bandwidth with the four step close */ bandwidth with the four-step close. Set the source address if needed. */
static void init_socket(int sd) { static void init_socket(int sd) {
static int bind_failed = 0;
struct linger l; struct linger l;
int res;
static int bind_failed=0;
struct sockaddr_storage ss; struct sockaddr_storage ss;
size_t sslen; size_t sslen;
l.l_onoff = 1; l.l_onoff = 1;
l.l_linger = 0; l.l_linger = 0;
if (setsockopt(sd, SOL_SOCKET, SO_LINGER, (const char *) &l, sizeof(struct linger))) if (setsockopt(sd, SOL_SOCKET, SO_LINGER, (const char *) &l, sizeof(l)) != 0) {
{
error("Problem setting socket SO_LINGER, errno: %d", socket_errno()); error("Problem setting socket SO_LINGER, errno: %d", socket_errno());
perror("setsockopt"); perror("setsockopt");
} }
if (o.spoofsource && !bind_failed) if (o.spoofsource && !bind_failed) {
{
o.SourceSockAddr(&ss, &sslen); o.SourceSockAddr(&ss, &sslen);
res=bind(sd, (struct sockaddr*)&ss, sslen); if (bind(sd, (struct sockaddr*)&ss, sslen) != 0) {
if (res<0)
{
error("%s: Problem binding source address (%s), errno: %d", __func__, inet_socktop(&ss), socket_errno()); error("%s: Problem binding source address (%s), errno: %d", __func__, inet_socktop(&ss), socket_errno());
perror("bind"); perror("bind");
bind_failed=1; bind_failed = 1;
} }
} }
} }