iPXE
peerblk.h
Go to the documentation of this file.
1#ifndef _IPXE_PEERBLK_H
2#define _IPXE_PEERBLK_H
3
4/** @file
5 *
6 * Peer Content Caching and Retrieval (PeerDist) protocol block downloads
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/refcnt.h>
15#include <ipxe/interface.h>
16#include <ipxe/crypto.h>
17#include <ipxe/aes.h>
18#include <ipxe/xferbuf.h>
19#include <ipxe/retry.h>
20#include <ipxe/process.h>
21#include <ipxe/pccrc.h>
22#include <ipxe/peerdisc.h>
23
24/** A PeerDist retrieval protocol decryption buffer descriptor */
26 /** Data transfer buffer */
28 /** Offset within data transfer buffer */
29 size_t offset;
30 /** Length to use from data transfer buffer */
31 size_t len;
32};
33
34/** PeerDist retrieval protocol decryption data transfer buffer indices */
36 /** Data before the trimmed content */
38 /** Data within the trimmed content */
40 /** Data after the trimmed content */
42 /** Number of decryption buffers */
44};
45
46/** A PeerDist block download */
48 /** Reference count */
49 struct refcnt refcnt;
50 /** Data transfer interface */
52 /** Raw data interface */
53 struct interface raw;
54 /** Retrieval protocol interface */
56
57 /** Original URI */
58 struct uri *uri;
59 /** Content range of this block */
61 /** Trimmed range of this block */
63 /** Offset of first byte in trimmed range within overall download */
64 size_t offset;
65
66 /** Digest algorithm */
68 /** Digest size
69 *
70 * Note that this may be shorter than the digest size of the
71 * digest algorithm.
72 */
73 size_t digestsize;
74 /** Digest context (statically allocated at instantiation time) */
75 void *digestctx;
76
77 /** Cipher algorithm */
79 /** Cipher context (dynamically allocated as needed) */
80 void *cipherctx;
81
82 /** Segment index */
83 unsigned int segment;
84 /** Segment identifier */
86 /** Segment secret */
88 /** Block index */
89 unsigned int block;
90 /** Block hash */
92
93 /** Current position (relative to incoming data stream) */
94 size_t pos;
95 /** Start of trimmed content (relative to incoming data stream) */
96 size_t start;
97 /** End of trimmed content (relative to incoming data stream) */
98 size_t end;
99 /** Data buffer */
101
102 /** Decryption process */
104 /** Decryption data buffer descriptors */
106 /** Remaining decryption length */
108 /** Remaining digest length (excluding AES padding bytes) */
110
111 /** Discovery client */
113 /** Current position in discovered peer list */
115 /** Block download queue */
117 /** List of queued block downloads */
119 /** Retry timer */
121 /** Number of full attempt cycles completed */
122 unsigned int cycles;
123 /** Most recent attempt failure */
124 int rc;
125
126 /** Time at which block download was started */
127 unsigned long started;
128 /** Time at which most recent attempt was started */
129 unsigned long attempted;
130};
131
132/** PeerDist block download queue */
134 /** Download opening process */
136 /** List of queued downloads */
138
139 /** Number of open downloads */
140 unsigned int count;
141 /** Maximum number of open downloads */
142 unsigned int max;
143
144 /** Open block download
145 *
146 * @v peerblk PeerDist block download
147 * @ret rc Return status code
148 */
149 int ( * open ) ( struct peerdist_block *peerblk );
150};
151
152/** Retrieval protocol block fetch response (including transport header)
153 *
154 * @v digestsize Digest size
155 * @v len Data block length
156 * @v vrf_len Length of uselessness
157 * @v blksize Cipher block size
158 */
159#define peerblk_msg_blk_t( digestsize, len, vrf_len, blksize ) \
160 struct { \
161 struct peerdist_msg_transport_header hdr; \
162 peerdist_msg_blk_t ( digestsize, len, vrf_len, \
163 blksize ) msg; \
164 } __attribute__ (( packed ))
165
166extern int peerblk_open ( struct interface *xfer, struct uri *uri,
167 struct peerdist_info_block *block );
168
169#endif /* _IPXE_PEERBLK_H */
AES algorithm.
unsigned char uint8_t
Definition stdint.h:10
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
Cryptographic API.
Object interfaces.
uint8_t block[3][8]
DES-encrypted blocks.
Definition mschapv2.h:1
Peer Content Caching and Retrieval: Content Identification [MS-PCCRC].
#define PEERDIST_DIGEST_MAX_SIZE
Maximum digest size for any supported algorithm.
Definition pccrc.h:298
peerdist_block_decrypt_index
PeerDist retrieval protocol decryption data transfer buffer indices.
Definition peerblk.h:35
@ PEERBLK_NUM_BUFFERS
Number of decryption buffers.
Definition peerblk.h:43
@ PEERBLK_AFTER
Data after the trimmed content.
Definition peerblk.h:41
@ PEERBLK_BEFORE
Data before the trimmed content.
Definition peerblk.h:37
@ PEERBLK_DURING
Data within the trimmed content.
Definition peerblk.h:39
int peerblk_open(struct interface *xfer, struct uri *uri, struct peerdist_info_block *block)
Open PeerDist block download.
Definition peerblk.c:1434
Peer Content Caching and Retrieval (PeerDist) protocol peer discovery.
Processes.
Reference counting.
Retry timers.
A cipher algorithm.
Definition crypto.h:51
A message digest algorithm.
Definition crypto.h:19
An object interface.
Definition interface.h:125
A doubly-linked list entry (or list head)
Definition list.h:19
A PeerDist discovery client.
Definition peerdisc.h:80
A PeerDist discovery peer.
Definition peerdisc.h:72
A PeerDist retrieval protocol decryption buffer descriptor.
Definition peerblk.h:25
struct xfer_buffer * xferbuf
Data transfer buffer.
Definition peerblk.h:27
size_t offset
Offset within data transfer buffer.
Definition peerblk.h:29
size_t len
Length to use from data transfer buffer.
Definition peerblk.h:31
PeerDist block download queue.
Definition peerblk.h:133
struct list_head list
List of queued downloads.
Definition peerblk.h:137
struct process process
Download opening process.
Definition peerblk.h:135
unsigned int count
Number of open downloads.
Definition peerblk.h:140
int(* open)(struct peerdist_block *peerblk)
Open block download.
Definition peerblk.h:149
unsigned int max
Maximum number of open downloads.
Definition peerblk.h:142
A PeerDist block download.
Definition peerblk.h:47
unsigned int segment
Segment index.
Definition peerblk.h:83
struct retry_timer timer
Retry timer.
Definition peerblk.h:120
struct interface raw
Raw data interface.
Definition peerblk.h:53
size_t end
End of trimmed content (relative to incoming data stream)
Definition peerblk.h:98
struct uri * uri
Original URI.
Definition peerblk.h:58
struct cipher_algorithm * cipher
Cipher algorithm.
Definition peerblk.h:78
struct peerdist_block_decrypt decrypt[PEERBLK_NUM_BUFFERS]
Decryption data buffer descriptors.
Definition peerblk.h:105
void * digestctx
Digest context (statically allocated at instantiation time)
Definition peerblk.h:75
size_t start
Start of trimmed content (relative to incoming data stream)
Definition peerblk.h:96
unsigned long started
Time at which block download was started.
Definition peerblk.h:127
struct peerdist_block_queue * queue
Block download queue.
Definition peerblk.h:116
struct digest_algorithm * digest
Digest algorithm.
Definition peerblk.h:67
unsigned int cycles
Number of full attempt cycles completed.
Definition peerblk.h:122
struct peerdist_range range
Content range of this block.
Definition peerblk.h:60
struct xfer_buffer buffer
Data buffer.
Definition peerblk.h:100
size_t digestsize
Digest size.
Definition peerblk.h:73
size_t offset
Offset of first byte in trimmed range within overall download.
Definition peerblk.h:64
uint8_t secret[PEERDIST_DIGEST_MAX_SIZE]
Segment secret.
Definition peerblk.h:87
struct peerdisc_client discovery
Discovery client.
Definition peerblk.h:112
size_t pos
Current position (relative to incoming data stream)
Definition peerblk.h:94
struct interface xfer
Data transfer interface.
Definition peerblk.h:51
struct process process
Decryption process.
Definition peerblk.h:103
void * cipherctx
Cipher context (dynamically allocated as needed)
Definition peerblk.h:80
unsigned long attempted
Time at which most recent attempt was started.
Definition peerblk.h:129
struct peerdist_range trim
Trimmed range of this block.
Definition peerblk.h:62
uint8_t hash[PEERDIST_DIGEST_MAX_SIZE]
Block hash.
Definition peerblk.h:91
size_t cipher_remaining
Remaining decryption length.
Definition peerblk.h:107
unsigned int block
Block index.
Definition peerblk.h:89
struct refcnt refcnt
Reference count.
Definition peerblk.h:49
struct list_head queued
List of queued block downloads.
Definition peerblk.h:118
struct peerdisc_peer * peer
Current position in discovered peer list.
Definition peerblk.h:114
size_t digest_remaining
Remaining digest length (excluding AES padding bytes)
Definition peerblk.h:109
struct interface retrieval
Retrieval protocol interface.
Definition peerblk.h:55
int rc
Most recent attempt failure.
Definition peerblk.h:124
A content information block.
Definition pccrc.h:394
A content range.
Definition pccrc.h:309
A retry timer.
Definition retry.h:22
A Uniform Resource Identifier.
Definition uri.h:65
A data transfer buffer.
Definition xferbuf.h:19
Data transfer buffer.