@@ -45,6 +45,49 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE;
4545#define DHCP6_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'S')
4646#define DHCP6_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'I')
4747
48+ //
49+ // For more information on DHCP options see RFC 8415, Section 21.1
50+ //
51+ // The format of DHCP options is:
52+ //
53+ // 0 1 2 3
54+ // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
55+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56+ // | option-code | option-len |
57+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58+ // | option-data |
59+ // | (option-len octets) |
60+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61+ //
62+ #define DHCP6_SIZE_OF_OPT_CODE (sizeof(UINT16))
63+ #define DHCP6_SIZE_OF_OPT_LEN (sizeof(UINT16))
64+
65+ //
66+ // Combined size of Code and Length
67+ //
68+ #define DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN (DHCP6_SIZE_OF_OPT_CODE + \
69+ DHCP6_SIZE_OF_OPT_LEN)
70+
71+ STATIC_ASSERT (
72+ DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN == 4 ,
73+ "Combined size of Code and Length must be 4 per RFC 8415"
74+ );
75+
76+ //
77+ // Offset to the length is just past the code
78+ //
79+ #define DHCP6_OPT_LEN_OFFSET (a ) (a + DHCP6_SIZE_OF_OPT_CODE)
80+ STATIC_ASSERT (
81+ DHCP6_OPT_LEN_OFFSET (0 ) == 2 ,
82+ "Offset of length is + 2 past start of option"
83+ );
84+
85+ #define DHCP6_OPT_DATA_OFFSET (a ) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN)
86+ STATIC_ASSERT (
87+ DHCP6_OPT_DATA_OFFSET (0 ) == 4 ,
88+ "Offset to option data should be +4 from start of option"
89+ );
90+
4891#define DHCP6_PACKET_ALL 0
4992#define DHCP6_PACKET_STATEFUL 1
5093#define DHCP6_PACKET_STATELESS 2
0 commit comments