[PATCH] Only send Acct-Session-Id and Connect-Info in Accounting-Requests

Nick Lowe nick.lowe at lugatech.com
Mon Jan 25 05:07:08 PST 2016


Version without broken whitespace attached.

Only send Acct-Session-Id and Connect-Info in Accounting-Requests

Signed-off-by: Nick Lowe <nick.lowe at lugatech.com>
---
 src/ap/ieee802_1x.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index 5f95a65..041b230 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -403,6 +403,7 @@ static int add_common_radius_sta_attr(struct
hostapd_data *hapd,
                       struct radius_msg *msg)
 {
     char buf[128];
+    struct radius_hdr *hdr;

     if (!hostapd_config_get_radius_attr(req_attr,
                         RADIUS_ATTR_NAS_PORT) &&
@@ -430,22 +431,26 @@ static int add_common_radius_sta_attr(struct
hostapd_data *hapd,
                 radius_mode_txt(hapd));
         buf[sizeof(buf) - 1] = '\0';
     }
-    if (!hostapd_config_get_radius_attr(req_attr,
-                        RADIUS_ATTR_CONNECT_INFO) &&
-        !radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
-                 (u8 *) buf, os_strlen(buf))) {
-        wpa_printf(MSG_ERROR, "Could not add Connect-Info");
-        return -1;
-    }

-    if (sta->acct_session_id) {
-        os_snprintf(buf, sizeof(buf), "%016lX",
-                sta->acct_session_id);
-        if (!radius_msg_add_attr(msg, RADIUS_ATTR_ACCT_SESSION_ID,
+    hdr = radius_msg_get_hdr(msg);
+    if (hdr->code == RADIUS_CODE_ACCOUNTING_REQUEST) {
+        if (!hostapd_config_get_radius_attr(req_attr,
+                            RADIUS_ATTR_CONNECT_INFO) &&
+            !radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
                      (u8 *) buf, os_strlen(buf))) {
-            wpa_printf(MSG_ERROR, "Could not add Acct-Session-Id");
+            wpa_printf(MSG_ERROR, "Could not add Connect-Info");
             return -1;
         }
+
+        if (sta->acct_session_id) {
+            os_snprintf(buf, sizeof(buf), "%016lX",
+                    sta->acct_session_id);
+            if (!radius_msg_add_attr(msg, RADIUS_ATTR_ACCT_SESSION_ID,
+                         (u8 *) buf, os_strlen(buf))) {
+                wpa_printf(MSG_ERROR, "Could not add Acct-Session-Id");
+                return -1;
+            }
+        }
     }

 #ifdef CONFIG_IEEE80211R
-- 
2.5.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Only-send-Acct-Session-Id-and-Connect-Info-in-Accoun.patch
Type: text/x-patch
Size: 2110 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/hostap/attachments/20160125/c45efa23/attachment-0001.bin>


More information about the Hostap mailing list