blob: 98b0c40aa4bab4d48bf6c7ba053c31af28605b61 [file] [log] [blame]
/*
* hostapd / Interface steering
* Copyright (c) 2015 Google, Inc.
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#ifndef STEERING_H
#define STEERING_H
#define MAX_STEERING_TIMESTAMP_FILES 100
/* 10 seconds is long enough to scan all channels on both bands at least twice
* at 100ms/channel.
*/
#define BANDSTEERING_DELAY_SECONDS 10
#define BANDSTEERING_EXPIRATION_SECONDS 120
extern char *steering_timestamp_path;
extern char *request_logging_path;
struct hostapd_data;
enum hostapd_hw_mode;
struct ieee80211_mgmt;
struct os_reltime;
typedef enum {
LOG_PROBE,
LOG_ASSOC,
LOG_BANDSTEERING_FAILED,
NUM_LOGGED_REQUEST_TYPES } logged_request_type;
typedef enum {
LOGGING_PATH,
STEERING_PATH,
NUM_STEERING_PATH_TYPES } steering_path_type;
/**
* Writes timestamp for the source address in mgmt to request_logging_path.
* Returns 1 if the write succeeded, 0 otherwise.
*/
int write_timestamp_file(const struct ieee80211_mgmt *mgmt,
const struct hostapd_data *hapd,
logged_request_type type,
const struct os_reltime timestamp);
/**
* Calls write_timestamp_file unless there is an existing file younger than
* BANDSTEERING_EXPIRATION_SECONDS. Also garbage collects before writing.
* Returns 0 on write or garbage collection failure, 1 otherwise.
*/
int maybe_write_timestamp_file(const struct ieee80211_mgmt *mgmt,
const struct hostapd_data *hapd,
logged_request_type type);
/**
* Reads a timestamp from either request_logging_path or steering_timestamp_path
* (based on path) for the source address in mgmt, putting the result in
* timestamp. Returns 1 if the read succeeded, 0 otherwise.
*/
int read_timestamp_file(const struct ieee80211_mgmt *mgmt,
logged_request_type type,
steering_path_type path_type,
struct os_reltime *timestamp);
/**
* Delete all but the most recent MAX_TIMESTAMP_FILES files of type LOG_PROBE in
* request_logging_path. Returns the number of files deleted.
*/
int garbage_collect_timestamp_files();
#endif /* STEERING_H */