driver_wifi.c revision a399b7655a1d835aa8606c2b29e4e777baac8635
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2004, Sam Leffler <sam@errno.com>
* Sun elects to license this software under the BSD license.
* See README for more details.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <stdarg.h>
#include <fcntl.h>
#include <unistd.h>
#include <stropts.h>
#include <string.h>
#include <stddef.h>
#include "wpa_impl.h"
#include "driver.h"
/*
* get_bssid - get the current BSSID
* @ifname: interface name, e.g., wlan0
* @bssid: buffer for BSSID (IEEE80211_ADDR_LEN = 6 bytes)
*
* Returns: 0 on success, -1 on failure
*
* Query kernel driver for the current BSSID and copy it to @bssid.
* Setting @bssid to 00:00:00:00:00:00 is recommended if the STA is not
* associated.
*/
int
{
int ret;
if (ret != DLADM_STATUS_OK)
return (-1);
return (-1);
return (WPA_STATUS(ret));
}
/*
* get_ssid - get the current SSID
* @ifname: interface name, e.g., wlan0
* @ssid: buffer for SSID (at least 32 bytes)
*
* Returns: length of the SSID on success, -1 on failure
*
* Query kernel driver for the current SSID and copy it to @ssid.
* Returning zero is recommended if the STA is not associated.
*/
int
{
int ret;
if (ret != DLADM_STATUS_OK)
return (-1);
return (-1);
return (ret);
}
static int
wpa_driver_wifi_set_wpa_ie(const char *ifname,
{
int ret;
return (WPA_STATUS(ret));
}
/*
* @ifname: interface name, e.g., wlan0
* @enabled: 1 = enable, 0 = disable
*
* Returns: 0 on success, -1 on failure
*
* be empty function, if WPA support is always enabled. Common
* configuration items are WPA IE (clearing it when WPA support is
* disabled), Privacy flag for capability field, roaming mode (need to
* allow wpa_supplicant to control roaming).
*/
static int
{
int ret;
return (-1);
return (WPA_STATUS(ret));
}
static int
{
int ret;
key_idx);
return (WPA_STATUS(ret));
}
/*
* set_key - configure encryption key
* @ifname: interface name, e.g., wlan0
* @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
* %WPA_ALG_TKIP, %WPA_ALG_CCMP); %WPA_ALG_NONE clears the key.
* @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
* @key_idx: key index (0..3), always 0 for unicast keys
* @set_tx: configure this key as the default Tx key (only used when
* driver does not support separate unicast/individual key
* packet number to be used for in replay protection; configured
* for Rx keys (in most cases, this is only used with broadcast
* keys and set to zero for unicast keys)
* @seq_len: length of the @seq, depends on the algorithm:
* TKIP: 6 octets, CCMP: 6 octets
* @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
* 8-byte Rx Mic Key
* @key_len: length of the key buffer in octets (WEP: 5 or 13,
* TKIP: 32, CCMP: 16)
*
* Returns: 0 on success, -1 on failure
*
* Configure the given key for the kernel driver. If the driver
* supports separate individual keys (4 default keys + 1 individual),
* @addr can be used to determine whether the key is default or
* individual. If only 4 keys are supported, the default key with key
* index 0 is used as the individual key. STA must be configured to use
* it as the default Tx key (@set_tx is set) and accept Rx for all the
* key indexes. In most cases, WPA uses only key indexes 1 and 2 for
* broadcast keys, so key index 0 is available for this kind of
* configuration.
*/
static int
{
char *alg_name;
int ret;
if (alg == WPA_ALG_NONE)
switch (alg) {
case WPA_ALG_WEP:
alg_name = "WEP";
break;
case WPA_ALG_TKIP:
alg_name = "TKIP";
break;
case WPA_ALG_CCMP:
alg_name = "CCMP";
break;
default:
" unknown/unsupported algorithm %d", alg);
return (-1);
}
" set_tx=%d seq_len=%d seq=%d key_len=%d",
" seq_len %d too big", seq_len);
return (-1);
}
return (WPA_STATUS(ret));
}
/*
* disassociate - request driver to disassociate
* @ifname: interface name, e.g., wlan0
* @reason_code: 16-bit reason code to be sent in the disassociation
* frame
*
* Return: 0 on success, -1 on failure
*/
static int
{
int ret;
reason_code, NULL);
return (WPA_STATUS(ret));
}
/*
* associate - request driver to associate
* @ifname: interface name, e.g., wlan0
* @bssid: BSSID of the selected AP
* @wpa_ie: WPA information element to be included in (Re)Association
* Request (including information element id and length). Use of
* this WPA IE is optional. If the driver generates the WPA IE, it
* can use @pairwise_suite, @group_suite, and @key_mgmt_suite
* to select proper algorithms. In this case, the driver has to
* notify wpa_supplicant about the used WPA IE by generating an
* event that the interface code will convert into EVENT_ASSOCINFO
* data (see wpa_supplicant.h). When using WPA2/IEEE 802.11i,
* @wpa_ie is used for RSN IE instead. The driver can determine
* which version is used by looking at the first byte of the IE
* @wpa_ie_len: length of the @wpa_ie
*
* Return: 0 on success, -1 on failure
*/
static int
{
int ret;
/*
* NB: Don't need to set the freq or cipher-related state as
* this is implied by the bssid which is used to locate
* the scanned node state which holds it.
*/
return (-1);
0, &bss);
return (WPA_STATUS(ret));
}
/*
* scan - request the driver to initiate scan
* @ifname: interface name, e.g., wlan0
*
* Return: 0 on success, -1 on failure
*
* Once the scan results are ready, the driver should report scan
* results event for wpa_supplicant which will eventually request the
* results with wpa_driver_get_scan_results().
*/
static int
wpa_driver_wifi_scan(const char *ifname)
{
int ret;
/*
* We force the state to INIT before calling ieee80211_new_state
* to get ieee80211_begin_scan called. We really want to scan w/o
* altering the current state but that's not possible right now.
*/
(void) wpa_driver_wifi_disassociate(ifname,
return (WPA_STATUS(ret));
}
/*
* get_scan_results - fetch the latest scan results
* @ifname: interface name, e.g., wlan0
* @results: pointer to buffer for scan results
* @max_size: maximum number of entries (buffer size)
*
* Return: number of scan result entries used on success, -1 on failure
*
* If scan results include more than @max_size BSSes, @max_size will be
* returned and the remaining entries will not be included in the
* buffer.
*/
int
wpa_driver_wifi_get_scan_results(const char *ifname,
{
!= DLADM_STATUS_OK) {
return (-1);
}
return (ret);
}
struct wpa_driver_ops wpa_driver_wifi_ops = {
};