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