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/uaccess.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 (userptr_t 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 56 of file pccrc.c.

56  {
57  static char buf[ ( 2 * PEERDIST_DIGEST_MAX_SIZE ) + 1 /* NUL */ ];
58  size_t digestsize = info->digestsize;
59 
60  /* Sanity check */
61  assert ( info != NULL );
62  assert ( digestsize != 0 );
63  assert ( base16_encoded_len ( digestsize ) < sizeof ( buf ) );
64 
65  /* Transcribe hash value */
66  base16_encode ( hash, digestsize, buf, sizeof ( buf ) );
67  return buf;
68 }
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:21
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
pseudo_bit_t hash[0x00010]
Hash algorithm.
Definition: arbel.h:13
#define PEERDIST_DIGEST_MAX_SIZE
Maximum digest size for any supported algorithm.
Definition: pccrc.h:298
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 79 of file pccrc.c.

80  {
81 
82  /* Sanity check */
83  if ( ( offset > info->raw.len ) ||
84  ( len > ( info->raw.len - offset ) ) ) {
85  DBGC ( info, "PCCRC %p data underrun at [%zx,%zx) of %zx\n",
86  info, offset, ( offset + len ), info->raw.len );
87  return -ERANGE;
88  }
89 
90  /* Copy data */
91  copy_from_user ( data, info->raw.data, offset, len );
92 
93  return 0;
94 }
u32 info
Definition: ar9003_mac.h:67
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
#define DBGC(...)
Definition: compiler.h:505
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#define ERANGE
Result too large.
Definition: errno.h:639
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References copy_from_user(), data, DBGC, ERANGE, info, len, 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 103 of file pccrc.c.

104  {
105  const struct peerdist_info *info = segment->info;
106  struct digest_algorithm *digest = info->digest;
107  uint8_t ctx[digest->ctxsize];
108  size_t digestsize = info->digestsize;
109  size_t secretsize = digestsize;
110  static const uint16_t magic[] = PEERDIST_SEGMENT_ID_MAGIC;
111 
112  /* Sanity check */
113  assert ( digestsize <= sizeof ( segment->hash ) );
114  assert ( digestsize <= sizeof ( segment->secret ) );
115  assert ( digestsize <= sizeof ( segment->id ) );
116 
117  /* Get segment hash of data */
118  memcpy ( segment->hash, hash, digestsize );
119 
120  /* Get segment secret */
121  memcpy ( segment->secret, secret, digestsize );
122 
123  /* Calculate segment identifier */
124  hmac_init ( digest, ctx, segment->secret, &secretsize );
125  assert ( secretsize == digestsize );
126  hmac_update ( digest, ctx, segment->hash, digestsize );
127  hmac_update ( digest, ctx, magic, sizeof ( magic ) );
128  hmac_final ( digest, ctx, segment->secret, &secretsize, segment->id );
129  assert ( secretsize == digestsize );
130 }
uint16_t segment
Code segment.
Definition: librm.h:252
unsigned short uint16_t
Definition: stdint.h:11
u32 info
Definition: ar9003_mac.h:67
void hmac_final(struct digest_algorithm *digest, void *digest_ctx, void *key, size_t *key_len, void *hmac)
Finalise HMAC.
Definition: hmac.c:115
uint32_t magic
Magic signature.
Definition: fdt.h:12
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
struct md4_digest digest
Digest of data already processed.
Definition: md4.h:12
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:391
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Content information.
Definition: pccrc.h:317
pseudo_bit_t hash[0x00010]
Hash algorithm.
Definition: arbel.h:13
unsigned char uint8_t
Definition: stdint.h:10
void hmac_init(struct digest_algorithm *digest, void *digest_ctx, void *key, size_t *key_len)
Initialise HMAC.
Definition: hmac.c:80
A message digest algorithm.
Definition: crypto.h:16
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
static void hmac_update(struct digest_algorithm *digest, void *digest_ctx, const void *data, size_t len)
Update HMAC.
Definition: hmac.h:21

References assert(), ctx, digest, digestsize, hash, 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 146 of file pccrc.c.

147  {
149  unsigned int blocks;
150  int rc;
151 
152  /* Get block description header */
153  if ( ( rc = peerdist_info_get ( info, &raw, offset,
154  sizeof ( raw ) ) ) != 0 )
155  return rc;
156 
157  /* Calculate number of blocks */
158  blocks = le32_to_cpu ( raw.blocks );
159 
160  return blocks;
161 }
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
uint32_t blocks
Number of blocks within the block description.
Definition: pccrc.h:17
Content Information version 1 block description header.
Definition: pccrc.h:157
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:79
__be32 raw[7]
Definition: CIB_PRM.h:28

References 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 170 of file pccrc.c.

171  {
172  size_t digestsize = info->digestsize;
173  unsigned int i;
174  size_t offset;
175  int blocks;
176  int rc;
177 
178  /* Sanity check */
179  assert ( index < info->segments );
180 
181  /* Calculate offset of first block description */
182  offset = ( sizeof ( struct peerdist_info_v1 ) +
183  ( info->segments *
184  sizeof ( peerdist_info_v1_segment_t ( digestsize ) ) ) );
185 
186  /* Iterate over block descriptions until we find this segment */
187  for ( i = 0 ; i < index ; i++ ) {
188 
189  /* Get number of blocks */
191  if ( blocks < 0 ) {
192  rc = blocks;
193  DBGC ( info, "PCCRC %p segment %d could not get number "
194  "of blocks: %s\n", info, i, strerror ( rc ) );
195  return rc;
196  }
197 
198  /* Move to next block description */
200  blocks ) );
201  }
202 
203  return offset;
204 }
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:62
uint32_t blocks
Number of blocks within the block description.
Definition: pccrc.h:17
#define DBGC(...)
Definition: compiler.h:505
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
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:146
#define peerdist_info_v1_segment_t(digestsize)
Content Information version 1 segment description.
Definition: pccrc.h:146
uint32_t segments
Number of segments within the content information.
Definition: pccrc.h:32
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define peerdist_info_v1_block_t(digestsize, blocks)
Content Information version 1 block description.
Definition: pccrc.h:179

References assert(), blocks, DBGC, digestsize, index, info, offset, peerdist_info_v1_block_t, peerdist_info_v1_blocks(), peerdist_info_v1_segment_t, rc, 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 212 of file pccrc.c.

212  {
213  struct peerdist_info_v1 raw;
216  size_t first_skip;
217  size_t last_skip;
218  size_t last_read;
219  int rc;
220 
221  /* Get raw header */
222  if ( ( rc = peerdist_info_get ( info, &raw, 0, sizeof ( raw ) ) ) != 0){
223  DBGC ( info, "PCCRC %p could not get V1 content information: "
224  "%s\n", info, strerror ( rc ) );
225  return rc;
226  }
227  assert ( raw.version.raw == cpu_to_le16 ( PEERDIST_INFO_V1 ) );
228 
229  /* Determine hash algorithm */
230  switch ( raw.hash ) {
233  break;
236  break;
239  break;
240  default:
241  DBGC ( info, "PCCRC %p unsupported hash algorithm %#08x\n",
242  info, le32_to_cpu ( raw.hash ) );
243  return -ENOTSUP;
244  }
245  info->digestsize = info->digest->digestsize;
246  assert ( info->digest != NULL );
247  DBGC2 ( info, "PCCRC %p using %s[%zd]\n",
248  info, info->digest->name, ( info->digestsize * 8 ) );
249 
250  /* Calculate number of segments */
251  info->segments = le32_to_cpu ( raw.segments );
252 
253  /* Get first segment */
254  if ( ( rc = peerdist_info_segment ( info, &first, 0 ) ) != 0 )
255  return rc;
256 
257  /* Calculate range start offset */
258  info->range.start = first.range.start;
259 
260  /* Calculate trimmed range start offset */
261  first_skip = le32_to_cpu ( raw.first );
262  info->trim.start = ( first.range.start + first_skip );
263 
264  /* Get last segment */
265  if ( ( rc = peerdist_info_segment ( info, &last,
266  ( info->segments - 1 ) ) ) != 0 )
267  return rc;
268 
269  /* Calculate range end offset */
270  info->range.end = last.range.end;
271 
272  /* Calculate trimmed range end offset */
273  if ( raw.last ) {
274  /* Explicit length to include from last segment is given */
275  last_read = le32_to_cpu ( raw.last );
276  last_skip = ( last.index ? 0 : first_skip );
277  info->trim.end = ( last.range.start + last_skip + last_read );
278  } else {
279  /* No explicit length given: range extends to end of segment */
280  info->trim.end = last.range.end;
281  }
282 
283  return 0;
284 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define PEERDIST_INFO_V1_HASH_SHA512
SHA-512 hash algorithm.
Definition: pccrc.h:103
u32 info
Definition: ar9003_mac.h:67
A content information segment.
Definition: pccrc.h:347
#define le32_to_cpu(value)
Definition: byteswap.h:113
Content Information version 1 data structure header.
Definition: pccrc.h:62
struct digest_algorithm sha512_algorithm
SHA-512 algorithm.
Definition: sha512.c:285
#define DBGC(...)
Definition: compiler.h:505
struct digest_algorithm sha384_algorithm
SHA-384 algorithm.
Definition: sha384.c:64
struct md4_digest digest
Digest of data already processed.
Definition: md4.h:12
#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:79
#define PEERDIST_INFO_V1_HASH_SHA384
SHA-384 hash algorithm.
Definition: pccrc.h:100
#define PEERDIST_INFO_V1_HASH_SHA256
SHA-256 hash algorithm.
Definition: pccrc.h:97
uint32_t last
Length to read in last segment, or zero.
Definition: pccrc.h:30
struct digest_algorithm sha256_algorithm
SHA-256 algorithm.
Definition: sha256.c:265
#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:362
uint32_t first
Length to skip in first segment.
Definition: pccrc.h:23
#define PEERDIST_INFO_V1
Content Information version 1.
Definition: pccrc.h:46

References assert(), cpu_to_le16, cpu_to_le32, DBGC, DBGC2, ENOTSUP, first, info, last, 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, raw, rc, sha256_algorithm, sha384_algorithm, sha512_algorithm, 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 292 of file pccrc.c.

292  {
293  const struct peerdist_info *info = segment->info;
294  size_t digestsize = info->digestsize;
296  ssize_t raw_offset;
297  int blocks;
298  int rc;
299 
300  /* Sanity checks */
301  assert ( segment->index < info->segments );
302 
303  /* Get raw description */
304  raw_offset = ( sizeof ( struct peerdist_info_v1 ) +
305  ( segment->index * sizeof ( raw ) ) );
306  if ( ( rc = peerdist_info_get ( info, &raw, raw_offset,
307  sizeof ( raw ) ) ) != 0 ) {
308  DBGC ( info, "PCCRC %p segment %d could not get segment "
309  "description: %s\n", info, segment->index,
310  strerror ( rc ) );
311  return rc;
312  }
313 
314  /* Calculate start offset of this segment */
315  segment->range.start = le64_to_cpu ( raw.segment.offset );
316 
317  /* Calculate end offset of this segment */
318  segment->range.end = ( segment->range.start +
319  le32_to_cpu ( raw.segment.len ) );
320 
321  /* Calculate block size of this segment */
322  segment->blksize = le32_to_cpu ( raw.segment.blksize );
323 
324  /* Locate block description for this segment */
325  raw_offset = peerdist_info_v1_block_offset ( info, segment->index );
326  if ( raw_offset < 0 ) {
327  rc = raw_offset;
328  return rc;
329  }
330 
331  /* Get number of blocks */
332  blocks = peerdist_info_v1_blocks ( info, raw_offset );
333  if ( blocks < 0 ) {
334  rc = blocks;
335  DBGC ( info, "PCCRC %p segment %d could not get number of "
336  "blocks: %s\n", info, segment->index, strerror ( rc ) );
337  return rc;
338  }
339  segment->blocks = blocks;
340 
341  /* Calculate segment hashes */
342  peerdist_info_segment_hash ( segment, raw.hash, raw.secret );
343 
344  return 0;
345 }
uint16_t segment
Code segment.
Definition: librm.h:252
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:62
uint32_t blocks
Number of blocks within the block description.
Definition: pccrc.h:17
#define DBGC(...)
Definition: compiler.h:505
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:170
Content information.
Definition: pccrc.h:317
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:103
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:79
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:146
#define peerdist_info_v1_segment_t(digestsize)
Content Information version 1 segment description.
Definition: pccrc.h:146
__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
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References assert(), blocks, 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 353 of file pccrc.c.

353  {
354  const struct peerdist_info_segment *segment = block->segment;
355  const struct peerdist_info *info = segment->info;
356  size_t digestsize = info->digestsize;
358  ssize_t raw_offset;
359  int rc;
360 
361  /* Sanity checks */
362  assert ( block->index < segment->blocks );
363 
364  /* Calculate start offset of this block */
366  ( block->index * segment->blksize ) );
367 
368  /* Calculate end offset of this block */
370  if ( block->range.end > segment->range.end )
372 
373  /* Locate block description */
374  raw_offset = peerdist_info_v1_block_offset ( info, segment->index );
375  if ( raw_offset < 0 ) {
376  rc = raw_offset;
377  return rc;
378  }
379 
380  /* Get block hash */
381  raw_offset += offsetof ( typeof ( raw ), hash[block->index] );
382  if ( ( rc = peerdist_info_get ( info, block->hash, raw_offset,
383  digestsize ) ) != 0 ) {
384  DBGC ( info, "PCCRC %p segment %d block %d could not get "
385  "hash: %s\n", info, segment->index, block->index,
386  strerror ( rc ) );
387  return rc;
388  }
389 
390  return 0;
391 }
uint16_t segment
Code segment.
Definition: librm.h:252
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u32 info
Definition: ar9003_mac.h:67
A content information segment.
Definition: pccrc.h:347
uint32_t blocks
Number of blocks within the block description.
Definition: pccrc.h:17
uint16_t block
Definition: tftp.h:12
#define DBGC(...)
Definition: compiler.h:505
uint32_t blksize
Block size for this segment.
Definition: pccrc.h:24
#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:170
Content information.
Definition: pccrc.h:317
pseudo_bit_t hash[0x00010]
Hash algorithm.
Definition: arbel.h:13
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:79
struct peerdist_range range
Content range.
Definition: pccrc.h:339
uint32_t end
Ending offset.
Definition: netvsc.h:18
__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
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define peerdist_info_v1_block_t(digestsize, blocks)
Content Information version 1 block description.
Definition: pccrc.h:179
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, and strerror().

◆ 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 423 of file pccrc.c.

423  {
424 
425  /* Initialise cursor */
426  cursor->offset = ( sizeof ( struct peerdist_info_v2 ) +
427  sizeof ( struct peerdist_info_v2_chunk ) );
428  cursor->remaining = 0;
429  cursor->len = 0;
430 }
unsigned int remaining
Number of segments remaining within this chunk.
Definition: pccrc.c:412
size_t offset
Raw data offset.
Definition: pccrc.c:410
size_t len
Accumulated segment length.
Definition: pccrc.c:414
Content Information version 2 data structure header.
Definition: pccrc.h:196
Content Information version 2 chunk description header.
Definition: pccrc.h:231

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 441 of file pccrc.c.

442  {
443  size_t digestsize = info->digestsize;
445  struct peerdist_info_v2_chunk chunk;
446  int rc;
447 
448  /* Get chunk description if applicable */
449  if ( ! cursor->remaining ) {
450 
451  /* Get chunk description */
452  if ( ( rc = peerdist_info_get ( info, &chunk,
453  ( cursor->offset -
454  sizeof ( chunk ) ),
455  sizeof ( chunk ) ) ) != 0 )
456  return rc;
457 
458  /* Update number of segments remaining */
459  cursor->remaining = ( be32_to_cpu ( chunk.len ) /
460  sizeof ( raw ) );
461  }
462 
463  /* Get segment description header */
464  if ( ( rc = peerdist_info_get ( info, &raw.segment, cursor->offset,
465  sizeof ( raw.segment ) ) ) != 0 )
466  return rc;
467 
468  /* Update cursor */
469  cursor->offset += sizeof ( raw );
470  cursor->remaining--;
471  if ( ! cursor->remaining )
472  cursor->offset += sizeof ( chunk );
473  cursor->len += be32_to_cpu ( raw.segment.len );
474 
475  return 0;
476 }
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:412
#define be32_to_cpu(value)
Definition: byteswap.h:116
size_t offset
Raw data offset.
Definition: pccrc.c:410
#define peerdist_info_v2_segment_t(digestsize)
Content Information version 2 segment description.
Definition: pccrc.h:280
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:79
size_t len
Accumulated segment length.
Definition: pccrc.c:414
__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:231

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 485 of file pccrc.c.

486  {
487  struct peerdist_info_v2_cursor cursor;
488  unsigned int segments;
489  int rc;
490 
491  /* Iterate over all segments */
492  for ( peerdist_info_v2_cursor_init ( &cursor ), segments = 0 ;
493  cursor.offset < info->raw.len ; segments++ ) {
494 
495  /* Update segment cursor */
497  &cursor ) ) != 0 ) {
498  DBGC ( info, "PCCRC %p segment %d could not update "
499  "segment cursor: %s\n",
500  info, segments, strerror ( rc ) );
501  return rc;
502  }
503  }
504 
505  /* Record accumulated length */
506  *len = cursor.len;
507 
508  return segments;
509 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A segment cursor.
Definition: pccrc.c:408
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:423
#define DBGC(...)
Definition: compiler.h:505
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint32_t len
Length.
Definition: ena.h:14
uint32_t segments
Number of segments within the content information.
Definition: pccrc.h:32
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:441

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, segments, 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 517 of file pccrc.c.

517  {
518  struct peerdist_info_v2 raw;
519  size_t len = 0;
520  int segments;
521  int rc;
522 
523  /* Get raw header */
524  if ( ( rc = peerdist_info_get ( info, &raw, 0, sizeof ( raw ) ) ) != 0){
525  DBGC ( info, "PCCRC %p could not get V2 content information: "
526  "%s\n", info, strerror ( rc ) );
527  return rc;
528  }
529  assert ( raw.version.raw == cpu_to_le16 ( PEERDIST_INFO_V2 ) );
530 
531  /* Determine hash algorithm */
532  switch ( raw.hash ) {
534  info->digest = &sha512_algorithm;
535  info->digestsize = ( 256 / 8 );
536  break;
537  default:
538  DBGC ( info, "PCCRC %p unsupported hash algorithm %#02x\n",
539  info, raw.hash );
540  return -ENOTSUP;
541  }
542  assert ( info->digest != NULL );
543  DBGC2 ( info, "PCCRC %p using %s[%zd]\n",
544  info, info->digest->name, ( info->digestsize * 8 ) );
545 
546  /* Calculate number of segments and total length */
548  if ( segments < 0 ) {
549  rc = segments;
550  DBGC ( info, "PCCRC %p could not get segment count and length: "
551  "%s\n", info, strerror ( rc ) );
552  return rc;
553  }
554  info->segments = segments;
555 
556  /* Calculate range start offset */
557  info->range.start = be64_to_cpu ( raw.offset );
558 
559  /* Calculate trimmed range start offset */
560  info->trim.start = ( info->range.start + be32_to_cpu ( raw.first ) );
561 
562  /* Calculate range end offset */
563  info->range.end = ( info->range.start + len );
564 
565  /* Calculate trimmed range end offset */
566  info->trim.end = ( raw.len ? be64_to_cpu ( raw.len ) :
567  info->range.end );
568 
569  return 0;
570 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u32 info
Definition: ar9003_mac.h:67
struct digest_algorithm sha512_algorithm
SHA-512 algorithm.
Definition: sha512.c:285
#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:49
#define be32_to_cpu(value)
Definition: byteswap.h:116
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static int peerdist_info_v2_segments(const struct peerdist_info *info, size_t *len)
Get number of segments and total length.
Definition: pccrc.c:485
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:79
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
uint32_t segments
Number of segments within the content information.
Definition: pccrc.h:32
#define PEERDIST_INFO_V2_HASH_SHA512_TRUNC
SHA-512 hash algorithm with output truncated to first 256 bits.
Definition: pccrc.h:225
#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:196
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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, segments, 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 578 of file pccrc.c.

578  {
579  const struct peerdist_info *info = segment->info;
580  size_t digestsize = info->digestsize;
582  struct peerdist_info_v2_cursor cursor;
583  unsigned int index;
584  size_t len;
585  int rc;
586 
587  /* Sanity checks */
588  assert ( segment->index < info->segments );
589 
590  /* Iterate over all segments before the target segment */
591  for ( peerdist_info_v2_cursor_init ( &cursor ), index = 0 ;
592  index < segment->index ; index++ ) {
593 
594  /* Update segment cursor */
596  &cursor ) ) != 0 ) {
597  DBGC ( info, "PCCRC %p segment %d could not update "
598  "segment cursor: %s\n",
599  info, index, strerror ( rc ) );
600  return rc;
601  }
602  }
603 
604  /* Get raw description */
605  if ( ( rc = peerdist_info_get ( info, &raw, cursor.offset,
606  sizeof ( raw ) ) ) != 0 ) {
607  DBGC ( info, "PCCRC %p segment %d could not get segment "
608  "description: %s\n",
609  info, segment->index, strerror ( rc ) );
610  return rc;
611  }
612 
613  /* Calculate start offset of this segment */
614  segment->range.start = ( info->range.start + cursor.len );
615 
616  /* Calculate end offset of this segment */
617  len = be32_to_cpu ( raw.segment.len );
618  segment->range.end = ( segment->range.start + len );
619 
620  /* Model as a segment containing a single block */
621  segment->blocks = 1;
622  segment->blksize = len;
623 
624  /* Calculate segment hashes */
625  peerdist_info_segment_hash ( segment, raw.hash, raw.secret );
626 
627  return 0;
628 }
uint16_t segment
Code segment.
Definition: librm.h:252
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A segment cursor.
Definition: pccrc.c:408
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:423
#define DBGC(...)
Definition: compiler.h:505
#define be32_to_cpu(value)
Definition: byteswap.h:116
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Content information.
Definition: pccrc.h:317
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:280
static void peerdist_info_segment_hash(struct peerdist_info_segment *segment, const void *hash, const void *secret)
Populate segment hashes.
Definition: pccrc.c:103
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:79
uint32_t len
Length.
Definition: ena.h:14
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:441
__be32 raw[7]
Definition: CIB_PRM.h:28
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

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 636 of file pccrc.c.

636  {
637  const struct peerdist_info_segment *segment = block->segment;
638  const struct peerdist_info *info = segment->info;
639  size_t digestsize = info->digestsize;
640 
641  /* Sanity checks */
642  assert ( block->index < segment->blocks );
643 
644  /* Model as a block covering the whole segment */
645  memcpy ( &block->range, &segment->range, sizeof ( block->range ) );
646  memcpy ( block->hash, segment->hash, digestsize );
647 
648  return 0;
649 }
uint16_t segment
Code segment.
Definition: librm.h:252
u32 info
Definition: ar9003_mac.h:67
A content information segment.
Definition: pccrc.h:347
uint16_t block
Definition: tftp.h:12
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:317
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14

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

◆ peerdist_info()

int peerdist_info ( userptr_t  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 673 of file pccrc.c.

673  {
675  int rc;
676 
677  /* Initialise structure */
678  memset ( info, 0, sizeof ( *info ) );
679  info->raw.data = data;
680  info->raw.len = len;
681 
682  /* Get version */
683  if ( ( rc = peerdist_info_get ( info, &version, 0,
684  sizeof ( version ) ) ) != 0 ) {
685  DBGC ( info, "PCCRC %p could not get version: %s\n",
686  info, strerror ( rc ) );
687  return rc;
688  }
689  DBGC2 ( info, "PCCRC %p version %d.%d\n",
690  info, version.major, version.minor );
691 
692  /* Determine version */
693  switch ( version.raw ) {
694  case cpu_to_le16 ( PEERDIST_INFO_V1 ) :
696  break;
697  case cpu_to_le16 ( PEERDIST_INFO_V2 ) :
699  break;
700  default:
701  DBGC ( info, "PCCRC %p unsupported version %d.%d\n",
702  info, version.major, version.minor );
703  return -ENOTSUP;
704  }
705  assert ( info->op != NULL );
706  assert ( info->op->info != NULL );
707 
708  /* Populate content information */
709  if ( ( rc = info->op->info ( info ) ) != 0 )
710  return rc;
711 
712  DBGC2 ( info, "PCCRC %p range [%08zx,%08zx) covers [%08zx,%08zx) with "
713  "%d segments\n", info, info->range.start, info->range.end,
714  info->trim.start, info->trim.end, info->segments );
715  return 0;
716 }
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:394
u32 version
Version number.
Definition: ath9k_hw.c:1983
#define PEERDIST_INFO_V2
Content Information version 2.
Definition: pccrc.h:49
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_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
Definition: pccrc.c:79
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
static struct peerdist_info_operations peerdist_info_v2_operations
Content information version 2 operations.
Definition: pccrc.c:652
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define PEERDIST_INFO_V1
Content Information version 1.
Definition: pccrc.h:46
Content Information version number.
Definition: pccrc.h:28
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 726 of file pccrc.c.

728  {
729  int rc;
730 
731  /* Sanity checks */
732  assert ( info != NULL );
733  assert ( info->op != NULL );
734  assert ( info->op->segment != NULL );
735  if ( index >= info->segments ) {
736  DBGC ( info, "PCCRC %p segment %d of [0,%d) out of range\n",
737  info, index, info->segments );
738  return -ERANGE;
739  }
740 
741  /* Initialise structure */
742  memset ( segment, 0, sizeof ( *segment ) );
743  segment->info = info;
744  segment->index = index;
745 
746  /* Populate content information segment */
747  if ( ( rc = info->op->segment ( segment ) ) != 0 )
748  return rc;
749 
750  DBGC2 ( info, "PCCRC %p segment %d range [%08zx,%08zx) with %d "
751  "blocks\n", info, segment->index, segment->range.start,
752  segment->range.end, segment->blocks );
753  DBGC2 ( info, "PCCRC %p segment %d digest %s\n", info, segment->index,
754  peerdist_info_hash_ntoa ( info, segment->hash ) );
755  DBGC2 ( info, "PCCRC %p segment %d secret %s\n", info, segment->index,
756  peerdist_info_hash_ntoa ( info, segment->secret ) );
757  DBGC2 ( info, "PCCRC %p segment %d identf %s\n", info, segment->index,
759  return 0;
760 }
uint16_t segment
Code segment.
Definition: librm.h:252
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:56
u32 info
Definition: ar9003_mac.h:67
#define DBGC(...)
Definition: compiler.h:505
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define ERANGE
Result too large.
Definition: errno.h:639
#define DBGC2(...)
Definition: compiler.h:522
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
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 770 of file pccrc.c.

772  {
773  const struct peerdist_info *info = segment->info;
774  size_t start;
775  size_t end;
776  int rc;
777 
778  /* Sanity checks */
779  assert ( segment != NULL );
780  assert ( info != NULL );
781  assert ( info->op != NULL );
782  assert ( info->op->block != NULL );
783  if ( index >= segment->blocks ) {
784  DBGC ( info, "PCCRC %p segment %d block %d of [0,%d) out of "
785  "range\n", info, segment->index, index, segment->blocks);
786  return -ERANGE;
787  }
788 
789  /* Initialise structure */
790  memset ( block, 0, sizeof ( *block ) );
791  block->segment = segment;
792  block->index = index;
793 
794  /* Populate content information block */
795  if ( ( rc = info->op->block ( block ) ) != 0 )
796  return rc;
797 
798  /* Calculate trimmed range */
799  start = block->range.start;
800  if ( start < info->trim.start )
801  start = info->trim.start;
802  end = block->range.end;
803  if ( end > info->trim.end )
804  end = info->trim.end;
805  if ( end < start )
806  end = start;
807  block->trim.start = start;
808  block->trim.end = end;
809 
810  DBGC2 ( info, "PCCRC %p segment %d block %d hash %s\n",
811  info, segment->index, block->index,
812  peerdist_info_hash_ntoa ( info, block->hash ) );
813  DBGC2 ( info, "PCCRC %p segment %d block %d range [%08zx,%08zx) covers "
814  "[%08zx,%08zx)\n", info, segment->index, block->index,
815  block->range.start, block->range.end, block->trim.start,
816  block->trim.end );
817  return 0;
818 }
uint16_t segment
Code segment.
Definition: librm.h:252
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:56
u32 info
Definition: ar9003_mac.h:67
size_t start
Start offset.
Definition: pccrc.h:311
uint16_t block
Definition: tftp.h:12
#define DBGC(...)
Definition: compiler.h:505
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:341
Content information.
Definition: pccrc.h:317
#define ERANGE
Result too large.
Definition: errno.h:639
#define DBGC2(...)
Definition: compiler.h:522
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
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:212
static int peerdist_info_v1_segment(struct peerdist_info_segment *segment)
Populate content information segment.
Definition: pccrc.c:292
static int peerdist_info_v1_block(struct peerdist_info_block *block)
Populate content information block.
Definition: pccrc.c:353

Content information version 1 operations.

Definition at line 394 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:517
static int peerdist_info_v2_block(struct peerdist_info_block *block)
Populate content information block.
Definition: pccrc.c:636
static int peerdist_info_v2_segment(struct peerdist_info_segment *segment)
Populate content information segment.
Definition: pccrc.c:578

Content information version 2 operations.

Definition at line 652 of file pccrc.c.

Referenced by peerdist_info().