ieee802_1x.h revision 04949598a23f501be6eec21697465fd46a28840a
1/*
2 * hostapd / IEEE 802.1X-2004 Authenticator
3 * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
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);
65int ieee802_1x_eapol_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
66			       const u8 *data, int len, int ack);
67u8 * 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);
70struct wpabuf * ieee802_1x_get_radius_cui(struct eapol_state_machine *sm);
71const u8 * ieee802_1x_get_key(struct eapol_state_machine *sm, size_t *len);
72void ieee802_1x_notify_port_enabled(struct eapol_state_machine *sm,
73				    int enabled);
74void ieee802_1x_notify_port_valid(struct eapol_state_machine *sm,
75				  int valid);
76void ieee802_1x_notify_pre_auth(struct eapol_state_machine *sm, int pre_auth);
77int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen);
78int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
79			   char *buf, size_t buflen);
80void hostapd_get_ntp_timestamp(u8 *buf);
81char *eap_type_text(u8 type);
82
83const char *radius_mode_txt(struct hostapd_data *hapd);
84int radius_sta_rate(struct hostapd_data *hapd, struct sta_info *sta);
85
86#endif /* IEEE802_1X_H */
87