]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Clean up AP-STA-CONNECTED/DISCONNECTED prints
authorJouni Malinen <j@w1.fi>
Sat, 18 May 2013 16:09:41 +0000 (19:09 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 18 May 2013 16:09:41 +0000 (19:09 +0300)
Use shared code to print the parameters so that they do not need to be
generated four times separately.

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

src/ap/sta_info.c

index cbafb47f0d711459f1f6f3e8f4c04ec3b10f076a..4e6d30189b346294fb91ba0f404fa0355bc76390 100644 (file)
@@ -855,6 +855,7 @@ void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
                           int authorized)
 {
        const u8 *dev_addr = NULL;
+       char buf[100];
 #ifdef CONFIG_P2P
        u8 addr[ETH_ALEN];
 #endif /* CONFIG_P2P */
@@ -871,44 +872,29 @@ void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
                dev_addr = p2p_group_get_dev_addr(hapd->p2p_group, sta->addr);
 #endif /* CONFIG_P2P */
 
+       if (dev_addr)
+               os_snprintf(buf, sizeof(buf), MACSTR " p2p_dev_addr=" MACSTR,
+                           MAC2STR(sta->addr), MAC2STR(dev_addr));
+       else
+               os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr));
+
        if (authorized) {
-               if (dev_addr)
-                       wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED
-                               MACSTR " p2p_dev_addr=" MACSTR,
-                               MAC2STR(sta->addr), MAC2STR(dev_addr));
-               else
-                       wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED
-                               MACSTR, MAC2STR(sta->addr));
+               wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s", buf);
+
                if (hapd->msg_ctx_parent &&
-                   hapd->msg_ctx_parent != hapd->msg_ctx && dev_addr)
-                       wpa_msg(hapd->msg_ctx_parent, MSG_INFO,
-                               AP_STA_CONNECTED MACSTR " p2p_dev_addr="
-                               MACSTR,
-                               MAC2STR(sta->addr), MAC2STR(dev_addr));
-               else if (hapd->msg_ctx_parent &&
-                        hapd->msg_ctx_parent != hapd->msg_ctx)
+                   hapd->msg_ctx_parent != hapd->msg_ctx)
                        wpa_msg(hapd->msg_ctx_parent, MSG_INFO,
-                               AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
+                               AP_STA_CONNECTED "%s", buf);
 
                sta->flags |= WLAN_STA_AUTHORIZED;
        } else {
-               if (dev_addr)
-                       wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED
-                               MACSTR " p2p_dev_addr=" MACSTR,
-                               MAC2STR(sta->addr), MAC2STR(dev_addr));
-               else
-                       wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED
-                               MACSTR, MAC2STR(sta->addr));
+               wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
+
                if (hapd->msg_ctx_parent &&
-                   hapd->msg_ctx_parent != hapd->msg_ctx && dev_addr)
+                   hapd->msg_ctx_parent != hapd->msg_ctx)
                        wpa_msg(hapd->msg_ctx_parent, MSG_INFO,
-                               AP_STA_DISCONNECTED MACSTR " p2p_dev_addr="
-                               MACSTR, MAC2STR(sta->addr), MAC2STR(dev_addr));
-               else if (hapd->msg_ctx_parent &&
-                        hapd->msg_ctx_parent != hapd->msg_ctx)
-                       wpa_msg(hapd->msg_ctx_parent, MSG_INFO,
-                               AP_STA_DISCONNECTED MACSTR,
-                               MAC2STR(sta->addr));
+                               AP_STA_DISCONNECTED "%s", buf);
+
                sta->flags &= ~WLAN_STA_AUTHORIZED;
        }