hostapd: adjust patches to work with git am
[openwrt/staging/xback.git] / package / network / services / hostapd / patches / 760-dynamic_own_ip.patch
index 2f5015892b7b46567fbb1a0ec655a6b668b36635..c4b14d41b00942f4f8fc41df1a6e68728eef4300 100644 (file)
@@ -1,3 +1,21 @@
+From: Felix Fietkau <nbd@nbd.name>
+Date: Thu, 15 Dec 2022 13:57:04 +0100
+Subject: [PATCH] hostapd: add support for automatically setting RADIUS own-ip
+ dynamically
+
+Some servers use the NAS-IP-Address attribute as a destination address
+
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
+@@ -2819,6 +2819,8 @@ static int hostapd_config_fill(struct ho
+       } else if (os_strcmp(buf, "iapp_interface") == 0) {
+               wpa_printf(MSG_INFO, "DEPRECATED: iapp_interface not used");
+ #endif /* CONFIG_IAPP */
++      } else if (os_strcmp(buf, "dynamic_own_ip_addr") == 0) {
++              bss->dynamic_own_ip_addr = atoi(pos);
+       } else if (os_strcmp(buf, "own_ip_addr") == 0) {
+               if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) {
+                       wpa_printf(MSG_ERROR,
 --- a/src/ap/ap_config.h
 +++ b/src/ap/ap_config.h
 @@ -310,6 +310,7 @@ struct hostapd_bss_config {
@@ -8,9 +26,22 @@
        char *nas_identifier;
        struct hostapd_radius_servers *radius;
        int acct_interim_interval;
+--- a/src/ap/ieee802_1x.c
++++ b/src/ap/ieee802_1x.c
+@@ -601,6 +601,10 @@ int add_common_radius_attr(struct hostap
+       struct hostapd_radius_attr *attr;
+       int len;
++      if (hapd->conf->dynamic_own_ip_addr)
++              radius_client_get_local_addr(hapd->radius,
++                                           &hapd->conf->own_ip_addr);
++
+       if (!hostapd_config_get_radius_attr(req_attr,
+                                           RADIUS_ATTR_NAS_IP_ADDRESS) &&
+           hapd->conf->own_ip_addr.af == AF_INET &&
 --- a/src/radius/radius_client.c
 +++ b/src/radius/radius_client.c
-@@ -163,6 +163,8 @@ struct radius_client_data {
+@@ -165,6 +165,8 @@ struct radius_client_data {
         */
        void *ctx;
  
@@ -19,7 +50,7 @@
        /**
         * conf - RADIUS client configuration (list of RADIUS servers to use)
         */
-@@ -720,6 +722,30 @@ static void radius_client_list_add(struc
+@@ -819,6 +821,30 @@ static void radius_close_acct_socket(str
  
  
  /**
@@ -50,7 +81,7 @@
   * radius_client_send - Send a RADIUS request
   * @radius: RADIUS client context from radius_client_init()
   * @msg: RADIUS message to be sent
-@@ -1238,6 +1264,10 @@ radius_change_server(struct radius_clien
+@@ -1711,6 +1737,10 @@ radius_change_server(struct radius_clien
                        wpa_printf(MSG_DEBUG, "RADIUS local address: %s:%u",
                                   inet_ntoa(claddr.sin_addr),
                                   ntohs(claddr.sin_port));
@@ -61,7 +92,7 @@
                }
                break;
  #ifdef CONFIG_IPV6
-@@ -1249,6 +1279,10 @@ radius_change_server(struct radius_clien
+@@ -1722,6 +1752,10 @@ radius_change_server(struct radius_clien
                                   inet_ntop(AF_INET6, &claddr6.sin6_addr,
                                             abuf, sizeof(abuf)),
                                   ntohs(claddr6.sin6_port));
        }
 --- a/src/radius/radius_client.h
 +++ b/src/radius/radius_client.h
-@@ -249,6 +249,8 @@ int radius_client_register(struct radius
+@@ -274,6 +274,8 @@ int radius_client_register(struct radius
  void radius_client_set_interim_error_cb(struct radius_client_data *radius,
                                        void (*cb)(const u8 *addr, void *ctx),
                                        void *ctx);
  int radius_client_send(struct radius_client_data *radius,
                       struct radius_msg *msg,
                       RadiusType msg_type, const u8 *addr);
---- a/src/ap/ieee802_1x.c
-+++ b/src/ap/ieee802_1x.c
-@@ -535,6 +535,10 @@ int add_common_radius_attr(struct hostap
-       struct hostapd_radius_attr *attr;
-       int len;
-+      if (hapd->conf->dynamic_own_ip_addr)
-+              radius_client_get_local_addr(hapd->radius,
-+                                           &hapd->conf->own_ip_addr);
-+
-       if (!hostapd_config_get_radius_attr(req_attr,
-                                           RADIUS_ATTR_NAS_IP_ADDRESS) &&
-           hapd->conf->own_ip_addr.af == AF_INET &&
---- a/hostapd/config_file.c
-+++ b/hostapd/config_file.c
-@@ -2688,6 +2688,8 @@ static int hostapd_config_fill(struct ho
-       } else if (os_strcmp(buf, "iapp_interface") == 0) {
-               wpa_printf(MSG_INFO, "DEPRECATED: iapp_interface not used");
- #endif /* CONFIG_IAPP */
-+      } else if (os_strcmp(buf, "dynamic_own_ip_addr") == 0) {
-+              bss->dynamic_own_ip_addr = atoi(pos);
-       } else if (os_strcmp(buf, "own_ip_addr") == 0) {
-               if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) {
-                       wpa_printf(MSG_ERROR,