Remove direct driver calls from accounting.c
authorJouni Malinen <j@w1.fi>
Thu, 24 Dec 2009 20:24:57 +0000 (22:24 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 24 Dec 2009 20:24:57 +0000 (22:24 +0200)
hostapd/accounting.c
hostapd/ap_drv_ops.c
hostapd/driver_i.h
hostapd/hostapd.h

index 4dd5ab9..12678bc 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * hostapd / RADIUS Accounting
- * Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
 
 #include "common.h"
 #include "hostapd.h"
+#include "drivers/driver.h"
 #include "radius/radius.h"
 #include "radius/radius_client.h"
 #include "eloop.h"
 #include "accounting.h"
 #include "ieee802_1x.h"
-#include "driver_i.h"
+#include "config.h"
 #include "sta_info.h"
 
 
@@ -185,7 +186,7 @@ static int accounting_sta_update_stats(struct hostapd_data *hapd,
                                       struct sta_info *sta,
                                       struct hostap_sta_driver_data *data)
 {
-       if (hostapd_read_sta_data(hapd, data, sta->addr))
+       if (hapd->drv.read_sta_data(hapd, data, sta->addr))
                return -1;
 
        if (sta->last_rx_bytes > data->rx_bytes)
@@ -248,7 +249,7 @@ void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta)
        time(&sta->acct_session_start);
        sta->last_rx_bytes = sta->last_tx_bytes = 0;
        sta->acct_input_gigawords = sta->acct_output_gigawords = 0;
-       hostapd_sta_clear_stats(hapd, sta->addr);
+       hapd->drv.sta_clear_stats(hapd, sta->addr);
 
        if (!hapd->conf->radius->acct_server)
                return;
index d663115..bce6859 100644 (file)
@@ -80,6 +80,24 @@ static int hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
 }
 
 
+static int hostapd_read_sta_data(struct hostapd_data *hapd,
+                                struct hostap_sta_driver_data *data,
+                                const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
+               return -1;
+       return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
+}
+
+
+static int hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
+               return 0;
+       return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
+}
+
+
 void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
 {
        ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
@@ -87,4 +105,6 @@ void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
        ops->send_eapol = hostapd_send_eapol;
        ops->set_authorized = hostapd_set_authorized;
        ops->set_key = hostapd_set_key;
+       ops->read_sta_data = hostapd_read_sta_data;
+       ops->sta_clear_stats = hostapd_sta_clear_stats;
 }
index d6ac63e..7de6c04 100644 (file)
@@ -108,15 +108,6 @@ hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
 }
 
 static inline int
-hostapd_read_sta_data(struct hostapd_data *hapd,
-                     struct hostap_sta_driver_data *data, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
-               return -1;
-       return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
-}
-
-static inline int
 hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
 {
        if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
@@ -265,14 +256,6 @@ hostapd_set_country(struct hostapd_data *hapd, const char *country)
 }
 
 static inline int
-hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
-               return 0;
-       return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
-}
-
-static inline int
 hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
                   const u8 *head, size_t head_len,
                   const u8 *tail, size_t tail_len, int dtim_period,
index 292a582..b5f8f11 100644 (file)
@@ -24,6 +24,7 @@ struct upnp_wps_device_sm;
 struct hapd_interfaces;
 struct hostapd_data;
 struct sta_info;
+struct hostap_sta_driver_data;
 
 #ifdef CONFIG_FULL_DYNAMIC_VLAN
 struct full_dynamic_vlan;
@@ -56,6 +57,10 @@ struct hostapd_driver_ops {
                       wpa_alg alg, const u8 *addr, int key_idx,
                       int set_tx, const u8 *seq, size_t seq_len,
                       const u8 *key, size_t key_len);
+       int (*read_sta_data)(struct hostapd_data *hapd,
+                            struct hostap_sta_driver_data *data,
+                            const u8 *addr);
+       int (*sta_clear_stats)(struct hostapd_data *hapd, const u8 *addr);
 };
 
 /**