iPXE
eap.h
Go to the documentation of this file.
1 #ifndef _IPXE_EAP_H
2 #define _IPXE_EAP_H
3 
4 /** @file
5  *
6  * Extensible Authentication Protocol
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/netdevice.h>
14 #include <ipxe/timer.h>
15 
16 /** EAP header */
17 struct eap_header {
18  /** Code */
20  /** Identifier */
22  /** Length */
24 } __attribute__ (( packed ));
25 
26 /** EAP request */
27 #define EAP_CODE_REQUEST 1
28 
29 /** EAP request */
30 struct eap_request {
31  /** Header */
32  struct eap_header hdr;
33  /** Type */
35 } __attribute__ (( packed ));
36 
37 /** EAP identity */
38 #define EAP_TYPE_IDENTITY 1
39 
40 /** EAP success */
41 #define EAP_CODE_SUCCESS 3
42 
43 /** EAP failure */
44 #define EAP_CODE_FAILURE 4
45 
46 /** EAP packet */
47 union eap_packet {
48  /** Header */
49  struct eap_header hdr;
50  /** Request */
51  struct eap_request req;
52 };
53 
54 /** EAP link block timeout
55  *
56  * We mark the link as blocked upon receiving a Request-Identity, on
57  * the basis that this most likely indicates that the switch will not
58  * yet be forwarding packets.
59  *
60  * There is no way to tell how frequently the Request-Identity packet
61  * will be retransmitted by the switch. The default value for Cisco
62  * switches seems to be 30 seconds, so treat the link as blocked for
63  * 45 seconds.
64  */
65 #define EAP_BLOCK_TIMEOUT ( 45 * TICKS_PER_SEC )
66 
67 /** EAP protocol wait timeout
68  *
69  * In the EAP model, the supplicant is a pure responder. The model
70  * also defines no acknowledgement response for the final Success or
71  * Failure "requests". This leaves open the possibility that the
72  * final Success or Failure packet is lost, with the supplicant having
73  * no way to determine the final authentication status.
74  *
75  * Sideband mechanisms such as EAPoL-Start may be used to restart the
76  * entire EAP process, as a (crude) workaround for this protocol flaw.
77  * When expecting to receive a further EAP request (e.g. an
78  * authentication challenge), we may wait for some length of time
79  * before triggering this restart. Choose a duration that is shorter
80  * than the link block timeout, so that there is no period during
81  * which we erroneously leave the link marked as not blocked.
82  */
83 #define EAP_WAIT_TIMEOUT ( EAP_BLOCK_TIMEOUT * 7 / 8 )
84 
85 /** An EAP supplicant */
87  /** Network device */
88  struct net_device *netdev;
89  /** Flags */
90  unsigned int flags;
91  /**
92  * Transmit EAP response
93  *
94  * @v supplicant EAP supplicant
95  * @v data Response data
96  * @v len Length of response data
97  * @ret rc Return status code
98  */
99  int ( * tx ) ( struct eap_supplicant *supplicant,
100  const void *data, size_t len );
101 };
102 
103 /** EAP authentication is in progress
104  *
105  * This indicates that we have received an EAP Request-Identity, but
106  * have not yet received a final EAP Success or EAP Failure.
107  */
108 #define EAP_FL_ONGOING 0x0001
109 
110 /** EAP supplicant is passive
111  *
112  * This indicates that the supplicant should not transmit any futher
113  * unsolicited packets (e.g. EAPoL-Start for a supplicant running over
114  * EAPoL). This could be because authentication has already
115  * completed, or because we are relying upon MAC Authentication Bypass
116  * (MAB) which may have a very long timeout.
117  */
118 #define EAP_FL_PASSIVE 0x0002
119 
120 extern int eap_rx ( struct eap_supplicant *supplicant,
121  const void *data, size_t len );
122 
123 #endif /* _IPXE_EAP_H */
int eap_rx(struct eap_supplicant *supplicant, const void *data, size_t len)
Handle EAP packet.
Definition: eap.c:136
#define __attribute__(x)
Definition: compiler.h:10
struct eap_header hdr
Header.
Definition: eap.h:32
unsigned short uint16_t
Definition: stdint.h:11
struct eap_request req
Request.
Definition: eap.h:51
struct eap_header hdr
Header.
Definition: eap.h:49
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
An EAP supplicant.
Definition: eap.h:86
iPXE timers
uint8_t type
Type.
Definition: eap.h:34
EAP header.
Definition: eap.h:17
EAP packet.
Definition: eap.h:47
uint8_t id
Identifier.
Definition: eap.h:21
A network device.
Definition: netdevice.h:352
unsigned char uint8_t
Definition: stdint.h:10
unsigned int flags
Flags.
Definition: eap.h:90
uint16_t len
Length.
Definition: eap.h:23
Network device management.
int(* tx)(struct eap_supplicant *supplicant, const void *data, size_t len)
Transmit EAP response.
Definition: eap.h:99
uint32_t len
Length.
Definition: ena.h:14
uint8_t code
Code.
Definition: eap.h:19
uint8_t data[48]
Additional event data.
Definition: ena.h:22
struct net_device * netdev
Network device.
Definition: eap.h:88
EAP request.
Definition: eap.h:30