mirror of
https://github.com/nmap/nmap.git
synced 2025-12-20 22:49:01 +00:00
Add nsock_setdevice function.
This function allows setting the device that will be used in SO_BINDTODEVICE setsockopt calls for all new sockets.
This commit is contained in:
@@ -95,6 +95,15 @@ static int nsock_make_socket(mspool *ms, msiod *iod, int family, int proto) {
|
||||
nsock_trace(ms, "Setting of IP options failed (IOD #%li)", iod->id);
|
||||
}
|
||||
}
|
||||
if (ms->device) {
|
||||
#ifdef SO_BINDTODEVICE
|
||||
errno = 0;
|
||||
if (setsockopt(iod->sd, SOL_SOCKET, SO_BINDTODEVICE, ms->device, strlen(ms->device) + 1) == -1) {
|
||||
if ((errno != EPERM && ms->tracelevel > 0) || ms->tracelevel > 5)
|
||||
nsock_trace(ms, "Setting of SO_BROADCAST failed (IOD #%li)", iod->id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (ms->broadcast) {
|
||||
if (setsockopt(iod->sd, SOL_SOCKET, SO_BROADCAST, (const char *)&(ms->broadcast), sizeof(int)) == -1) {
|
||||
if (ms->tracelevel > 0)
|
||||
|
||||
Reference in New Issue
Block a user