summaryrefslogtreecommitdiff
path: root/gdhcp/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdhcp/common.c')
-rwxr-xr-xgdhcp/common.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gdhcp/common.c b/gdhcp/common.c
index 8f7a65cc..1d667d17 100755
--- a/gdhcp/common.c
+++ b/gdhcp/common.c
@@ -595,7 +595,8 @@ int dhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
int dhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
uint32_t source_ip, int source_port,
- uint32_t dest_ip, int dest_port)
+ uint32_t dest_ip, int dest_port,
+ const char *interface)
{
struct sockaddr_in client;
int fd, n, opt = 1;
@@ -609,6 +610,13 @@ int dhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
if (fd < 0)
return -errno;
+ if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,
+ interface, strlen(interface) + 1) < 0) {
+ int err = errno;
+ close(fd);
+ return -err;
+ }
+
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
int err = errno;
close(fd);