blob: 58f6084ed10abd568a59094e8e6d54eb7471b0c1 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * hostapd / IEEE 802.1X-2004 Authenticator
3 * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef IEEE802_1X_H
10#define IEEE802_1X_H
11
12struct hostapd_data;
13struct sta_info;
14struct eapol_state_machine;
15struct hostapd_config;
16struct hostapd_bss_config;
17
18#ifdef _MSC_VER
19#pragma pack(push, 1)
20#endif /* _MSC_VER */
21
22/* RFC 3580, 4. RC4 EAPOL-Key Frame */
23
24struct ieee802_1x_eapol_key {
25 u8 type;
26 u16 key_length;
27 u8 replay_counter[8]; /* does not repeat within the life of the keying
28 * material used to encrypt the Key field;
29 * 64-bit NTP timestamp MAY be used here */
30 u8 key_iv[16]; /* cryptographically random number */
31 u8 key_index; /* key flag in the most significant bit:
32 * 0 = broadcast (default key),
33 * 1 = unicast (key mapping key); key index is in the
34 * 7 least significant bits */
35 u8 key_signature[16]; /* HMAC-MD5 message integrity check computed with
36 * MS-MPPE-Send-Key as the key */
37
38 /* followed by key: if packet body length = 44 + key length, then the
39 * key field (of key_length bytes) contains the key in encrypted form;
40 * if packet body length = 44, key field is absent and key_length
41 * represents the number of least significant octets from
42 * MS-MPPE-Send-Key attribute to be used as the keying material;
43 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
44} STRUCT_PACKED;
45
46#ifdef _MSC_VER
47#pragma pack(pop)
48#endif /* _MSC_VER */
49
50
51void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
52 size_t len);
53void ieee802_1x_new_station(struct hostapd_data *hapd, struct sta_info *sta);
54void ieee802_1x_free_station(struct sta_info *sta);
55
56void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta);
57void ieee802_1x_abort_auth(struct hostapd_data *hapd, struct sta_info *sta);
58void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
59 struct sta_info *sta, int authorized);
60void ieee802_1x_dump_state(FILE *f, const char *prefix, struct sta_info *sta);
61int ieee802_1x_init(struct hostapd_data *hapd);
62void ieee802_1x_deinit(struct hostapd_data *hapd);
63int ieee802_1x_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
64 const u8 *buf, size_t len, int ack);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080065int ieee802_1x_eapol_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
66 const u8 *data, int len, int ack);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070067u8 * ieee802_1x_get_identity(struct eapol_state_machine *sm, size_t *len);
68u8 * ieee802_1x_get_radius_class(struct eapol_state_machine *sm, size_t *len,
69 int idx);
70const u8 * ieee802_1x_get_key(struct eapol_state_machine *sm, size_t *len);
71void ieee802_1x_notify_port_enabled(struct eapol_state_machine *sm,
72 int enabled);
73void ieee802_1x_notify_port_valid(struct eapol_state_machine *sm,
74 int valid);
75void ieee802_1x_notify_pre_auth(struct eapol_state_machine *sm, int pre_auth);
76int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen);
77int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
78 char *buf, size_t buflen);
79void hostapd_get_ntp_timestamp(u8 *buf);
80char *eap_type_text(u8 type);
81
82const char *radius_mode_txt(struct hostapd_data *hapd);
83int radius_sta_rate(struct hostapd_data *hapd, struct sta_info *sta);
84
85#endif /* IEEE802_1X_H */