wpa_impl.h revision 4ac67f0276a8313b5cefec38af347b94b7bfb526
/*
* 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.
*/
#ifndef __WPA_IMPL_H
#define __WPA_IMPL_H
#include <libdladm.h>
#include <libdllink.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BIT(n) (1 << (n))
#define WPA_CIPHER_NONE BIT(0)
#define WPA_KEY_MGMT_IEEE8021X BIT(0)
#define WPA_PROTO_WPA BIT(0)
#pragma pack(1)
struct ieee802_1x_hdr {
/* followed by length octets of data */
};
#pragma pack()
#define EAPOL_VERSION 2
enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
};
enum { EAPOL_KEY_TYPE_RC4 = 1,
EAPOL_KEY_TYPE_RSN = 2,
EAPOL_KEY_TYPE_WPA = 254
};
#define WPA_NONCE_LEN 32
#define WPA_REPLAY_COUNTER_LEN 8
#define MAX_PSK_LENGTH 64
#define WPA_PMK_LEN 32
#pragma pack(1)
struct wpa_eapol_key {
/* followed by key_data_length bytes of key_data */
};
#pragma pack()
#define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 BIT(0)
#define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
#define WPA_CAPABILITY_PREAUTH BIT(0)
#define GENERIC_INFO_ELEM 0xdd
#define RSN_INFO_ELEM 0x30
#define MAX_LOGBUF 4096
#define MAX_SCANRESULTS 64
enum {
REASON_UNSPECIFIED = 1,
REASON_INVALID_IE = 13,
REASON_AKMP_NOT_VALID = 20,
};
/*
* wpa_supplicant
*/
#define PMKID_LEN 16
#define PMK_LEN 32
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
struct rsn_pmksa_cache {
struct rsn_pmksa_cache *next;
int akmp; /* WPA_KEY_MGMT_* */
};
struct rsn_pmksa_candidate {
struct rsn_pmksa_candidate *next;
};
#pragma pack(1)
struct wpa_ptk {
union {
struct {
} auth;
} u;
};
#pragma pack()
struct wpa_supplicant {
struct l2_packet_data *l2;
unsigned char own_addr[IEEE80211_ADDR_LEN];
/* The handle required for libdladm calls */
char kname[DLADM_SECOBJ_NAME_MAX];
/* ANonce from the last 1/4 msg */
int renew_snonce;
struct wpa_config *conf;
int reassociate; /* reassociation requested */
/*
* Selected configuration
*/
int proto;
int pairwise_cipher;
int group_cipher;
int key_mgmt;
struct wpa_driver_ops *driver;
enum {
} wpa_state;
int pmksa_count; /* number of entries in PMKSA cache */
struct rsn_pmksa_candidate *pmksa_candidates;
/*
* number of EAPOL packets received after the
* previous association event
*/
int eapol_received;
};
struct wpa_ie_data {
int proto;
int pairwise_cipher;
int group_cipher;
int key_mgmt;
int capabilities;
};
/* WPA configuration */
struct wpa_ssid {
int bssid_set;
int psk_set;
char *passphrase;
int pairwise_cipher;
int group_cipher;
int key_mgmt;
int proto; /* Bitfield of allowed protocols (WPA_PROTO_*) */
};
struct wpa_config {
int eapol_version;
/* int ap_scan; */
};
struct wpa_config *wpa_config_read(void *);
void wpa_config_free(struct wpa_config *);
/*
* Debugging function - conditional printf and hex dump.
* Driver wrappers can use these for debugging purposes.
*/
void wpa_printf(int, char *, ...);
void wpa_event_handler(void *, wpa_event_type);
void wpa_supplicant_rx_eapol(void *, unsigned char *, unsigned char *, size_t);
void wpa_supplicant_scan(void *, void *);
void wpa_supplicant_req_scan(struct wpa_supplicant *, int, int);
void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *, int, int);
void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *);
void wpa_supplicant_disassociate(struct wpa_supplicant *, int);
void pmksa_cache_free(struct wpa_supplicant *);
void pmksa_candidate_free(struct wpa_supplicant *);
size_t, struct wpa_ie_data *);
#ifdef __cplusplus
}
#endif
#endif /* __WPA_IMPL_H */