Add User-Name/CUI from RADIUS ACL in Accounting messages
authorMichael Braun <michael-dev@fami-braun.de>
Sun, 19 Aug 2012 11:27:30 +0000 (14:27 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 19 Aug 2012 11:27:30 +0000 (14:27 +0300)
This allows User-Name and Chargeable-User-Identity attributes to be
passed from Access-Accept into Accounting messages even when IEEE 802.1X
is not used.

Signed-hostap: Michael Braun <michael-dev@fami-braun.de>

src/ap/accounting.c

index 8c60d0e..7563b52 100644 (file)
@@ -81,7 +81,17 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
        }
 
        if (sta) {
+               /* Use 802.1X identity if available */
                val = ieee802_1x_get_identity(sta->eapol_sm, &len);
+
+               /* Use RADIUS ACL identity if 802.1X provides no identity */
+               if (!val && sta->identity) {
+                       val = (u8 *) sta->identity;
+                       len = os_strlen(sta->identity);
+               }
+
+               /* Use STA MAC if neither 802.1X nor RADIUS ACL provided
+                * identity */
                if (!val) {
                        os_snprintf(buf, sizeof(buf), RADIUS_ADDR_FORMAT,
                                    MAC2STR(sta->addr));
@@ -122,6 +132,15 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
                        wpa_printf(MSG_ERROR, "Could not add CUI");
                        goto fail;
                }
+
+               if (!b && sta->radius_cui &&
+                   !radius_msg_add_attr(msg,
+                                        RADIUS_ATTR_CHARGEABLE_USER_IDENTITY,
+                                        (u8 *) sta->radius_cui,
+                                        os_strlen(sta->radius_cui))) {
+                       wpa_printf(MSG_ERROR, "Could not add CUI from ACL");
+                       goto fail;
+               }
        }
 
        return msg;