mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 17:42:41 +00:00
ucentral: development update
* update ieee8021x * update schema * update ucode * add dhcp option82 support Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
From db9935dc0f0dd2e2e081961a2f3550bbea1e009c Mon Sep 17 00:00:00 2001
|
||||
From 3c182c1abcf3f1764820acab816d8419f813a18b Mon Sep 17 00:00:00 2001
|
||||
From: John Crispin <john@phrozen.org>
|
||||
Date: Thu, 27 May 2021 13:25:03 +0200
|
||||
Subject: [PATCH 38/40] mac80211: update to latest HEAD
|
||||
Subject: [PATCH 01/30] mac80211: update to latest HEAD
|
||||
|
||||
Signed-off-by: John Crispin <john@phrozen.org>
|
||||
---
|
||||
package/kernel/mac80211/Makefile | 8 +-
|
||||
package/kernel/mac80211/ath.mk | 13 +-
|
||||
package/kernel/mac80211/broadcom.mk | 4 +-
|
||||
.../files/lib/netifd/wireless/mac80211.sh | 165 +++-
|
||||
.../files/lib/netifd/wireless/mac80211.sh | 197 +++--
|
||||
.../mac80211/files/lib/wifi/mac80211.sh | 105 ++-
|
||||
package/kernel/mac80211/mac80211.sh.diff | 58 ++
|
||||
.../ath/080-ath10k_thermal_config.patch | 2 +-
|
||||
...PN-replay-protection-for-fragmented-.patch | 180 ++++
|
||||
...fragments-with-multicast-DA-for-PCIe.patch | 66 ++
|
||||
@@ -57,7 +58,8 @@ Signed-off-by: John Crispin <john@phrozen.org>
|
||||
...-accept-forward-invalid-EAPOL-frames.patch | 94 ++
|
||||
...protection-against-mixed-key-and-fra.patch | 68 ++
|
||||
.../500-mac80211_configure_antenna_gain.patch | 24 +-
|
||||
52 files changed, 3280 insertions(+), 278 deletions(-)
|
||||
53 files changed, 3346 insertions(+), 302 deletions(-)
|
||||
create mode 100644 package/kernel/mac80211/mac80211.sh.diff
|
||||
create mode 100644 package/kernel/mac80211/patches/ath/300-ath10k-add-CCMP-PN-replay-protection-for-fragmented-.patch
|
||||
create mode 100644 package/kernel/mac80211/patches/ath/301-ath10k-drop-fragments-with-multicast-DA-for-PCIe.patch
|
||||
create mode 100644 package/kernel/mac80211/patches/ath/302-ath10k-drop-fragments-with-multicast-DA-for-SDIO.patch
|
||||
@@ -204,7 +206,7 @@ index fb576c5809..473bbf597c 100644
|
||||
AG => Dual A-PHY G-PHY
|
||||
G => G-PHY
|
||||
diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
|
||||
index 92c56afd24..f1ed47802a 100644
|
||||
index 92c56afd24..5856d0571f 100644
|
||||
--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
|
||||
+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
|
||||
@@ -26,7 +26,6 @@ drv_mac80211_init_device_config() {
|
||||
@@ -475,7 +477,21 @@ index 92c56afd24..f1ed47802a 100644
|
||||
|
||||
chan_is_dfs() {
|
||||
local phy="$1"
|
||||
@@ -935,7 +1050,7 @@ drv_mac80211_setup() {
|
||||
@@ -921,13 +1036,6 @@ drv_mac80211_setup() {
|
||||
local found
|
||||
|
||||
for wdev in $(list_phy_interfaces "$phy"); do
|
||||
- found=0
|
||||
- for cwdev in $OLDAPLIST $OLDSPLIST $OLDUMLIST; do
|
||||
- if [ "$wdev" = "$cwdev" ]; then
|
||||
- found=1
|
||||
- break
|
||||
- fi
|
||||
- done
|
||||
if [ "$found" = "0" ]; then
|
||||
ip link set dev "$wdev" down
|
||||
iw dev "$wdev" del
|
||||
@@ -935,7 +1043,7 @@ drv_mac80211_setup() {
|
||||
done
|
||||
|
||||
# convert channel to frequency
|
||||
@@ -484,6 +500,48 @@ index 92c56afd24..f1ed47802a 100644
|
||||
|
||||
[ -n "$country" ] && {
|
||||
iw reg get | grep -q "^country $country:" || {
|
||||
@@ -992,33 +1100,24 @@ drv_mac80211_setup() {
|
||||
for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
||||
NEWAPLIST=
|
||||
for_each_interface "ap" mac80211_prepare_vif
|
||||
- NEW_MD5=$(test -e "${hostapd_conf_file}" && md5sum ${hostapd_conf_file})
|
||||
- OLD_MD5=$(uci -q -P /var/state get wireless._${phy}.md5)
|
||||
- if [ "${NEWAPLIST}" != "${OLDAPLIST}" ]; then
|
||||
- mac80211_vap_cleanup hostapd "${OLDAPLIST}"
|
||||
- fi
|
||||
+ mac80211_vap_cleanup hostapd "${OLDAPLIST}"
|
||||
[ -n "${NEWAPLIST}" ] && mac80211_iw_interface_add "$phy" "${NEWAPLIST%% *}" __ap
|
||||
local add_ap=0
|
||||
local primary_ap=${NEWAPLIST%% *}
|
||||
[ -n "$hostapd_ctrl" ] && {
|
||||
local no_reload=1
|
||||
if [ -n "$(ubus list | grep hostapd.$primary_ap)" ]; then
|
||||
- [ "${NEW_MD5}" = "${OLD_MD5}" ] || {
|
||||
- ubus call hostapd.$primary_ap reload
|
||||
- no_reload=$?
|
||||
- if [ "$no_reload" != "0" ]; then
|
||||
- mac80211_vap_cleanup hostapd "${OLDAPLIST}"
|
||||
- mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)"
|
||||
- mac80211_vap_cleanup none "$(uci -q -P /var/state get wireless._${phy}.umlist)"
|
||||
- sleep 2
|
||||
- mac80211_iw_interface_add "$phy" "${NEWAPLIST%% *}" __ap
|
||||
- for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
||||
- fi
|
||||
- }
|
||||
+ mac80211_vap_cleanup hostapd "${OLDAPLIST}"
|
||||
+ mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)"
|
||||
+ mac80211_vap_cleanup none "$(uci -q -P /var/state get wireless._${phy}.umlist)"
|
||||
+ sleep 2
|
||||
+ mac80211_iw_interface_add "$phy" "${NEWAPLIST%% *}" __ap
|
||||
+ for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
||||
fi
|
||||
if [ "$no_reload" != "0" ]; then
|
||||
add_ap=1
|
||||
ubus wait_for hostapd
|
||||
+ ip link set $primary_ap down
|
||||
local hostapd_res="$(ubus call hostapd config_add "{\"iface\":\"$primary_ap\", \"config\":\"${hostapd_conf_file}\"}")"
|
||||
ret="$?"
|
||||
[ "$ret" != 0 -o -z "$hostapd_res" ] && {
|
||||
diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
|
||||
index 3e99f06693..0763da8fd8 100644
|
||||
--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
|
||||
@@ -618,6 +676,70 @@ index 3e99f06693..0763da8fd8 100644
|
||||
set wireless.radio${devidx}.disabled=1
|
||||
|
||||
set wireless.default_radio${devidx}=wifi-iface
|
||||
diff --git a/package/kernel/mac80211/mac80211.sh.diff b/package/kernel/mac80211/mac80211.sh.diff
|
||||
new file mode 100644
|
||||
index 0000000000..2fb6d472b3
|
||||
--- /dev/null
|
||||
+++ b/package/kernel/mac80211/mac80211.sh.diff
|
||||
@@ -0,0 +1,58 @@
|
||||
+--- mac80211.sh 2021-06-05 15:10:48.522323044 +0200
|
||||
++++ mac80211.new 2021-06-08 10:09:52.652540350 +0200
|
||||
+@@ -1036,13 +1036,6 @@
|
||||
+ local found
|
||||
+
|
||||
+ for wdev in $(list_phy_interfaces "$phy"); do
|
||||
+- found=0
|
||||
+- for cwdev in $OLDAPLIST $OLDSPLIST $OLDUMLIST; do
|
||||
+- if [ "$wdev" = "$cwdev" ]; then
|
||||
+- found=1
|
||||
+- break
|
||||
+- fi
|
||||
+- done
|
||||
+ if [ "$found" = "0" ]; then
|
||||
+ ip link set dev "$wdev" down
|
||||
+ iw dev "$wdev" del
|
||||
+@@ -1107,33 +1100,24 @@
|
||||
+ for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
||||
+ NEWAPLIST=
|
||||
+ for_each_interface "ap" mac80211_prepare_vif
|
||||
+- NEW_MD5=$(test -e "${hostapd_conf_file}" && md5sum ${hostapd_conf_file})
|
||||
+- OLD_MD5=$(uci -q -P /var/state get wireless._${phy}.md5)
|
||||
+- if [ "${NEWAPLIST}" != "${OLDAPLIST}" ]; then
|
||||
+- mac80211_vap_cleanup hostapd "${OLDAPLIST}"
|
||||
+- fi
|
||||
++ mac80211_vap_cleanup hostapd "${OLDAPLIST}"
|
||||
+ [ -n "${NEWAPLIST}" ] && mac80211_iw_interface_add "$phy" "${NEWAPLIST%% *}" __ap
|
||||
+ local add_ap=0
|
||||
+ local primary_ap=${NEWAPLIST%% *}
|
||||
+ [ -n "$hostapd_ctrl" ] && {
|
||||
+ local no_reload=1
|
||||
+ if [ -n "$(ubus list | grep hostapd.$primary_ap)" ]; then
|
||||
+- [ "${NEW_MD5}" = "${OLD_MD5}" ] || {
|
||||
+- ubus call hostapd.$primary_ap reload
|
||||
+- no_reload=$?
|
||||
+- if [ "$no_reload" != "0" ]; then
|
||||
+- mac80211_vap_cleanup hostapd "${OLDAPLIST}"
|
||||
+- mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)"
|
||||
+- mac80211_vap_cleanup none "$(uci -q -P /var/state get wireless._${phy}.umlist)"
|
||||
+- sleep 2
|
||||
+- mac80211_iw_interface_add "$phy" "${NEWAPLIST%% *}" __ap
|
||||
+- for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
||||
+- fi
|
||||
+- }
|
||||
++ mac80211_vap_cleanup hostapd "${OLDAPLIST}"
|
||||
++ mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)"
|
||||
++ mac80211_vap_cleanup none "$(uci -q -P /var/state get wireless._${phy}.umlist)"
|
||||
++ sleep 2
|
||||
++ mac80211_iw_interface_add "$phy" "${NEWAPLIST%% *}" __ap
|
||||
++ for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
||||
+ fi
|
||||
+ if [ "$no_reload" != "0" ]; then
|
||||
+ add_ap=1
|
||||
+ ubus wait_for hostapd
|
||||
++ ip link set $primary_ap down
|
||||
+ local hostapd_res="$(ubus call hostapd config_add "{\"iface\":\"$primary_ap\", \"config\":\"${hostapd_conf_file}\"}")"
|
||||
+ ret="$?"
|
||||
+ [ "$ret" != 0 -o -z "$hostapd_res" ] && {
|
||||
diff --git a/package/kernel/mac80211/patches/ath/080-ath10k_thermal_config.patch b/package/kernel/mac80211/patches/ath/080-ath10k_thermal_config.patch
|
||||
index de6f9d9bb0..55d48daa79 100644
|
||||
--- a/package/kernel/mac80211/patches/ath/080-ath10k_thermal_config.patch
|
||||
|
||||
6
feeds/tip/certificates/files/etc/uci-defaults/99-tip-certificates.sh
Executable file
6
feeds/tip/certificates/files/etc/uci-defaults/99-tip-certificates.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin.sh
|
||||
|
||||
uci add system certificates
|
||||
uci set system.@certificates[-1].key=/etc/ucentral/key.pem
|
||||
uci set system.@certificates[-1].cert=/etc/ucentral/cert.pem
|
||||
uci set system.@certificates[-1].ca=/etc/ucentral/cas.pem
|
||||
@@ -9,7 +9,7 @@ PKG_MAINTAINER:=John Crispin <john@phrozen.org>
|
||||
PKG_SOURCE_URL=https://github.com/blogic/ieee8021x.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2021-04-12
|
||||
PKG_SOURCE_VERSION:=53caaa84e483cfe0fb63c024347ce71df0c707a4
|
||||
PKG_SOURCE_VERSION:=c1f36559dc0ed2deeac0531a3d5854f1955ae928
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
@@ -17,8 +17,4 @@ start_service() {
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
# add a dummy user DB until we have EAP-TLS support
|
||||
echo "\"bob\" MD5 \"hello\"" > /tmp/run/hostapd-ieee8021x.eap_user
|
||||
echo "\"bob\" MD5 \"hello\" [2]" >> /tmp/run/hostapd-ieee8021x.eap_user
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ PKG_RELEASE:=1
|
||||
PKG_SOURCE_URL=https://github.com/blogic/ucentral-schema.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2021-02-15
|
||||
PKG_SOURCE_VERSION:=c60d97fbb5408fc53d4a8f522f7a698ff5f7f8d7
|
||||
PKG_SOURCE_VERSION:=4fdbdc781009ceffe61bb1104c6b18d710aa18a4
|
||||
|
||||
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
|
||||
@@ -24,21 +24,7 @@
|
||||
],
|
||||
"ipv4": {
|
||||
"addressing": "dynamic"
|
||||
},
|
||||
"ssids": [
|
||||
{
|
||||
"name": "OpenWifi",
|
||||
"wifi-bands": [
|
||||
"2G"
|
||||
],
|
||||
"bss-mode": "ap",
|
||||
"encryption": {
|
||||
"proto": "psk2",
|
||||
"key": "OpenWifi",
|
||||
"ieee80211w": "optional"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "LAN",
|
||||
@@ -55,7 +41,9 @@
|
||||
"addressing": "static",
|
||||
"subnet": "192.168.1.1/24",
|
||||
"dhcp": {
|
||||
"relay-server" : "192.168.178.1"
|
||||
"relay-server" : "192.168.178.1",
|
||||
"circuit-id-format": "{Interface}:{VLAN-Id}:{SSID}:{Model}:{Name}:{AP-MAC}:{Location}",
|
||||
"remote-id-format": "{Client-MAC-Hex} {SSID}"
|
||||
}
|
||||
},
|
||||
"ssids": [
|
||||
|
||||
@@ -39,6 +39,13 @@
|
||||
],
|
||||
"services": {
|
||||
"ieee8021x": {
|
||||
"use-local-certificates": true,
|
||||
"users": [
|
||||
{
|
||||
"user-name": "john",
|
||||
"password": "aaaaaaaa"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ssh": {
|
||||
"port": 22
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"uuid": 2,
|
||||
"radios": [
|
||||
{
|
||||
"band": "2G",
|
||||
"country": "CA",
|
||||
"channel-mode": "HE",
|
||||
"channel-width": 80,
|
||||
"channel": 32
|
||||
}
|
||||
],
|
||||
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "WAN",
|
||||
"role": "upstream",
|
||||
"services": [ "lldp" ],
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"WAN*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"ipv4": {
|
||||
"addressing": "dynamic"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "LAN",
|
||||
"role": "downstream",
|
||||
"services": [ "ssh", "lldp" ],
|
||||
"ethernet": [
|
||||
{
|
||||
"select-ports": [
|
||||
"LAN*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": "192.168.1.1/24",
|
||||
"dhcp": {
|
||||
"lease-first": 10,
|
||||
"lease-count": 100,
|
||||
"lease-time": "6h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ssid",
|
||||
"role": "downstream",
|
||||
"ipv4": {
|
||||
"addressing": "static",
|
||||
"subnet": "192.168.2.1/24",
|
||||
"dhcp": {
|
||||
"lease-first": 10,
|
||||
"lease-count": 100,
|
||||
"lease-time": "6h"
|
||||
}
|
||||
},
|
||||
"ssids": [
|
||||
{
|
||||
"name": "OpenWifi",
|
||||
"wifi-bands": [
|
||||
"2G"
|
||||
],
|
||||
"bss-mode": "ap",
|
||||
"encryption": {
|
||||
"proto": "psk2",
|
||||
"key": "OpenWifi",
|
||||
"ieee80211w": "optional"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
],
|
||||
"metrics": {
|
||||
"statistics": {
|
||||
"interval": 120,
|
||||
"types": [ "ssids", "lldp", "clients" ]
|
||||
},
|
||||
"health": {
|
||||
"interval": 120
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"lldp": {
|
||||
"describe": "uCentral",
|
||||
"location": "universe"
|
||||
},
|
||||
"ssh": {
|
||||
"port": 22
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ PKG_RELEASE:=1
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=https://github.com/jow-/ucode.git
|
||||
PKG_SOURCE_DATE:=2021-03-15
|
||||
PKG_SOURCE_VERSION:=42de7ab196a0cc82c1a40adffcea7b481a09e11c
|
||||
PKG_SOURCE_VERSION:=856a0c05fbbde4363634e7f8d5de7ed66d0e0cdc
|
||||
PKG_MIRROR_HASH:=
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
PKG_LICENSE:=ISC
|
||||
|
||||
239
patches/0012-dnsmasq-add-relay-option82-support.patch
Normal file
239
patches/0012-dnsmasq-add-relay-option82-support.patch
Normal file
@@ -0,0 +1,239 @@
|
||||
From 8ca8d0669ea2b36a5542d9bcda32cddf9cd7cd0f Mon Sep 17 00:00:00 2001
|
||||
From: John Crispin <john@phrozen.org>
|
||||
Date: Tue, 8 Jun 2021 09:12:38 +0200
|
||||
Subject: [PATCH] dnsmasq: add relay / option82 support
|
||||
|
||||
Signed-off-by: John Crispin <john@phrozen.org>
|
||||
---
|
||||
.../services/dnsmasq/files/dnsmasq.init | 10 +-
|
||||
.../dnsmasq/patches/200-option82.patch | 195 ++++++++++++++++++
|
||||
2 files changed, 201 insertions(+), 4 deletions(-)
|
||||
create mode 100644 package/network/services/dnsmasq/patches/200-option82.patch
|
||||
|
||||
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
|
||||
index 680e72f9e7..51f405b73c 100644
|
||||
--- a/package/network/services/dnsmasq/files/dnsmasq.init
|
||||
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
|
||||
@@ -761,12 +761,14 @@ dhcp_relay_add() {
|
||||
[ -n "$server_addr" ] || return 0
|
||||
|
||||
config_get interface "$cfg" interface
|
||||
- if [ -z "$interface" ]; then
|
||||
- xappend "--dhcp-relay=$local_addr,$server_addr"
|
||||
- else
|
||||
+ config_get suboption1 "$cfg" suboption1
|
||||
+ config_get suboption2 "$cfg" suboption2
|
||||
+ config_get suboption151 "$cfg" suboption151
|
||||
+ config_get suboption152 "$cfg" suboption152
|
||||
+ if [ -n "$interface" ]; then
|
||||
network_get_device ifname "$interface" || return
|
||||
- xappend "--dhcp-relay=$local_addr,$server_addr,$ifname"
|
||||
fi
|
||||
+ xappend "--dhcp-relay=$local_addr,$server_addr,$ifname,$suboption1,$suboption2,$suboption151,$suboption152"
|
||||
}
|
||||
|
||||
dnsmasq_ipset_add() {
|
||||
diff --git a/package/network/services/dnsmasq/patches/200-option82.patch b/package/network/services/dnsmasq/patches/200-option82.patch
|
||||
new file mode 100644
|
||||
index 0000000000..7883b12922
|
||||
--- /dev/null
|
||||
+++ b/package/network/services/dnsmasq/patches/200-option82.patch
|
||||
@@ -0,0 +1,195 @@
|
||||
+diff --git a/src/dhcp.c b/src/dhcp.c
|
||||
+index 97324f2..48e08b1 100644
|
||||
+--- a/src/dhcp.c
|
||||
++++ b/src/dhcp.c
|
||||
+@@ -1057,14 +1057,83 @@ char *host_from_dns(struct in_addr addr)
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
++extern void insert_option82(struct dhcp_packet *mess, size_t *sz, char *opt, int len);
|
||||
++
|
||||
++static char *insert_suboption(char *opt, char id, char *string, struct ifreq *ifr, u8 *client)
|
||||
++{
|
||||
++ char *len, *o = opt;
|
||||
++
|
||||
++ if (!string || !*string)
|
||||
++ return opt;
|
||||
++
|
||||
++ *o++ = id;
|
||||
++ len = o++;
|
||||
++
|
||||
++ while (*string) {
|
||||
++ if (*string == '%') {
|
||||
++ string++;
|
||||
++ switch(*string) {
|
||||
++ case 'i':
|
||||
++ memcpy(o, ifr->ifr_name, strlen(ifr->ifr_name));
|
||||
++ o += strlen(ifr->ifr_name);
|
||||
++ break;
|
||||
++ case 'a':
|
||||
++ memcpy(o, ifr->ifr_hwaddr.sa_data, 6);
|
||||
++ o += 6;
|
||||
++ break;
|
||||
++ case 'A':
|
||||
++ sprintf(o, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
++ ifr->ifr_hwaddr.sa_data[0],
|
||||
++ ifr->ifr_hwaddr.sa_data[1],
|
||||
++ ifr->ifr_hwaddr.sa_data[2],
|
||||
++ ifr->ifr_hwaddr.sa_data[3],
|
||||
++ ifr->ifr_hwaddr.sa_data[4],
|
||||
++ ifr->ifr_hwaddr.sa_data[5]);
|
||||
++ o += 17;
|
||||
++ break;
|
||||
++ case 'c':
|
||||
++ memcpy(o, client, 6);
|
||||
++ o += 6;
|
||||
++ break;
|
||||
++ case 'C':
|
||||
++ sprintf(o, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
++ client[0],
|
||||
++ client[1],
|
||||
++ client[2],
|
||||
++ client[3],
|
||||
++ client[4],
|
||||
++ client[5]);
|
||||
++ o += 17;
|
||||
++ break;
|
||||
++ }
|
||||
++ } else {
|
||||
++ *o++ = *string;
|
||||
++ }
|
||||
++ string++;
|
||||
++ }
|
||||
++
|
||||
++ *len = o - opt - 2;
|
||||
++
|
||||
++ return o;
|
||||
++}
|
||||
++
|
||||
+ static int relay_upstream4(struct dhcp_relay *relay, struct dhcp_packet *mess, size_t sz, int iface_index)
|
||||
+ {
|
||||
+ /* ->local is same value for all relays on ->current chain */
|
||||
++ struct ifreq ifr;
|
||||
+ union all_addr from;
|
||||
+-
|
||||
++ char opt82[512] = { 82, 12 };
|
||||
++ char *o = &opt82[2];
|
||||
++ int len;
|
||||
++
|
||||
+ if (mess->op != BOOTREQUEST)
|
||||
+ return 0;
|
||||
+
|
||||
++ if (!if_indextoname(iface_index, ifr.ifr_name))
|
||||
++ return -1;
|
||||
++ if (ioctl(daemon->dhcpfd, SIOCGIFHWADDR, &ifr))
|
||||
++ return -1;
|
||||
++
|
||||
+ /* source address == relay address */
|
||||
+ from.addr4 = relay->local.addr4;
|
||||
+
|
||||
+@@ -1080,10 +1149,22 @@ static int relay_upstream4(struct dhcp_relay *relay, struct dhcp_packet *mess,
|
||||
+ /* plug in our address */
|
||||
+ mess->giaddr.s_addr = relay->local.addr4.s_addr;
|
||||
+ }
|
||||
++
|
||||
++ o = insert_suboption(o, 1, relay->sub_opt1, &ifr, mess->chaddr);
|
||||
++ o = insert_suboption(o, 2, relay->sub_opt2, &ifr, mess->chaddr);
|
||||
++ o = insert_suboption(o, 151, relay->sub_opt151, &ifr, mess->chaddr);
|
||||
++ o = insert_suboption(o, 152, relay->sub_opt152, &ifr, mess->chaddr);
|
||||
++
|
||||
++ len = o - opt82;
|
||||
++ opt82[1] = len - 2;
|
||||
++
|
||||
++ insert_option82(mess, &sz, opt82, len);
|
||||
+
|
||||
+ if ((mess->hops++) > 20)
|
||||
+ return 1;
|
||||
+
|
||||
++
|
||||
++
|
||||
+ for (; relay; relay = relay->current)
|
||||
+ {
|
||||
+ union mysockaddr to;
|
||||
+diff --git a/src/dnsmasq.h b/src/dnsmasq.h
|
||||
+index e770454..abc79f8 100644
|
||||
+--- a/src/dnsmasq.h
|
||||
++++ b/src/dnsmasq.h
|
||||
+@@ -1005,6 +1005,10 @@ struct dhcp_relay {
|
||||
+ char *interface; /* Allowable interface for replies from server, and dest for IPv6 multicast */
|
||||
+ int iface_index; /* working - interface in which requests arrived, for return */
|
||||
+ struct dhcp_relay *current, *next;
|
||||
++ char sub_opt1[64];
|
||||
++ char sub_opt2[64];
|
||||
++ char sub_opt151[16];
|
||||
++ char sub_opt152[16];
|
||||
+ };
|
||||
+
|
||||
+ extern struct daemon {
|
||||
+diff --git a/src/option.c b/src/option.c
|
||||
+index 0a72406..b06d1c8 100644
|
||||
+--- a/src/option.c
|
||||
++++ b/src/option.c
|
||||
+@@ -3957,10 +3957,25 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
||||
+ case LOPT_RELAY: /* --dhcp-relay */
|
||||
+ {
|
||||
+ struct dhcp_relay *new = opt_malloc(sizeof(struct dhcp_relay));
|
||||
+- comma = split(arg);
|
||||
+- new->interface = opt_string_alloc(split(comma));
|
||||
++ char *args[7] = {}, **arg_p = args;
|
||||
++
|
||||
++ while (arg) {
|
||||
++ comma = split(arg);
|
||||
++ *arg_p++ = arg;
|
||||
++ arg = comma;
|
||||
++ }
|
||||
++
|
||||
++ if (args[3] && *args[3])
|
||||
++ memcpy(new->sub_opt1, args[3], strlen(args[3]) + 1);
|
||||
++ if (args[4] && *args[4])
|
||||
++ memcpy(new->sub_opt2, args[4], strlen(args[4]) + 1);
|
||||
++ if (args[5] && *args[5])
|
||||
++ memcpy(new->sub_opt151, args[5], strlen(args[5]) + 1);
|
||||
++ if (args[6] && *args[6])
|
||||
++ memcpy(new->sub_opt152, args[6], strlen(args[6]) + 1);
|
||||
++ new->interface = opt_string_alloc(args[2]);
|
||||
+ new->iface_index = 0;
|
||||
+- if (inet_pton(AF_INET, arg, &new->local) && inet_pton(AF_INET, comma, &new->server))
|
||||
++ if (inet_pton(AF_INET, args[0], &new->local) && inet_pton(AF_INET, args[1], &new->server))
|
||||
+ {
|
||||
+ new->next = daemon->relay4;
|
||||
+ daemon->relay4 = new;
|
||||
+@@ -3977,7 +3992,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
||||
+ free(new->interface);
|
||||
+ ret_err_free(_("Bad dhcp-relay"), new);
|
||||
+ }
|
||||
+-
|
||||
++
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+diff --git a/src/rfc2131.c b/src/rfc2131.c
|
||||
+index 3f50755..792a274 100644
|
||||
+--- a/src/rfc2131.c
|
||||
++++ b/src/rfc2131.c
|
||||
+@@ -2785,6 +2785,21 @@ static void apply_delay(u32 xid, time_t recvtime, struct dhcp_netid *netid)
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
++void insert_option82(struct dhcp_packet *mess, size_t *sz, char *opt82, int len)
|
||||
++{
|
||||
++ if (!option_find(mess, *sz, OPTION_AGENT_ID, 2)) {
|
||||
++ unsigned char *end = option_find(mess, *sz, OPTION_END, 1);
|
||||
++ int space = 312 - (end - mess->options) - 1;
|
||||
++
|
||||
++ if (space < len)
|
||||
++ return;
|
||||
++ memcpy(end, opt82, len);
|
||||
++ end[len] = OPTION_END;
|
||||
++ *sz += len;
|
||||
++ }
|
||||
++}
|
||||
++
|
||||
++
|
||||
+ #endif
|
||||
+
|
||||
+
|
||||
--
|
||||
2.25.1
|
||||
|
||||
Reference in New Issue
Block a user