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