1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-23 16:17:36 +02:00
openwrt-packages/net/wifidog/patches/020-Modify-get-ip-from-iface-method.patch
Ilya Lipnitskiy 5d8d4fbbcb
treewide: Run refresh on all packages
The crude loop I wrote to come up with this changeset:

  find -L package/feeds/packages/ -name patches | \
  sed 's/patches$/refresh/' | sort | xargs make

Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
2021-02-20 16:02:15 -08:00

27 lines
920 B
Diff

From 37b2dda9b1d62eb91028f6d590beddd36f7b79c8 Mon Sep 17 00:00:00 2001
From: Nathan Samson <nathan@nathansamson.be>
Date: Mon, 1 Feb 2016 21:37:22 +0100
Subject: [PATCH] Modify get ip from iface method.
This used to use a RAW socket, while now it used a DGRAM socket.
Previously it failed with operation not permitted, while this version
seems to work reliably.
--- a/src/util.c
+++ b/src/util.c
@@ -174,11 +174,13 @@ get_iface_ip(const char *ifname)
u_int32_t ip;
/* Create a socket */
- if ((sockd = socket(AF_INET, SOCK_RAW, htons(0x8086))) < 0) {
+ if ((sockd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
debug(LOG_ERR, "socket(): %s", strerror(errno));
return NULL;
}
+ /* I want to get an IPv4 IP address */
+ if_data.ifr_addr.sa_family = AF_INET;
/* Get IP of internal interface */
strncpy(if_data.ifr_name, ifname, 15);
if_data.ifr_name[15] = '\0';