summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/eapol.h
blob: dcf392946eac5a9fc18f870073203ddcd9a424d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef _IPXE_EAPOL_H
#define _IPXE_EAPOL_H

/** @file
 *
 * Extensible Authentication Protocol over LAN (EAPoL)
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

#include <stdint.h>
#include <ipxe/netdevice.h>
#include <ipxe/tables.h>
#include <ipxe/eap.h>

/** EAPoL header */
struct eapol_header {
	/** Version */
	uint8_t version;
	/** Type */
	uint8_t type;
	/** Payload length */
	uint16_t len;
} __attribute__ (( packed ));

/** 802.1X-2001 */
#define EAPOL_VERSION_2001 1

/** EAPoL-encapsulated EAP packets */
#define EAPOL_TYPE_EAP 0

/** EAPoL start */
#define EAPOL_TYPE_START 1

/** EAPoL key */
#define EAPOL_TYPE_KEY 5

/** An EAPoL supplicant */
struct eapol_supplicant {
	/** EAP supplicant */
	struct eap_supplicant eap;
	/** EAPoL-Start retransmission timer */
	struct retry_timer timer;
	/** EAPoL-Start transmission count */
	unsigned int count;
};

/** Delay between EAPoL-Start packets */
#define EAPOL_START_INTERVAL ( 2 * TICKS_PER_SEC )

/** Maximum number of EAPoL-Start packets to transmit */
#define EAPOL_START_COUNT 3

/** An EAPoL handler */
struct eapol_handler {
	/** Type */
	uint8_t type;
	/**
	 * Process received packet
	 *
	 * @v supplicant	EAPoL supplicant
	 * @v iobuf		I/O buffer
	 * @v ll_source		Link-layer source address
	 * @ret rc		Return status code
	 *
	 * This method takes ownership of the I/O buffer.
	 */
	int ( * rx ) ( struct eapol_supplicant *supplicant,
		       struct io_buffer *iobuf, const void *ll_source );
};

/** EAPoL handler table */
#define EAPOL_HANDLERS __table ( struct eapol_handler, "eapol_handlers" )

/** Declare an EAPoL handler */
#define __eapol_handler __table_entry ( EAPOL_HANDLERS, 01 )

extern struct net_protocol eapol_protocol __net_protocol;

#endif /* _IPXE_EAPOL_H */