Remove direct driver calls from accounting.c

This commit is contained in:
Jouni Malinen 2009-12-24 22:24:57 +02:00
parent 41d719d6e0
commit a3d4fafa41
4 changed files with 30 additions and 21 deletions

View file

@ -1,6 +1,6 @@
/* /*
* hostapd / RADIUS Accounting * 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 * 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 * it under the terms of the GNU General Public License version 2 as
@ -16,12 +16,13 @@
#include "common.h" #include "common.h"
#include "hostapd.h" #include "hostapd.h"
#include "drivers/driver.h"
#include "radius/radius.h" #include "radius/radius.h"
#include "radius/radius_client.h" #include "radius/radius_client.h"
#include "eloop.h" #include "eloop.h"
#include "accounting.h" #include "accounting.h"
#include "ieee802_1x.h" #include "ieee802_1x.h"
#include "driver_i.h" #include "config.h"
#include "sta_info.h" #include "sta_info.h"
@ -185,7 +186,7 @@ static int accounting_sta_update_stats(struct hostapd_data *hapd,
struct sta_info *sta, struct sta_info *sta,
struct hostap_sta_driver_data *data) 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; return -1;
if (sta->last_rx_bytes > data->rx_bytes) 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); time(&sta->acct_session_start);
sta->last_rx_bytes = sta->last_tx_bytes = 0; sta->last_rx_bytes = sta->last_tx_bytes = 0;
sta->acct_input_gigawords = sta->acct_output_gigawords = 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) if (!hapd->conf->radius->acct_server)
return; return;

View 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) void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
{ {
ops->set_ap_wps_ie = hostapd_set_ap_wps_ie; 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->send_eapol = hostapd_send_eapol;
ops->set_authorized = hostapd_set_authorized; ops->set_authorized = hostapd_set_authorized;
ops->set_key = hostapd_set_key; ops->set_key = hostapd_set_key;
ops->read_sta_data = hostapd_read_sta_data;
ops->sta_clear_stats = hostapd_sta_clear_stats;
} }

View file

@ -107,15 +107,6 @@ hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
hapd->drv_priv, elem, elem_len); hapd->drv_priv, elem, elem_len);
} }
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 static inline int
hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason) hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
{ {
@ -264,14 +255,6 @@ hostapd_set_country(struct hostapd_data *hapd, const char *country)
return hapd->driver->set_country(hapd->drv_priv, country); return hapd->driver->set_country(hapd->drv_priv, 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 static inline int
hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd, hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
const u8 *head, size_t head_len, const u8 *head, size_t head_len,

View file

@ -24,6 +24,7 @@ struct upnp_wps_device_sm;
struct hapd_interfaces; struct hapd_interfaces;
struct hostapd_data; struct hostapd_data;
struct sta_info; struct sta_info;
struct hostap_sta_driver_data;
#ifdef CONFIG_FULL_DYNAMIC_VLAN #ifdef CONFIG_FULL_DYNAMIC_VLAN
struct full_dynamic_vlan; struct full_dynamic_vlan;
@ -56,6 +57,10 @@ struct hostapd_driver_ops {
wpa_alg alg, const u8 *addr, int key_idx, wpa_alg alg, const u8 *addr, int key_idx,
int set_tx, const u8 *seq, size_t seq_len, int set_tx, const u8 *seq, size_t seq_len,
const u8 *key, size_t key_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);
}; };
/** /**