Use otherwise-useless byte in DHCP feature option as a version number
[people/xl0/gpxe.git] / src / include / gpxe / features.h
1 #ifndef _GPXE_FEATURES_H
2 #define _GPXE_FEATURES_H
3
4 #include <stdint.h>
5 #include <gpxe/tables.h>
6 #include <gpxe/dhcp.h>
7
8 /** @file
9  *
10  * Feature list
11  *
12  */
13
14 /**
15  * @defgroup dhcpfeatures DHCP feature option tags
16  *
17  * DHCP feature option tags are Etherboot encapsulated options in the
18  * range 0x10-0x7f.
19  *
20  * @{
21  */
22
23 /** PXE API extensions */
24 #define DHCP_EB_FEATURE_PXE_EXT 0x10
25
26 /** iSCSI */
27 #define DHCP_EB_FEATURE_ISCSI 0x11
28
29 /** AoE */
30 #define DHCP_EB_FEATURE_AOE 0x12
31
32 /** HTTP */
33 #define DHCP_EB_FEATURE_HTTP 0x13
34
35 /** HTTPS */
36 #define DHCP_EB_FEATURE_HTTPS 0x14
37
38 /** @} */
39
40 /** Declare a feature code for DHCP */
41 #define __dhcp_feature __table ( uint8_t, dhcp_features, 01 )
42
43 /** Construct a DHCP feature table entry */
44 #define DHCP_FEATURE( feature_opt, version ) \
45         _DHCP_FEATURE ( OBJECT, feature_opt, version )
46 #define _DHCP_FEATURE( _name, feature_opt, version ) \
47         __DHCP_FEATURE ( _name, feature_opt, version )
48 #define __DHCP_FEATURE( _name, feature_opt, version )           \
49         uint8_t __dhcp_feature_ ## _name [] __dhcp_feature = {  \
50                 feature_opt, DHCP_BYTE ( version )              \
51         };
52
53 /** Declare a named feature */
54 #define __feature_name __table ( char *, features, 01 )
55
56 /** Construct a named feature */
57 #define FEATURE_NAME( text ) \
58         _FEATURE_NAME ( OBJECT, text )
59 #define _FEATURE_NAME( _name, text ) \
60         __FEATURE_NAME ( _name, text )
61 #define __FEATURE_NAME( _name, text )                           \
62         char * __feature_ ## _name __feature_name = text;
63
64 /** Declare a feature */
65 #define FEATURE( text, feature_opt, version )                   \
66         FEATURE_NAME ( text );                                  \
67         DHCP_FEATURE ( feature_opt, version );
68
69 #endif /* _GPXE_FEATURES_H */