wpa_supplicant.c revision fe3e6e3a98f98e7ab1a751934c0116fb914b9c82
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
* Sun elects to license this software under the BSD license.
* See README for more details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <syslog.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <door.h>
#include <libscf.h>
#include <libdladm.h>
#include <libdllink.h>
#include <sys/ethernet.h>
#include "wpa_impl.h"
#include "wpa_enc.h"
#include "driver.h"
#include "eloop.h"
#include "l2_packet.h"
extern struct wpa_driver_ops wpa_driver_wifi_ops;
int wpa_debug_level = MSG_ERROR;
/*
* wpa_printf - conditional printf
* @level: priority level (MSG_*) of the message
* @fmt: printf format string, followed by optional arguments
*
* This function is used to print conditional debugging and error messages. The
* configuration.
*/
void
{
char buffer[MAX_LOGBUF];
if (level < wpa_debug_level)
return;
/* LINTED E_SEC_PRINTF_VAR_FMT */
}
/*
* wpa_hexdump - conditional hex dump
* @level: priority level (MSG_*) of the message
* @title: title of for the message
* @buf: data buffer to be dumped
* @len: length of the @buf
*
* This function is used to print conditional debugging and error messages. The
* configuration. The contents of @buf is printed out has hex dump.
*/
void
{
size_t i;
int n;
if (level < wpa_debug_level)
return;
for (i = 0; i < len; i++) {
if (n >= MAX_LOGBUF) break;
}
}
static const char *
{
char *pos;
if (ssid_len > MAX_ESSID_LENGTH)
*pos = '_';
}
return (ssid_txt);
}
/* ARGSUSED */
void
{
return;
if (ssid) {
}
}
}
void
{
}
void
{
}
/* ARGSUSED */
static void
{
wpa_supplicant_req_scan(wpa_s, 0, 0);
}
void
{
}
void
{
}
static void
{
}
}
static void
{
if (addr) {
}
}
static void
{
}
static int
{
struct wpa_ie_data ie;
/* RSN or WPA */
} else {
}
"the selected BSS.");
return (-1);
}
if (sel & WPA_CIPHER_CCMP) {
} else if (sel & WPA_CIPHER_TKIP) {
} else if (sel & WPA_CIPHER_WEP104) {
} else if (sel & WPA_CIPHER_WEP40) {
} else {
return (-1);
}
if (sel & WPA_CIPHER_CCMP) {
} else if (sel & WPA_CIPHER_TKIP) {
} else if (sel & WPA_CIPHER_NONE) {
} else {
"cipher.");
return (-1);
}
if (sel & WPA_KEY_MGMT_IEEE8021X) {
} else if (sel & WPA_KEY_MGMT_PSK) {
} else {
"key management type.");
return (-1);
}
if (*wpa_ie_len < 0) {
return (-1);
}
else {
}
return (0);
}
{
int wpa_ie_len;
wpa_s->reassociate = 0;
if (bss->we_wpa_ie_len &&
}
wpa_ie, &wpa_ie_len)) {
"management and encryption suites");
return;
}
} else {
wpa_ie_len = 0;
}
/* Timeout for IEEE 802.11 authentication and association */
}
void
{
IEEE80211_ADDR_LEN) != 0) {
}
}
static dladm_wlan_ess_t *
{
int i;
struct wpa_ie_data ie;
/* try to find matched AP */
"wpa_ie_len=%d",
bss->we_wpa_ie_len);
if (bss->we_wpa_ie_len == 0) {
}
bss->we_ssid_len) != 0) {
continue;
}
continue;
}
continue;
}
continue;
}
continue;
}
continue;
}
*selected_ssid = ssid;
}
return (selected);
}
static void
{
int num;
if (num < 0)
return;
if (num > MAX_SCANRESULTS) {
}
if (selected) {
if (wpa_s->reassociate ||
IEEE80211_ADDR_LEN) != 0) {
} else {
"selected AP.");
}
} else {
}
}
/*
* wpa_event_handler - report a driver event for wpa_supplicant
* @wpa_s: pointer to wpa_supplicant data; this is the @ctx variable registered
* with wpa_driver_events_init()
* @event: event type (defined above)
*
* Driver wrapper code should call this function whenever an event is received
* from the driver.
*/
void
{
switch (event) {
case EVENT_ASSOC:
/* async event */
} else {
/* Timeout for receiving first EAPOL packet */
}
}
break;
case EVENT_DISASSOC:
break;
case EVENT_SCAN_RESULTS:
/* reset vars */
wpa_s->rx_replay_counter_set = 0;
wpa_s->eapol_received = 0;
break;
default:
break;
}
}
/* ARGSUSED */
static void
{
}
static int
{
return (-1);
return (-1);
}
return (-1);
}
return (0);
}
static int door_id = -1;
/* ARGSUSED */
static void
{
/* LINTED E_BAD_PTR_CAST_ALIGN */
}
/*
* Create the driver to wpad door
*/
int
{
int error = 0;
/*
* Create the door
*/
if (door_id < 0) {
error = -1;
goto out;
}
int newfd;
(void) door_revoke(door_id);
door_id = -1;
error = -1;
goto out;
}
}
(void) door_revoke(door_id);
door_id = -1;
error = -1;
goto out;
}
}
out:
return (error);
}
void
{
if (door_id == -1)
return;
}
}
}
static int
{
return (-1);
}
return (-1);
}
return (0);
}
static struct wpa_ssid *
{
return (NULL);
/*
* Set default supported values
*/
if (ssid->passphrase) {
}
"management, but no PSK configured.");
}
return (ssid);
}
struct wpa_config *
wpa_config_read(void *arg)
{
struct wpa_config *config;
return (NULL);
} else {
}
return (config);
}
void
{
}
}
static int
{
int retv;
return (-1);
if (retv != 0)
if (setsid() == -1)
return (-1);
return (-1);
if (!noclose) {
(void) close(0);
(void) close(1);
(void) close(2);
}
}
return (0);
}
/*
* make sure wpad is running under SMF context.
*/
static boolean_t
is_smf_context(void)
{
char *fmri;
}
int
{
struct wpa_supplicant wpa_s;
int c;
int exitcode;
char door_file[MAXPATHLEN];
if (!is_smf_context()) {
"wpad is an smf(5) managed service and cannot be run from "
"the command line; please use dladm(1M).\n");
return (SMF_EXIT_ERR_NOSMF);
}
for (;;) {
if (c < 0)
break;
switch (c) {
case 'i':
break;
case 'k':
break;
default:
return (SMF_EXIT_ERR_CONFIG);
}
}
/*
* key name is required to retrieve PSK value through libwdladm APIs.
* key is saved by dladm command by keyname
* see dladm.
*/
return (-1);
}
return (-1);
}
if (daemon(0, 0))
return (-1);
/*
* Hold this link open to prevent a link renaming operation.
*/
return (-1);
}
dlpi_close(dh);
return (-1);
}
/*
* Get the device name of the link, which will be used as the door
* file name used to communicate with the driver. Note that different
* links use different doors.
*/
"Failed to get device name of link '%s'.", link);
dlpi_close(dh);
return (-1);
}
eloop_init(&wpa_s);
/*
* get ESSID and PSK value
*/
exitcode = -1;
goto cleanup;
}
exitcode = 0;
/*
* Setup door file to communicate with driver
*/
exitcode = -1;
goto cleanup;
}
exitcode = -1;
goto cleanup;
}
/*
* This link is hold again in wpa_supplicant_driver_init(), so that
* we release the first reference.
*/
dlpi_close(dh);
eloop_run();
}
dlpi_close(dh);
return (exitcode);
}