• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 struct hostapd_data;
13 struct sta_info;
14 struct eapol_state_machine;
15 struct hostapd_config;
16 struct 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 
24 struct 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 
51 void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
52 			size_t len);
53 void ieee802_1x_new_station(struct hostapd_data *hapd, struct sta_info *sta);
54 void ieee802_1x_free_station(struct sta_info *sta);
55 
56 void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta);
57 void ieee802_1x_abort_auth(struct hostapd_data *hapd, struct sta_info *sta);
58 void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
59 				   struct sta_info *sta, int authorized);
60 void ieee802_1x_dump_state(FILE *f, const char *prefix, struct sta_info *sta);
61 int ieee802_1x_init(struct hostapd_data *hapd);
62 void ieee802_1x_deinit(struct hostapd_data *hapd);
63 int ieee802_1x_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
64 			 const u8 *buf, size_t len, int ack);
65 int ieee802_1x_eapol_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
66 			       const u8 *data, int len, int ack);
67 u8 * ieee802_1x_get_identity(struct eapol_state_machine *sm, size_t *len);
68 u8 * ieee802_1x_get_radius_class(struct eapol_state_machine *sm, size_t *len,
69 				 int idx);
70 const u8 * ieee802_1x_get_key(struct eapol_state_machine *sm, size_t *len);
71 void ieee802_1x_notify_port_enabled(struct eapol_state_machine *sm,
72 				    int enabled);
73 void ieee802_1x_notify_port_valid(struct eapol_state_machine *sm,
74 				  int valid);
75 void ieee802_1x_notify_pre_auth(struct eapol_state_machine *sm, int pre_auth);
76 int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen);
77 int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
78 			   char *buf, size_t buflen);
79 void hostapd_get_ntp_timestamp(u8 *buf);
80 char *eap_type_text(u8 type);
81 
82 const char *radius_mode_txt(struct hostapd_data *hapd);
83 int radius_sta_rate(struct hostapd_data *hapd, struct sta_info *sta);
84 
85 #endif /* IEEE802_1X_H */
86