iPXE
pccrr.h
Go to the documentation of this file.
1#ifndef _IPXE_PCCRR_H
2#define _IPXE_PCCRR_H
4/** @file
5 *
6 * Peer Content Caching and Retrieval: Retrieval Protocol [MS-PCCRR]
7 *
8 * All fields are in network byte order.
9 *
10 */
12FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13FILE_SECBOOT ( PERMITTED );
14
15#include <stdint.h>
16
17struct interface;
18
19/** Magic retrieval URI path */
20#define PEERDIST_MAGIC_PATH "/116B50EB-ECE2-41ac-8429-9F9E963361B7/"
21
22/** Retrieval protocol version */
24 /** Raw version number */
26 /** Major:minor version number */
27 struct {
28 /** Minor version number */
30 /** Major version number */
32 } __attribute__ (( packed ));
33} __attribute__ (( packed ));
34
35/** Retrieval protocol version 1.0 */
36#define PEERDIST_MSG_VERSION_1_0 0x00000001UL
37
38/** Retrieval protocol version 2.0 */
39#define PEERDIST_MSG_VERSION_2_0 0x00000002UL
40
41/** Retrieval protocol supported versions */
43 /** Minimum supported protocol version */
45 /** Maximum supported protocol version */
47} __attribute__ (( packed ));
48
49/** Retrieval protocol block range */
51 /** First block in range */
53 /** Number of blocks in range */
55} __attribute__ (( packed ));
56
57/** Retrieval protocol segment ID header */
59 /** Digest size (i.e. length of segment ID) */
61 /* Followed by a single variable-length ID and padding:
62 *
63 * uint8_t id[digestsize];
64 * uint8_t pad[ (-digestsize) & 0x3 ];
65 */
66} __attribute__ (( packed ));
67
68/** Retrieval protocol segment ID
69 *
70 * @v digestsize Digest size
71 */
72#define peerdist_msg_segment_t( digestsize ) \
73 struct { \
74 struct peerdist_msg_segment segment; \
75 uint8_t id[digestsize]; \
76 uint8_t pad[ ( -(digestsize) ) & 0x3 ]; \
77 } __attribute__ (( packed ))
78
79/** Retrieval protocol block range list header */
81 /** Number of ranges */
83 /* Followed by an array of block ranges:
84 *
85 * struct peerdist_msg_range range[count];
86 */
87} __attribute__ (( packed ));
88
89/** Retrieval protocol block range list
90 *
91 * @v count Number of ranges
92 */
93#define peerdist_msg_ranges_t( count ) \
94 struct { \
95 struct peerdist_msg_ranges ranges; \
96 struct peerdist_msg_range range[count]; \
97 } __attribute__ (( packed ))
98
99/** Retrieval protocol data block header */
101 /** Length of data block */
103 /* Followed by the (encrypted) data block:
104 *
105 * uint8_t data[len];
106 */
107} __attribute__ (( packed ));
108
109/** Retrieval protocol data block */
110#define peerdist_msg_block_t( len ) \
111 struct { \
112 struct peerdist_msg_block block; \
113 uint8_t data[len]; \
114 } __attribute__ (( packed ))
115
116/** Retrieval protocol initialisation vector header */
118 /** Cipher block size */
120 /* Followed by the initialisation vector:
121 *
122 * uint8_t data[blksize];
123 */
124} __attribute__ (( packed ));
125
126/** Retrieval protocol initialisation vector */
127#define peerdist_msg_iv_t( blksize ) \
128 struct { \
129 struct peerdist_msg_iv iv; \
130 uint8_t data[blksize]; \
131 } __attribute__ (( packed ))
132
133/** Retrieval protocol useless VRF data header */
135 /** Length of useless VRF data */
137 /* Followed by a variable-length useless VRF data block and
138 * padding:
139 *
140 * uint8_t data[len];
141 * uint8_t pad[ (-len) & 0x3 ];
142 */
143} __attribute__ (( packed ));
144
145/** Retrieval protocol useless VRF data */
146#define peerdist_msg_useless_vrf_t( vrf_len ) \
147 struct { \
148 struct peerdist_msg_useless_vrf vrf; \
149 uint8_t data[vrf_len]; \
150 uint8_t pad[ ( -(vrf_len) ) & 0x3 ]; \
151 } __attribute__ (( packed ))
152
153/** Retrieval protocol message header */
155 /** Protocol version
156 *
157 * This is the protocol version in which the message type was
158 * first defined.
159 */
161 /** Message type */
163 /** Message size (including this header) */
165 /** Cryptographic algorithm ID */
167} __attribute__ (( packed ));
168
169/** Retrieval protocol cryptographic algorithm IDs */
171 /** No encryption */
173 /** AES-128 in CBC mode */
175 /** AES-192 in CBC mode */
177 /** AES-256 in CBC mode */
180
181/** Retrieval protocol transport response header */
183 /** Length (excluding this header)
184 *
185 * This seems to be identical in both purpose and value to the
186 * length found within the message header, and therefore
187 * serves no useful purpose.
188 */
190} __attribute__ (( packed ));
191
192/** Retrieval protocol negotiation request */
194 /** Message header */
196 /** Supported versions */
198} __attribute__ (( packed ));
199
200/** Retrieval protocol negotiation request version */
201#define PEERDIST_MSG_NEGO_REQ_VERSION PEERDIST_MSG_VERSION_1_0
202
203/** Retrieval protocol negotiation request type */
204#define PEERDIST_MSG_NEGO_REQ_TYPE 0x00000000UL
205
206/** Retrieval protocol negotiation response */
208 /** Message header */
210 /** Supported versions */
212} __attribute__ (( packed ));
213
214/** Retrieval protocol negotiation response version */
215#define PEERDIST_MSG_NEGO_RESP_VERSION PEERDIST_MSG_VERSION_1_0
216
217/** Retrieval protocol negotiation response type */
218#define PEERDIST_MSG_NEGO_RESP_TYPE 0x00000001UL
219
220/** Retrieval protocol block list request header */
222 /** Message header */
224 /* Followed by a segment ID and a block range list:
225 *
226 * peerdist_msg_segment_t(digestsize) segment;
227 * peerdist_msg_ranges_t(count) ranges;
228 */
229} __attribute__ (( packed ));
230
231/** Retrieval protocol block list request
232 *
233 * @v digestsize Digest size
234 * @v count Block range count
235 */
236#define peerdist_msg_getblklist_t( digestsize, count ) \
237 struct { \
238 struct peerdist_msg_getblklist getblklist; \
239 peerdist_msg_segment_t ( digestsize ) segment; \
240 peerdist_msg_ranges_t ( count ) ranges; \
241 } __attribute__ (( packed ))
242
243/** Retrieval protocol block list request version */
244#define PEERDIST_MSG_GETBLKLIST_VERSION PEERDIST_MSG_VERSION_1_0
245
246/** Retrieval protocol block list request type */
247#define PEERDIST_MSG_GETBLKLIST_TYPE 0x00000002UL
248
249/** Retrieval protocol block fetch request header */
251 /** Message header */
253 /* Followed by a segment ID, a block range list, and a useless
254 * VRF block:
255 *
256 * peerdist_msg_segment_t(digestsize) segment;
257 * peerdist_msg_ranges_t(count) ranges;
258 * peerdist_msg_vrf_t(vrf_len) vrf;
259 */
260} __attribute__ (( packed ));
261
262/** Retrieval protocol block fetch request
263 *
264 * @v digestsize Digest size
265 * @v count Block range count
266 * @v vrf_len Length of uselessness
267 */
268#define peerdist_msg_getblks_t( digestsize, count, vrf_len ) \
269 struct { \
270 struct peerdist_msg_getblks getblks; \
271 peerdist_msg_segment_t ( digestsize ) segment; \
272 peerdist_msg_ranges_t ( count ) ranges; \
273 peerdist_msg_useless_vrf_t ( vrf_len ); \
274 } __attribute__ (( packed ))
275
276/** Retrieval protocol block fetch request version */
277#define PEERDIST_MSG_GETBLKS_VERSION PEERDIST_MSG_VERSION_1_0
278
279/** Retrieval protocol block fetch request type */
280#define PEERDIST_MSG_GETBLKS_TYPE 0x00000003UL
281
282/** Retrieval protocol block list response header */
284 /** Message header */
286 /* Followed by a segment ID, a block range list, and a next
287 * block index:
288 *
289 * peerdist_msg_segment_t(digestsize) segment;
290 * peerdist_msg_ranges_t(count) ranges;
291 * uint32_t next;
292 */
293} __attribute__ (( packed ));
294
295/** Retrieval protocol block list response
296 *
297 * @v digestsize Digest size
298 * @v count Block range count
299 */
300#define peerdist_msg_blklist_t( digestsize, count ) \
301 struct { \
302 struct peerdist_msg_blklist blklist; \
303 peerdist_msg_segment_t ( digestsize ) segment; \
304 peerdist_msg_ranges_t ( count ) ranges; \
305 uint32_t next; \
306 } __attribute__ (( packed ))
307
308/** Retrieval protocol block list response version */
309#define PEERDIST_MSG_BLKLIST_VERSION PEERDIST_MSG_VERSION_1_0
310
311/** Retrieval protocol block list response type */
312#define PEERDIST_MSG_BLKLIST_TYPE 0x00000004UL
313
314/** Retrieval protocol block fetch response header */
316 /** Message header */
318 /* Followed by a segment ID, a block index, a next block
319 * index, a data block, a useless VRF block, and an
320 * initialisation vector:
321 *
322 * peerdist_msg_segment_t(digestsize) segment;
323 * uint32_t index;
324 * uint32_t next;
325 * peerdist_msg_block_t(len) data;
326 * peerdist_msg_useless_vrf_t(vrf_len) vrf;
327 * peerdist_msg_iv_t(blksize) iv;
328 */
329} __attribute__ (( packed ));
330
331/** Retrieval protocol block fetch response
332 *
333 * @v digestsize Digest size
334 * @v len Data block length
335 * @v vrf_len Length of uselessness
336 * @v blksize Cipher block size
337 */
338#define peerdist_msg_blk_t( digestsize, len, vrf_len, blksize ) \
339 struct { \
340 struct peerdist_msg_blk blk; \
341 peerdist_msg_segment_t ( digestsize ) segment; \
342 uint32_t index; \
343 uint32_t next; \
344 peerdist_msg_block_t ( len ) block; \
345 peerdist_msg_useless_vrf_t ( vrf_len ) vrf; \
346 peerdist_msg_iv_t ( blksize ) iv; \
347 } __attribute__ (( packed ))
348
349/** Retrieval protocol block fetch response version */
350#define PEERDIST_MSG_BLK_VERSION PEERDIST_MSG_VERSION_1_0
351
352/** Retrieval protocol block fetch response type */
353#define PEERDIST_MSG_BLK_TYPE 0x00000005UL
354
355/** A retrieval protocol mechanism */
357 /** Name */
358 const char *name;
359 /**
360 * Open retrieval protocol connection
361 *
362 * @v xfer Data transfer interface
363 * @v location Peer location
364 * @v digestsize Digest size
365 * @v id Segment identifier
366 * @v block Block index
367 * @ret rc Return status code
368 */
369 int ( * open ) ( struct interface *xfer, const char *location,
370 size_t digestsize, const uint8_t *id,
371 unsigned int block );
372};
373
375extern struct peerdist_retrieval peerdist_get;
376
377#endif /* _IPXE_PCCRR_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
uint8_t id
Request identifier.
Definition ena.h:1
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
enum peerdist_msg_algorithm __attribute__
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
uint8_t block[3][8]
DES-encrypted blocks.
Definition mschapv2.h:1
struct peerdist_retrieval peerdist_get
PeerDist retrieval protocol using HTTP GET or local file.
Definition pccrr.c:190
struct peerdist_retrieval peerdist_post
PeerDist retrieval protocol using HTTP POST.
Definition pccrr.c:143
peerdist_msg_algorithm
Retrieval protocol cryptographic algorithm IDs.
Definition pccrr.h:170
@ PEERDIST_MSG_AES_192_CBC
AES-192 in CBC mode.
Definition pccrr.h:176
@ PEERDIST_MSG_AES_128_CBC
AES-128 in CBC mode.
Definition pccrr.h:174
@ PEERDIST_MSG_PLAINTEXT
No encryption.
Definition pccrr.h:172
@ PEERDIST_MSG_AES_256_CBC
AES-256 in CBC mode.
Definition pccrr.h:178
uint32_t digestsize
Digest size (i.e.
Definition pccrr.h:1
An object interface.
Definition interface.h:125
Retrieval protocol block fetch response header.
Definition pccrr.h:315
struct peerdist_msg_header hdr
Message header.
Definition pccrr.h:317
Retrieval protocol block list response header.
Definition pccrr.h:283
struct peerdist_msg_header hdr
Message header.
Definition pccrr.h:285
Retrieval protocol data block header.
Definition pccrr.h:100
uint32_t len
Length of data block.
Definition pccrr.h:102
Retrieval protocol block list request header.
Definition pccrr.h:221
struct peerdist_msg_header hdr
Message header.
Definition pccrr.h:223
Retrieval protocol block fetch request header.
Definition pccrr.h:250
struct peerdist_msg_header hdr
Message header.
Definition pccrr.h:252
Retrieval protocol message header.
Definition pccrr.h:154
union peerdist_msg_version version
Protocol version.
Definition pccrr.h:160
uint32_t type
Message type.
Definition pccrr.h:162
uint32_t len
Message size (including this header).
Definition pccrr.h:164
uint32_t algorithm
Cryptographic algorithm ID.
Definition pccrr.h:166
Retrieval protocol initialisation vector header.
Definition pccrr.h:117
uint32_t blksize
Cipher block size.
Definition pccrr.h:119
Retrieval protocol negotiation request.
Definition pccrr.h:193
struct peerdist_msg_header hdr
Message header.
Definition pccrr.h:195
struct peerdist_msg_versions versions
Supported versions.
Definition pccrr.h:197
Retrieval protocol negotiation response.
Definition pccrr.h:207
struct peerdist_msg_header hdr
Message header.
Definition pccrr.h:209
struct peerdist_msg_versions versions
Supported versions.
Definition pccrr.h:211
Retrieval protocol block range.
Definition pccrr.h:50
uint32_t count
Number of blocks in range.
Definition pccrr.h:54
uint32_t first
First block in range.
Definition pccrr.h:52
Retrieval protocol block range list header.
Definition pccrr.h:80
uint32_t count
Number of ranges.
Definition pccrr.h:82
Retrieval protocol segment ID header.
Definition pccrr.h:58
uint32_t digestsize
Digest size (i.e.
Definition pccrr.h:60
Retrieval protocol transport response header.
Definition pccrr.h:182
uint32_t len
Length (excluding this header).
Definition pccrr.h:189
Retrieval protocol useless VRF data header.
Definition pccrr.h:134
uint32_t len
Length of useless VRF data.
Definition pccrr.h:136
Retrieval protocol supported versions.
Definition pccrr.h:42
union peerdist_msg_version max
Maximum supported protocol version.
Definition pccrr.h:46
union peerdist_msg_version min
Minimum supported protocol version.
Definition pccrr.h:44
A retrieval protocol mechanism.
Definition pccrr.h:356
const char * name
Name.
Definition pccrr.h:358
int(* open)(struct interface *xfer, const char *location, size_t digestsize, const uint8_t *id, unsigned int block)
Open retrieval protocol connection.
Definition pccrr.h:369
Retrieval protocol version.
Definition pccrr.h:23
uint32_t raw
Raw version number.
Definition pccrr.h:25
uint16_t minor
Minor version number.
Definition pccrr.h:29
uint16_t major
Major version number.
Definition pccrr.h:31