iPXE
Data Structures | Functions | Variables
pccrc.c File Reference

Peer Content Caching and Retrieval: Content Identification [MS-PCCRC]. More...

#include <errno.h>
#include <assert.h>
#include <ipxe/sha256.h>
#include <ipxe/sha512.h>
#include <ipxe/hmac.h>
#include <ipxe/base16.h>
#include <ipxe/pccrc.h>

Go to the source code of this file.

Data Structures

struct  peerdist_info_v2_cursor
 A segment cursor. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static const char * peerdist_info_hash_ntoa (const struct peerdist_info *info, const void *hash)
 Transcribe hash value (for debugging) More...
 
static int peerdist_info_get (const struct peerdist_info *info, void *data, size_t offset, size_t len)
 Get raw data. More...
 
static void peerdist_info_segment_hash (struct peerdist_info_segment *segment, const void *hash, const void *secret)
 Populate segment hashes. More...
 
static int peerdist_info_v1_blocks (const struct peerdist_info *info, size_t offset)
 Get number of blocks within a block description. More...
 
static ssize_t peerdist_info_v1_block_offset (const struct peerdist_info *info, unsigned int index)
 Locate block description. More...
 
static int peerdist_info_v1 (struct peerdist_info *info)
 Populate content information. More...
 
static int peerdist_info_v1_segment (struct peerdist_info_segment *segment)
 Populate content information segment. More...
 
static int peerdist_info_v1_block (struct peerdist_info_block *block)
 Populate content information block. More...
 
static void peerdist_info_v2_cursor_init (struct peerdist_info_v2_cursor *cursor)
 Initialise segment cursor. More...
 
static int peerdist_info_v2_cursor_next (const struct peerdist_info *info, struct peerdist_info_v2_cursor *cursor)
 Update segment cursor to next segment description. More...
 
static int peerdist_info_v2_segments (const struct peerdist_info *info, size_t *len)
 Get number of segments and total length. More...
 
static int peerdist_info_v2 (struct peerdist_info *info)
 Populate content information. More...
 
static int peerdist_info_v2_segment (struct peerdist_info_segment *segment)
 Populate content information segment. More...
 
static int peerdist_info_v2_block (struct peerdist_info_block *block)
 Populate content information block. More...
 
int peerdist_info (const void *data, size_t len, struct peerdist_info *info)
 Populate content information. More...
 
int peerdist_info_segment (const struct peerdist_info *info, struct peerdist_info_segment *segment, unsigned int index)
 Populate content information segment. More...
 
int peerdist_info_block (const struct peerdist_info_segment *segment, struct peerdist_info_block *block, unsigned int index)
 Populate content information block. More...
 

Variables

static struct peerdist_info_operations peerdist_info_v1_operations
 Content information version 1 operations. More...
 
static struct peerdist_info_operations peerdist_info_v2_operations
 Content information version 2 operations. More...
 

Detailed Description

Peer Content Caching and Retrieval: Content Identification [MS-PCCRC].

Definition in file pccrc.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ peerdist_info_hash_ntoa()

static const char* peerdist_info_hash_ntoa ( const struct peerdist_info info,
const void *  hash 
)
inlinestatic

Transcribe hash value (for debugging)

Parameters
infoContent information
hashHash value
Return values
stringHash value string

Definition at line 55 of file pccrc.c.

55  {
56  static char buf[ ( 2 * PEERDIST_DIGEST_MAX_SIZE ) + 1 /* NUL */ ];
57  size_t digestsize = info->digestsize;
58 
59  /* Sanity check */
60  assert ( info != NULL );
61  assert ( digestsize != 0 );
62  assert ( base16_encoded_len ( digestsize ) < sizeof ( buf ) );
63 
64  /* Transcribe hash value */
65  base16_encode ( hash, digestsize, buf, sizeof ( buf ) );
66  return buf;
67 }
pseudo_bit_t hash[0x00010]
Definition: arbel.h:13
u32 info
Definition: ar9003_mac.h:67
static size_t base16_encoded_len(size_t raw_len)
Calculate length of base16-encoded data.
Definition: base16.h:24
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define PEERDIST_DIGEST_MAX_SIZE
Maximum digest size for any supported algorithm.
Definition: pccrc.h:297
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References assert(), base16_encoded_len(), digestsize, hash, info, NULL, and PEERDIST_DIGEST_MAX_SIZE.

Referenced by peerdist_info_block(), and peerdist_info_segment().

◆ peerdist_info_get()

static int peerdist_info_get ( const struct peerdist_info info,
void *  data,
size_t  offset,
size_t  len 
)
static

Get raw data.

Parameters
infoContent information
dataData buffer
offsetStarting offset
lenLength
Return values
rcReturn status code

Definition at line 78 of file pccrc.c.

79  {
80 
81  /* Sanity check */
82  if ( ( offset > info->raw.len ) ||
83  ( len > ( info->raw.len - offset ) ) ) {
84  DBGC ( info, "PCCRC %p data underrun at [%zx,%zx) of %zx\n",
85  info, offset, ( offset + len ), info->raw.len );
86  return -ERANGE;
87  }
88 
89  /* Copy data */
90  memcpy ( data, ( info->raw.data + offset ), len );
91 
92  return 0;
93 }
u32 info
Definition: ar9003_mac.h:67
#define DBGC(...)
Definition: compiler.h:505
void * memcpy(void *dest, const void *src, size_t len) __nonnull
ring len
Length.
Definition: dwmac.h:231
#define ERANGE
Result too large.
Definition: errno.h:639
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint16_t offset
Offset to command line.
Definition: bzimage.h:8

References data, DBGC, ERANGE, info, len, memcpy(), and offset.

Referenced by peerdist_info(), peerdist_info_v1(), peerdist_info_v1_block(), peerdist_info_v1_blocks(), peerdist_info_v1_segment(), peerdist_info_v2(), peerdist_info_v2_cursor_next(), and peerdist_info_v2_segment().

◆ peerdist_info_segment_hash()

static void peerdist_info_segment_hash ( struct peerdist_info_segment segment,
const void *  hash,
const void *  secret 
)
static

Populate segment hashes.

Parameters
segmentContent information segment to fill in
hashSegment hash of data
secretSegment secret

Definition at line 102 of file pccrc.c.

103  {
104  const struct peerdist_info *info = segment->info;
105  struct digest_algorithm *digest = info->digest;
106  uint8_t ctx[ hmac_ctxsize ( digest ) ];
107  size_t digestsize = info->digestsize;
108  static const uint16_t magic[] = PEERDIST_SEGMENT_ID_MAGIC;
109 
110  /* Sanity check */
111  assert ( digestsize <= sizeof ( segment->hash ) );
112  assert ( digestsize <= sizeof ( segment->secret ) );
113  assert ( digestsize <= sizeof ( segment->id ) );
114 
115  /* Get segment hash of data */
116  memcpy ( segment->hash, hash, digestsize );
117 
118  /* Get segment secret */
119  memcpy ( segment->secret, secret, digestsize );
120 
121  /* Calculate segment identifier */
122  hmac_init ( digest, ctx, segment->secret, digestsize );
123  hmac_update ( digest, ctx, segment->hash, digestsize );
124  hmac_update ( digest, ctx, magic, sizeof ( magic ) );
125  hmac_final ( digest, ctx, segment->id );
126 }
void hmac_init(struct digest_algorithm *digest, void *ctx, const void *key, size_t key_len)
Initialise HMAC.
Definition: hmac.c:57
uint16_t segment
Code segment.
Definition: librm.h:138
pseudo_bit_t hash[0x00010]
Definition: arbel.h:13
unsigned short uint16_t
Definition: stdint.h:11
u32 info
Definition: ar9003_mac.h:67
uint16_t magic
Magic signature.
Definition: bzimage.h:6
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define PEERDIST_SEGMENT_ID_MAGIC
Magic string constant used to calculate segment identifier.
Definition: pccrc.h:390
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Content information.
Definition: pccrc.h:316
static void hmac_update(struct digest_algorithm *digest, void *ctx, const void *data, size_t len)
Update HMAC.
Definition: hmac.h:42
static size_t hmac_ctxsize(struct digest_algorithm *digest)
Calculate HMAC context size.
Definition: hmac.h:28
unsigned char uint8_t
Definition: stdint.h:10
A message digest algorithm.
Definition: crypto.h:18
void hmac_final(struct digest_algorithm *digest, void *ctx, void *hmac)
Finalise HMAC.
Definition: hmac.c:87
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14

References assert(), ctx, digestsize, hash, hmac_ctxsize(), hmac_final(), hmac_init(), hmac_update(), info, magic, memcpy(), PEERDIST_SEGMENT_ID_MAGIC, and segment.

Referenced by peerdist_info_v1_segment(), and peerdist_info_v2_segment().

◆ peerdist_info_v1_blocks()

static int peerdist_info_v1_blocks ( const struct peerdist_info info,
size_t  offset 
)
static

Get number of blocks within a block description.

Parameters
infoContent information
offsetBlock description offset
Return values
blocksNumber of blocks, or negative error

Definition at line 142 of file pccrc.c.

143  {
145  unsigned int blocks;
146  int rc;
147 
148  /* Get block description header */
149  if ( ( rc = peerdist_info_get ( info, &raw, offset,
150  sizeof ( raw ) ) ) != 0 )
151  return rc;
152 
153  /* Calculate number of blocks */
154  blocks = le32_to_cpu ( raw.blocks );
155 
156  return blocks;
157 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u32 info
Definition: ar9003_mac.h:67
#define le32_to_cpu(value)
Definition: byteswap.h:113
Content Information version 1 block description header.
Definition: pccrc.h:156
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:78
uint32_t blocks
Number of blocks within the block description.
Definition: pccrc.h:163
__be32 raw[7]
Definition: CIB_PRM.h:28
uint16_t offset
Offset to command line.
Definition: bzimage.h:8

References peerdist_info_v1_block::blocks, info, le32_to_cpu, offset, peerdist_info_get(), raw, and rc.

Referenced by peerdist_info_v1_block_offset(), and peerdist_info_v1_segment().

◆ peerdist_info_v1_block_offset()

static ssize_t peerdist_info_v1_block_offset ( const struct peerdist_info info,
unsigned int  index 
)
static

Locate block description.

Parameters
infoContent information
indexSegment index
Return values
offsetBlock description offset, or negative error

Definition at line 166 of file pccrc.c.

167  {
168  size_t digestsize = info->digestsize;
169  unsigned int i;
170  size_t offset;
171  int blocks;
172  int rc;
173 
174  /* Sanity check */
175  assert ( index < info->segments );
176 
177  /* Calculate offset of first block description */
178  offset = ( sizeof ( struct peerdist_info_v1 ) +
179  ( info->segments *
180  sizeof ( peerdist_info_v1_segment_t ( digestsize ) ) ) );
181 
182  /* Iterate over block descriptions until we find this segment */
183  for ( i = 0 ; i < index ; i++ ) {
184 
185  /* Get number of blocks */
186  blocks = peerdist_info_v1_blocks ( info, offset );
187  if ( blocks < 0 ) {
188  rc = blocks;
189  DBGC ( info, "PCCRC %p segment %d could not get number "
190  "of blocks: %s\n", info, i, strerror ( rc ) );
191  return rc;
192  }
193 
194  /* Move to next block description */
196  blocks ) );
197  }
198 
199  return offset;
200 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u32 info
Definition: ar9003_mac.h:67
Content Information version 1 data structure header.
Definition: pccrc.h:61
#define DBGC(...)
Definition: compiler.h:505
long index
Definition: bigint.h:62
uint32_t segments
Number of segments within the content information.
Definition: pccrc.h:83
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int peerdist_info_v1_blocks(const struct peerdist_info *info, size_t offset)
Get number of blocks within a block description.
Definition: pccrc.c:142
#define peerdist_info_v1_segment_t(digestsize)
Content Information version 1 segment description.
Definition: pccrc.h:145
uint32_t blocks
Number of blocks within the block description.
Definition: pccrc.h:163
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
#define peerdist_info_v1_block_t(digestsize, blocks)
Content Information version 1 block description.
Definition: pccrc.h:178

References assert(), peerdist_info_v1_block::blocks, DBGC, digestsize, index, info, offset, peerdist_info_v1_block_t, peerdist_info_v1_blocks(), peerdist_info_v1_segment_t, rc, peerdist_info_v1::segments, and strerror().

Referenced by peerdist_info_v1_block(), and peerdist_info_v1_segment().

◆ peerdist_info_v1()

static int peerdist_info_v1 ( struct peerdist_info info)
static

Populate content information.

Parameters
infoContent information to fill in
Return values
rcReturn status code

Definition at line 208 of file pccrc.c.

208  {
209  struct peerdist_info_v1 raw;
211  struct peerdist_info_segment last;
212  size_t first_skip;
213  size_t last_skip;
214  size_t last_read;
215  int rc;
216 
217  /* Get raw header */
218  if ( ( rc = peerdist_info_get ( info, &raw, 0, sizeof ( raw ) ) ) != 0){
219  DBGC ( info, "PCCRC %p could not get V1 content information: "
220  "%s\n", info, strerror ( rc ) );
221  return rc;
222  }
223  assert ( raw.version.raw == cpu_to_le16 ( PEERDIST_INFO_V1 ) );
224 
225  /* Determine hash algorithm */
226  switch ( raw.hash ) {
228  info->digest = &sha256_algorithm;
229  break;
231  info->digest = &sha384_algorithm;
232  break;
234  info->digest = &sha512_algorithm;
235  break;
236  default:
237  DBGC ( info, "PCCRC %p unsupported hash algorithm %#08x\n",
238  info, le32_to_cpu ( raw.hash ) );
239  return -ENOTSUP;
240  }
241  info->digestsize = info->digest->digestsize;
242  assert ( info->digest != NULL );
243  DBGC2 ( info, "PCCRC %p using %s[%zd]\n",
244  info, info->digest->name, ( info->digestsize * 8 ) );
245 
246  /* Calculate number of segments */
247  info->segments = le32_to_cpu ( raw.segments );
248 
249  /* Get first segment */
250  if ( ( rc = peerdist_info_segment ( info, &first, 0 ) ) != 0 )
251  return rc;
252 
253  /* Calculate range start offset */
254  info->range.start = first.range.start;
255 
256  /* Calculate trimmed range start offset */
257  first_skip = le32_to_cpu ( raw.first );
258  info->trim.start = ( first.range.start + first_skip );
259 
260  /* Get last segment */
261  if ( ( rc = peerdist_info_segment ( info, &last,
262  ( info->segments - 1 ) ) ) != 0 )
263  return rc;
264 
265  /* Calculate range end offset */
266  info->range.end = last.range.end;
267 
268  /* Calculate trimmed range end offset */
269  if ( raw.last ) {
270  /* Explicit length to include from last segment is given */
271  last_read = le32_to_cpu ( raw.last );
272  last_skip = ( last.index ? 0 : first_skip );
273  info->trim.end = ( last.range.start + last_skip + last_read );
274  } else {
275  /* No explicit length given: range extends to end of segment */
276  info->trim.end = last.range.end;
277  }
278 
279  return 0;
280 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define PEERDIST_INFO_V1_HASH_SHA512
SHA-512 hash algorithm.
Definition: pccrc.h:102
u32 info
Definition: ar9003_mac.h:67
A content information segment.
Definition: pccrc.h:346
#define le32_to_cpu(value)
Definition: byteswap.h:113
Content Information version 1 data structure header.
Definition: pccrc.h:61
uint32_t first
First block in range.
Definition: pccrr.h:14
struct digest_algorithm sha512_algorithm
SHA-512 algorithm.
Definition: sha512.c:284
#define DBGC(...)
Definition: compiler.h:505
struct digest_algorithm sha384_algorithm
SHA-384 algorithm.
Definition: sha384.c:63
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define cpu_to_le32(value)
Definition: byteswap.h:107
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:78
#define PEERDIST_INFO_V1_HASH_SHA384
SHA-384 hash algorithm.
Definition: pccrc.h:99
#define PEERDIST_INFO_V1_HASH_SHA256
SHA-256 hash algorithm.
Definition: pccrc.h:96
struct digest_algorithm sha256_algorithm
SHA-256 algorithm.
Definition: sha256.c:264
#define DBGC2(...)
Definition: compiler.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
__be32 raw[7]
Definition: CIB_PRM.h:28
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define PEERDIST_INFO_V1
Content Information version 1.
Definition: pccrc.h:45

References assert(), cpu_to_le16, cpu_to_le32, DBGC, DBGC2, peerdist_range::end, ENOTSUP, first, peerdist_info_segment::index, info, le32_to_cpu, NULL, peerdist_info_get(), PEERDIST_INFO_V1, PEERDIST_INFO_V1_HASH_SHA256, PEERDIST_INFO_V1_HASH_SHA384, PEERDIST_INFO_V1_HASH_SHA512, peerdist_info_segment::range, raw, rc, sha256_algorithm, sha384_algorithm, sha512_algorithm, peerdist_range::start, and strerror().

◆ peerdist_info_v1_segment()

static int peerdist_info_v1_segment ( struct peerdist_info_segment segment)
static

Populate content information segment.

Parameters
segmentContent information segment to fill in
Return values
rcReturn status code

Definition at line 288 of file pccrc.c.

288  {
289  const struct peerdist_info *info = segment->info;
290  size_t digestsize = info->digestsize;
292  ssize_t raw_offset;
293  int blocks;
294  int rc;
295 
296  /* Sanity checks */
297  assert ( segment->index < info->segments );
298 
299  /* Get raw description */
300  raw_offset = ( sizeof ( struct peerdist_info_v1 ) +
301  ( segment->index * sizeof ( raw ) ) );
302  if ( ( rc = peerdist_info_get ( info, &raw, raw_offset,
303  sizeof ( raw ) ) ) != 0 ) {
304  DBGC ( info, "PCCRC %p segment %d could not get segment "
305  "description: %s\n", info, segment->index,
306  strerror ( rc ) );
307  return rc;
308  }
309 
310  /* Calculate start offset of this segment */
311  segment->range.start = le64_to_cpu ( raw.segment.offset );
312 
313  /* Calculate end offset of this segment */
314  segment->range.end = ( segment->range.start +
315  le32_to_cpu ( raw.segment.len ) );
316 
317  /* Calculate block size of this segment */
318  segment->blksize = le32_to_cpu ( raw.segment.blksize );
319 
320  /* Locate block description for this segment */
321  raw_offset = peerdist_info_v1_block_offset ( info, segment->index );
322  if ( raw_offset < 0 ) {
323  rc = raw_offset;
324  return rc;
325  }
326 
327  /* Get number of blocks */
328  blocks = peerdist_info_v1_blocks ( info, raw_offset );
329  if ( blocks < 0 ) {
330  rc = blocks;
331  DBGC ( info, "PCCRC %p segment %d could not get number of "
332  "blocks: %s\n", info, segment->index, strerror ( rc ) );
333  return rc;
334  }
335  segment->blocks = blocks;
336 
337  /* Calculate segment hashes */
338  peerdist_info_segment_hash ( segment, raw.hash, raw.secret );
339 
340  return 0;
341 }
uint16_t segment
Code segment.
Definition: librm.h:138
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u32 info
Definition: ar9003_mac.h:67
#define le32_to_cpu(value)
Definition: byteswap.h:113
Content Information version 1 data structure header.
Definition: pccrc.h:61
#define DBGC(...)
Definition: compiler.h:505
long index
Definition: bigint.h:62
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static ssize_t peerdist_info_v1_block_offset(const struct peerdist_info *info, unsigned int index)
Locate block description.
Definition: pccrc.c:166
Content information.
Definition: pccrc.h:316
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void peerdist_info_segment_hash(struct peerdist_info_segment *segment, const void *hash, const void *secret)
Populate segment hashes.
Definition: pccrc.c:102
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:78
static int peerdist_info_v1_blocks(const struct peerdist_info *info, size_t offset)
Get number of blocks within a block description.
Definition: pccrc.c:142
#define peerdist_info_v1_segment_t(digestsize)
Content Information version 1 segment description.
Definition: pccrc.h:145
__be32 raw[7]
Definition: CIB_PRM.h:28
signed long ssize_t
Definition: stdint.h:7
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
#define le64_to_cpu(value)
Definition: byteswap.h:114

References assert(), DBGC, digestsize, index, info, le32_to_cpu, le64_to_cpu, peerdist_info_get(), peerdist_info_segment_hash(), peerdist_info_v1_block_offset(), peerdist_info_v1_blocks(), peerdist_info_v1_segment_t, raw, rc, segment, and strerror().

◆ peerdist_info_v1_block()

static int peerdist_info_v1_block ( struct peerdist_info_block block)
static

Populate content information block.

Parameters
blockContent information block to fill in
Return values
rcReturn status code

Definition at line 349 of file pccrc.c.

349  {
350  const struct peerdist_info_segment *segment = block->segment;
351  const struct peerdist_info *info = segment->info;
352  size_t digestsize = info->digestsize;
354  ssize_t raw_offset;
355  int rc;
356 
357  /* Sanity checks */
358  assert ( block->index < segment->blocks );
359 
360  /* Calculate start offset of this block */
362  ( block->index * segment->blksize ) );
363 
364  /* Calculate end offset of this block */
366  if ( block->range.end > segment->range.end )
368 
369  /* Locate block description */
370  raw_offset = peerdist_info_v1_block_offset ( info, segment->index );
371  if ( raw_offset < 0 ) {
372  rc = raw_offset;
373  return rc;
374  }
375 
376  /* Get block hash */
377  raw_offset += offsetof ( typeof ( raw ), hash[block->index] );
378  if ( ( rc = peerdist_info_get ( info, block->hash, raw_offset,
379  digestsize ) ) != 0 ) {
380  DBGC ( info, "PCCRC %p segment %d block %d could not get "
381  "hash: %s\n", info, segment->index, block->index,
382  strerror ( rc ) );
383  return rc;
384  }
385 
386  return 0;
387 }
uint16_t segment
Code segment.
Definition: librm.h:138
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
pseudo_bit_t hash[0x00010]
Definition: arbel.h:13
struct pci_range range
PCI bus:dev.fn address range.
Definition: pcicloud.c:40
u32 info
Definition: ar9003_mac.h:67
A content information segment.
Definition: pccrc.h:346
#define DBGC(...)
Definition: compiler.h:505
long index
Definition: bigint.h:62
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
uint32_t start
Starting offset.
Definition: netvsc.h:12
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static ssize_t peerdist_info_v1_block_offset(const struct peerdist_info *info, unsigned int index)
Locate block description.
Definition: pccrc.c:166
Content information.
Definition: pccrc.h:316
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:78
uint8_t block[3][8]
DES-encrypted blocks.
Definition: mschapv2.h:12
uint32_t end
Ending offset.
Definition: netvsc.h:18
__be32 raw[7]
Definition: CIB_PRM.h:28
uint32_t blksize
Cipher block size.
Definition: pccrr.h:14
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:47
signed long ssize_t
Definition: stdint.h:7
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
#define peerdist_info_v1_block_t(digestsize, blocks)
Content Information version 1 block description.
Definition: pccrc.h:178
if(natsemi->flags &NATSEMI_64BIT) return 1

References assert(), block, DBGC, digestsize, hash, info, offsetof, peerdist_info_get(), peerdist_info_v1_block_offset(), peerdist_info_v1_block_t, raw, rc, segment, strerror(), and typeof().

◆ peerdist_info_v2_cursor_init()

static void peerdist_info_v2_cursor_init ( struct peerdist_info_v2_cursor cursor)
inlinestatic

Initialise segment cursor.

Parameters
cursorSegment cursor

Definition at line 419 of file pccrc.c.

419  {
420 
421  /* Initialise cursor */
422  cursor->offset = ( sizeof ( struct peerdist_info_v2 ) +
423  sizeof ( struct peerdist_info_v2_chunk ) );
424  cursor->remaining = 0;
425  cursor->len = 0;
426 }
unsigned int remaining
Number of segments remaining within this chunk.
Definition: pccrc.c:408
size_t offset
Raw data offset.
Definition: pccrc.c:406
size_t len
Accumulated segment length.
Definition: pccrc.c:410
Content Information version 2 data structure header.
Definition: pccrc.h:195
Content Information version 2 chunk description header.
Definition: pccrc.h:230

References peerdist_info_v2_cursor::len, peerdist_info_v2_cursor::offset, and peerdist_info_v2_cursor::remaining.

Referenced by peerdist_info_v2_segment(), and peerdist_info_v2_segments().

◆ peerdist_info_v2_cursor_next()

static int peerdist_info_v2_cursor_next ( const struct peerdist_info info,
struct peerdist_info_v2_cursor cursor 
)
static

Update segment cursor to next segment description.

Parameters
infoContent information
offsetCurrent offset
remainingNumber of segments remaining within this chunk
Return values
rcReturn status code

Definition at line 437 of file pccrc.c.

438  {
439  size_t digestsize = info->digestsize;
441  struct peerdist_info_v2_chunk chunk;
442  int rc;
443 
444  /* Get chunk description if applicable */
445  if ( ! cursor->remaining ) {
446 
447  /* Get chunk description */
448  if ( ( rc = peerdist_info_get ( info, &chunk,
449  ( cursor->offset -
450  sizeof ( chunk ) ),
451  sizeof ( chunk ) ) ) != 0 )
452  return rc;
453 
454  /* Update number of segments remaining */
455  cursor->remaining = ( be32_to_cpu ( chunk.len ) /
456  sizeof ( raw ) );
457  }
458 
459  /* Get segment description header */
460  if ( ( rc = peerdist_info_get ( info, &raw.segment, cursor->offset,
461  sizeof ( raw.segment ) ) ) != 0 )
462  return rc;
463 
464  /* Update cursor */
465  cursor->offset += sizeof ( raw );
466  cursor->remaining--;
467  if ( ! cursor->remaining )
468  cursor->offset += sizeof ( chunk );
469  cursor->len += be32_to_cpu ( raw.segment.len );
470 
471  return 0;
472 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u32 info
Definition: ar9003_mac.h:67
unsigned int remaining
Number of segments remaining within this chunk.
Definition: pccrc.c:408
#define be32_to_cpu(value)
Definition: byteswap.h:116
size_t offset
Raw data offset.
Definition: pccrc.c:406
#define peerdist_info_v2_segment_t(digestsize)
Content Information version 2 segment description.
Definition: pccrc.h:279
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:78
size_t len
Accumulated segment length.
Definition: pccrc.c:410
__be32 raw[7]
Definition: CIB_PRM.h:28
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
Content Information version 2 chunk description header.
Definition: pccrc.h:230

References be32_to_cpu, digestsize, info, peerdist_info_v2_chunk::len, peerdist_info_v2_cursor::len, peerdist_info_v2_cursor::offset, peerdist_info_get(), peerdist_info_v2_segment_t, raw, rc, and peerdist_info_v2_cursor::remaining.

Referenced by peerdist_info_v2_segment(), and peerdist_info_v2_segments().

◆ peerdist_info_v2_segments()

static int peerdist_info_v2_segments ( const struct peerdist_info info,
size_t len 
)
static

Get number of segments and total length.

Parameters
infoContent information
lenLength to fill in
Return values
rcNumber of segments, or negative error

Definition at line 481 of file pccrc.c.

482  {
483  struct peerdist_info_v2_cursor cursor;
484  unsigned int segments;
485  int rc;
486 
487  /* Iterate over all segments */
488  for ( peerdist_info_v2_cursor_init ( &cursor ), segments = 0 ;
489  cursor.offset < info->raw.len ; segments++ ) {
490 
491  /* Update segment cursor */
493  &cursor ) ) != 0 ) {
494  DBGC ( info, "PCCRC %p segment %d could not update "
495  "segment cursor: %s\n",
496  info, segments, strerror ( rc ) );
497  return rc;
498  }
499  }
500 
501  /* Record accumulated length */
502  *len = cursor.len;
503 
504  return segments;
505 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A segment cursor.
Definition: pccrc.c:404
u32 info
Definition: ar9003_mac.h:67
static void peerdist_info_v2_cursor_init(struct peerdist_info_v2_cursor *cursor)
Initialise segment cursor.
Definition: pccrc.c:419
#define DBGC(...)
Definition: compiler.h:505
ring len
Length.
Definition: dwmac.h:231
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int peerdist_info_v2_cursor_next(const struct peerdist_info *info, struct peerdist_info_v2_cursor *cursor)
Update segment cursor to next segment description.
Definition: pccrc.c:437

References DBGC, info, len, peerdist_info_v2_cursor::len, peerdist_info_v2_cursor::offset, peerdist_info_v2_cursor_init(), peerdist_info_v2_cursor_next(), rc, and strerror().

Referenced by peerdist_info_v2().

◆ peerdist_info_v2()

static int peerdist_info_v2 ( struct peerdist_info info)
static

Populate content information.

Parameters
infoContent information to fill in
Return values
rcReturn status code

Definition at line 513 of file pccrc.c.

513  {
514  struct peerdist_info_v2 raw;
515  size_t len = 0;
516  int segments;
517  int rc;
518 
519  /* Get raw header */
520  if ( ( rc = peerdist_info_get ( info, &raw, 0, sizeof ( raw ) ) ) != 0){
521  DBGC ( info, "PCCRC %p could not get V2 content information: "
522  "%s\n", info, strerror ( rc ) );
523  return rc;
524  }
525  assert ( raw.version.raw == cpu_to_le16 ( PEERDIST_INFO_V2 ) );
526 
527  /* Determine hash algorithm */
528  switch ( raw.hash ) {
530  info->digest = &sha512_algorithm;
531  info->digestsize = ( 256 / 8 );
532  break;
533  default:
534  DBGC ( info, "PCCRC %p unsupported hash algorithm %#02x\n",
535  info, raw.hash );
536  return -ENOTSUP;
537  }
538  assert ( info->digest != NULL );
539  DBGC2 ( info, "PCCRC %p using %s[%zd]\n",
540  info, info->digest->name, ( info->digestsize * 8 ) );
541 
542  /* Calculate number of segments and total length */
543  segments = peerdist_info_v2_segments ( info, &len );
544  if ( segments < 0 ) {
545  rc = segments;
546  DBGC ( info, "PCCRC %p could not get segment count and length: "
547  "%s\n", info, strerror ( rc ) );
548  return rc;
549  }
550  info->segments = segments;
551 
552  /* Calculate range start offset */
553  info->range.start = be64_to_cpu ( raw.offset );
554 
555  /* Calculate trimmed range start offset */
556  info->trim.start = ( info->range.start + be32_to_cpu ( raw.first ) );
557 
558  /* Calculate range end offset */
559  info->range.end = ( info->range.start + len );
560 
561  /* Calculate trimmed range end offset */
562  info->trim.end = ( raw.len ? be64_to_cpu ( raw.len ) :
563  info->range.end );
564 
565  return 0;
566 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct pci_range range
PCI bus:dev.fn address range.
Definition: pcicloud.c:40
u32 info
Definition: ar9003_mac.h:67
struct digest_algorithm sha512_algorithm
SHA-512 algorithm.
Definition: sha512.c:284
#define DBGC(...)
Definition: compiler.h:505
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#define PEERDIST_INFO_V2
Content Information version 2.
Definition: pccrc.h:48
#define be32_to_cpu(value)
Definition: byteswap.h:116
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
ring len
Length.
Definition: dwmac.h:231
static int peerdist_info_v2_segments(const struct peerdist_info *info, size_t *len)
Get number of segments and total length.
Definition: pccrc.c:481
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define be64_to_cpu(value)
Definition: byteswap.h:117
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:78
#define DBGC2(...)
Definition: compiler.h:522
#define PEERDIST_INFO_V2_HASH_SHA512_TRUNC
SHA-512 hash algorithm with output truncated to first 256 bits.
Definition: pccrc.h:224
#define cpu_to_le16(value)
Definition: byteswap.h:106
uint32_t end
Ending offset.
Definition: netvsc.h:18
__be32 raw[7]
Definition: CIB_PRM.h:28
Content Information version 2 data structure header.
Definition: pccrc.h:195
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References assert(), be32_to_cpu, be64_to_cpu, cpu_to_le16, DBGC, DBGC2, ENOTSUP, info, len, NULL, peerdist_info_get(), PEERDIST_INFO_V2, PEERDIST_INFO_V2_HASH_SHA512_TRUNC, peerdist_info_v2_segments(), raw, rc, sha512_algorithm, and strerror().

◆ peerdist_info_v2_segment()

static int peerdist_info_v2_segment ( struct peerdist_info_segment segment)
static

Populate content information segment.

Parameters
segmentContent information segment to fill in
Return values
rcReturn status code

Definition at line 574 of file pccrc.c.

574  {
575  const struct peerdist_info *info = segment->info;
576  size_t digestsize = info->digestsize;
578  struct peerdist_info_v2_cursor cursor;
579  unsigned int index;
580  size_t len;
581  int rc;
582 
583  /* Sanity checks */
584  assert ( segment->index < info->segments );
585 
586  /* Iterate over all segments before the target segment */
587  for ( peerdist_info_v2_cursor_init ( &cursor ), index = 0 ;
588  index < segment->index ; index++ ) {
589 
590  /* Update segment cursor */
592  &cursor ) ) != 0 ) {
593  DBGC ( info, "PCCRC %p segment %d could not update "
594  "segment cursor: %s\n",
595  info, index, strerror ( rc ) );
596  return rc;
597  }
598  }
599 
600  /* Get raw description */
601  if ( ( rc = peerdist_info_get ( info, &raw, cursor.offset,
602  sizeof ( raw ) ) ) != 0 ) {
603  DBGC ( info, "PCCRC %p segment %d could not get segment "
604  "description: %s\n",
605  info, segment->index, strerror ( rc ) );
606  return rc;
607  }
608 
609  /* Calculate start offset of this segment */
610  segment->range.start = ( info->range.start + cursor.len );
611 
612  /* Calculate end offset of this segment */
613  len = be32_to_cpu ( raw.segment.len );
614  segment->range.end = ( segment->range.start + len );
615 
616  /* Model as a segment containing a single block */
617  segment->blocks = 1;
618  segment->blksize = len;
619 
620  /* Calculate segment hashes */
621  peerdist_info_segment_hash ( segment, raw.hash, raw.secret );
622 
623  return 0;
624 }
uint16_t segment
Code segment.
Definition: librm.h:138
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A segment cursor.
Definition: pccrc.c:404
u32 info
Definition: ar9003_mac.h:67
static void peerdist_info_v2_cursor_init(struct peerdist_info_v2_cursor *cursor)
Initialise segment cursor.
Definition: pccrc.c:419
#define DBGC(...)
Definition: compiler.h:505
long index
Definition: bigint.h:62
#define be32_to_cpu(value)
Definition: byteswap.h:116
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
ring len
Length.
Definition: dwmac.h:231
Content information.
Definition: pccrc.h:316
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define peerdist_info_v2_segment_t(digestsize)
Content Information version 2 segment description.
Definition: pccrc.h:279
static void peerdist_info_segment_hash(struct peerdist_info_segment *segment, const void *hash, const void *secret)
Populate segment hashes.
Definition: pccrc.c:102
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:78
static int peerdist_info_v2_cursor_next(const struct peerdist_info *info, struct peerdist_info_v2_cursor *cursor)
Update segment cursor to next segment description.
Definition: pccrc.c:437
__be32 raw[7]
Definition: CIB_PRM.h:28
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14

References assert(), be32_to_cpu, DBGC, digestsize, index, info, len, peerdist_info_v2_cursor::len, peerdist_info_v2_cursor::offset, peerdist_info_get(), peerdist_info_segment_hash(), peerdist_info_v2_cursor_init(), peerdist_info_v2_cursor_next(), peerdist_info_v2_segment_t, raw, rc, segment, and strerror().

◆ peerdist_info_v2_block()

static int peerdist_info_v2_block ( struct peerdist_info_block block)
static

Populate content information block.

Parameters
blockContent information block to fill in
Return values
rcReturn status code

Definition at line 632 of file pccrc.c.

632  {
633  const struct peerdist_info_segment *segment = block->segment;
634  const struct peerdist_info *info = segment->info;
635  size_t digestsize = info->digestsize;
636 
637  /* Sanity checks */
638  assert ( block->index < segment->blocks );
639 
640  /* Model as a block covering the whole segment */
641  memcpy ( &block->range, &segment->range, sizeof ( block->range ) );
642  memcpy ( block->hash, segment->hash, digestsize );
643 
644  return 0;
645 }
uint16_t segment
Code segment.
Definition: librm.h:138
u32 info
Definition: ar9003_mac.h:67
A content information segment.
Definition: pccrc.h:346
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Content information.
Definition: pccrc.h:316
uint8_t block[3][8]
DES-encrypted blocks.
Definition: mschapv2.h:12
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14

References assert(), block, digestsize, info, memcpy(), and segment.

◆ peerdist_info()

int peerdist_info ( const void *  data,
size_t  len,
struct peerdist_info info 
)

Populate content information.

Parameters
dataRaw data
lenLength of raw data
infoContent information to fill in
Return values
rcReturn status code

Definition at line 669 of file pccrc.c.

670  {
672  int rc;
673 
674  /* Initialise structure */
675  memset ( info, 0, sizeof ( *info ) );
676  info->raw.data = data;
677  info->raw.len = len;
678 
679  /* Get version */
680  if ( ( rc = peerdist_info_get ( info, &version, 0,
681  sizeof ( version ) ) ) != 0 ) {
682  DBGC ( info, "PCCRC %p could not get version: %s\n",
683  info, strerror ( rc ) );
684  return rc;
685  }
686  DBGC2 ( info, "PCCRC %p version %d.%d\n",
687  info, version.major, version.minor );
688 
689  /* Determine version */
690  switch ( version.raw ) {
691  case cpu_to_le16 ( PEERDIST_INFO_V1 ) :
693  break;
694  case cpu_to_le16 ( PEERDIST_INFO_V2 ) :
696  break;
697  default:
698  DBGC ( info, "PCCRC %p unsupported version %d.%d\n",
699  info, version.major, version.minor );
700  return -ENOTSUP;
701  }
702  assert ( info->op != NULL );
703  assert ( info->op->info != NULL );
704 
705  /* Populate content information */
706  if ( ( rc = info->op->info ( info ) ) != 0 )
707  return rc;
708 
709  DBGC2 ( info, "PCCRC %p range [%08zx,%08zx) covers [%08zx,%08zx) with "
710  "%d segments\n", info, info->range.start, info->range.end,
711  info->trim.start, info->trim.end, info->segments );
712  return 0;
713 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u32 info
Definition: ar9003_mac.h:67
#define DBGC(...)
Definition: compiler.h:505
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static struct peerdist_info_operations peerdist_info_v1_operations
Content information version 1 operations.
Definition: pccrc.c:390
u32 version
Driver version.
Definition: ath9k_hw.c:1983
#define PEERDIST_INFO_V2
Content Information version 2.
Definition: pccrc.h:48
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
ring len
Length.
Definition: dwmac.h:231
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:78
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define DBGC2(...)
Definition: compiler.h:522
static struct peerdist_info_operations peerdist_info_v2_operations
Content information version 2 operations.
Definition: pccrc.c:648
#define cpu_to_le16(value)
Definition: byteswap.h:106
uint8_t data[48]
Additional event data.
Definition: ena.h:22
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define PEERDIST_INFO_V1
Content Information version 1.
Definition: pccrc.h:45
Content Information version number.
Definition: pccrc.h:27
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), cpu_to_le16, data, DBGC, DBGC2, ENOTSUP, info, len, memset(), NULL, peerdist_info_get(), PEERDIST_INFO_V1, peerdist_info_v1_operations, PEERDIST_INFO_V2, peerdist_info_v2_operations, rc, strerror(), and version.

◆ peerdist_info_segment()

int peerdist_info_segment ( const struct peerdist_info info,
struct peerdist_info_segment segment,
unsigned int  index 
)

Populate content information segment.

Parameters
infoContent information
segmentContent information segment to fill in
indexSegment index
Return values
rcReturn status code

Definition at line 723 of file pccrc.c.

725  {
726  int rc;
727 
728  /* Sanity checks */
729  assert ( info != NULL );
730  assert ( info->op != NULL );
731  assert ( info->op->segment != NULL );
732  if ( index >= info->segments ) {
733  DBGC ( info, "PCCRC %p segment %d of [0,%d) out of range\n",
734  info, index, info->segments );
735  return -ERANGE;
736  }
737 
738  /* Initialise structure */
739  memset ( segment, 0, sizeof ( *segment ) );
740  segment->info = info;
741  segment->index = index;
742 
743  /* Populate content information segment */
744  if ( ( rc = info->op->segment ( segment ) ) != 0 )
745  return rc;
746 
747  DBGC2 ( info, "PCCRC %p segment %d range [%08zx,%08zx) with %d "
748  "blocks\n", info, segment->index, segment->range.start,
749  segment->range.end, segment->blocks );
750  DBGC2 ( info, "PCCRC %p segment %d digest %s\n", info, segment->index,
751  peerdist_info_hash_ntoa ( info, segment->hash ) );
752  DBGC2 ( info, "PCCRC %p segment %d secret %s\n", info, segment->index,
753  peerdist_info_hash_ntoa ( info, segment->secret ) );
754  DBGC2 ( info, "PCCRC %p segment %d identf %s\n", info, segment->index,
756  return 0;
757 }
uint16_t segment
Code segment.
Definition: librm.h:138
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static const char * peerdist_info_hash_ntoa(const struct peerdist_info *info, const void *hash)
Transcribe hash value (for debugging)
Definition: pccrc.c:55
u32 info
Definition: ar9003_mac.h:67
#define DBGC(...)
Definition: compiler.h:505
long index
Definition: bigint.h:62
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define ERANGE
Result too large.
Definition: errno.h:639
#define DBGC2(...)
Definition: compiler.h:522
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), DBGC, DBGC2, ERANGE, index, info, memset(), NULL, peerdist_info_hash_ntoa(), rc, and segment.

◆ peerdist_info_block()

int peerdist_info_block ( const struct peerdist_info_segment segment,
struct peerdist_info_block block,
unsigned int  index 
)

Populate content information block.

Parameters
segmentContent information segment
blockContent information block to fill in
indexBlock index
Return values
rcReturn status code

Definition at line 767 of file pccrc.c.

769  {
770  const struct peerdist_info *info = segment->info;
771  size_t start;
772  size_t end;
773  int rc;
774 
775  /* Sanity checks */
776  assert ( segment != NULL );
777  assert ( info != NULL );
778  assert ( info->op != NULL );
779  assert ( info->op->block != NULL );
780  if ( index >= segment->blocks ) {
781  DBGC ( info, "PCCRC %p segment %d block %d of [0,%d) out of "
782  "range\n", info, segment->index, index, segment->blocks);
783  return -ERANGE;
784  }
785 
786  /* Initialise structure */
787  memset ( block, 0, sizeof ( *block ) );
788  block->segment = segment;
789  block->index = index;
790 
791  /* Populate content information block */
792  if ( ( rc = info->op->block ( block ) ) != 0 )
793  return rc;
794 
795  /* Calculate trimmed range */
796  start = block->range.start;
797  if ( start < info->trim.start )
798  start = info->trim.start;
799  end = block->range.end;
800  if ( end > info->trim.end )
801  end = info->trim.end;
802  if ( end < start )
803  end = start;
804  block->trim.start = start;
805  block->trim.end = end;
806 
807  DBGC2 ( info, "PCCRC %p segment %d block %d hash %s\n",
808  info, segment->index, block->index,
809  peerdist_info_hash_ntoa ( info, block->hash ) );
810  DBGC2 ( info, "PCCRC %p segment %d block %d range [%08zx,%08zx) covers "
811  "[%08zx,%08zx)\n", info, segment->index, block->index,
812  block->range.start, block->range.end, block->trim.start,
813  block->trim.end );
814  return 0;
815 }
uint16_t segment
Code segment.
Definition: librm.h:138
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static const char * peerdist_info_hash_ntoa(const struct peerdist_info *info, const void *hash)
Transcribe hash value (for debugging)
Definition: pccrc.c:55
u32 info
Definition: ar9003_mac.h:67
size_t start
Start offset.
Definition: pccrc.h:310
#define DBGC(...)
Definition: compiler.h:505
long index
Definition: bigint.h:62
uint32_t start
Starting offset.
Definition: netvsc.h:12
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct peerdist_range trim
Trimmed content range.
Definition: pccrc.h:340
Content information.
Definition: pccrc.h:316
#define ERANGE
Result too large.
Definition: errno.h:639
#define DBGC2(...)
Definition: compiler.h:522
uint8_t block[3][8]
DES-encrypted blocks.
Definition: mschapv2.h:12
uint32_t end
Ending offset.
Definition: netvsc.h:18
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), block, DBGC, DBGC2, end, ERANGE, index, info, memset(), NULL, peerdist_info_hash_ntoa(), rc, segment, start, peerdist_range::start, and peerdist_info::trim.

Variable Documentation

◆ peerdist_info_v1_operations

struct peerdist_info_operations peerdist_info_v1_operations
static
Initial value:
= {
}
static int peerdist_info_v1(struct peerdist_info *info)
Populate content information.
Definition: pccrc.c:208
static int peerdist_info_v1_segment(struct peerdist_info_segment *segment)
Populate content information segment.
Definition: pccrc.c:288
static int peerdist_info_v1_block(struct peerdist_info_block *block)
Populate content information block.
Definition: pccrc.c:349

Content information version 1 operations.

Definition at line 390 of file pccrc.c.

Referenced by peerdist_info().

◆ peerdist_info_v2_operations

struct peerdist_info_operations peerdist_info_v2_operations
static
Initial value:
= {
}
static int peerdist_info_v2(struct peerdist_info *info)
Populate content information.
Definition: pccrc.c:513
static int peerdist_info_v2_block(struct peerdist_info_block *block)
Populate content information block.
Definition: pccrc.c:632
static int peerdist_info_v2_segment(struct peerdist_info_segment *segment)
Populate content information segment.
Definition: pccrc.c:574

Content information version 2 operations.

Definition at line 648 of file pccrc.c.

Referenced by peerdist_info().