Skip to content

Commit dd7b7d7

Browse files
committed
socket_bindtodevice: make whole function conditional on SO_BINDTODEVICE definition
1 parent 156e848 commit dd7b7d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

nbase/nbase_misc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ int block_socket(int sd) {
264264
/* Use the SO_BINDTODEVICE sockopt to bind with a specific interface (Linux
265265
only). Pass NULL or an empty string to remove device binding. */
266266
int socket_bindtodevice(int sd, const char *device) {
267+
#ifdef SO_BINDTODEVICE
267268
char padded[sizeof(int)];
268269
size_t len;
269270

@@ -281,7 +282,6 @@ int socket_bindtodevice(int sd, const char *device) {
281282
len = sizeof(padded);
282283
}
283284

284-
#ifdef SO_BINDTODEVICE
285285
/* Linux-specific sockopt asking to use a specific interface. See socket(7). */
286286
if (setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, device, len) < 0)
287287
return 0;

0 commit comments

Comments
 (0)