]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add Acct-Session-Id into Access-Request messages
authorJouni Malinen <j@w1.fi>
Tue, 18 Dec 2012 16:13:31 +0000 (18:13 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 18 Dec 2012 16:13:31 +0000 (18:13 +0200)
This optional attribute may make it easier to bind together the
Access-Request and Accounting-Request messages. The accounting session
identifier is now generated when the STA associates instead of waiting
for the actual session to start after successfull authentication.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/ap/accounting.c
src/ap/accounting.h
src/ap/ieee802_1x.c
src/ap/sta_info.c

index 7563b52e17313d353b66d0485b01e360cbc42ed2..954053131a7a67abcd654749f32781083461b986 100644 (file)
@@ -26,8 +26,6 @@
  * input/output octets and updates Acct-{Input,Output}-Gigawords. */
 #define ACCT_DEFAULT_UPDATE_INTERVAL 300
 
-static void accounting_sta_get_id(struct hostapd_data *hapd,
-                                 struct sta_info *sta);
 static void accounting_sta_interim(struct hostapd_data *hapd,
                                   struct sta_info *sta);
 
@@ -210,7 +208,6 @@ void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta)
        if (sta->acct_session_started)
                return;
 
-       accounting_sta_get_id(hapd, sta);
        hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
                       HOSTAPD_LEVEL_INFO,
                       "starting accounting session %08X-%08X",
@@ -377,7 +374,7 @@ void accounting_sta_stop(struct hostapd_data *hapd, struct sta_info *sta)
 }
 
 
-static void accounting_sta_get_id(struct hostapd_data *hapd,
+void accounting_sta_get_id(struct hostapd_data *hapd,
                                  struct sta_info *sta)
 {
        sta->acct_session_id_lo = hapd->acct_session_id_lo++;
index 9d13d011cdd857b701d28ed9260111bbd6bdbfff..dcc54ee94b54901aefa000c264c4f19e4eb6e4fc 100644 (file)
 #define ACCOUNTING_H
 
 #ifdef CONFIG_NO_ACCOUNTING
+static inline void accounting_sta_get_id(struct hostapd_data *hapd,
+                                        struct sta_info *sta)
+{
+}
+
 static inline void accounting_sta_start(struct hostapd_data *hapd,
                                        struct sta_info *sta)
 {
@@ -29,6 +34,7 @@ static inline void accounting_deinit(struct hostapd_data *hapd)
 {
 }
 #else /* CONFIG_NO_ACCOUNTING */
+void accounting_sta_get_id(struct hostapd_data *hapd, struct sta_info *sta);
 void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta);
 void accounting_sta_stop(struct hostapd_data *hapd, struct sta_info *sta);
 int accounting_init(struct hostapd_data *hapd);
index 5b011201c5b057ca7a103c55f9f3d11c357aca27..3098d74ba71084ea8f1f9bd02faf980128a0038c 100644 (file)
@@ -454,6 +454,16 @@ static int add_common_radius_sta_attr(struct hostapd_data *hapd,
                return -1;
        }
 
+       if (sta->acct_session_id_hi || sta->acct_session_id_lo) {
+               os_snprintf(buf, sizeof(buf), "%08X-%08X",
+                           sta->acct_session_id_hi, sta->acct_session_id_lo);
+               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;
+               }
+       }
+
        return 0;
 }
 
index 6bc43d2d5e95fc4763557cbab880a11521f1ce72..97cd0136b86dcb441e1ac5d48ee21fea7d3d436a 100644 (file)
@@ -493,6 +493,7 @@ struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr)
                return NULL;
        }
        sta->acct_interim_interval = hapd->conf->acct_interim_interval;
+       accounting_sta_get_id(hapd, sta);
 
        /* initialize STA info data */
        wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout "