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

Use socket_bindtodevice instead of bare setsockopt in Nsock.

This commit is contained in:
david
2012-11-16 21:02:57 +00:00
parent 8dd3a8a66e
commit 641dddafb5

View File

@@ -104,13 +104,11 @@ static int nsock_make_socket(mspool *ms, msiod *iod, int family, int type, int p
} }
} }
if (ms->device) { if (ms->device) {
#ifdef SO_BINDTODEVICE
errno = 0; errno = 0;
if (setsockopt(iod->sd, SOL_SOCKET, SO_BINDTODEVICE, ms->device, strlen(ms->device) + 1) == -1) { if (!socket_bindtodevice(iod->sd, ms->device)) {
if ((errno != EPERM && ms->tracelevel > 0) || ms->tracelevel > 5) if ((errno != EPERM && ms->tracelevel > 0) || ms->tracelevel > 5)
nsock_trace(ms, "Setting of SO_BINDTODEVICE failed (IOD #%li)", iod->id); nsock_trace(ms, "Setting of SO_BINDTODEVICE failed (IOD #%li)", iod->id);
} }
#endif
} }
if (ms->broadcast) { if (ms->broadcast) {
if (setsockopt(iod->sd, SOL_SOCKET, SO_BROADCAST, (const char *)&(ms->broadcast), sizeof(int)) == -1) { if (setsockopt(iod->sd, SOL_SOCKET, SO_BROADCAST, (const char *)&(ms->broadcast), sizeof(int)) == -1) {