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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Version without broken whitespace attached.

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

Signed-off-by: Nick Lowe <nick.lowe@xxxxxxxxxxxx>
---
 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
From 032e3fa6ebab90cdb40e1aeadd2d9bebee06b7a1 Mon Sep 17 00:00:00 2001
From: Nick Lowe <nick.lowe@xxxxxxxxxxxx>
Date: Mon, 25 Jan 2016 10:49:33 +0000
Subject: [PATCH 5/6] Only send Acct-Session-Id and Connect-Info in
 Accounting-Requests

Signed-off-by: Nick Lowe <nick.lowe@xxxxxxxxxxxx>
---
 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

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux