Last active
October 10, 2022 06:41
-
-
Save ammarfaizi2/33684cb617b33f92ca2a3e57a62762d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/socket.h> | |
#define IFACE_NAME "wl0" | |
int connect(int fd, const struct sockaddr *daddr, socklen_t addrlen) | |
{ | |
int ret; | |
if (daddr->sa_family == AF_INET) | |
setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, IFACE_NAME, | |
sizeof(IFACE_NAME)); | |
__asm__ volatile ( | |
"syscall" | |
: [eax]"=a"(ret) | |
: [rax]"a"(42), [rdi]"D"(fd), [rsi]"S"(daddr), | |
[rdx]"d"(addrlen) | |
: "rcx", "r11", "memory" | |
); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment